NAV Navbar
php

Langkah Awal

Selamat datang di laman dokumentasi API Duitku. Integrasikan API ini untuk mulai bertransaksi menggunakan Duitku di situs anda.

Request Transaction

Langkah pertama pada proses transaksi diawali dengan melakukan Request Transaksi ke sistem Duitku. Anda dapat membuat permintaan transaksi dengan membuat request menggunakan API ini.

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 = 'test@test.com'; // 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":"test@test.com",
   "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":"test@test.com",
      "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 Kode merchant, didapatkan dari laman Merchant Duitku D0010
paymentAmount integer Y Jumlah nominal transaksi 150000
merchantOrderId string(50) Y Nomor transaksi dari merchant abcde12345
productDetails string(255) Y Keterangan detil produk Payment for A shop
email string{255} Y Alamat email customer anda your_customer@email.com
additionalParam string(255) N Parameter tambahan (opsional)
paymentMethod string(2) Y Metode Pembayaran BK / VC / BT
merchantUserInfo string(255) N Username atau email pelanggan di situs merchant (opsional) test@example.com
customerVaName string(20) Y Nama yang akan muncul pada halaman konfirmasi pembayaran bank John Doe
phoneNumber string(50) Y customer phoneNumber (opsional) 08123456789
itemDetails ItemDetail Y Item Details (opsional)
customerDetail CustomerDetail N Customer Detail
returnUrl string(255) Y Tautan untuk mengarahkan setelah transaksi selesai atau dibatalkan http://www.example.com/return
callbackUrl string(255) Y Tautan untuk callback transaksi http://www.example.com/callback
signature string(255) Y Kode identifikasi transaksi. Berisikan parameter-parameter transaksi yang di hash menggunakan metode hashing MD5 Formula: MD5(merchantcode + orderId + amount + merchantKey)
expiryPeriod int N Masa berlaku transaksi sebelum kedaluwarsa 5, 10 or 60 (in minutes)
shopee Shopee N Hanya untuk ShopeePay (opsional)

Duitku menggunakan merchantCode dan merchantKey untuk memberikan akses kepada API. Anda dapat mendapatkan merchantCode pada Merchant Portal.

Untuk Dokumentasi Fixed dan open amount VA bisa unduh dokumen berikut Tautan.

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 Kode merchant, didapatkan dari laman Merchant Duitku D0010
reference string Reference dari duitku (need to be saved on your system)
paymentUrl string Tautan laman pembayaran jika ingin menggunakan laman duitku
vaNumber string Nomor pembayaran atau va 1199xxxxx
amount integer Payment amount 150000
qrString string QR String jika menggunakan pembayaran QRIS atau shopeepay (anda perlu membuat kode QR dari string ini

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')
}
?>

Setelah Request HTTP Post yang pertama anda kirimkan dari situs anda, Duitku akan mengirimkan respon berupa return value berbentuk HTTP Post. Anda dibutuhkan untuk menyediakan satu laman untuk menerima hasil dari respon callback dari Duitku.

Parameters

Method : HTTP POST

Type : x-www-form-urlencoded

Parameter Description Example
merchantCode Kode merchant, didapatkan dari laman Merchant Duitku D0010
amount Jumlah nominal transaksi 150000
merchantOrderId Nomor transaksi dari merchant abcde12345
productDetail Keterangan detil produk Payment for A shop
additionalParam Parameter tambahan (opsional)
paymentCode Metode Pembayaran VC
resultCode Hasil status transaksi 00 - Success
merchantUserId Username atau email pelanggan di situs merchant (opsional) test@example.com
reference Nomor referensi transaksi dari Duitku. Mohon disimpan untuk keperluan pencatatan atau pelacakan transaksi. ABCEDE
signature Kode identifikasi transaksi. Berisikan parameter-parameter transaksi yang di hash menggunakan metode hashing MD5 Formula: MD5(merchantcode + amount + merchantOrderId + merchantKey)

ShopeePay

Parameter Description Example
Default Parameter Refer to Callback
spUserHash Jika menggunakan ShopeePay xxxyyyzzz

Redirect

Setelah transaksi berhasil atau dibatalkan, Duitku akan mengarahkan pelanggan kembali ke situs anda menggunakan parameter berikut.

Example

GET: http://www.merchantweb.com/redirect.php?merchantOrderId=xxx&resultCode=yyy&reference=zzz

Parameters

Parameter Description Example
merchantOrderId Nomor transaksi dari merchant abcde12345
reference Nomor referensi transaksi dari Duitku. Mohon disimpan untuk keperluan pencatatan atau pelacakan transaksi. d011111
resultCode Hasil status transaksi 00 - Success 01 - Pending 02 - Canceled

Check Transaction

API ini digunakan untuk merchant melaukan permintaan pengiriman ulang transaksi dalam bentuk form Post back.

Fungsi ini bersifat opsional untuk merchant dan dapat digunakan pada tahap setelah dan tidak bergantung pada proses Request Transaksi.

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 Kode merchant, didapatkan dari laman Merchant Duitku D0010
merchantOrderId Nomor transaksi dari merchant abcde12345
signature Kode identifikasi transaksi. Berisikan parameter-parameter transaksi yang di hash menggunakan metode hashing MD5 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 Order Id dari merchant
reference Reference dari duitku
amount Jumlah pembayaran
statusCode Kode Status
statusMessage

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
email 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 Detail

"shopee": {
  "promo_ids": "string"
}
Parameter Type Required Description Example
promo_ids string(50) N Voucher code 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

Berikut adalah daftar testing pembayaran yang dapat digunakan di Sandbox Environtment:

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 transaksi virtual account sandbox Click-here

Indodana Pay Later

Phone Number | PIN 081282325566|000000

Changelog

Version 2.0

Feb 2021

Jan 2020

Jan 2019

Version 1.0

php