Direct SDK Usage

A step-by-step guide on how to initialize Direct SDK on Android.

👍

Visit our Brankas Collection for Android, to see a sample project of how to integrate the SDK.

📘

Minimum Requirements

  1. Android Studio 3.0 but preferably the latest version
  2. Minimum Android SDK: API 17 or Android 4.2

Installation & Updating

Please refer to the Installation page for Android platform installation and update steps

Initialization

  1. Call the initialize function from the DirectTapSDK and pass the context and api key provided by Brankas.
import as.brank.sdk.tap.request.direct.DirectTapSDK;

DirectTapSDK.INSTANCE.initialize(context, apiKey, null, false);
import `as`.brank.sdk.tap.request.direct.DirectTapSDK

DirectTapSDK.initialize(context, apiKey, null, false)

📘

To use the Sandbox environment, set the optional isDebug option to true

  1. The checkout function can now be called once the initialize function has been called.

Usage

The SDK has a checkout function wherein it responds with a redirect url used to launch the Tap web application. An option is given either to use the url manually or let the SDK launch it through its internal WebView.

In order to use the checkout function, an DirectTapRequest is needed to be created and be passed. It has the following details:

  1. sourceAccount - the account to be used as a sender of money for bank transfer. It consists of BankCode (code for a specific bank) and Country (country of origin)

📘

If bankCode is set to null, an internal bank selection screen will be shown inside Tap web application. If it has been filled up, that bank would automatically be selected instead.

  1. destinationAccountId - the ID of the registered account of the receiver of money for bank transfer. This is provided by Brankas. Each registered account has a corresponding ID.

  2. amount - the amount of money to be transferred. It consists of Currency (the currency of the money to be transferred) and the amount itself in centavos (e.g. If Php 1 would have been transferred, "100" should be passed)

  3. memo - the note or description attached to the bank transfer

  4. customer - pertains to the details of the sender of money. It consists of firstName, lastName, email and mobileNumber

  5. referenceId

  6. client - pertains to the customizations in the Tap Web Application and callback url once bank transfer is finished. It consists of displayName (name in the header to be shown in the Tap Web Application), logoUrl (URL of the logo to be shown), returnUrl (URL where Tap would be redirecting after bank transfer is finished), failUrl (optional URL where Tap would be redirecting if bank transfer has failed), statementRetrieval (optional Boolean that shows the list of statements after bank transfer is finished; its default value is false)

  7. dismissalDialog - pertains to the showing of alert dialog when closing the WebView. It consists of message, positiveButtonText and negativeButtonText. Just set this value to null to remove the alert dialog when closing the application.

  8. expiryDate - refers to the expiry time of the created invoice, default value is null

  9. uniqueAmount- refers to the enabling of centavo reconciliation workaround logic, default value is UniqueAmount.NONE

Here is a sample on how to use it and call:

import as.brank.sdk.core.CoreError;
import as.brank.sdk.tap.CoreListener;
import as.brank.sdk.tap.request.direct.DirectTapSDK;
import tap.model.direct.*;
import tap.model.Currency;
import tap.request.direct.DirectTapRequest;
import tap.model.Reference;
import tap.model.direct.Transaction;
import tap.model.BankCode;
import tap.model.Country;
import tap.model.DismissalDialog;
import tap.model.Currency;

DirectTapSDK.INSTANCE.checkout(activity,
        new DirectTapRequest.Builder()
        .sourceAccount(new Account(null,Country.PH))
        .destinationAccountId("2149bhds-bb56-11rt-acdd-86667t74b165")
        .amount(new Amount(Currency.PHP,"10000"))
        .memo("Sample Bank Transfer")
        .customer(new Customer("Owner","Name","[email protected]","63"))
        .client(new Client("Sample Client",null,"www.google.com"))
        .referenceId("sample-reference").build(),
        new CoreListener<String> {
@Override
public void onResult(@Nullable String str,@Nullable CoreError coreError){
        if(coreError!=null)
        System.out.println("Error: "+coreError.getErrorMessage());
        }
        },1000);

// Used to retrieve the result from Tap Web Application
@Override
    void onActivityResult(int requestCode,int resultCode,Intent data){
            super.onActivityResult(requestCode,resultCode,data);

            if(requestCode==1000){
            // Transaction is successful
            if(resultCode==RESULT_OK){
            // Retrieve transaction
            Transaction transaction=data.getParcelableExtra<Reference<Transaction>>(DirectTapSDK.TRANSACTION).get();
        Systemout.println("TRANSACTION ID: "+transaction.getId());
        }
        }
        }
import `as`.brank.sdk.core.CoreError
import `as`.brank.sdk.tap.CoreListener
import `as`.brank.sdk.tap.request.direct.DirectTapSDK
import tap.model.direct.*;
import tap.model.Currency;
import tap.request.direct.DirectTapRequest;
import tap.model.Reference;
import tap.model.direct.Transaction;
import tap.model.BankCode;
import tap.model.Country;
import tap.model.DismissalDialog;
import tap.model.Currency;

DirectTapSDK.checkout(activity, 
    DirectTapRequest.Builder()
            .sourceAccount(Account(null, Country.PH))
            .destinationAccountId("2149bhds-bb56-11rt-acdd-86667t74b165")
            .amount(Amount(Currency.PHP, "10000"))
            .memo("Sample Bank Transfer")
            .customer(Customer("Owner", "Name", "[email protected]", "63"))
            .client(Client("Sample Client", null, "www.google.com"))
            .referenceId("sample-reference").build(),
    object: CoreListener<String?> {
            override fun onResult(str: String?, coreError: CoreError?) {
                   println("Error: "+coreError?.getErrorMessage().orEmpty())
            }
    }, 1000)

    // Used to retrieve the result from Tap Web Application
    override fun onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data)

            if(requestCode == 1000) {
            // Transaction is successful
                    if(resultCode == RESULT_OK) {
                    // Retrieve transaction
                        val transaction = data?.getParcelableExtra<Reference<Transaction>>(DirectTapSDK.TRANSACTION)!!.get!!
                            println("TRANSACTION ID: "+transaction.getId())
                    }
            }
        }

📘

The useRememberMe in the checkout function is set to true by default. To disable the usage of Remember Me inside the Tap Web Application, just pass false to the last parameter in the checkout function

The actionBarText in the checkout function is set to null by default - thus, the ActionBar gets hidden. To show it, just pass a String to it


Did this page help you?