Snap PHP Integration Steps

  1. Obtain Snap Token
  2. Show Snap Payment page
  3. Transaction Status
  4. Handling HTTP Notification
  5. Get Status Process


Obtaining Snap Token

On this step, we will try to obtain the Snap token when performing a transaction. There are at least 3 components that are required to obtain the Snap token:

  1. server key
  2. Transaction ID
  3. Transaction Total Nominal


The example below shows a sample PHP Code to obtain Snap token.

<?php
require_once(dirname(__FILE__) . 'Veritrans.php');

//Set Your server key
Veritrans_Config::$serverKey = "<Set your Sandbox ServerKey here>";

// Uncomment for production environment
// Veritrans_Config::$isProduction = true;

Veritrans_Config::$isSanitized = true;
Veritrans_Config::$is3ds = true;

$transaction = array(
    'transaction_details' => array(
        'order_id' => "<your order_id>",
        'gross_amount' => 10000 // no decimal allowed
        )
    );

$snapToken = Veritrans_Snap::getSnapToken($transaction);
?>


The sample code above utilizes the Veritrans-PHP library that can been downloaded at [Github - Zip] and used at the sandbox/test environment.

Veritrans.php file is assumed to be located in the same directory as the source code. server_key value has been explained on Getting Started - Preparation.

By default, all available payment methods will be displayed on the Snap page. To enable only specifics payment methods, follow the steps in Snap - Other Features.


Adding Transaction Information (Optional)

Merchant can add more information in the variable $transaction, i.e. customer data, order item data, and method of payment. This addition of data will affect the Snap payment page and transaction log on the MAP (Merchant Administration Portal).

Most fields on Snap page will be filled automatically and information related to order item and delivery address will be displayed.
Complete details of Snap transaction data structure and attributes can be found in Snap API reference.

PHP sample code that includes all transaction data is shown as follow:

<?php
require_once(dirname(__FILE__) . 'Veritrans.php');

//Set Your server key
Veritrans_Config::$serverKey = "<Set your Sandbox ServerKey here>";

// Uncomment for production environment
// Veritrans_Config::$isProduction = true;

Veritrans_Config::$isSanitized = true;
Veritrans_Config::$is3ds = true;

// Fill transaction details
$transaction_details = array(
  'order_id' => rand(),
  'gross_amount' => 145000, // no decimal allowed
);

// Mandatory for Mandiri bill payment and BCA KlikPay
// Optional for other payment methods
$item1_details = array(
    'id' => 'a1',
    'price' => 50000,
    'quantity' => 2,
    'name' => "Apple"
    );

// Optional
$item2_details = array(
    'id' => 'a2',
    'price' => 45000,
    'quantity' => 1,
    'name' => "Orange"
    );

$item_details = array ($item1_details, $item2_details);

// Optional
$billing_address = array(
    'first_name'    => "Andri",
    'last_name'     => "Litani",
    'address'       => "Mangga 20",
    'city'          => "Jakarta",
    'postal_code'   => "16602",
    'phone'         => "081122334455",
    'country_code'  => 'IDN'
    );

// Optional
$shipping_address = array(
    'first_name'    => "Obet",
    'last_name'     => "Supriadi",
    'address'       => "Manggis 90",
    'city'          => "Jakarta",
    'postal_code'   => "16601",
    'phone'         => "08113366345",
    'country_code'  => 'IDN'
    );

$customer_details = array(
    'first_name'    => "Andri", //optional
    'last_name'     => "Litani", //optional
    'email'         => "andri@litani.com", //mandatory
    'phone'         => "081122334455", //mandatory
    'billing_address'  => $billing_address, //optional
    'shipping_address' => $shipping_address //optional
    );

// Fill transaction details
$transaction = array(
    'transaction_details' => $transaction_details,
    'customer_details' => $customer_details,
    'item_details' => $item_details,
    );

$snapToken = Veritrans_Snap::getSnapToken($transaction);
?>



Response On Snap Token Request

Status Code Description Example
201 Success obtain Snap token. "token": "d379aa71-99eb-4dd1-b9bb-eefe813746e9"
400 Failed. Wrong parameter. "transaction_details.gross_amount is not equal to the sum of item_details"
401 Failed. Credential key error. "Access denied, please check client or server key"
500 Failed. Something happen on our system. "Sorry, we encountered internal server error. We will fix this soon."

