Alipay+ DocsAlipay+ Docs

Cancel a payment

This guide explains how to implement the cancelPayment API to handle cancellation requests from Alipay+.

Cancellation scenario

Alipay+ automatically calls the cancelPayment API to initiate a cancellation in the following scenarios:

  • Payment expiration: Alipay+ does not receive the final payment result (success or failure) from the Mobile Payment Provider (MPP) within the payment expiration time.
  • Merchant authorization release: In credit card authorization scenarios, the merchant voids the authorization on the same day it was made.

MPP requirements

When you receive a cancelPayment request, you must ensure that the cancellation succeeds, regardless of the payment status (S, F, or U).

To prevent user complaints, funds must be refunded to the user as soon as possible. If there is a timeout or temporary system problem on your end, Alipay+ will retry the request.

Cancellation rules

All cancellation requests are subject to the following rules:

  • Cancellable period: A payment can only be canceled within the agreed cancellable period, which is from the time the transaction is initiated to 00:30 UTC+8 of T+1 day. You must process the cancellation request from Alipay+ for the payment within this period.

Note: The cancellable period extends thirty (30) minutes after the daily cut-off, so you must support processing cancellation requests for transactions initiated around 24:00 UTC+8 of T day.

  • Cancellable amount: Only the full amount of the payment can be canceled. Partial cancellations are not supported.
  • Settlement and fees: Canceled transactions do not proceed to the settlement stage and are not included in the clearing and settlement files. Canceled transactions incur no fees.

Processing logic

When receiving the cancelPayment API request, take the following into consideration:

  • Handle the request parameters properly:
    • paymentRequestId: The unique ID that is assigned by Alipay+ to identify the original payment request. This field is an API idempotency field. For requests that are initiated with the same paymentRequestId, the MPP needs to return the same result.
  • Return the response properly:
    • result: The result of the payment cancellation.
      • If the payment cancellation succeeds, set the value of result.resultStatus to S and the value of result.resultCode to SUCCESS.
      • If the payment cancellation fails, set the value of result.resultStatus to F and the value of result.resultCode accordingly. See the Result code section.
      • If the payment cancellation result is unknown, set the value of result.resultStatus to U and the value of result.resultCode accordingly. See the Result code section.

For more information about the cancelPayment API, see the cancelPayment API.

Sample

The following samples show the request and response when the Alipay+ calls the cancelPayment API.

Request from Alipay+ to the MPP

copy
{
  "acquirerId": "1022188000000000001",
  "pspId":"1022172000000000001",
  "paymentRequestId":"20200101234567890132"
}

Response from the MPP to Alipay+

copy
{
 "result": {
    "resultCode":"SUCCESS",
    "resultStatus":"S",
    "resultMessage":"Success"
  }
}