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 the payment if the payment result is not returned after a long time. The cancellation cannot be performed if being out of the cancellable period specified in the contract. Use the same paymentId or paymentRequestId that is used in the payment API to cancel the payment transaction.

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 original payment ID of the payment request to be canceled, generated by Antom to uniquely identify the payment when the merchant initiates the original 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 original payment request ID of the payment request to be canceled, generated by the merchant to uniquely 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

merchantAccountId String  

The unique ID to identify a merchant account.

Note: Specify this parameter when you use a single client ID across multiple locations.

More information:

  • Maximum length: 32 characters

Response parameters

result Result  REQUIRED

Indicates whether this API is called successfully. If this API is successfully called, the payment is canceled successfully.

Show child parameters

paymentId String  

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

Note: This field is returned when the cancellation succeeds (the value of result.resultStatus is S). 

More information:

  • Maximum length: 64 characters

paymentRequestId String  

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

Note: This field is returned when the cancellation succeeds (the value of result.resultStatus is S). 

More information:

  • Maximum length: 64 characters

cancelTime Datetime  

The actual execution completion time of the payment cancellation process, which is the date and time when the payment cancellation succeeds.

Note: This field is returned when the cancellation succeeds (the value of result.resultStatus is S).

More information:

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

Request

URL
Request Body

Response

Case
Success
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 succeeded.
  • If the value of result.resultStatus is F, the cancellation failed. 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 successfully. 

ACCESS_DENIEDFAccess is denied.

Contact Antom Technical Support for detailed reasons. 

INVALID_APIFThe called API is invalid or not active.

Contact Antom Technical Support to resolve the issue. 

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.  

KEY_NOT_FOUNDFThe private key or public key of <span>Antom</span> or the merchant is not found.

Check whether the private key or public key exists. If not, upload the private key in Antom Developer Center. 

MERCHANT_BALANCE_NOT_ENOUGHFThe merchant balance is insufficient.

Call the interface again after the merchant has sufficient balance. 

NO_INTERFACE_DEFFAPI is not defined.

Check whether the URL is correct. Please refer to the endpoint in the API documentation. 

ORDER_NOT_EXISTFThe order does not exist.

Check whether paymentId is correct. If correct, contact Antom Technical Support for specific reasons. 

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.  

PARAM_ILLEGALFThe required parameters are not passed, or illegal parameters exist. For example, a non-numeric input, an invalid date, or the length and type of the parameter are wrong.

Check and verify whether the required request fields (including the header fields and body fields) of the current API are correctly passed and valid. 

PROCESS_FAILFA general business failure occurred.

Do not retry. Human intervention is usually needed. It is recommended that you contact Antom Technical Support to troubleshoot the issue. 

SYSTEM_ERRORFA system error occurred.

Do not retry, and contact Antom Technical Support for more details. 

REQUEST_TRAFFIC_EXCEED_LIMITUThe request traffic exceeds the limit.

Call the interface again to resolve the issue. If not resolved, contact Antom Technical Support. 

PAYMENT_METHOD_NOT_SUPPORTEDFThe payment method does not support canceling or refunding transactions if the payment status is successful.

Do not retry. Contact Antom Technical Support to get more information. 

UNKNOWN_EXCEPTIONUAn API call has failed, which is caused by unknown reasons.

Call the interface again to resolve the issue. If not resolved, contact Antom Technical Support. 

USER_NOT_EXISTFThe user does not exist on the payment method side.

Contact Antom Technical Support for detailed reasons.  

USER_STATUS_ABNORMALFThe user status is abnormal on the payment method side.

Contact Antom Technical Support to know the specific reasons.