NAV Navbar
java

Introduction

Welcome to Duitku Android SDK Documentation, Integrate this SDK to start your payment with Duitku Payment Gateway.

Transaction Flow

Transactionflow

  1. Checkout, customers doing checkout in merchant's android apps then the apps sending request transaction to merchant's server.
  2. Request Transaction, after receiving request from apps, merchant server sending Request Transaction to Duitku API.
  3. Get Request Transaction, Merchant server got response from Duitku.
  4. Response, Merchant server send the response back to android apps.
  5. Callback Notification, Duitku send callback notification to merchant's server.

Environment

The standar IDE for development is android studio, version 3.4 above. For the project details, these are the recommended spesifications:

This documentation is also contains:

Integration

Import Duitku SDK Library To Merchant Apps

Import Duitku SDK Library to build gradle in your apps

import Duitku SDK Library

implementation 'com.duitku:duitku-android-sdk:1.0.2-beta-1'

Import Duitku SDK Class

Merchant needs to import Duitku SDK Class to use Duitku SDK function on merchant's app

import Duitku SDK Class

import 'com.duitku.sdk.DuitkuCallback.DuitkuCallbackTransaction;'
import 'com.duitku.sdk.DuitkuClient;'
import 'com.duitku.sdk.DuitkuUtility.BaseKitDuitku;'
import 'com.duitku.sdk.DuitkuUtility.DuitkuKit;'
import 'com.duitku.sdk.Model.ItemDetails;'

Extends DuitkuClient

public class MainActivity extends DuitkuClient

Declare DuitkuKit in Activity

DuitkuKit duitku ;
DuitkuCallbackTransaction callbackKit ;

Include Function To Respond Callback Transaction

public void onSuccessTransaction(String status, String reference, String amount, String Code) {
    Toast.makeText(MainActivity.this,"Transaction"+status,Toast.LENGTH_LONG).show();

    clearSdkTask(); //REQUIRED
    super.onSuccessTransaction(status, reference, amount, Code);
}

@Override
public void onPendingTransaction(String status, String reference, String amount, String Code) { 
    Toast.makeText(MainActivity.this,"Transaction"+status,Toast.LENGTH_LONG).show();

    clearSdkTask(); //REQUIRED
    super.onPendingTransaction(status, reference, amount, Code);
}

@Override
public void onCancelTransaction(String status, String reference, String amount, String Code) { 
    Toast.makeText(MainActivity.this,"Transaction :"+status,Toast.LENGTH_LONG).show();

    clearSdkTask(); //REQUIRED
    super.onCancelTransaction(status, reference, amount, Code);
}

There are 3 different function in catch callback situation, 
Merchant must create 3 pages that used to show the customers about ther transaction status. 
This is an example to show status with toast.

OnResume Activity

protected void onResume() {
    super.onResume();
    run(MainActivity.this); //context
} 

Request Transaction To Merchant Server

Add Method For RequestTransaction To Merchant Server

private void requestTransaction(){
    //set false if callback from duitku
    callbackKit.setCallbackFromMerchant(true);   

    run(MainActivity.this); //context
    //set base url merchant
    BaseKitDuitku.setBaseUrlApiDuitku("Merchant site url"); 
    BaseKitDuitku.setUrlRequestTransaction("Request transaction module"); 
    BaseKitDuitku.setUrlCheckTransaction("Check transaction module"); 
    BaseKitDuitku.setUrlPaymentMethodList("List Payment module");
    duitku.setPaymentAmount("10000");
    duitku.setProductDetails("");
    duitku.setEmail("");
    duitku.setPhoneNumber("");
    duitku.setAdditionalParam(""); //optional
    duitku.setMerchantUserInfo(""); //optional
    duitku.setCustomerVaName("");
    duitku.setExpiryPeriod("");
    duitku.setCallbackUrl("http://merchantsite.com");
    duitku.setReturnUrl("http://merchantsite.com");

    // Customer Detail
    duitku.setFirstName("John");//optional 
    duitku.setLastName("Doe");//optional 

    // Address
    duitku.setAddress("Jl. Kembangan Raya");//optional
    duitku.setCity("Jakarta");//optional
    duitku.setPostalCode("11530");//optional 
    duitku.setCountryCode("ID");//optional 

    //set item details
    ItemDetails itemDetails = new ItemDetails(10000,2,"shoes");
    ArrayList<ItemDetails> arrayList = new  ArrayList<ItemDetails> ();
    arrayList.add(itemDetails);
    duitku.setItemDetails(arrayList);
}

Function Description
callbackKit.setCallbackFromMerchant Set notification from Duitku or from Merchant. Set value to true to use merchant notification page, or false to use duitku notification page.
run(MainActivity.this) Run Duitku SDK.
BaseKitDuitku.setBaseUrlApiDuitku Merchant site url to access request transaction module and check transaction module.
BaseKitDuitku.setUrlRequestTransaction Request transaction module on merchant server.
BaseKitDuitku.setUrlCheckTransaction Check transaction module on merchant server.
BaseKitDuitku.setUrlPaymentMethodList List of payment method module on merchant server.
duitku.setPaymentAmount Amount of transaction.
duitku.setProductDetails Product detail of transaction.
duitku.setEmail Customer email address, this field is mandatory.
duitku.setPhoneNumber Customer phone number, this field is mandatory.
duitku.setAdditionalParam Additional paramater for merchant purpose.
duitku.setMerchantUserInfo Merchant user info.
duitku.setCustomerVaName Name shown in VA so customer can see this name in mobile banking or ATM machine, this field is used only by VA payment channel.
duitku.setExpiryPeriod Expiry time of the transaction.
duitku.setCallbackUrl Merchant callback url, this must be linked to merchant server to update the status of transaction.
duitku.setReturnUrl Merchant return url, this must be linked to merchant server to redirect customer from duitku to merchant page after transaction is finished or cancelled.
duitku.setItemDetails Item details about the purchase, merchant needs to create ItemDetail Object to fill the detail. Total all Amount in ItemDetail must be equal to total amount of transaction.

Set Toolbar To No Action Bar

Merchant need to set toolbar to No Action Bar in activity that running Duitku SDK function.

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

Start Payment Function

Call StartPayment Function

startPayment(MainActivity.this);

Merchant need to call startPayment() Function to continue the payment process.

Error Handling

Exception from call site #1 bootstrap

If you encounter error exception like this, you need to set compile option like code on the right side in app.gradle

compileOptions {
    targetCompatibility = "8"
    sourceCompatibility = "8"
}

Getting Error At WebView

If you encounter error exeption like this, you need to add dependencies in app.gradle

implementation 'androidx.appcompat:appcompat:1.0.2'

Merchant Server Side

These are sample of merchant server module to do transaction with Duitku Android SDK

Description Value
Merchant Server Base URL Example, https://www.merchantsite.com
Request Transaction download
Check Transaction download
Payment List download

Sample Android Project

Sample project Sample-project