Charge Transactions

Midtrans provides facility to add more features to Charge Transaction. Using these features, you can -

  • Set custom fields
  • Set custom expiry
  • Add metadata
    The subsequent sections explain these features in detail.


Set Custom Field

Set Custom Fields is a feature that enables you to charge a transaction with unique data according to your need. Midtrans provides three custom fields to save custom data about the transaction.

The steps to set these custom fields are given below.

  1. Set Custom field label on MAP.
  • Login to your MAP account.
  • On the Dashboard, go to Settings > General Settings > Interface Settings.
  • Enter custom text in Custom field 1 label, Custom field 2 label, Custom field 3 label.
  • Click Save.
  1. Send Charge API request with the custom fields value.
  2. The label and value of the custom fields can be checked using the Order ID of a transaction.
  3. Midtrans sends HTTP POST Notification with these custom fields to Payment Notification URL specified on MAP.
{
  "payment_type": "bank_transfer",
  "bank_transfer": {
    "bank": "permata"
  },
  "transaction_details": {
    "order_id": "C17550",
    "gross_amount": 145000
  },
  "custom_field1": "custom field 1 content",
  "custom_field2": "custom field 2 content",
  "custom_field3": "custom field 3 content"
}
{
    "status_code": "200",
    "status_message": "Success, Credit Card transaction is successful",
    "transaction_id": "1eae238a-cb9e-4f92-b284-aac8b39e4eab",
    "order_id": "C17550",
    "gross_amount": "145000.00",
    "payment_type": "credit_card",
    "transaction_time": "2016-06-28 09:42:20",
    "transaction_status": "capture",
    "fraud_status": "accept",
    "approval_code": "256084",
    "masked_card": "48111111-1114",
    "bank": "bni"
}

Set Custom Field Notifications

{
  "masked_card": "48111111-1114",
  "approval_code": "256084",
  "bank": "bni",
  "transaction_time": "2016-06-28 09:42:20",
  "custom_field1": "Toko Rani",
  "custom_field2": "Jakarta",
  "custom_field3": "RR",
  "gross_amount": "10000.00",
  "order_id": "C17550",
  "payment_type": "credit_card",
  "signature_key": "ad7ccda03d8ec6f2f415661fb511d47fcd17dcc7d7e1ade96a305dd5d3bc2bea5438a8bdfe1aeedabdefb226000338ac169fc18d5ae73788fd5e78dbac945ce4",
  "status_code": "200",
  "transaction_id": "1eae238a-cb9e-4f92-b284-aac8b39e4eab",
  "transaction_status": "capture",
  "fraud_status": "accept",
  "status_message": "midtrans payment notification"
}
JSON AttributeDescriptionType
custom_field1The value of custom field 1.String(255)
custom_field2The value of custom field 2.String(255)
custom_field3The value of custom field 3.String(255)


Set Custom Expiry

{
  "payment_type": "bank_transfer",
  "bank_transfer": {
    "bank": "permata"
  },
  "transaction_details": {
    "order_id": "C17550",
    "gross_amount": 145000
  },
  "custom_expiry": {
      "order_time": "2016-12-07 11:54:12 +0700",
      "expiry_duration": 60,
      "unit": "minute"
  }
}

Set Custom Expiry feature enables you to set an expiry time for the payment of every transaction with transaction_status:pending. The list of payment methods, with transaction_status:pending is given below.

The transaction is rejected if the custom expiry exceeds the allowed maximum time.

See Custom Expiry Object for reference.

📘

Note

  • For QRIS with acquirer AirPay (Shopee) and ShopeePay, the allowed maximum time of expiry is one hour.
  • For Gopay, the allowed maximum time of expiry is 7 days.


Set Metadata

Set Metadata is similar to Set Custom Field which enables you to put free-form JSON object instead of String. You can use this metadata as a transaction tag and retrieve it using Get Status or HTTP Notifications URL. Additionally, you can also configure the fraud detection rules based on the metadata fields.

{
  "payment_type": "bank_transfer",
  "bank_transfer": {
    "bank": "permata"
  },
  "transaction_details": {
    "order_id": "C17550",
    "gross_amount": 145000
  },
  "metadata": {
    "you": "can",
    "put": "any",
    "parameter": "you like"
  }
}
{
    "status_code": "200",
    "status_message": "Success, Credit Card transaction is successful",
    "transaction_id": "1eae238a-cb9e-4f92-b284-aac8b39e4eab",
    "order_id": "C17550",
    "gross_amount": "145000.00",
    "payment_type": "credit_card",
    "transaction_time": "2016-06-28 09:42:20",
    "transaction_status": "capture",
    "fraud_status": "accept",
    "approval_code": "256084",
    "masked_card": "48111111-1114",
    "bank": "bni"
}
{
  "masked_card": "48111111-1114",
  "approval_code": "256084",
  "bank": "bni",
  "transaction_time": "2016-06-28 09:42:20",
  "gross_amount": "10000.00",
  "order_id": "C17550",
  "payment_type": "credit_card",
  "signature_key": "ad7ccda03d8ec6f2f415661fb511d47fcd17dcc7d7e1ade96a305dd5d3bc2bea5438a8bdfe1aeedabdefb226000338ac169fc18d5ae73788fd5e78dbac945ce4",
  "status_code": "200",
  "transaction_id": "1eae238a-cb9e-4f92-b284-aac8b39e4eab",
  "transaction_status": "capture",
  "fraud_status": "accept",
  "status_message": "midtrans payment notification",
  "metadata": {
    "you": "can",
    "put": "any",
    "parameter": "you like"
  }
}
JSON AttributeDescriptionType
metadataObject containing the metadata parameters.JSON Object
Language
Authorization
Basic
base64
:
Click Try It! to start a request and see the response here!