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.
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".
Request
Response
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 | Further action |
---|---|---|---|
SUCCESS | S | Success | The order is canceled. The merchant needs to set the status of receipt to cancel. |
CANCEL_WINDOW_EXCEED | F | The 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_INVALID | F | The client is invalid. | Check whether clientId is correct. |
ORDER_NOT_EXIST | F | The order does not exist. | Check whether paymentId is correct. |
ORDER_STATUS_INVALID | F | The 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_ACCEPTABLE | F | The server does not implement the media type that is acceptable to the client. | Check whether the media type is correct. |
METHOD_NOT_SUPPORTED | F | The server does not implement the requested HTTP method. | Check whether the HTTP method is correct. |
MERCHANT_BALANCE_NOT_ENOUGH | F | The merchant balance is not enough. | Call the interface again after the merchant has sufficient balance. |