Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solution

Cancel

You can use the cancel API to cancel a transaction. The cancellation period is subject to the contract.

Before issuing a cancellation, you must be familiar with the following information:

  • After a paid transaction is canceled, the payment amount is returned to a user's account.
  • Commission fee: The commission fee is returned for the canceled transaction.
  • Partial cancellation: Only a full cancellation is allowed.
  • Cancellation period: Before 00:15 on T+1 day (UTC+8:00).

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 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 paid and the payment result is still unknown after you receive the Antom asynchronous notification or use the inquiryPayment API.

The transaction is canceled. Full refund without charging the commission fee if the payment success notification of the canceled transaction is received.

Table 2. Handling of a cancellation request in different scenarios

Notes: A refunded transaction cannot be canceled. Otherwise, the error code PROCESS_FAIL is returned.

How to cancel a transaction

Step 1: Call the cancel API

You can cancel a transaction by using the cancel API. You must pass in one of the following parameters in your request:

Parameter

Required or not

Description

paymentId

OPTIONAL

The unique identifier that Antom assigns to a transaction.

paymentRequestId

OPTIONAL

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 API, Antom is to synchronously return the cancellation result by result.resultStatus :

resultStatus

Explanation

S

The cancellation is successful. cancelTime indicates the time when the cancellation succeeds.

F

The cancellation failed. See Error codes of the cancel 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