Cancel
After the buyer places an order, you can close that order using the cancel API within a limited period. The supported cancellation period is subject to the contract.
Before issuing a cancellation, ensure to take note of the following information:
- If a transaction is canceled before the payment is completed, the buyer will be unable to proceed with the payment.
- If a transaction is canceled after the payment is completed, funds will be refunded to the buyer’s account.
- Partial cancellation: Not allowed. Only a full cancellation is allowed.
- Cancellation period: Varies by payment method. See the following table for details:
Payment method | Cancellation period |
Thailand-based online banking | Cancellation of the transaction can be done at any time from order placement to before payment is completed. Once the payment is successful, the transaction cannot be canceled. |
Other payment methods | Transactions can be canceled at any time from the order placement until 00:15 (GMT+8) on T+1 day. |
Cancellation steps
You can call the cancel API to cancel a transaction under the following scenarios:
- You need to close an order while its status on Antom’s side remains processing
- Other scenarios requiring transaction cancellation
Step 1: Initiate a cancellation request
Call the cancel API to cancel a single transaction by passing one of the following IDs:
Parameter name | Required | Description |
paymentId | No | The unique transaction ID returned by Antom when an order is placed. |
paymentRequestId | No | The unique request ID assigned by the merchant when an order is placed. |
The code below shows a sample of calling the cancel API:
Initiate a cancellation request with paymentRequestId:
public static void payCancel() {
AlipayPayCancelRequest alipayPayCancelRequest = new AlipayPayCancelRequest();
// replace with your paymentRequestId
alipayPayCancelRequest.setPaymentRequestId("yourPaymentRequestId");
AlipayPayCancelResponse alipayPayCancelResponse = null;
try {
alipayPayCancelResponse = CLIENT.execute(alipayPayCancelRequest);
} catch (AlipayApiException e) {
String errorMsg = e.getMessage();
// handle error condition
}
}
The following code shows a sample of the request message:
{
"paymentRequestId": "paymentRequestIdXXXX"
}
Step 2: Obtain cancellation result
After calling the cancel API, Antom returns a cancellation response:
{
"cancelTime": "2019-06-12T19:07:11+08:00",
"paymentId": "2019061218401080010018882020035XXXX",
"paymentRequestId": "paymentRequestIdXXXX",
"result": {
"resultCode": "SUCCESS",
"resultMessage": "Success",
"resultStatus": "S"
}
}
The table below shows the possible values of result.resultStatus returned in the response, please handle the result according to the guidance provided:
result.resultStatus | Message | Further action |
| Cancellation is successful. cancelTime indicates the success time. | No further action is needed. |
| Cancellation failed. | See Result/Error codes of the cancel API for troubleshooting. |
| Cancellation result is unknown. | Please retry the API call with the original request. If the issue persists, contact Antom Technical Support. |
Notes:
- If no response is received, it may indicate a network timeout. Please retry the API call with the original request. If the issue persists, contact Antom Technical Support.
- Transactions with prior refunds (full or partial) cannot be canceled. Canceling such transactions returns error code
PROCESS_FAIL
.- After cancellation, even if you receive an asynchronous notification of payment success, the transaction status in your system should still be maintained as
CANCELLED
.