Introduction
Welcome to duitku API, you can use this API to integrate with your website.
Request Transaction
You can create an inquiry transaction with this API.
HTTP Request
Method : HTTP POST
Type : application/json
Development : https://sandbox.duitku.com/webapi/api/merchant/v2/inquiry
Production : https://passport.duitku.com/webapi/api/merchant/v2/inquiry
Request Parameters
<?php
$merchantCode = 'D0001'; // from duitku
$merchantKey = '732B39FC61796845775D2C4FB05332AF'; // from duitku
$paymentAmount = 40000;
$paymentMethod = 'VC'; // VC = Credit Card
$merchantOrderId = time() . ''; // from merchant, unique
$productDetails = 'Test Pay with duitku';
$email = '[email protected]'; // your customer email
$phoneNumber = '08123456789'; // your customer phone number (optional)
$additionalParam = ''; // optional
$merchantUserInfo = ''; // optional
$customerVaName = 'John Doe'; // display name on bank confirmation display
$callbackUrl = 'http://example.com/callback'; // url for callback
$returnUrl = 'http://example.com/return'; // url for redirect
$expiryPeriod = 10; // set the expired time in minutes
$signature = md5($merchantCode . $merchantOrderId . $paymentAmount . $merchantKey);
// Customer Detail
$firstName = "John";
$lastName = "Doe";
// Address
$alamat = "Jl. Kembangan Raya";
$city = "Jakarta";
$postalCode = "11530";
$countryCode = "ID";
$address = array(
'firstName' => $firstName,
'lastName' => $lastName,
'address' => $alamat,
'city' => $city,
'postalCode' => $postalCode,
'phone' => $phoneNumber,
'countryCode' => $countryCode
);
$customerDetail = array(
'firstName' => $firstName,
'lastName' => $lastName,
'email' => $email,
'phoneNumber' => $phoneNumber,
'billingAddress' => $address,
'shippingAddress' => $address
);
$item1 = array(
'name' => 'Test Item 1',
'price' => 10000,
'quantity' => 1);
$item2 = array(
'name' => 'Test Item 2',
'price' => 30000,
'quantity' => 3);
$itemDetails = array(
$item1, $item2
);
$params = array(
'merchantCode' => $merchantCode,
'paymentAmount' => $paymentAmount,
'paymentMethod' => $paymentMethod,
'merchantOrderId' => $merchantOrderId,
'productDetails' => $productDetails,
'additionalParam' => $additionalParam,
'merchantUserInfo' => $merchantUserInfo,
'customerVaName' => $customerVaName,
'email' => $email,
'phoneNumber' => $phoneNumber,
'itemDetails' => $itemDetails,
'customerDetail' => $customerDetail,
'callbackUrl' => $callbackUrl,
'returnUrl' => $returnUrl,
'signature' => $signature,
'expiryPeriod' => $expiryPeriod
);
$params_string = json_encode($params);
//echo $params_string;
$url = 'https://sandbox.duitku.com/webapi/api/merchant/v2/inquiry'; // Sandbox
// $url = 'https://passport.duitku.com/webapi/api/merchant/v2/inquiry'; // Production
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($params_string))
);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//execute post
$request = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpCode == 200)
{
$result = json_decode($request, true);
//header('location: '. $result['paymentUrl']);
echo "paymentUrl :". $result['paymentUrl'] . "<br />";
echo "merchantCode :". $result['merchantCode'] . "<br />";
echo "reference :". $result['reference'] . "<br />";
echo "vaNumber :". $result['vaNumber'] . "<br />";
echo "amount :". $result['amount'] . "<br />";
echo "statusCode :". $result['statusCode'] . "<br />";
echo "statusMessage :". $result['statusMessage'] . "<br />";
}
else
echo $httpCode;
?>
Example Json Request
{
"merchantCode":"D0001",
"paymentAmount":40000,
"paymentMethod":"VC",
"merchantOrderId":"1579838431",
"productDetails":"Test Pay with duitku",
"additionalParam":"",
"merchantUserInfo":"",
"customerVaName":"John Doe",
"email":"[email protected]",
"phoneNumber":"08123456789",
"itemDetails":[
{
"name":"Test Item 1",
"price":10000,
"quantity":1
},
{
"name":"Test Item 2",
"price":30000,
"quantity":3
}
],
"customerDetail":{
"firstName":"John",
"lastName":"Doe",
"email":"[email protected]",
"phoneNumber":"08123456789",
"billingAddress":{
"firstName":"John",
"lastName":"Doe",
"address":"Jl. Kembangan Raya",
"city":"Jakarta",
"postalCode":"11530",
"phone":"08123456789",
"countryCode":"ID"
},
"shippingAddress":{
"firstName":"John",
"lastName":"Doe",
"address":"Jl. Kembangan Raya",
"city":"Jakarta",
"postalCode":"11530",
"phone":"08123456789",
"countryCode":"ID"
}
},
"callbackUrl":"http:\/\/example.com\/callback",
"returnUrl":"http:\/\/example.com\/return",
"signature":"506f88f1000dfb4a6541ff94d9b8d1e6",
"expiryPeriod":10
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
merchantCode | string(50) | Y | Merchant Code from duitku | D0010 |
paymentAmount | integer | Y | Payment Amount | 150000 |
merchantOrderId | string(50) | Y | Order Id from Merchant | abcde12345 |
productDetails | string(255) | Y | Product Detail | Payment for A shop |
string{255} | Y | your customer email | [email protected] | |
additionalParam | string(255) | N | additional parameter(optional) | |
paymentMethod | string(2) | Y | Payment Method | BK / VC / BT |
merchantUserInfo | string(255) | N | Username or email customer (optional) | [email protected] |
customerVaName | string(20) | Y | The name that will appear on the bank's payment confirmation page | John Doe |
phoneNumber | string(50) | Y | customer phoneNumber (optional) | 08123456789 |
itemDetails | Object | Y | Item Details (optional) | |
customerDetail | CustomerDetail | N | Customer Detail | |
returnUrl | string(255) | Y | Url for redirect when transaction is finish or canceled | http://www.example.com/return |
callbackUrl | string(255) | Y | Url for transaction Callback | http://www.example.com/callback |
signature | string(255) | Y | Signature | Formula: MD5(merchantcode + orderId + amount + merchantKey) |
expiryPeriod | int | N | The validity period of the transaction before it expires | 5, 10 or 60 (in minutes) |
shopee | Shopee | N | ShopeePay Only |
Duitku uses merchantCode and merchantKey to allow access to the API. You can register a new merchantCode at our Merchant Portal.
For fixed and open amount VA Documentation, you can download Here.
Response Parameters
{
"merchantCode": "sample string 1",
"reference": "sample string 2",
"paymentUrl": "sample string 3",
"vaNumber": "sample string 4",
"qrString": "sample string 5",
"amount": "sample string 6",
"statusCode": "sample string 7",
"statusMessage": "sample string 8"
}
Parameter | Type | Description | Example |
---|---|---|---|
merchantCode | string | Merchant Code from duitku | D0010 |
reference | string | Reference from duitku (need to be saved on your system) | |
paymentUrl | string | Payment url if you want to use duitku payment page | |
vaNumber | string | Generated va number if using virtual account payment | 1199xxxxx |
amount | integer | Payment amount | 150000 |
qrString | string | QR string if using QRIS payment (need to generate QR Code from this) |
Callback
<?php
$apiKey = 'YOUR_MERCHANT_KEY_HERE'; // Your api key
$merchantCode = isset($_POST['merchantCode']) ? $_POST['merchantCode'] : null;
$amount = isset($_POST['amount']) ? $_POST['amount'] : null;
$merchantOrderId = isset($_POST['merchantOrderId']) ? $_POST['merchantOrderId'] : null;
$productDetail = isset($_POST['productDetail']) ? $_POST['productDetail'] : null;
$additionalParam = isset($_POST['additionalParam']) ? $_POST['additionalParam'] : null;
$paymentMethod = isset($_POST['paymentCode']) ? $_POST['paymentCode'] : null;
$resultCode = isset($_POST['resultCode']) ? $_POST['resultCode'] : null;
$merchantUserId = isset($_POST['merchantUserId']) ? $_POST['merchantUserId'] : null;
$reference = isset($_POST['reference']) ? $_POST['reference'] : null;
$signature = isset($_POST['signature']) ? $_POST['signature'] : null;
if(!empty($merchantCode) && !empty($amount) && !empty($merchantOrderId) && !empty($signature))
{
$params = $merchantCode . $amount . $merchantOrderId . $apiKey;
$calcSignature = md5($params);
if($signature == $calcSignature)
{
//Your code here
echo "SUCCESS"; // Please response with success
}
else
{
throw new Exception('Bad Signature')
}
}
else
{
throw new Exception('Bad Parameter')
}
?>
Return values are returned as HTTP POST, Merchant will need to provide a call-back page to catch the result.
Parameters
Method : HTTP POST
Type : x-www-form-urlencoded
Parameter | Description | Example |
---|---|---|
merchantCode | Merchant Code from duitku | D0010 |
paymentAmount | Payment Amount | 150000 |
merchantOrderId | Order Id from Merchant | abcde12345 |
productDetail | Product Detail | Payment for A shop |
additionalParam | additional parameter(optional) | |
paymentCode | Payment Method | VC |
resultCode | Payment status | 00 - Success 01 - Failed |
merchantUserId | User id from merchant | [email protected] |
reference | Reference from duitku, Please save this to trace the transaction | ABCEDE |
signature | Signature | Formula: MD5(merchantcode + amount + merchantOrderId + merchantKey) |
sp_user_hash | ShopeePay Only |
Redirect
After the transaction is finish or cancel, Duitku will redirect the customer back to merchant website with the following parameters.
Example
GET: http://www.merchantweb.com/redirect.php?merchantOrderId=xxx&resultCode=yyy&reference=zzz
Parameters
Parameter | Description | Example |
---|---|---|
merchantOrderId | Order Id from merchant | abcde12345 |
reference | Reference from duitku | d011111 |
resultCode | Result Code | 00 |
Check Transaction
This API used to check status of transaction.
Check Transaction HTTP Request
Development :
POST: https://sandbox.duitku.com/webapi/api/merchant/transactionStatus
Production :
POST: https://passport.duitku.com/webapi/api/merchant/transactionStatus
Check Transaction Request Parameters
<?php
$merchantCode = 'YOUR_MERCHANT_CODE_HERE'; // from duitku
$merchantKey = 'YOUR_MERCHANT_KEY_HERE'; // from duitku
$merchantOrderId = '1234'; // from merchant, unique
$signature = md5($merchantCode . $merchantOrderId . $merchantKey);
$params = array(
'merchantCode' => $merchantCode,
'merchantOrderId' => $merchantOrderId,
'signature' => $signature
);
$params_string = json_encode($params);
$url = 'http://sandbox.duitku.com/webapi/api/merchant/transactionStatus';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($params_string))
);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//execute post
$request = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpCode == 200)
{
$result = json_decode($request, true);
}
else
echo $httpCode;
?>
Parameter | Description | Example |
---|---|---|
merchantCode | From Duitku Merchant Dashboard | D0010 |
merchantOrderId | Merchant transaction number/ Order id | abcde12345 |
signature | Formula : md5(merchantCode + merchantOrderId + merchantKey) |
Check Transaction Response Parameters
The above command returns JSON structured like this:
{
"merchantOrderId": "sample string 1",
"reference": "sample string 2",
"amount": "sample string 3",
"statusCode": "sample string 4",
"statusMessage": "sample string 5"
}
Parameter | Description |
---|---|
merchantOrderId | Merchant transaction number/ Order id |
reference | Duitku Reference Number |
amount | Transaction Amount |
statusCode | Status Code |
statusMessage | Status Message |
JSON Object
Collection of JSON objects.
Item Details
"itemDetails": [{
"price": 50000,
"quantity": 2,
"name": "Apel",
}]
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
name | string(50) | Y | Name of the item | Item 1 |
quantity | integer | Y | Quantity of the item bought | 10 |
price | integer | Y | Price of the Item Note: Don't add decimal |
Customer Detail
"customerDetail": {
"firstName": "string",
"lastName": "string",
"email": "string",
"phoneNumber": "string",
"billingAddress": {
"firstName": "string",
"lastName": "string",
"address": "string",
"city": "string",
"postalCode": "string",
"phone": "string",
"countryCode": "string"
},
"shippingAddress": {
"firstName": "string",
"lastName": "string",
"address": "string",
"city": "string",
"postalCode": "string",
"phone": "string",
"countryCode": "string"
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
firstName | string(50) | N | Customer First Name | John |
lastName | string(50) | N | Customer First Name | Doe |
string(50) | N | Customer Email | ||
phoneNumber | string(50) | N | Customer phone number | 081234567890 |
billingAddress | Address | N | Customer billing address | |
shippingAddress | Address | N | Customer shipping address |
Address
{
"firstName": "string",
"lastName": "string",
"address": "string",
"city": "string",
"postalCode": "string",
"phone": "string",
"countryCode": "string"
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
firstName | string(50) | N | Customer First Name | John |
lastName | string(50) | N | Customer First Name | Doe |
address | string(50) | N | Address for billing or shipping | |
city | string(50) | N | City description for the address | |
postalCode | string(50) | N | Postal code for the address | |
phone | string(50) | N | Phone number for billing or shipping | |
countryCode | string(50) | N | ISO 3166-1 alpha-3 | ID - for indonesia |
Shopee
"shopee": {
"promo_ids": "string"
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
promo_ids | string(50) | N | Voucher | campaign111 |
Payment Method
Payment method available on duitku.
Payment Method | Description |
---|---|
VC | Credit Card (Visa / Master) |
BK | BCA KlikPay |
BC | BCA Virtual Account |
M1 | Mandiri Virtual Account (Deprecated) |
M2 | Mandiri Virtual Account |
BT | Permata Bank Virtual Account |
A1 | ATM Bersama |
B1 | CIMB Niaga Virtual Account |
I1 | BNI Virtual Account |
VA | Maybank Virtual Account |
FT | Ritel |
OV | OVO |
DN | Indodana Paylater |
SP | Shopee Pay |
SA | Shopee Pay Apps |
AG | Bank Artha Graha |
S1 | Bank Sahabat Sampoerna |
LA | LinkAja Apps (Percentage Fee) |
LF | LinkAja Apps (Fixed Fee) |
Result Code
Result Code Callback
Result Code | Description |
---|---|
00 | Success |
01 | Failed |
Result Code Redirect
Result Code | Description |
---|---|
00 | Success |
01 | Pending |
02 | Canceled / Failed |
Testing
Here is a list of dummy transaction credentials that can be used for transaction in the Sandbox Environment:
Credit Card
3D Secure Transaction
Card Type | Credit Card Number | Valid Thru | CVV |
---|---|---|---|
VISA | 4000 0000 0000 0044 | 02/22 | 123 |
MASTERCARD | 5500 0000 0000 0004 | 02/22 | 123 |
Virtual Account
Demo transaction virtual account sandbox Click-here
Indodana Pay Later
Phone Number | PIN 081282325566|000000
Changelog
Version 2.0
Jan 2020
- Add CustomerDetail parameter in the request inquiry
- Add CustomerDetail in JSON Object
- Add Address in JSON Object
Jan 2019
- Add customerVaName parameters and expiryPeriod in the request inquiry
- Add response parameter vaNumber, amount, statusCode and statusMessage on the inquiryResponse
Version 1.0
- API Documentation created