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.

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.

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 1. 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 Alipay Technical support if the value of result.resultStatus is still U after three consecutive retries.

Table 2. Explanation of result.resultStatus