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

Cancel a payment

You can cancel the transactions that have been successfully paid in the Alipay system by using the cancel API. The cancellation cannot be performed if being out of the cancellable period that is specified in the contract. Usually, transactions on the transaction (T) day can be canceled before T+1 00:15, and the time zone is GMT +8.

When to use the cancel API

For payment scenarios with a specific transaction closing time of the merchant, for example, a flash sale, hotel reservation, or flight ticket purchase, the cancel API must be integrated. You can initiate a payment cancellation for one of the following cases:

  • After the payment is successful and within the cancellable period, if the payment needs to be canceled, call the cancel API. If the transaction is canceled successfully, the full amount will be refunded. There is no fee charged for cancellation, but the cancellable period is usually only one day.
  • If the transaction is not paid and the transaction needs to be canceled in advance before Alipay's payment expiration time (one minute), call the cancel API. If the transaction is not paid when the transaction is canceled but is paid after you cancel the transaction, the full amount will also be refunded to users.
  • If you cannot receive the asynchronous notification or get a confirmative result (S or F) from the inquiryPayment response, terminate the transaction by calling the cancel API to keep the transaction status consistent between you and the user.


  • After the transaction is canceled, the transaction status will be changed to CANCELLED. Even if an asynchronous notification of payment success is received after the transaction is canceled, the order status in the system is still CANCELLED.
  • A transaction that has been refunded cannot be canceled. An error code of PROCESS_FAIL will be returned if you retry to cancel a transaction that has been refunded.

How to call the cancel API

To cancel a transaction, call the cancel API by specifying the paymentId or paymentRequestId field with the same value as that of the transaction to be canceled. Assume that the domain name is, the request URLs are:

  • Sandbox environment:
  • Production environment:

The example below shows a cancellation request that uses the paymentRequestId field to cancel the transaction. The paymentRequestId field is assigned by the merchant to identify each unique request. It is suggested to use this field for the cancellation process.

   "paymentRequestId": "pay_1089760038715669_102775745075669"   

The example below shows a cancellation request that uses the paymentId field to cancel the transaction:


Cancellation result

As long as the cancel request is initiated, Alipay will guarantee that the transaction will be canceled or refunded:

  • If the user has not completed the payment, the transaction will be canceled.
  • If the user has completed the payment, the transaction will be refunded.

The example below shows a cancellation response. The time when the payment cancellation succeeds is indicated by the value of cancelTime.


The cancellation result is returned in the result.resultStatus field of the cancel response. The following graphic shows the processing logic of calling the cancel API:

Cancellation result.jpg

Figure 1. Further actions for different cancel results

  • S: indicates that the cancellation succeeded.
  • F: indicates that the cancellation failed. Take further actions according to resultCode and then retry the cancel API until a result of S is obtained.
  • U: indicates that the cancellation result is unknown. Use the same request parameters to retry the cancellation request. If you call the cancel request three times and still gets U, contact Alipay Technical Support.


  • The store and forward logic might be implemented in the gateway. If the cancel request reaches to the gateway before the pay request, the cancel request should not be relayed to the next hop.
  • When cancellation service is not allowed, try the refund service.