# Cancel a Pay In transaction with the API > Cancel transactions with void, refund, or reverse operations. Return funds to customers automatically based on settlement status, with support for full and partial refunds How you cancel a pay-in transaction depends on the transaction status. If a transaction hasn't been settled yet, you can void it. If a transaction has been settled, or settlement is pending, you can refund the transaction. Payabli offers a convenient third method, *reversal*, which dynamically refunds or voids a transaction based on its settlement status. This guide explains how to void, refund, and reverse transactions with the Payabli API. ## Choose a method First, choose a transaction cancellation method. To streamline your integration with Payabli, use reverse. diagram explained in surrounding text ### Void A void cancels an existing sale or captured authorization. Voiding non-captured authorizations prevents future captures. You can void unsettled transactions. If a transaction has been settled, refund it instead. ### Refund A Refund sends money back to the accountholder after transaction has been settled. If a transaction hasn't been settled, void it instead. ### Reversal A reversal allows you to either refund or void a transaction without knowing the transaction's settlement status. Send a reversal request for a transaction, and Payabli automatically determines whether it's a refund or void. Reverse lets you integrate a single function for transaction cancellations and has Payabli dynamically handle the logic. ## Path parameters When canceling a transaction via the API, you always need the `transId`, which is the `referenceId` for the transaction. For refunds and reversals, you also need the `amount` to refund. *Required for voids, refunds, and reversals* The referenceId identifying the transaction (PaymentId). You can find this in the success response for the payment you want to void. *Required for refunds and reversals* The amount to refund from the original transaction, minus any service fee charged on the original transaction. This amount can't be greater than the original total amount of the transaction minus the service fee. For example, if a transaction was \$90 plus a \$10 service fee, you can refund up to \$90. Set the amount to 0 (zero) to refund the total amount of the transaction minus any service fee. ## Void a transaction You can void transactions that haven't settled yet. This example voids the transaction with a `referenceId` of `10-3ffa27df-b171-44e0-b251-e95fbfc7a723`: A successful void returns a 200 status and `isSuccess` set to `true`. If you try to void a transaction that has already been voided, the API returns a 400 status with "Invalid TransStatus" in the response text. ```json Invalid TransStatus response { "responseText": "Declined: Invalid TransStatus", } ``` ## Refund a transaction You can refund settled transactions. If you use the Enhanced Refund Flow, see [the guide](/guides/pay-in-refunds-enhanced-flow-overview) for information about how refunds are handled in different scenarios. Tab through to see examples of full and partial refunds using both the v1 and v2 APIs. This example refunds the transaction with a `referenceId` of `10-3ffa27df-b171-44e0-b251-e95fbfc7a723` for the total amount of the transaction. This example refunds a partial amount of \$100.99 of the transaction with a `referenceId` of `10-3ffa27df-b171-44e0-b251-e95fbfc7a723`. This example refunds the transaction with a `referenceId` of `10-3ffa27df-b171-44e0-b251-e95fbfc7a723` for the total amount of the transaction. This example refunds a partial amount of \$100.99 of the transaction with a `referenceId` of `10-3ffa27df-b171-44e0-b251-e95fbfc7a723`. A successful refund returns a 200 status with a JSON body. This example shows a successful refund response for a full refund. The `resultText` value is "INITIATED" for refunds that have been initiated but not yet completed. This response is only returned in accounts with the Enhanced Refund Flow enabled. This example shows a successful refund response for a partial refund. The `resultText` value is "CAPTURED". This example shows a successful refund response for a full refund. This example shows a successful refund response for a partial refund. Just like sale transactions, you can void a refund transaction before the batch closes. Use the `referenceId` from the refund transaction response as the `transId` in the void request. ## Reverse a transaction You can use reversal to either refund or void a transaction without knowing the transaction's settlement status. See the [API reference](/developers/api-reference/moneyin/reverse-a-transaction) for this endpoint. Because reversing a transaction either voids or refunds it, keep these points in mind when creating requests: * If a transaction isn't settled, the reversal request is treated as a void. Only full voids supported. Partial voids aren't supported. * If a transaction is settled, the reversal request is treated as a refund. Both full and partial refunds are supported. Payabli refunds the amount passed in the request. * There isn't a v2 version of the reverse endpoint as there is with void and refund. Use the v1 endpoint for reversals. When using the `api/MoneyIn/reverse/` endpoint, the transaction's batch status determines how your reversal request is processed: | Batch Status | Reversal Type | How it's Treated | Result | | ---------------- | ------------- | --------------------------- | -------------------------- | | Open | Full | Processed as Void | ✓ Success | | Open | Partial | Attempted as Partial Void | ✗ Rejected (not supported) | | Closed (Settled) | Full | Processed as Full Refund | ✓ Success | | Closed (Settled) | Partial | Processed as Partial Refund | ✓ Success | These examples show how to reverse a transaction. This example will refund the transaction with a `referenceId` of `10-3ffa27df-b171-44e0-b251-e95fbfc7a723` for the total amount of the transaction, if the transaction is settled. If the transaction isn't settled, it voids the transaction. This example refunds \$53.76 of the transaction with a `referenceId` of `10-3ffa27df-b171-44e0-b251-e95fbfc7a723`, if the transaction is settled. If the transaction isn't settled, it reverses \$53.76 of the original authorized amount, and captures the rest. A successful reverse returns a 200 status with a JSON body. You can tell whether the operation was a refund or a void based on the `resultText` value. A "REVERSED" value means the operation was a void. A "CAPTURED" value means that the operation was a refund. ## Related resources See these related resources to help you get the most out of Payabli. * **[Make a sale transaction](/guides/pay-in-developer-transactions-create)** - You need to make a transaction before voiding or refunding it * **[Pay In schemas](/guides/pay-in-schemas-overview)** - Learn about Pay In (money in) transaction schemas * **[Pay In statuses](/guides/pay-in-status-reference)** - Learn about Pay In (money in) statuses * **[Void API (v2)](/developers/api-reference/moneyinV2/void-a-transaction)** - API reference for v2 of the void a transaction endpoint * **[Refund API (v2)](/developers/api-reference/moneyinV2/refund-a-settled-transaction)** - API reference for v2 of the refund a settled transaction endpoint * **[Refund split transaction](/developers/api-reference/moneyin/refund-a-settled-transaction-with-instructions)** - API reference for refunding a split transaction with instructions