/v1/payments/cancel
POST /v1/payments/cancel
The cancel
API is used to cancel a payment when the payment result does not return for a long time. You can also use the API to cancel a payment authorization after the authorization is completed.
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 originalpaymentRequestId
of the payment request to be canceled.
Message structure
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:
Request
Property | Data Type | Required | Description |
paymentId | String | No | The unique ID that is assigned by the wallet to identify a payment.
Max. length: 64 characters. |
paymentRequestId | String | No | The unique ID is assigned by a merchant to identify a payment request.
Max. length: 64 characters. |
Response
Property | Data Type | Required | Description |
result | Yes | The request result, which contains information such as result status and error codes. | |
paymentId | String | No | The unique ID is assigned by the wallet to identify a payment. Max. length: 64 characters. |
paymentRequestId | String | No | The unique ID is assigned by a merchant to identify a payment request. Max. length: 64 characters. |
cancelTime | String | 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. |
Result process logic
In the response, the result.resultStatus
field indicates the result of processing a request. The following table describes each result status:
resultStatus | Decription |
S | The cancellation is successful. The corresponding
|
U | The status of the cancellation result is unknown. The corresponding
|
F | The cancellation fails. The corresponding
|
Error codes
Error codes are usually classified into the following categories:
- Common error codes are common across all mini program's APIs.
- API-specific error codes: are listed in the following table.
resultCode | resultStatus | resultMessage |
SUCCESS | S | Success |
MSG_PARSE_ERROR | F | Message parsed error. |
FUNCTION_NOT_MATCH | F | Function parameter does not match API. |
INVALID_CLIENT | F | Invalid client. |
INVALID_SIGNATURE | F | Signature is invalid. |
INVALID_CLIENT_STATUS | F | Invalid client status. |
ORDER_NOT_EXIST | F | The order doesn't exist. |
Samples
Request
{
"paymentId": "20221124111212800100166473700277756"
}
Response
{
"result": {
"resultCode": "SUCCESS",
"resultStatus": "S",
"resultMessage": "Success"
},
"paymentId": "20221124111212800100166473700277756",
"cancelTime": "2022-11-24T19:04:30+03:00",
"paymentRequestId": "rrIX-vONE-HiNM-QLMJ-emWN-sFlC-JX"
}