API Documentation October 18, 2016
API Documentation October 18, 2016
by midtrans
Contents
1 Getting Started 3
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1. Register to Veritrans Sandbox/Production account. . . . . . . . . . . . . . . . . . 5
2. Fill in the required information in Merchant Admin Portal (MAP). . . . . . . . . . . 6
3. Take note of your account Access Keys. . . . . . . . . . . . . . . . . . . . . . . . 7
4. Configure Redirection URL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Library and Plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2 Backend Integration 12
Endpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Request Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
JSON Parameter (Request Body) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
JSON Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Credit Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Expiry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Response Success . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Response Failed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3 Frontend Integration 20
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Snap.js location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Snap JS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
pay(snapToken, options) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
show() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1
hide() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
JS Callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4 Other Features 26
Two Clicks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Initial Transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Successive Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5 Status Code 28
Code 2xx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Code 3xx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Code 4xx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Code 5xx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6 Testing Credentials 32
Credit Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
General Testing Card Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Bank-Specific Testing Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Expiry Date and CVV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Bank Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Direct Debit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
e-Wallet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Convenience Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2
Getting Started
Overview
3
payment flow
Preparation
4
1. Register to Veritrans Sandbox/Production account.
Veritrans has one central login to access both production and sandbox account. Sandbox is utilized
for development period while production is utilized when the merchant has completed the integra-
tion process and want to go live. Data and transaction made on sandbox account will not trigger an
actual purchase while in production account will trigger an actual process. Register for Veritrans Sand-
box/Production account here.
Once logged in, there will be a small button on the header of the dashboard that shows
you on whether you are in the production or sandbox environment. The color of the na-
givation sidebar also set differently between Production (light blue) and Sandbox (dark
blue) for further clarity.
5
2. Fill in the required information in Merchant Admin Portal (MAP).
6
general settings
Warning!
7
access keys
Caution!
8
redirection url
9
map redirection url
Warning!
We are trying to make the integration process as easy as possible. This section contains a list of plugins
and libraries owned by Veritrans. If you write your own plugin or library and would like us to link it,
contact [email protected].
Libraries
10
Platform Resources
PHP Github
Plugin
Platform Resources
Prestashop v1.6
Github
Magento v1.8, v1.9
Github
Opencart v2.0, v2.1, v2.2
Github
Wordpress Wordpress v3.9.1 - v4.x
Woocommerce WooCommerce v2.1.11 - v2.5.x
Github
11
Backend Integration
Endpoint
Production: https://app.veritrans.co.id/snap/v1/transactions
Sandbox: https://app.sandbox.veritrans.co.id/snap/v1/transactions
Request Headers
SERVER_KEY = "VT-server-Cpo03kYDOc0cNUKgt6hnLkKg"
AUTH_STRING = Base64("VT-server-Cpo03kYDOc0cNUKgt6hnLkKg:")
AUTH_STRING = "VlQtc2VydmVyLUNwbzAza1lET2MwY05VS2d0NmhuTGtLZzo="
• Accept: application/json
• Content-Type: application/json
• Authorization: Basic AUTH_STRING
12
Snap validates HTTP request by using Basic Authentication method. The username is your
SERVER_KEY while the password is empty. You can see your SERVER-KEY on Settings - Access
Keys.
AUTH_STRING = Base64(SERVER_KEY + :)
Short request
{
"transaction_details": {
"order_id": "ORDER-101",
"gross_amount": 10000
}
}
Complete request
{
"transaction_details": {
"order_id": "ORDER-101",
"gross_amount": 10000
},
"credit_card": {
"secure": true,
"channel": "migs",
"bank": "bca",
"installment": {
"required": false,
"terms": {
"bni": [3, 6, 12],
"mandiri": [3, 6, 12],
"cimb": [3],
"bca": [3, 6, 12],
"offline": [6, 12]
}
}
13
},
"item_details": [{
"id": "ITEM1",
"price": 10000,
"quantity": 1,
"name": "Veritrans Bear"
}],
"customer_details": {
"first_name": "TEST",
"last_name": "VERITRANSER",
"email": "[email protected]",
"phone": "+628123456",
"billing_address": {
"first_name": "TEST",
"last_name": "VERITRANSER",
"email": "[email protected]",
"phone": "081 2233 44-55",
"address": "Sudirman",
"city": "Jakarta",
"postal_code": "12190",
"country_code": "IDN"
},
"shipping_address": {
"first_name": "TEST",
"last_name": "VERITRANSER",
"email": "[email protected]",
"phone": "0 8128-75 7-9338",
"address": "Sudirman",
"city": "Jakarta",
"postal_code": "12190",
"country_code": "IDN"
}
},
"expiry": {
"start_time": "2017-04-13 18:11:08 +0700",
"unit": "minutes",
"duration": 1
}
}
14
Parameter Description
transaction_details.order_id Unique transaction ID. A single ID could be used only
String(255) (required) once by a Merchant.
transaction_details.gross_amount Amount to be charged
Integer (required)
enabled_payments List of payment types that should be enabled. If blank,
Array (optional) all active payment types are included.
Options:
credit_card, mandiri_clickpay, cimb_clicks,
bca_klikbca, bca_klikpay, bri_epay,
telkomsel_cash, echannel, bbm_money, xl_tunai,
indosat_dompetku, mandiri_ecash, permata_va,
bca_va, kioson, indomaret.
15
JSON Object
Address
{
"first_name": "TESTER",
"last_name": "VERITRANS",
"email": "[email protected]",
"phone": "081 2233 44-55",
"address": "Sudirman",
"city": "Jakarta",
"postal_code": "12190",
"country_code": "IDN"
}
Parameter Description
first_name
String(255)
last_name
String(255)
email
String(255)
phone
String(255)
address
String(255)
country_code
String(255)
postal_code
String(255)
city
String(255)
16
Credit Card
{
"save_card": true,
"secure": true,
"channel": "migs",
"bank": "maybank",
"installment": {
"required": false,
"terms": {
"bni": [3, 6, 12],
"mandiri": [3, 6, 12],
"cimb": [3],
"bca": [3, 6, 12],
"offline": [6, 12]
}
}
}
Parameter Description
secure Use 3D-Secure authentication when using credit card
Boolean
bank Acquiring bank. Options: bca, bni, mandiri, cimb, bri,
String danamon, maybank
channel Acquiring channel. Options: migs
String
whitelist_bins Allowed credit card BIN number
Array
installment.required Force installment when using credit card
Boolean
installment.terms Available installment terms
Object
Expiry
{
"start_time": "2017-04-13 18:11:08 +0700",
17
"unit": "minutes",
"duration": 1
}
Parameter Description
start_time Timestamp in yyyy-MM-dd hh:mm:ss Z format
String(255)
duration
Integer
unit Expiry unit. Options: day, hour, minute (plural term
String also accepted)
Response
Response Success
{
"token": "d379aa71-99eb-4dd1-b9bb-eefe813746e9"
}
Field Description
token Snap token for frontend integration
String(36)
Response Failed
Authentication Failed
{
"error_messages": [
"Access denied, please check client or server key"
]
18
}
Field Description
error_messages Error messages
Array
Validation Error
{
"error_messages": [
"transaction_details.gross_amount is not equal to the sum of item_details"
]
}
Field Description
error_messages Error messages
Array
{
"error_messages": [
"Sorry, we encountered internal server error. We will fix this soon."
]
}
Field Description
error_messages Error messages
Array
19
Frontend Integration
Summary
<html>
<head>
<script type="text/javascript"
src="https://app.sandbox.veritrans.co.id/snap/snap.js"
data-client-key="CLIENT-KEY"></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('<SNAP_TOKEN>');
});
</script>
</body>
</html>
Frontend integration goal is to show Snap payment page within your site.
Include snap.js into your page so snap module is available. Don’t forget to put your CLIENT-KEY as
value of data-client-key attribute in snap.js script tag. You can see your CLIENT-KEY on Settings
- Access Keys.
You can start payment process by calling snap.pay with SNAP_TOKEN acquired from backend integra-
tion as parameter.
20
Snap.js location
Production: https://app.veritrans.co.id/snap/snap.js
Sandbox: https://app.sandbox.veritrans.co.id/snap/snap.js
Snap JS
pay(snapToken, options)
snap.pay('YOUR_SNAP_TOKEN', {
onSuccess: function(result){console.log('success');console.log(result);},
onPending: function(result){console.log('pending');console.log(result);},
onError: function(result){console.log('error');console.log(result);},
onClose: function(){console.log('customer closed the popup without finishing the p
})
Parameter:
Name Description
snapToken token acquired from backend integration
String (required)
options.onSuccess Payment success callback (200 status_code)
Function (optional)
options.onPending Payment pending callback (201 status_code)
Function (optional)
options.onError Payment error callback (4xx or 5xx status_code)
Function (optional)
options.onClose Called if customer has closed the payment popup
Function (optional) prematurely without finishing the payment
options.language Sets the language. This will override language setting on
String (optional) Merchant Administration Portal. Supported values are
en (English) and id (Bahasa Indonesia). Defaults to id
options.skipOrderSummary Skips the order summary page if set to true. Set to
Boolean (optional) false by default.
21
Name Description
options.autoCloseDelay Auto closes the last page of indomaret and bank transfer
Integer (optional) payments after the specified time delay. The time delay
is specified in seconds. Setting it to 0 will disable this
feature. Defaults to 0.
onSuccess, onPending, & onError function accept one parameter which is Transaction Result ob-
ject.
if(snapToken){
callback(null, snapToken);
} else {
callback(new Error('Failed to fetch snap token'),null);
}
}
payButton.onclick(function(){
snap.show();
ajaxGetToken(transactionData, function(error, snapToken){
if(error){
snap.hide();
} else {
snap.pay(snapToken);
}
});
});
show()
Show snap loading page. Helper function if you want to show instant loading feedback while getting
SNAP_TOKEN using AJAX.
If AJAX success, call snap.pay to continue payment process. Else, call snap.hide to end loading
page.
22
hide()
Hide active snap page. Complementary function of snap.show. Helper function if you want to show
instant loading feedback while getting SNAP_TOKEN using AJAX.
JS Callback
23
Error result
{
"status_code": "406",
"status_message": ["transaction has been processed"]
}
Name Description
status_code Transaction status code. Possible value: 200, 201, 202,
String 400, 404, 406, 500
status_message Transaction status message
String
order_id Merchant’s payment ID
String
gross_amount Processed gross amount
String
payment_type Payment type paid by customer. Possible value:
String credit_card, bca_klikpay, bca_klikbca,
bri_epay, mandiri_clickpay, telkomsel_cash,
xl_tunai, bank_transfer, echannel,
indosat_dompetku, mandiri_ecash, cstore
transaction_time Timestamp in yyyy-MM-dd hh:mm:ss format
String
transaction_status Transaction status. Possible value: capture,
String settlement, pending, cancel, expired
fraud_status Fraud status. Possible values: accept, challenge,
String deny
approval_code Bank approval code
String
masked_card Customer’s masked card (only in credit_card &
String mandiri_clickpay)
bank Acquiring Bank
String
permata_va_number Permata VA Number (only in bank_transfer)
String
bill_key Customer bill key (only in echannel)
String
biller_code Customer biller code (only in echannel)
String
24
Name Description
redirect_url Where customer should be redirected (only in
String bca_klikbca)
saved_token_id TWO_CLICKS_TOKEN value. Only available in
String credit_card payment type
saved_token_id_expired_at Specifies the expiration time of the TWO_CLICKS_TOKEN
String
Warning!
For security reason, results from JS callback should only be used for UI feedback to user and should NOT
be used to alter transaction status on your database. We provide HTTP Notification for that purpose.
You can set your payment HTTP Notification URL in Settings - Configuration
25
Other Features
Two Clicks
Two clicks feature allows you to capture customer’s card number, expiry date, email and phone number
as a TWO_CLICKS_TOKEN. For successive payments by the same customer the TWO_CLICKS_TOKEN
can be utilised to pre fill the details. Customer just needs to fill out the cvv number to finish the pay-
ment.
snap.pay('YOUR_SNAP_TOKEN', {
onSuccess: function(result) {
if (result.saved_token_id) {
// save customer's TWO_CLICKS_TOKEN in database
26
}
}
})
Initial Transaction
Successive Transactions
27
Status Code
Goal: Understand all status codes used by API. For more inquiries, please contact us at support@veritrans.
co.id or visit our support web page.
Status Codes used by Veritrans API are categorized into 2xx, 3xx, 4xx dan 5xx.
Code 2xx
Status Description
200 Credit Card: Success. Request is successful, and
transaction is successful (authorize, capture, settlement,
cancel, get order, approve challenge transactions),
accepted by Veritrans and bank.
Other payment methods: Success. Transaction is
successful/settlement.
28
Status Description
201 Credit Card: Challenge. Transaction successfully sent
to bank but the process has not been completed, need
manual action from merchant to complete the
transaction process. If the merchant does not perform
any action until settlement time (H+1 16:00) Veritrans
will cancel the transaction.
Bank Transfer: Pending. Transaction successfully sent
to bank but the process has not been completed by the
customer. By default the transaction will expire within 24
hours.
Cimb Clicks: Pending. Transaction successfully sent to
bank but the process has not been completed by the
customer. By default the transaction will expire within 2
hours.
BRI ePay: Pending. Transaction successfully sent to
bank but the process has not been completed by the
customer. By default the transaction will expire within 2
hours.
Klik BCA: Pending. Transaction successfully sent to
bank but the process has not been completed by the
customer. By default the transaction will expire within 2
hours.
BCA Klikpay: Pending. Transaction successfully sent to
bank but the process has not been completed by the
customer. By default the transaction will expire within 2
hours.
Mandiri Bill Payment: Pending. Transaction
successfully sent to bank but the process has not been
completed by the customer. By default the transaction
will expire within 2 hours.
XL Tunai: Pending. Transaction successfully sent to
provider but the process has not been completed by the
customer. By default the transaction will expire within 2
hours.
Indomaret: Pending. Transaction successfully sent to
provider but the process has not been completed by the
customer. By default the transaction will expire within 2
hours.
29
Status Description
202 Credit Card: Denied. Transaction has been processed
but is denied by payment provider or Veritrans’ fraud
detection system.
Other payment methods: Denied. Transaction has
been processed but is denied by payment provider.
Code 3xx
Status Description
300 Move Permanently, current and all future requests
should be directed to the new URL
Code 4xx
Status Description
400 Validation Error, merchant sent bad request data
example; validation error, invalid transaction type,
invalid credit card format, etc.
401 Access denied due to unauthorized transaction, please
check client key or server key
402 Merchant doesn’t have access for this payment type
403 The requested resource is only capable of generating
content not acceptable according to the accepting
headers that sent in the request
404 The requested resource is not found
405 Http method is not allowed
406 Duplicate order ID. Order ID has already been utilized
previously
407 Expired transaction
408 Merchant sent the wrong data type
409 Merchant has sent too many transactions for the same
card number
30
Status Description
410 Merchant account is deactivated. Please contact
Veritrans support
411 Token id is missing, invalid, or timed out
412 Merchant cannot modify status of the transaction
413 The request cannot be processed due to malformed
syntax in the request body
Code 5xx
Status Description
500 Internal Server Error
501 The feature has not finished yet, it will be available soon
502 Internal Server Error: Bank Connection Problem
503 Internal Server Error
504 Internal Server Error: Fraud detection is unavailable
31
Testing Credentials
Here is a list of dummy transaction credentials that can be used for transaction in the Sandbox Envi-
ronment.
Credit Card
Normal Transaction
VISA Description
No Authentication Accept Transaction: 4011 1111 1111 1112
Merchant Disables 3DS Challenge by FDS Transaction: 4111 1111 1111 1111
Denied by FDS Transaction: 4211 1111 1111 1110
Denied by Bank Transaction: 4311 1111 1111 1119
MASTERCARD Description
No Authentication Accept Transaction: 5481 1611 1111 1081
Merchant Disables 3DS Challenge by FDS Transaction: 5110 1111 1111 1119
Denied by FDS Transaction: 5210 1111 1111 1118
Denied by Bank Transaction: 5310 1111 1111 1117
32
3D Secure Transaction
VISA Description
Full Authentication Accept Transaction: 4811 1111 1111 1114
Cardholder is 3DS ready Denied by Bank Transaction: 4911 1111 1111 1113
Attempted Authentication Accept Transaction: 4411 1111 1111 1118
Cardholder is not Challenge by FDS Transaction: 4511 1111 1111 1117
enrolled for 3DS Denied by FDS Transaction: 4611 1111 1111 1116
Denied by Bank Transaction: 4711 1111 1111 1115
MASTERCARD Description
Full Authentication Accept Transaction: 5211 1111 1111 1117
Cardholder is 3DS ready Denied by Bank Transaction: 5111 1111 1111 1118
Attempted Authentication Accept Transaction: 5410 1111 1111 1116
Cardholder is not Challenge by FDS Transaction: 5510 1111 1111 1115
enrolled for 3DS Denied by FDS Transaction: 5411 1111 1111 1115
Denied by Bank Transaction: 5511 1111 1111 1114
33
Bank Card Number
BRI
Full Authentication 4365 0263 3573 7199 5520 0298 7089 9100
Attempted Authentication 4365 0278 6723 2690 5520 0254 8646 8439
Maybank
Full Authentication 4055 7720 2603 6004 5520 0867 5210 2334
Attempted Authentication 4055 7713 3514 4012 5520 0867 7490 8452
Denied Card
34
Input Value
Expiry Month 01
Expiry Year 2020
CVV 123
Bank Transfer
Direct Debit
35
Payment Methods Description
BCA Klikpay Veritrans will redirect BCA Klikpay test transaction to a
payment simulator.
KlikBCA Veritrans will register user id filled in KlikBCA input. To
perform a test transaction, use the KlikBca Simulator
e-Wallet
Convenience Store
36