Cancel transaction is triggered to void the transaction. If transaction is already settled (status : settlement
) you should perform refund
instead if the payment method supports it.
Cancel API can be used in both Core API and Snap integrations.
Card Payment
Card payment can be voided with Cancel method if the transaction has not been settled. The time interval during which the pre-authorized transaction can be cancelled depends on the Acquiring Bank.
Acquiring Bank | Trigger Cancel Method |
---|---|
BNI | After pre-authorization payment has been captured. |
Mandiri | After the initial charge of the pre-authorized payment. |
BCA, BRI, MAYBANK | Before and after pre-authorization payment has been captured. |
Pending Payment
Payment with transaction_status:pending
can be voided with cancel method if the transaction has not expired or has not been completed. The list of payment methods with transaction_status:pending
are given below.
- Bank Transfer: Permata Virtual Account, BCA Virtual Account, Mandiri Bill Payment, BNI Virtual Account, BRI Virtual Account, CIMB Virtual Account
- Direct Debit: BCA KlikPay, KlikBCA, BRImo, CIMB Clicks, Danamon Online Banking, UOB Ezpay
- E-money: QRIS, GoPay, ShopeePay
- Over the Counter: Indomaret, Alfamart
- Cardless Credit: Akulaku, Kredivo
Cancel Multi-use VA
Merchant can use the same cancel API to disable a created multi-use VA. In the multi-use VA context, the transaction does not need to be in a pending
status to be cancelled.
Multi-use VA can be cancelled using order_id
or transaction_id
of the transaction. The id that can be used is the parent id (the 1st transaction that created by merchant) or the child id (the subsequent transactions that is created when the next payment happened).
Once the multi-use VA got cancelled, merchant can always recreate the same VA number if merchant use a custom VA number.
Cancel Multi-use VA
Merchant can only cancel the
order_id
ortransaction_id
that is not older than 6 months.
Cancel Transaction Method
See sample on the right -- try it yourself!
HTTP Method | Endpoint | Definition |
---|---|---|
POST | BASE_URL/v2/{order_id OR transaction_id}/cancel | Cancel transaction |
Cancel Transaction Response and Notification
{
"status_code" : "200",
"status_message" : "Success, transaction is canceled",
"transaction_id" : "249fc620-6017-4540-af7c-5a1c25788f46",
"masked_card" : "48111111-1114",
"order_id" : "example-1424936368",
"payment_type" : "credit_card",
"transaction_time" : "2015-02-26 14:39:33",
"transaction_status" : "cancel",
"fraud_status" : "accept",
"bank" : "bni",
"gross_amount" : "30000.00"
}
{
"status_code" : "412",
"status_message" : "Merchant cannot modify the status of the transaction"
}
{
"masked_card": "48111111-1114",
"approval_code": "325511",
"bank": "mandiri",
"eci": "05",
"transaction_time": "2016-07-04 13:32:44",
"gross_amount": "244108.00",
"order_id": "160288131764",
"payment_type": "credit_card",
"signature_key": "71f3b14d3036d2a60dac7fef1cdde7bebdbb2dbeebc68bcf5e7819fe8be7c9241611ea1e769e0c6775735805174c02b9d6b5cf89a11de1861d5efb298c9898b7",
"status_code": "202",
"transaction_id": "ffd82cd2-4f0d-4b24-b4b8-e201b0c3d80e",
"transaction_status": "cancel",
"fraud_status": "accept",
"status_message": "midtrans payment notification"
}
JSON Attribute | Description | Type |
---|---|---|
status_code | Status code of transaction cancel result. | String |
status_message | Description of transaction cancel result. | String |
transaction_id | Transaction ID given by Midtrans. | String |
masked_card | First 8-digits and last 4-digits of customer's credit card number. | String |
order_id | Order ID specified by you. | String |
payment_type | The payment method used by the customer. | String |
transaction_time | Timestamp of transaction in ISO 8601 format. Time Zone: GMT+7. | String |
transaction_status | Transaction status after charge credit card transaction. Possible values arecapture : Transaction is accepted by the bank and ready for settlement. Note: Cancel transaction to deny / cancel it. Otherwise, transaction is settled automatically. deny : transaction is denied by the bank or FDS.authorize : Credit card is authorized in pre-authorization feature. | String |
fraud_status | Detection result by Fraud Detection System (FDS). Possible values areaccept : Approved by FDS.deny : Denied by FDS. Transaction automatically failed. | String |
bank | The acquiring bank of the transaction. | String |
gross_amount | Total amount of transaction in IDR. | String |