BRI Direct Debit

BRI offers 2 payment schemes, which are; 1) Tokenization scheme, and 2) Recurring scheme.

Integration Steps

Overview of integration process with BRI Direct Debit


1. Card Registration

Card Registration process should be done before payment can be made and processed. Merchant will send card registration request from customer to DOKU. The request includes customer's card number that is registered to customer's BRI account.

Each card/account can only registered/bind to one customer on one merchant. Customer needs to verify OTP and input PIN on BRI page.

CBC Encryption

To request card registration process, merchant requires to bring object cardData which value should be encrypted using CBC Algorithm.

CBC Encryption - Steps:

  1. Prepare shared key from DOKU as Secret Key

    • Substring shared key only 16 digits

    • Example code:

    private String getSharedKey(String sharedKey) {
        if (sharedKey.length() != 16) {
    sharedKey = sharedKey.length() > 16 ? sharedKey.substring(0, 16) : String.format("%-16s", sharedKey).replace(' ', '-');
        }
        return sharedKey;
    }
  2. Generate Initial Value (IV)

    • Generate initial value with 16 bytes and then encode using Base 64

    • Example code:

    byte[] iv = new byte[16];
    new SecureRandom().nextBytes(iv);
    IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
    String ivString = Base64.getEncoder().encodeToString(ivParameterSpec.getIV());
  3. Using Cipher CBC

    • Value that will be encrypted combine with secret key generated before

    • After that encode the value using Base 64

    • Example code:

    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); //NOSONAR
    cipher.init(Cipher.ENCRYPT_MODE, key, ivParameterSpec);
    byte[] cipherText = cipher.doFinal(input.getBytes());
    String cipherString = Base64.getEncoder().encodeToString(cipherText);
  4. Combine CBC and IV

    • Combine value CBC Cipher with IV value with separator (|)

    • Example code:

    String value = cipherString + "|" + ivString;

Tools Using Java - Steps:

  • Install JDK 17

  • Go to folder

  • Run with command java -jar cbc-tools.jar

Card Registration Flow

API Endpoint

Environment
Endpoint

HTTP Method

POST

API Production

Path

.../direct-debit/core/v1/registration-card-bind

Sample of Request Header, Request Body and Response Body

Notes:

Parameter with (*) is mandatory

Paramater without (*) is optional/conditional


2. OTP Verification

Once customer has registered their card through the platform, merchant needs to verify the card. Merchant can hit this API to verify the OTP.

OTP Verification Flow

API Endpoint

Environment
Endpoint

HTTP Method

POST

API Production

Path

.../direct-debit/core/v1/otp-verification

Sample of Request Header, Request Body and Response Body

Notes:

Parameter with (*) is mandatory

Paramater without (*) is optional/conditional


3. Payment

After customer's card is registered, payment process can be requested by bringing the card token generated in card registration process. After merchant hit payment API, DOKU will deduct customer's balance.

Payment - Tokenization

In tokenization scheme, every payment needs to be verified by customer with inputting OTP and/or PIN. In order to do that, merchant needs to bring parameter paymentType : "SALE"in payment request body.

And as the response, merchant will receive parameter webRedirectUrl to redirect the customer to merchant's page/platform to complete the payment by inputting OTP and/or PIN. After the payment is completed, merchant then will receive the notification.

Payment - Recurring

In recurring scheme, the payment process will be scheduled. Hence, verification using OTP and/or PIN is not required in every payment. Customers only need to do the verification during card registration process and it will give merchant the authorization to run scheduled payment. In order to do that, merchant needs to bring parameter CHANNEL-ID : "H2H" in request header andpaymentType : "RECURRING"in payment request body.

And as the response, merchant will not receive parameter webRedirectUrl to redirect the customer to merchant's page/platform to complete the payment. Payment request will be directly processed by acquirer and merchant will receive the notification.

Payment Flow

This below payment flow is for tokenization scheme.

API Endpoint

Environment
Endpoint

HTTP Method

POST

API Production

Path

.../direct-debit/core/v1/debit/payment-host-to-host

Sample of Request Header, Request Body and Response Body

Notes:

Parameter with (*) is mandatory

Paramater without (*) is optional/conditional


4. Payment Notification

After payment is completed, DOKU will send HTTP Notification to merchant's defined Notification URL. Learn how to handle the notification from DOKU.


5. Additional Feature

Online Refund

This endpoint is used to create refund request for previous successful payment. Merchant can request a transaction refund to DOKU. Full refund and partial refund are available to be requested.

Online Refund Flow

API Endpoint

Environment
Endpoint

HTTP Method

POST

API Production

Path

.../direct-debit/core/v1/debit/refund

Sample of Request Header, Request Body and Response Body

Notes:

Parameter with (*) is mandatory

Paramater without (*) is optional/conditional

Card Registration Unbinding

If a registered customer no longer wants their account/card to be bind/linked and wish to remove themself from DOKU's and merchant’s system, merchant can send account unbinding request that is initiated by customer.

API Endpoint

Environment
Endpoint

HTTP Method

POST

API Production

Path

.../direct-debit/core/v1/registration-card-unbind

Sample of Request Header, Request Body and Response Body

Notes:

Parameter with (*) is mandatory

Paramater without (*) is optional/conditional

Last updated