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 21 or Android 5.0

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.direct.DirectTapSDK;

DirectTapSDK.INSTANCE.initialize(context, apiKey, null, false);
import `as`.brank.sdk.tap.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 via retrieveCheckoutURL() function 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, it will show an internal bank selection screen 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.
  • language- optional enum that changes the language being used within Tap Web App.
  1. 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.
  2. expiryDate - refers to the expiry time of the created invoice, default value is null
  3. 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.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();
        		System.out.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 `as`.brank.sdk.core.CoreError
import `as`.brank.sdk.tap.CoreListener
import `as`.brank.sdk.tap.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())
            		}
        	}
    	}

📘

How to Set Up the Checkout Function

useRememberMe is set to true by default. To disable, just pass false to the last parameter.

actionBarText is set to null by default so the ActionBar gets hidden. To show it, just pass a String to it.

showBackButton is set to true by default. To hide the button, just set the value to false.

App Tracking and Privacy Changes

Logging of Tap Web Flow

A new feature has been added internally, starting v4.0 of Direct Tap SDK. Brankas can track the flow of a transaction while performing a Fund Transfer within Tap Web App. This will aid in pointing out some errors within transactions and eventually improve the overall experience.

How to turn off the logging feature

The logging feature is enabled by default. To turn off the feature, you can change the value of isLoggingEnabled within the initialize() function as the below samples;

import as.brank.sdk.tap.direct.DirectTapSDK;

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

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