Show Snap Payment page

On this step, we will try to show Snap payment page. There are at least 3 components that are required to do this:

  1. Client Key
  2. Snap.js
  3. Snap token

Include snap.js into your page so that snap module will be available. Don’t forget to put your CLIENT-KEY as the value of data-client-key attribute in snap.js script tag.

<html>
  <head>
    <script type="text/javascript"
            src="https://app.sandbox.midtrans.com/snap/snap.js"
            data-client-key="<Set Your Sandbox Client Key Here>"></script> 
  </head>
  <body>
    <button id="pay-button">Pay!</button>
    <script type="text/javascript">
      var payButton = document.getElementById('pay-button');
      payButton.addEventListener('click', function () {
        snap.pay('<?php echo $snap_Token; ?>'); // store your snap token here
      });
    </script>
  </body>
</html>


Referring to the steps above, the displayed Snap page is as follows:

snap

Transaction Status

Midtrans provides three means for merchant to obtain the transaction status.

  1. Email Notification
  2. HTTP(S) Notification
  3. Merchant Administration Portal

Email Notification

Merchant can configure the email notification setting at Settings - Email Notification in MAP.

config_payment



HTTP(S) POST Notification

Notification through HTTP(S) POST will be sent to the merchant’s server when customer completes the payment process. Merchant can utilize the HTTP(S) POST notification to update a payment status or send the item of a transaction in real time.

Enable Midtrans HTTP(S) POST Notification by setting the Payment Notification URL at Settings - Configuration.
config_payment


The content of the HTTP(S) POST notification consists of JSON object.
A sample notification is described as followed:

Credit Card

HTTP Notification example of a successful credit card transaction:

