NAV Navbar
php shell

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 = '[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;
?>
curl --location --request POST 'https://sandbox.duitku.com/webapi/api/merchant/v2/inquiry' \
--header 'Content-Type: application/json' \
--data 
{ 
   "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 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 [email protected]
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) [email protected]
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')
}
?>
curl --location --request POST 'YOUR_CALLBACK_URL_HERE' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'merchantOrderId=test' \
--data-urlencode 'amount=test' \
--data-urlencode 'merchantCode=test' \
--data-urlencode 'productDetails=test' \
--data-urlencode 'additionalParam=test' \
--data-urlencode 'paymentCode=test' \
--data-urlencode 'resultCode=test' \
--data-urlencode 'merchantUserId=test' \
--data-urlencode 'reference=test' \
--data-urlencode 'signature=test'

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) [email protected]
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

Get Payment Method

Proses ini digunakan untuk mendapatkan metode pembayaran dari project merchant. API ini berisi nama metode pembayaran, biaya dan url ke gambar metode pembayaran

Development:

https://sandbox.duitku.com/webapi/api/merchant/paymentmethod/getpaymentmethod

Production :

https://passport.duitku.com/webapi/api/merchant/paymentmethod/getpaymentmethod

Request Parameter

curl -X POST https://sandbox.duitku.com/webapi/api/merchant/paymentmethod/getpaymentmethod
     -H "Content-Type: application/json" 
     -d "{\"merchantcode\": \"sample string\",
  \"amount\": \"10000\",
  \"datetime\": \"2019-12-12 12:12:12\",
  \"signature\": \"sample string\"}"

Example Code

<?php

    $json = file_get_contents('php://input');
    date_default_timezone_set('Asia/Jakarta');
    $result = json_decode($json);

    // Set your merchant code (Note: Server key for sandbox and production mode are different)
    $merchantCode = "YOUR MERCHANT CODE"; 
    // Set your merchant key (Note: Server key for sandbox and production mode are different)
    $merchantKey = "YOUR MERCHANT KEY";

    $datetime = date('Y-m-d H:i:s');  
    $paymentAmount = $result->{'paymentAmount'};
    $signature = hash('sha256',$merchantCode . $paymentAmount . $datetime . $merchantKey);

    $itemsParam = array(
        'merchantcode' => $merchantCode,
        'amount' => $paymentAmount,
        'datetime' => $datetime,
        'signature' => $signature
    );

    class emp{}

    $params = array_merge((array)$result,$itemsParam);

    $params_string = json_encode($params);

    $url = 'https://sandbox.duitku.com/webapi/api/merchant/paymentmethod/getpaymentmethod'; 

    $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)
    {
            echo $request ;
    }
    else{
            $response = new emp();
            $response->statusMessage = "Server Error . $httpCode ";
            $response->error = $httpCode;
            die(json_encode($response)); 

    }

?>

Format JSON yang digunakan untuk proses Permintaan GetPaymentMethod adalah sebagai berikut:

Data Description

Name Type Status Description
merchantcode String M Merchant code from Duitku
amount Decimal M Nominal Transaksi
Tidak ada kode desimal (.) Dan tidak ada digit desimal.
datetime Datetime M Format : yyyy-MM-dd HH:mm:ss
signature String M Sha256(merchantcode + paymentAmount + datetime + apiKey)

Response Parameter

Format JSON yang digunakan untuk proses Respons GetPaymentMethod adalah sebagai berikut:

{
    "paymentFee": [        
        {
            "paymentMethod": "VA",
            "paymentName": "VA MAYBANK",
            "paymentImage": "https://passport.duitku.com/merchant/Content/Image/PG/VA.PNG",
            "totalFee": "1000"
        }
    ],
    "responseCode": "00",
    "responseMessage": "SUCCESS"
}

Data Description

Name Type Description
paymentMethod String Metode Pembayaran
paymentName String Nama Metode Pembayaran
paymentImage String Url ke sumber gambar pembayaran
totalFee String Biaya Pembayaran
responseCode String • Response Code
• 00 = Sukses, 01 = Gagal
responseMessage String Pesan Jika Transaksi Gagal

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 = 'https://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;
?>
curl -X POST https://sandbox.duitku.com/webapi/api/merchant/transactionStatus
     -H "Content-Type: application/json" 
     -d "{\"merchantcode\": \"YOUR_MERCHANT_CODE_HERE\",
  \"merchantOrderId\": \"YOUR_MERCHANT_ORDER_ID_HERE\",
  \"signature\": \"SIGNATURE\"
  }"
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)
LQ LinkAja QRIS
DA DANA

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

Jun 2021

Feb 2021

Jan 2020

Jan 2019

Version 1.0