Cancel
You can use the cancel API to actively cancel a transaction. The cancellation period is subject to the contract.
Before issuing a cancellation, you must be familiar with the following information:
- If the transaction is canceled before the payment is successful, the buyer will not be able to continue the payment.
- For transactions cancelled after successful payment, the funds will be returned to the user's account.
- Commission fee: There are no fees charged for canceled transactions.
- Partial cancellation: Only a full cancellation is allowed.
- Cancel period: See the following table for details:
Payment method | Cancel period |
Indonesia Local Payment Method and JKOPay | Cancellation is not supported. |
Thai online banking, mobile banking APP and bank transfer payment methods |
|
Card Payment |
|
Mercado Pago (Brazil, Chile, Mexico and Peru) | The transaction can be canceled within seven days after the payment is successful. |
Other payment methods | Payment success can be in T +1 day of 00:15(UTC +8:00) before the cancellation. |
Table 1. Payment method cancellation period
When to cancel a transaction
If you have business scenarios where there are transactions that need to be canceled (such as flash sales, hotel booking services, and ticket selling services). You can cancel a transaction by using the cancel API. After a transaction is canceled, the payment status is CANCELLED. Even if a notification of a successful payment is received after the transaction is canceled, the payment status remains CANCELLED. You can cancel a transaction in the following scenarios, and Antom handles the cancellation accordingly:
Scenario | Result |
The cancellation request is issued when the transaction is paid and within the cancellation period. | Full refund without charging the commission fee. |
The cancellation request is issued when the transaction has been paid, and the transaction result cannot be obtained through Antom asynchronous notification and calling the inquiryPayment API. | Close the transaction. A full refund will be issued without charging the commission fee if an asynchronous payment success notification is subsequently received. |
The buyer does not submit payment: For example, the buyer does not click the confirmation button in AlipayHK. | The buyer is still able to authorize and pay. |
The buyer submit payment and initiate cancellation within the 10-minute payment period. | The buyer is unable to pay, but can continue to authorize. |
Table 2. Cancel transaction scenario and processing
Note:
- Refunded transactions (including full refund and partial refund) cannot be canceled. Canceling refunded transactions will return
PROCESS_FAILerror code.- Even if you receive a payment success asynchronous notification after the transaction is canceled, the system's transaction status should remain the
CANCELLED.
How to cancel a transaction
Step 1: Call the cancel API
When you close an order and receive an asynchronous payment success notification from Antom, you need to call the cancel API to cancel the transaction. Pass in one of the following two IDs in the request:
Parameter | Required | Description |
paymentId | No | The unique identifier that Antom assigns to a transaction. |
paymentRequestId | No |
|
Table 3. Details of the request parameters of the cancel API
The following code shows how to call the cancel API using 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:
{
"paymentId": "2019061218401080010018882020035****"
}
{
"paymentRequestId": "paymentRequestId****"
}The following code shows a sample of the response message:
{
"cancelTime": "2019-06-12T19:07:11+08:00",
"paymentId": "2019061218401080010018882020035****",
"paymentRequestId": "pay_2089760038715669_20277574507****",
"result": {
"resultCode": "SUCCESS",
"resultMessage": "Success",
"resultStatus": "S"
}
}Step 2: Obtain the cancellation result
After you call the cancel API, Antom will use the result.resultStatus field of the cancel response to synchronously return the transaction cancellation result.
The table below displays the possible returned values and please follow the corresponding instructions for handling:
result.resultStatus | Message | Handling suggestions |
S | The cancellation is successful. | No further action is required. Note: If the buyer does not submit payment when the API is called, the payment process will continue. |
F | The cancellation failed. | Please process accordingly based on the resultCode. |
U | Cancellation failed for unknown reason. | Keep the original request unchanged and re-call the API to solve the problem. If the problem is not resolved, contact Antom Technical Support. |
Table 4. Possible values returned in the result.resultStatus
Note: If you do not receive a response message, it may be due to a network timeout. Keep the original request unchanged and re-call the API to solve the problem. If the problem is not resolved, contact Antom Technical Support.