{
  "status_code": "200",
  "status_message": "Veritrans payment notification",
  "transaction_id": "3a351906-2a89-47b6-8b88-d890e626ba4d",
  "masked_card": "481111-1114",
  "order_id": "VTCC001",
  "payment_type": "credit_card",
  "transaction_time": "2015-04-27 14:29:32",
  "transaction_status": "capture",
  "fraud_status": "accept",
  "approval_code": "1430119773366",
  "signature_key": "e192d421a3a4ad5c53d866d6591d75c3982e4019cd6f8954a0aa0d9387af44b983ca182c9c8b0fdfd5ba1ec2d10057f37b6dfb86742f5657800fa82282993e68",
  "bank": "mandiri",
  "eci": "05",
  "gross_amount": "145000.00"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
capture Transaction is accepted and ready to for settlement.
cancel Transaction is cancelled and will not proceed to settlement.
settlement Funds from the transaction has moved from customer to merchant's account.
deny Transaction is denied by the bank or Midtrans Fraud Detection System.


fraud_status Definition
accept Transaction passes Midtrans Fraud Detection System.
challenge Transaction is a suspicious transaction. Manually accepts or denied transaction.
deny Transaction is denied by Midtrans Fraud Detection System.


Transaction result between transaction_status and fraud_status

transaction_status fraud_status Definition
capture accept Transaction success
capture challenge Transaction challenge (hit our FDS). Manually accepts or denied transaction.
deny any Transaction is denied



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for credit card: map_transaction


List of available MAP transaction status for Credit Card is described below:

Transaction Status Definition
Success Transaction is accepted and will be settled.
Challenge Credit card transaction is marked as suspicious transaction by Midtrans Fraud Detection System. Merchant has to manually Accept or Deny the transaction through Midtrans Dashboard.
Failure Failure transaction can be caused by various reasons:
1. Transaction is denied by the Bank.
2. Credit card transaction is rejected by Midtrans Fraud Detection System.
Cancel Cancelled transaction can be caused by various reasons:
1. Successful transaction is cancelled before Settlement.
2. Challenge Transaction is denied by merchant.

Permata Virtual Account

HTTP Notification example of a successful Permata Virtual Account transaction:

{
  "status_code": "200",
  "status_message": "Veritrans payment notification",
  "transaction_id": "9a31e442-951f-490d-9b9c-9e618ec98874",
  "order_id": "VTVA001",
  "payment_type": "bank_transfer",
  "transaction_time": "2015-04-27 14:39:16",
  "transaction_status": "settlement",
  "permata_va_number": "8778006776893528",
  "signature_key": "31b482e796c35153e829a85c59d831313694cd0c7cecdbb85a7a33474f431fbea75f440f57d09608ea1889a9eedd950017f1162ae37a2ec9b00084d932fb5309",
  "gross_amount": "145000.00"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
pending payment transaction has not been processed and is waiting to be completed.
cancel Transaction has been cancelled. Permata VA Number is now invalid.
expire Transaction has not been completed by the expiry date. Permata VA Number is now invalid.
settlement Funds from the transaction has moved from customer to merchant's account.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for Permata Virtual Account: Snap transfer Test 3


List of available MAP transaction status for Permata Virtual Account is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by various reasons:
1. Transaction is denied by the Bank.
2. Pending Transaction has not been paid and is expired.

Mandiri Clickpay

HTTP Notification example of a successful Mandiri clickpay transaction:

{
  "status_code": "200",
  "status_message": "Veritrans payment notification",
  "transaction_id": "fdb6322d-2fef-42c5-a956-d6b575247f0b",
  "masked_card": "411111-1111",
  "order_id": "VTMC001",
  "payment_type": "mandiri_clickpay",
  "transaction_time": "2015-04-27 14:44:38",
  "transaction_status": "settlement",
  "fraud_status": "accept",
  "approval_code": "1430120681256",
  "signature_key": "6dfe98c7e8e1cc4725fa10d82e696816a04c5c0fdf819af3fef65d825b4b1cad0c024a3f1813f3cb590657d8cd3edabfb4e91dbb4376344f7460ed00637cd967",
  "gross_amount": "145000.00"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
settlement Funds from the transaction has moved from customer to merchant's account.
deny Transaction is denied by the bank.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for Mandiri Clickpay: Snap Mandiri Test 3


List of available MAP transaction status for Mandiri clickpay is described below:

Transaction Status Definition
Settlement Transaction is accepted and has been settled.
Failure Transaction is denied by the Bank.

CIMB Clicks

HTTP Notification example of a successful CIMB Clicks transaction:

{
  "status_code": "200",
  "status_message": "Veritrans payment notification",
  "transaction_id": "47c11d2a-a8ca-4337-8681-8837ad023d65",
  "order_id": "VTCimb001",
  "payment_type": "cimb_clicks",
  "transaction_time": "2015-04-27 14:58:01",
  "transaction_status": "settlement",
  "approval_code": "1430121525724",
  "signature_key": "d70a32353c173b543b7580f8927a3c46c547ef4486457ca8b61f44eb644e7a76cccbbd244ec6f188d3ef8cc164950a02f8350e7d305fd635795b909aa0188975",
  "gross_amount": "145000.00"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
pending Transaction has not been processed and is waiting to be completed.
cancel CIMB Clicks transaction has been cancelled.
expire CIMB Clicks Transaction has not been completed after 2 hours.
deny Transaction is denied by the bank.
settlement Funds from the transaction has moved from customer to merchant's account.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for CIMB Clicks: Snap CIMB Test 4


List of available MAP transaction status for CIMB Clicks is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by various reasons:
1. Transaction is denied by the Bank.
2. Pending Transaction has not been paid and is expired.

e-Pay BRI

HTTP Notification example of a successful e-Pay BRI transaction:

{
  "status_code": "200",
  "status_message": "Veritrans payment notification",
  "transaction_id": "3479c572-1d36-49c0-b5b1-22c876df411f",
  "order_id": "VTEB001",
  "payment_type": "bri_epay",
  "transaction_time": "2015-04-27 15:04:48",
  "transaction_status": "settlement",
  "fraud_status": "accept",
  "approval_code": "1430121888862",
  "signature_key": "39ec591fbf754982e0fb83d125b60ff1863b41878799d1adada69476d6f3b746631addce8bf51a9d7bb76d92cea5a4291d57ed4626c0dc8cfefa5f3112887bcd",
  "gross_amount": "145000.00"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
pending Transaction has not been processed and is waiting to be completed.
cancel e-Pay BRI transaction has been cancelled.
expire e-Pay BRI Transaction has not been completed after 2 hours.
deny Transaction is denied by the bank.
settlement Funds from the transaction has moved from customer to merchant's account.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for e-Pay BRI: Snap epay Test 4


List of available MAP transaction status for e-Pay BRI is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Refer to Dashboard Operation to know more about Settlement.
Failure Failure transaction can be caused by various reasons:
1. Transaction is denied by the Bank.
2. Pending Transaction has not been paid and is expired.


GO-PAY

HTTP Notification example of a successful GO-PAY transaction:

{
  "status_code": "200",
  "status_message": "midtrans payment notification",
  "transaction_id": "1c28dbbb-8596-48e4-85d7-9f1382db8a1f",
  "order_id": "order03",
  "gross_amount": "275000.00",
  "payment_type": "gopay",
  "transaction_time": "2016-06-19 15:54:42",
  "transaction_status": "settlement",
  "signature_key": "973d175e6368ad844b5817882489e6b22934d796a41a0573c066b1e64532dc0001087b87d877a3eac37cba20a733e1305f5e62739e65ff501d5d33c5ac62530f"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
pending QR/Link created, but transaction has not been paid by customer and is waiting to be completed.
cancel GO-PAY transaction has been cancelled.
expire GO-PAY Transaction has not been completed after 15 minutes (can be customized).
settlement Funds from the transaction has moved from customer to merchant's account.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.


List of available MAP transaction status for GO-PAY is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Refer to Dashboard Operation to know more about Settlement.
Failure Failure transaction can be caused by various reasons:
1. Transaction is denied by the Provider.
2. Pending Transaction has not been paid and is expired.


Telkomsel Cash

HTTP Notification example of a successful Telkomsel Cash transaction:

{
  "status_code": "200",
  "status_message": "Veritrans payment notification",
  "transaction_id": "ee925bec-3bef-43a6-bb10-cbe8ab8fa68a",
  "order_id": "Test-Order-6",
  "payment_type": "telkomsel_cash",
  "transaction_time": "2015-04-27 15:08:21",
  "transaction_status": "settlement",
  "signature_key": "a1ea0f3fd4690896464752a311fe0d7e53c9f75138f06c1cdd4d4d8bf7664214ff9ef2966a966e9507709041d6403f81ea2b3b76ce67f1437bc5e82913c4c545",
  "gross_amount": "145000.00"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
deny Transaction is denied by the provider.
settlement Funds from the transaction has moved from customer to merchant's account.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for Telkomsel Cash: Snap Tcash


List of available MAP transaction status for Telkomsel Cash is described below:

Transaction Status Definition
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by various reasons:
1. Transaction is denied by the Bank.
2. Pending Transaction has not been paid and is expired.

XL Tunai

HTTP Notification example of a successful XL Tunai transaction:

{
  "status_code": "200",
  "status_message": "Veritrans payment notification",
  "transaction_id": "1731610c-cbe5-4f59-a976-8206f3a59bc0",
  "order_id": "vtimage07",
  "payment_type": "xl_tunai",
  "transaction_time": "2015-04-27 15:20:40",
  "transaction_status": "settlement",
  "signature_key": "288f5b0f069d5d15383d1e0a13c34944c8681f5d0d1168727e9a3678581bda48736780b558567d16d35be9ee09f552f9a008f04980a5afef6bfc57a6df180f78",
  "gross_amount": "145000.00"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
pending Transaction has not been processed and is waiting to be completed.
cancel XL Tunai transaction has been cancelled.
expire XL Tunai Transaction has not been completed after 2 hours.
deny Transaction is denied by the bank.
settlement Funds from the transaction has moved from customer to merchant's account.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for XL Tunai: Snap transfer Test 3


List of available MAP transaction status for XL Tunai is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by various reasons:
1. Transaction is denied by the Bank.
2. Pending Transaction has not been paid and is expired.

Mandiri Bill Payment

HTTP Notification example of a successful Mandiri Bill Payment transaction:

{
    "status_code": "200",
    "status_message": "Success, Mandiri Bill transaction is successful",
    "transaction_id": "0b53c7dc­e63c­4bbc­a371­6b1ca5c925c7",
    "order_id": "1421816431",
    "payment_type": "echannel",
    "transaction_time": "2015­01­21 12:00:31",
    "transaction_status": "settlement",
    "fraud_status": "accept",
    "biller_code": "70012",
    "bill_key": "000857123456",
    "signature_key": "e04f6657ee37f44c625282ac0a505cc1ea776901e51708823fe63921f47e24277868fc6f1e3ea1071074ab32455d679b47b20b4ad56a4ecba1d1dc9bbfa3aa80",
    "gross_amount": "400000.00"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
pending Transaction has not been processed and is waiting to be completed.
cancel Transaction has been cancelled. Mandiri Bill Number is now invalid.
expire Transaction has not been completed by the expiry date. Mandiri Bill Number is now invalid.
settlement Funds from the transaction has moved from customer to merchant's account.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for Mandiri Bill Payment: Snap mbill Test 3


List of available MAP transaction status for Mandiri Bill Payment is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by various reasons:
1. Transaction is denied by the Bank.
2. Pending Transaction has not been paid and is expired.

Indomaret

HTTP Notification example of a successful Indomaret transaction:

{
     "status_code": "200",
     "status_message": "Veritrans payment notification",
     "transaction_id": "f8e2c3f8-e210-45ab-88ec-c0be989b0631",
     "order_id": "0900099957582",
     "gross_amount": "149000.00",
     "payment_type": "cstore",
     "transaction_time": "2017-01-19 14:39:01",
    "transaction_status": "settlement",
     "approval_code": "09211701070999568803",
     "signature_key": "4a14241267ff535503c65074407beb98fa81a2c031435afe5a5d523905d3ba3222427831945719ff285738dd28c4d32afeb7aca32f026070c58b9fa4520b3",
     "payment_code": "63756290009995",
     "store": "indomaret"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
pending Transaction has not been processed and is waiting to be completed.
cancel Transaction has been cancelled. Indomaret payment code Number is now invalid.
expire Transaction has not been completed by the expiry date. Indomaret payment code Number is now invalid.
settlement Funds from the transaction has moved from customer to merchant's account.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status under Transaction menu on MAP.

Example of a successful transaction status for Indomaret: Snap indomrt3


List of available MAP transaction status for Indomaret is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by various reasons:
1. Transaction is denied by the Bank.
2. Pending Transaction has not been paid and is expired.

Alfamart

HTTP Notification example of a successful Alfamart transaction:

{
  "status_code": "200",
  "status_message": "midtrans payment notification",
  "transaction_id": "991af93c-1049-4973-b38f-d6052c72e367",
  "order_id": "order04",
  "gross_amount": "162500.00",
  "payment_type": "cstore",
  "transaction_time": "2016-06-20 11:44:07",
  "transaction_status": "settlement",
  "approval_code": "59061607081045705101",
  "signature_key": "a198f93ac43cf98171dcb4bd0323c7e3afbee77a162a09e2381f0a218c761a4ef0254d7650602971735c486fea2e8e9c6d41ee65d6a53d65a12fb1c824e86f9f",
  "payment_code": "25709650945026",
  "store": "alfamart"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
pending Transaction has not been processed and is waiting to be completed.
cancel Transaction has been cancelled. Alfamart payment code Number is now invalid.
expire Transaction has not been completed by the expiry date. Alfamart payment code Number is now invalid.
settlement Funds from the transaction has moved from customer to merchant's account.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status under Transaction menu on MAP.

Example of a successful transaction status for Alfamart: Snap alfamart


List of available MAP transaction status for Indomaret is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by various reasons:
1. Transaction is denied by Alfamart.
2. Pending Transaction has not been paid and is expired.

Akulaku

HTTP Notification example of a successful Akulaku transaction:

{
  "transaction_time": "2018-08-24 16:20:36",
  "gross_amount": "11000.00",
  "order_id": "orderid-01",
  "payment_type": "akulaku",
  "signature_key": "35c4111539e184b268b7c1cd62a9c254e5d27c992c8fd55084f930b69b09eaafcfe14b0d512c697648295fdb45de777e1316b401f4729846a91b3de88cde3f05",
  "status_code": "200",
  "transaction_id": "b3a40398-d95d-4bb9-afe8-9a57bc0786ea",
  "transaction_status": "settlement",
  "fraud_status": "accept",
  "status_message": "midtrans payment notification"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
pending Transaction has not been processed and is waiting to be completed.
deny Transaction is denied by Akulaku.
settlement Funds from the transaction has moved from customer to merchant's account.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status under Transaction menu on MAP.

Example of a successful transaction status for Akulaku: Snap akulaku


List of available MAP transaction status for Akulaku is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by various reasons:
1. Transaction is denied by Akulaku.
2. Pending Transaction has not been paid and is expired.

Indosat Dompetku

HTTP Notification example of a successful Indosat Dompetku transaction:

{
  "status_code": "200",
  "status_message": "Veritrans payment notification",
  "transaction_id": "0b7696f1-f9ca-4f4b-a389-ede2c2dddb5c",
  "order_id": "vtdompetku03",
  "payment_type": "indosat_dompetku",
  "transaction_time": "2015-06-24 11:20:24",
  "transaction_status": "settlement",
  "signature_key": "73c70c8354e0705a16bd5d47d0ab3029a70b79bef0fe3b29161557110205d3679f0ea177101f56fe6313a887f340be7d302750ce8a4e0f67753c70548159895e",
  "gross_amount": "145000.00"
}


Available HTTP(S) POST Notification Status

transaction_status Definition
deny Transaction is denied by the provider.
settlement Funds from the transaction has moved from customer to merchant's account.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for Indosat Dompetku: Snap dompetku Test 3


List of available MAP transaction status for Indosat Dompetku is described below:

Transaction Status Definition
Settlement Transaction is accepted and has been settled.
Failure Transaction is denied by the Provider.

Mandiri E-cash

HTTP Notification example of a successful Mandiri E-cash transaction:

{
  "status_code": "200",
  "status_message": "Veritrans payment notification",
  "transaction_id": "0b7696f1-f9ca-4f4b-a389-ede2c2dddb5c",
  "order_id": "vtecash03",
  "payment_type": "mandiri_ecash",
  "transaction_time": "2015-06-24 11:20:24",
  "transaction_status": "settlement",
  "signature_key": "73c70c8354e0705a16bd5d47d0ab3029a70b79bef0fe3b29161557110205d3679f0ea177101f56fe6313a887f340be7d302750ce8a4e0f67753c70548159895e",
  "gross_amount": "145000.00"
}


Available HTTP(S) POST Notification Status

Pending Transaction has not been processed and is waiting to be completed.
Settlement Transaction is accepted and has been settled.
Expired Failure transaction caused by pending Transaction has not been paid and is expired.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for Mandiri E-cash: Snap mandiriecash


List of available MAP transaction status for Mandiri E-cash is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by pending Transaction has not been paid and is expired.

BCA VA

HTTP Notification example of a successful BCA VA transaction:

{
    "va_numbers": [
          {
            "bank": "bca",
            "va_number": "05028708961"
          }
        ],
    "transaction_time": "2017-01-19 17:36:33",
    "gross_amount": "9000.00",
    "order_id": "test-1484822143",
    "payment_type": "bank_transfer",
    "signature_key": "cf2da321a084528d6bd4e66ee813212cb2ad0532ddfe2ac40c2cd38385b625ab20d426dbfa7d8729aeac36bb0f1c556a476d25945bc8b258f22f99895dade602",
    "status_code": "200",
    "transaction_id": "30bd8825-4673-488a-a03d-1ceda4930b15",
    "transaction_status": "settlement",
    "fraud_status": "accept",
    "status_message": "Veritrans payment notification"
}


Available HTTP(S) POST Notification Status

Pending Transaction that has not been completed.
Settlement Transaction is accepted and has been settled.
Expired Failure transaction caused by pending Transaction has not been paid and is expired.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for BCA VA: Snap bcava


List of available MAP transaction status for BCA VA is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by pending Transaction has not been paid and is expired.

BNI VA

HTTP Notification example of a successful BNI VA transaction:

{
  "va_numbers": [
    {
      "bank": "bni",
      "va_number": "8578000000111111"
    }
  ],
  "payment_amounts": [
    {
      "paid_at": "2016-06-19 20:12:22",
      "amount": "20000.00"
    }
  ],
  "transaction_time": "2016-06-19 19:12:22",
  "gross_amount": "20000.00",
  "order_id": "1466323342",
  "payment_type": "bank_transfer",
  "signature_key": "fe5f725ea770c451017e9d6300af72b830a668d2f7d5da9b778ec2c4f9177efe5127d492d9ddfbcf6806ea5cd7dc1a7337c674d6139026b28f49ad0ea1ce5107",
  "status_code": "200",
  "transaction_id": "9aed5972-5b6a-401e-894b-a32c91ed1a3a",
  "transaction_status": "settlement",
  "fraud_status": "accept",
  "status_message": "midtrans payment notification"
}


Available HTTP(S) POST Notification Status

Pending Transaction that has not been completed.
Settlement Transaction is accepted and has been settled.
Expired Failure transaction caused by pending Transaction has not been paid and is expired.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for BNI VA: Snap bniva


List of available MAP transaction status for BNI VA is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by pending Transaction has not been paid and is expired.

BCA KlikPay

HTTP Notification example of a successful BCA KlikPay transaction:

{
    "approval_code": "112233",
    "transaction_time": "2017-01-19 15:40:43",
    "gross_amount": "33000.00",
    "order_id": "bcaklikpay01",
    "payment_type": "bca_klikpay",
    "signature_key": "644e39ab19d830b9ebcd2b4ae9f28c2dfaab06a33dd47d3fe2a94f2229b2478eb0606c43eec16e9836294b479b2e9867c309aad7a93a2d32d8b2f81c731f3379",
    "status_code": "200",
    "transaction_id": "1e22e73d-b496-41d6-a7b0-3acb763d2020",
    "transaction_status": "settlement",
    "fraud_status": "accept",
    "status_message": "Veritrans payment notification"
}


Available HTTP(S) POST Notification Status

Pending Transaction that has not been completed.
Settlement Transaction is accepted and has been settled.
Expired Failure transaction caused by pending Transaction has not been paid and is expired.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for BCA KlikPay: Snap bcaklikpay


List of available MAP transaction status for BCA KlikPay is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by pending Transaction has not been paid and is expired.

Klik BCA

HTTP Notification example of a successful Klik BCA transaction:

{
    "status_code": "200",
    "status_message": "Veritrans payment notification",
    "transaction_id": "63d28e4d-870a-43ea-a0ef-7739e0104f9a",
    "order_id": "jktrs11715",
    "gross_amount": "99000.00",
    "payment_type": "bca_klikbca",
    "transaction_time": "2017-01-13 14:50:02",
    "transaction_status": "settlement",
    "approval_code": "aius11715",
    "signature_key": "a2a6e288d6ab8e6d9101c99b4df1ee285d62fdd9e160a66a2d7463521dfc2a928224256a932963c2f4d8ee486d90123cfcef770651afc55a5fb8af00100477d4"
}


Available HTTP(S) POST Notification Status

Pending Transaction that has not been completed.
Settlement Transaction is accepted and has been settled.
Expired Failure transaction caused by pending Transaction has not been paid and is expired.



Merchant Admin Portal(MAP) Transaction Status

Merchant can check the transactions status from payments menu on MAP.

Example of a successful transaction status for Klik BCA: Snap klikbca


List of available MAP transaction status for Klik BCA is described below:

Transaction Status Definition
Pending Transaction that has not been completed will generate a Pending status.
Once customer complete the transaction, the status will turn into Settlement.
Settlement Transaction is accepted and has been settled.
Failure Failure transaction can be caused by pending Transaction has not been paid and is expired.

Handling HTTP(S) Notification

The following figure is a sample code for merchant to receive HTTP(S) POST and JSON object by utilizing Veritrans-PHP library. This PHP code is executed when notification URL endpoint (https://tokoecomm.com/notification) is accessed.


<?php

require_once('Veritrans.php');
Veritrans_Config::$isProduction = false;
Veritrans_Config::$serverKey = '<your serverkey>';
$notif = new Veritrans_Notification();

$transaction = $notif->transaction_status;
$type = $notif->payment_type;
$order_id = $notif->order_id;
$fraud = $notif->fraud_status;

if ($transaction == 'capture') {
  // For credit card transaction, we need to check whether transaction is challenge by FDS or not
  if ($type == 'credit_card'){
    if($fraud == 'challenge'){
      // TODO set payment status in merchant's database to 'Challenge by FDS'
      // TODO merchant should decide whether this transaction is authorized or not in MAP
      echo "Transaction order_id: " . $order_id ." is challenged by FDS";
      }
      else {
      // TODO set payment status in merchant's database to 'Success'
      echo "Transaction order_id: " . $order_id ." successfully captured using " . $type;
      }
    }
  }
else if ($transaction == 'settlement'){
  // TODO set payment status in merchant's database to 'Settlement'
  echo "Transaction order_id: " . $order_id ." successfully transfered using " . $type;
  }
  else if($transaction == 'pending'){
  // TODO set payment status in merchant's database to 'Pending'
  echo "Waiting customer to finish transaction order_id: " . $order_id . " using " . $type;
  }
  else if ($transaction == 'deny') {
  // TODO set payment status in merchant's database to 'Denied'
  echo "Payment using " . $type . " for transaction order_id: " . $order_id . " is denied.";
  }
  else if ($transaction == 'expire') {
  // TODO set payment status in merchant's database to 'expire'
  echo "Payment using " . $type . " for transaction order_id: " . $order_id . " is expired.";
  }
  else if ($transaction == 'cancel') {
  // TODO set payment status in merchant's database to 'Denied'
  echo "Payment using " . $type . " for transaction order_id: " . $order_id . " is canceled.";
}
?>



Get Status Process

In this step, we will try using get status process to retrieving information from a transaction that has occured. Here is a sample code to perform the get status process using Veritrans-php library.

<?php
include_once(dirname(__FILE__) . '/veritrans/Veritrans.php'); //include PHP library

Veritrans_Config::$serverKey = <Your Server Key>;
Veritrans_Config::$isProduction = <true / false>;   // false = sandbox
$order_status_obj = Veritrans_Transaction::status($order);
$status = $order_status_obj->transaction_status;
?>


Here's a sample code to do the get status process after a certain time duration. This code can run at certain interval (eg: every 6 minutes) or run manually.

<?php 
include_once(dirname(__FILE__) . '/veritrans/Veritrans.php');
Veritrans_Config::$serverKey = <Your Server Key>;
Veritrans_Config::$isProduction = <true / false>;   // false = sandbox

/**
 * Assume we can load order data from database to $orders array
 * Each $order is an object, with property of:
 * $order->timestamp : unix timestamp when order is created (timestamp)
 * $order->order_id  : order_id that is sent to Midtrans API (string)
 * $order->transaction_status : status of the order (string)
 * $order->set_status($status): update order status according to parameter (string)
 * $order->save()    : save the order to database
 */
$orders = /* LOAD FROM DATABASE AS ARRAY */ ;
foreach ($orders as $order) {
  //determine how long the order has been made (in seconds).
  $duration_since_order = time() - $order->timestamp;
  
  //check If the order after 360 seconds (6 minutes), and still no pending/capture/settlement/deny/cancel/failure status.
  if ( $duration_since_order > 360 && $order->transaction_status === null ){
    //Do get status for that order
    $order_status_obj = Veritrans_Transaction::status($order->order_id);
    $status = $order_status_obj->transaction_status;
    
    //Update order status & save to database
    $order->set_status($status);
    $order->save();
  }
}
?>


Get status response

Success Response

{
 "status_code" : "200",
  "status_message" : "Success, transaction found",
  "transaction_id" : "249fc620-6017-4540-af7c-5a1c25788f46",
  "masked_card" : "481111-1114",
  "order_id" : "example-1424936368",
  "payment_type" : "credit_card",
  "transaction_time" : "2015-02-26 14:39:33",
  "transaction_status" : "capture",
  "fraud_status" : "accept",
  "approval_code" : "1424936374393",
  "signature_key" : "2802a264cb978fbc59f631c68d120cbda8dc853f5dfdc52301c615cf4f14e7a0b09aa...",
  "bank" : "bni",
  "gross_amount" : "30000.00"
}


Failed respon

{
  "status_code": "404",
  "status_message": "The requested resource is not found"
}

For more information about the getStatus API, visit the following page: API getStatus.

Why merchants need to use getStatus process?

Merchants need to use the getStatus process if the notification of http (s) submitted by Midtrans is considered late by the merchant.