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

cancel

POST /v1/payments/cancel

Use this API 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. 

A couple of things to note before calling this API:

To cancel the payment, you must provide one of the following parameters:

  • paymentId: The original payment ID of the payment request to be canceled, generated by Antom when the merchant initiates the original payment.
  • paymentRequestId: The original payment request ID of the payment request to be canceled.   

Structure

A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see: 

Note: Set the data type of each field (except array) as String. This means that you must use double quotation marks (" ") to enclose the field value. Examples:

  • If the data type of a field is Integer and its value is 20, set it as "20". 
  • If the data type of a field is Boolean and its value is true, set it as "true". 

Request parameters

paymentId String  

The unique ID that is assigned by Antom to identify a payment. paymentId and paymentRequestId cannot both be null. A one-to-one correspondence between paymentId and paymentRequestId exists.

More information:

  • Maximum length: 64 characters

paymentRequestId String  

The unique ID that is assigned by a merchant to identify a payment request. paymentRequestId and paymentId cannot both be null. If both paymentRequestId and paymentId are provided, paymentId takes precedence.

More information:

  • Maximum length: 64 characters

Response parameters

result Result  REQUIRED

The request result contains information such as status and error codes.

Show child parameters

paymentId String  

The unique ID that is assigned by Antom to identify a payment.

More information:

  • Maximum length: 64 characters

paymentRequestId String  

The unique ID that is assigned by a merchant to identify a payment request. 

More information:

  • Maximum length: 64 characters

cancelTime Datetime  

The actual execution completion time of the payment cancellation process, that is, the date and time when the payment cancellation succeeds. This parameter is returned only when the cancellation succeeds.

More information:

  • The value follows the ISO 8601 standard format. For example, "2019-11-27T12:01:01+08:00".
API Explorer

Request

URL
Request Body

Response

Response Body

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

CodeValueMessageFurther action
SUCCESSSSuccess

The order is canceled. The merchant needs to set the status of receipt to cancel.

CANCEL_WINDOW_EXCEEDFThe cancellation date exceeds the period during which cancellation is supported. The period is agreed upon in the contract.

The transaction cannot be canceled anymore. Initiate a refund against the transaction.

CLIENT_INVALIDFThe client is invalid.

Check whether clientId is correct.

ORDER_NOT_EXISTFThe order does not exist.

Check whether paymentId is correct.

ORDER_STATUS_INVALIDFThe transaction cannot be further processed because the order status is invalid.

Check the order status of the transaction or contact Antom Technical Support for detailed reasons.   

MEDIA_TYPE_NOT_ACCEPTABLEFThe server does not implement the media type that is acceptable to the client.

Check whether the media type is correct.

METHOD_NOT_SUPPORTEDFThe server does not implement the requested HTTP method.

Check whether the HTTP method is correct.

MERCHANT_BALANCE_NOT_ENOUGHFThe merchant balance is not enough.

Call the interface again after the merchant has sufficient balance.