# Cancel

> Learn how to close a transaction using the cancel API within a limited period.

You can use the [**cancel**](https://docs.antom.com/ac/ams/paymentc_online.md) API to cancel a transaction. The cancellation period is subject to the contract.

Before issuing a cancellation, ensure to take note of the following information:

-   If a transaction is canceled before the payment is completed, the buyer will be unable to proceed with the payment.
-   If a transaction is canceled after the payment is completed, funds will be refunded to the buyer’s account.
-   **Commission fee**: The commission fee is returned for the canceled transaction.
-   **Partial cancellation**: Only a full cancellation is allowed.
-   **Cancellation period**: The cancellation period depends on the payment method that a buyer used for a payment. See the following table for details:

| **Payment method** | **Cancellation period** |
| --- | --- |
| Indonesia-based payment methods, and [JKOPay](https://docs.antom.com/ac/antomop/jkopay.md) | Cancellation is not allowed. |
| Thailand-based Online Banking, Mobile Banking APP, and Bank Transfer payment methods | - The transaction can be canceled before the payment of a submitted order is completed. - A paid transaction cannot be canceled. |
| Card payment methods | - A transaction can be canceled for up to seven days after it is paid. - A transaction whose payment is captured cannot be canceled. |
| [Mercado Pago](https://docs.antom.com/ac/antomop/mp_mdx.md) (Brazil, Chile, Mexico, and Peru) | A transaction can be canceled for up to seven days after it is paid. |
| Other payment methods | A paid transaction can be canceled before 00:15 on T+1 day (UTC+8:00). |

Table 1. Cancellation periods of payment methods

# When to cancel a transaction

If you have business scenarios where there are transactions that need to be canceled (such as flash sales, hotel booking services, and ticket selling services). You can cancel a transaction by using the [**cancel**](https://docs.antom.com/ac/ams/paymentc_online.md) API. After a transaction is canceled, the payment status is `CANCELLED`. Even if a notification of a successful payment is received after the transaction is canceled, the payment status remains `CANCELLED`. You can cancel a transaction in the following scenarios, and Antom handles the cancellation accordingly:

| **Scenario** | **Result** |
| --- | --- |
| The cancellation request is issued when the transaction is paid and within the cancellation period. | Full refund without charging the commission fee. |
| The cancellation request is issued when the transaction is not paid and within the payment expiration period (14 minutes). | The transaction is canceled. Full refund without charging the commission fee if the transaction is paid after it is canceled. |
| The cancellation request is issued when the transaction is paid and the payment result is still unknown after you receive the Antom asynchronous notification or use the [**inquiryPayment**](https://docs.antom.com/ac/ams/paymentri_online.md) API. | The transaction is canceled. Full refund without charging the commission fee if the payment success notification of the canceled transaction is received. |
| For card payments, the cancellation request is issued when the payment is authorized but is not captured. | The authorized transaction is canceled. |

Table 2. Handling of a cancellation request in different scenarios

> **Notes**:
>
> -   You cannot cancel a transaction that has been refunded, including full and partial refunds. Attempting to cancel a refunded transaction results in the `PROCESS_FAIL` error code.
> -   You cannot cancel a card payment after the payment funds are captured. However, you can initiate a refund for the payment.
> -   For the [Mercado Pago](https://docs.antom.com/ac/antomop/mp_mdx.md) payment method in Brazil, Chile, Mexico, and Peru, if you specify a payment expiration time that is earlier than seven days after the payment is initiated, you need to call the [**cancel**](https://docs.antom.com/ac/ams/paymentc_online.md) API to close the transaction to prevent the buyer from further payments.  

# How to cancel a transaction

## Step 1:  Call the cancel API

You can cancel a transaction by using the [**cancel**](https://docs.antom.com/ac/ams/paymentc_online.md) API. You must pass in one of the following parameters in your request:

| **Parameter** | **Required** | **Description** |
| --- | --- | --- |
| _paymentId_ | No | The unique identifier that Antom assigns to a transaction. |
| _paymentRequestId_ | No | The unique identifier that you assign to a request. |

Table 3. Details of the request parameters of the **cancel** API

## Step 2: Obtain the cancellation result

After you call the [**cancel**](https://docs.antom.com/ac/ams/paymentc_online.md) API, Antom synchronously returns the cancellation result by _result.resultStatus_ :

| _**resultStatus**_ | **Description** |
| --- | --- |
| `S` | The cancellation is successful. _cancelTime_ indicates the time when the cancellation succeeds. |
| `F` | The cancellation failed. See [Error codes](https://docs.antom.com/ac/ams/paymentc_online.md#result-codes) of the [**cancel**](https://docs.antom.com/ac/ams/paymentc_online.md) API for troubleshooting. |
| `U` | The cancellation is unknown. Resend the API request with the same value of _paymentRequestId_. _paymentRequestId_ is the unique identifier of a cancellation, so resending the request by using the same value of the parameter cannot trigger multiple cancellations. Contact Antom Technical Support if the value of _result.resultStatus_ is still `U` after three consecutive retries. |

Table 4. Explanation of _result.resultStatus_

> **Common questions**
>
> **Q: Will I receive an asynchronous notification after canceling a transaction?**
>
> A: No. The cancellation operation currently returns results synchronously and does not provide asynchronous notifications.
>
> **Q: What is the validity period for canceling a transaction?**
>
> A: A transaction can be canceled as long as no capture has been initiated for the order.