> For the complete documentation index, see [llms.txt](https://docs.hyperswitch.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyperswitch.io/integrations/prism/python/payment-service/void.md).

# Void

## Overview

The `void` method cancels an authorized payment before funds are captured. This releases the held funds back to the customer's payment method, effectively canceling the transaction.

**Business Use Case:** A customer cancels their order before it ships. The payment was authorized at checkout, but since you're not shipping, you void the authorization to release the hold on their funds.

## Purpose

**Why use void?**

| Scenario                     | Benefit                                     |
| ---------------------------- | ------------------------------------------- |
| **Order cancellation**       | Release funds when customer cancels         |
| **Fulfillment failure**      | Void if item is out of stock                |
| **Authorization timing out** | Clean up old authorizations                 |
| **Fraud prevention**         | Void suspicious transactions before capture |

**Key outcomes:**

* Held funds released immediately
* No charge to customer
* Transaction terminated cleanly

## Request Fields

| Field                      | Type   | Required | Description                                   |
| -------------------------- | ------ | -------- | --------------------------------------------- |
| `merchant_transaction_id`  | string | Yes      | Your unique transaction reference             |
| `connector_transaction_id` | string | Yes      | The connector's transaction ID from authorize |
| `void_reason`              | string | No       | Reason for voiding                            |

## Response Fields

| Field                      | Type          | Description                              |
| -------------------------- | ------------- | ---------------------------------------- |
| `merchant_transaction_id`  | string        | Your transaction reference (echoed back) |
| `connector_transaction_id` | string        | Connector's transaction ID               |
| `status`                   | PaymentStatus | Current status: VOIDED                   |
| `voided_amount`            | int64         | Amount voided in minor units             |
| `status_code`              | int           | HTTP-style status code (200, 404, etc.)  |

## Example

### SDK Setup

```python
from hyperswitch_prism import PaymentClient

payment_client = PaymentClient(
    connector='stripe',
    api_key='YOUR_API_KEY',
    environment='SANDBOX'
)
```

### Request

```python
request = {
    "merchant_transaction_id": "txn_order_001",
    "connector_transaction_id": "pi_3Oxxx...",
    "void_reason": "Customer cancelled order"
}

response = await payment_client.void(request)
```

### Response

```python
{
    "merchant_transaction_id": "txn_order_001",
    "connector_transaction_id": "pi_3Oxxx...",
    "status": "VOIDED",
    "voided_amount": 1000,
    "status_code": 200
}
```

## Void vs Refund

| Action     | When to Use                               | Effect on Customer                    |
| ---------- | ----------------------------------------- | ------------------------------------- |
| **Void**   | Before capture, during authorization hold | Funds released immediately, no charge |
| **Refund** | After capture, funds already transferred  | Funds returned, may take 5-10 days    |

## Error Handling

| Error Code | Meaning               | Action                            |
| ---------- | --------------------- | --------------------------------- |
| `404`      | Transaction not found | Verify connector\_transaction\_id |
| `409`      | Already captured      | Cannot void, use refund instead   |
| `410`      | Already voided        | Already voided, idempotent result |

## Best Practices

* Void as soon as you know the transaction won't complete
* Void is cheaper than refund (no chargeback risk, no settlement costs)
* Authorizations typically expire in 7-10 days if not captured

## Next Steps

* [authorize](/integrations/prism/python/payment-service/authorize.md) - Create initial authorization
* [capture](/integrations/prism/python/payment-service/capture.md) - Complete payment instead of voiding
* [refund](/integrations/prism/python/payment-service/refund.md) - Return funds after capture


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hyperswitch.io/integrations/prism/python/payment-service/void.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
