Cancel API

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.

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 BankTrigger Cancel Method
BNIAfter pre-authorization payment has been captured.
MandiriAfter the initial charge of the pre-authorized payment.
BCA, BRI, MAYBANKBefore 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.

Endpoints: /api/v1/core/{{transaction_id}}/cancel

HTTP Method: POST

Response Body

{
  "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"
}
FieldTypeDescription
status_codeStringStatus code of transaction cancel result.
status_messageStringDescription of transaction cancel result.
transaction_idStringTransaction ID given by Midtrans.
masked_cardStringFirst 8-digits and last 4-digits of customer's credit card number.
order_idStringOrder ID specified by you.
payment_typeStringThe payment method used by the customer.
transaction_timeStringTimestamp of transaction in ISO 8601 format. Time Zone: GMT+7.
transaction_statusStringTransaction status after charge credit card transaction. Possible values are
capture : 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.
fraud_statusStringDetection result by Fraud Detection System (FDS). Possible values are
accept : Approved by FDS.
deny: Denied by FDS. Transaction automatically failed.
bankStringThe acquiring bank of the transaction.
gross_amountStringTotal amount of transaction in IDR.