POST /v1/payments/cancel is used to cancel a payment when the payment result has not been returned for an extended period, or when the merchant, after reviewing the customer's order, decides not to accept it. Upon successful invocation of the cancel API, the full amount paid by the customer will be returned.
To cancel a payment, you need to provide one of the following parameters:
paymentId: The original payment ID of the payment request to be canceled. It is generated by Alipay when a merchant initiates the original payment.paymentRequestId: The original paymentRequestId of the payment request to be canceled.All monetary amounts in requests and responses must be expressed in the smallest currency unit (IQD fils). For example, 100 IQD equals 100000.

my.getAuthCode JSAPI with scopes=USER_ID.authCode and returns.authCode to the Mini Program.authCode to the merchant backend.authCode to apply the accessToken.accessToken information to the merchant backend, such as customerId, accessToken, refreshToken, etc.customerId.customerId as referenceBuyerId, paymentNotifyUrl(optional), etc.redirectionUrl.my.tradePay JSAPI with redirectionUrl to conduct the payment./v1/payments/cancel.| Method | Path |
|---|---|
POST | /v1/payments/cancel |
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see: OpenAPIs Overview.
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
paymentId | string | No | The unique ID that is assigned by the wallet to identify a payment. Max. length: 64 characters. | "202312061112128001001660x" |
paymentRequestId | string | No | The unique ID is assigned by a merchant to identify a payment request. Max. length: 64 characters. | "20231127190741010007000x" |
extendInfo | string | No | The extension information that wallets and merchants want to describe. The format should be JSON format. Max. length: 2048 characters. | "extendInfo: This is additional information" |
paymentId or paymentRequestId must be provided.{
"paymentId": "202312061112128001001660090000xxxx"
}
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
result | object | Yes | The request result, which contains information such as result status and error codes. | { "resultCode": "SUCCESS", "resultStatus": "S", "resultMessage": "Success." } |
paymentId | string | No | The unique ID is assigned by the wallet to identify a payment. Max. length: 64 characters. | "202312061112128001001660x" |
paymentRequestId | string | No | The unique ID is assigned by a merchant to identify a payment request. Max. length: 64 characters. | "20231127190741010007000x" |
cancelTime | datetime | No | The actual time when the payment cancellation process is completed. This property is returned only when the cancellation succeeds. The value follows the ISO 8601 standard. | "2023-01-08T12:12:12+08:00" |
{
"result": {
"resultCode": "SUCCESS",
"resultStatus": "S",
"resultMessage": "Success."
},
"paymentId": "202312061112128001001660090000xxxx",
"paymentRequestId": "20231127190741010007000070000xxxx",
"cancelTime": "2023-01-08T12:12:12+08:00"
}
In the response, the result.resultStatus field indicates the result of processing a request. The following table describes each result status:
| resultStatus | Description |
|---|---|
S | It means that the cancellation is successful. The corresponding result.resultCode is "SUCCESS", and the result.resultMessage is "Success.". |
U | It means that the status of the cancellation result is unknown. The corresponding result.resultCode is UNKNOWN_EXCEPTION, and result.resultMessage is "An API calling is failed, which is caused by unknown reasons". For details, see the Common error codes section. |
F | It means that the cancellation fails. The corresponding result.resultCode and result.resultMessage may vary based on different situations. For details, see the Error codes section. |
Error codes are usually classified into the following categories:
| resultStatus | resultCode | resultMessage |
|---|---|---|
F | ORDER_STATUS_INVALID | The order is in invalid status such as CLOSED. |
F | ORDER_HAS_BEEN_CAPTURED | The cancellation does not support when the order has been captured. |
F | ORDER_HAS_BEEN_REFUNDED | The cancellation does not support when the order has been refunded. |
F | ORDER_HAS_BEEN_VOIDED | The cancellation does not support when the order has been voided. |
F | CANCEL_NOT_ALLOWED | The cancellation not allowed in agreement. |
F | CANCEL_WINDOW_EXCEED | The cancellation date is beyond the period that is agreed in the contract. |
F | ORDER_NOT_EXIST | The order does not exist. |
F | KEY_NOT_FOUND | The key is not found. |
F | CLIENT_INVALID | The client is invalid. |
F | INVALID_SIGNATURE | The signature is invalid. |
F | METHOD_NOT_SUPPORTED | The server does not implement the requested HTTP method. |
F | MEDIA_TYPE_NOT_ACCEPTABLE | The server does not implement the media type that can be accepted by the client. |
F | PARTNER_STATUS_ABNORMAL | The partner status is abnormal. |
F | PARTNER_BALANCE_NOT_ENOUGH | The partner balance is not enough. |
The merchant can call this cancel API to cancel the payment transaction within T day under these circumstances and E-Wallet will not settle payment this transaction in T+N day either.
For refunds after the money has been settled to the merchant, the merchant backend should call refund API instead.
51051000101000100008 for escrow)