Payment Cancellation
Use this interface to cancel a payment if the payment result is not returned for a long time, or to cancel a payment authorization after the authorization is completed.
Request parameters
Response parameters
The request result, which contains information related to the request result, such as status and error codes.
Result status. Possible values are:
- S: Indicates that the result status is successful.
- F: Indicates that the result status is failed.
- U: Indicates that the result status is unknown.
The actual execution completion time of the payment cancellation process, that is, the date and time when the payment cancellation succeeds. The value follows the ISO 8601 standard. This parameter is returned only when the cancellation succeeds.
More information
To cancel the payment, you must provide one of the following parameters:
- paymentId: The original payment ID of the payment request to be cancelled, generated by Alipay when the merchant initiates the original payment.
- paymentRequestId: The original paymentRequestId of the payment request to be cancelled.
Result process logic
For different request results, different actions are to be performed. See the following list for details:
- If the value of result.resultStatus is S, the cancellation succeeds.
If the value of result.resultStatus is F, the cancellation fails. See the returned error code and determine further actions.
- If the value of result.resultStatus is U, the cancellation result is unknown. Use the same request parameters to retry the cancellation request.
- If no response is returned, use the same request parameters to retry the cancellation request.
Result/Error codes
Code | Value | Message |
---|---|---|
SUCCESS | S | Success |
CANCEL_WINDOW_EXCEED | F | The cancellation date exceeds the period during which cancellation is supported. The period is agreed in the contract. |
ORDER_NOT_EXIST | F | The order doesn't exist. |
PROCESS_FAIL | F | A general business failure occurred. Don't retry. |
PARAM_ILLEGAL | F | Illegal parameters exist. For example, a non-numeric input, or an invalid date. |
KEY_NOT_FOUND | F | The key is not found. |
ACCESS_DENIED | F | Access denied |
REQUEST_TRAFFIC_EXCEED_LIMIT | U | The request traffic exceeds the limit. |
API_INVALID | F | API is invalid or not active. |
CLIENT_INVALID | F | The client is invalid. |
SIGNATURE_INVALID | F | The signature is invalid. |
METHOD_NOT_SUPPORTED | F | The server does not implement the requested HTTP method. |
MEDIA_TYPE_NOT_ACCEPTABLE | F | The server does not implement the media type that is acceptable to the client. |
UNKNOWN_EXCEPTION | U | An API calling is failed, which is caused by unknown reasons. |
Request
Method
POST
Endpoint
v1/payments/cancel
Header
Accept: application/json