Balance SDK Usage

A step-by-step guide on how to initialize Balance 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 BalanceTapSDK and pass the context and api key provided by Brankas.
import as.brank.sdk.tap.balance.BalanceTapSDK;

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

BalanceTapSDK.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, a BalanceTapRequest is needed to be created and be passed. It has the following details:

  1. country - refers to the country of origin of the bank you wanted to do balance retrieval with. There are three countries currently supported: Philippines (PH), Indonesia (ID) and Thailand (TH)

  2. bankCodes - refers to the list of banks to be shown within the Tap Web Application. If null value is passed, the SDK automatically fills up all the available banks depending on the country passed

  3. externalId - refers to the identifier passed to track the request

  4. successURL - refers to the URL where the user will be redirected to after a successful balance retrieval

  5. failURL - refers to the URL where the user will be redirected to after a failed balance retrieval

  6. organizationName - refers to the name of the organization that will be displayed while doing balance retrieval

  7. redirectDuration - refers to the time in seconds when the user should be redirected upon finishing balance retrieval. The default value is 60 seconds.

  8. 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.

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

import `as`.brank.sdk.tap.balance.BalanceTapSDK
import `as`.brank.sdk.core.CoreError
import `as`.brank.sdk.tap.CoreListener
import tap.model.BankCode
import tap.model.Country
import tap.request.balance.BalanceTapRequest

val request = BalanceTapRequest.Builder()
            .country(Country.PH)
            .externalId("External ID")
            .successURL("https://google.com")
            .failURL("https://hello.com")
            .organizationName("Organization Name")

BalanceTapSDK.checkout(this, request.build(), object: CoreListener<String>() {

        override fun onResult(data: String?, error: CoreError?) {
                println("DATA: "+data)
        }

}, 3000, false, true);

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if(requestCode == 2000) {
            if(resultCode == RESULT_OK) {
                val balanceId = data?.getStringExtra(BalanceTapSDK.BALANCE_ID)
                Toast.makeText(this,
                    "Balance Retrieval Successful! Here is the balance id: $balanceId",
                    Toast.LENGTH_SHORT).show()
            }
            else {
                val error = data?.getStringExtra(BalanceTapSDK.ERROR)
                val errorCode = data?.getStringExtra(BalanceTapSDK.ERROR_CODE)
                Toast.makeText(this, "$error ($errorCode)", Toast.LENGTH_LONG).show()
            }
        }
	}
import as.brank.sdk.tap.balance.BalanceTapSDK;
import as.brank.sdk.core.CoreError;
import as.brank.sdk.tap.CoreListener;
import tap.model.BankCode;
import tap.model.Country;
import tap.request.balance.BalanceTapRequest;

BalanceTapRequest.Builder request = new BalanceTapRequest.Builder()
        .country(Country.PH)
        .externalId("External ID")
        .successURL("https://google.com")
        .failURL("https://hello.com")
        .organizationName("Organization Name");

        BalanceTapSDK.INSTANCE.checkout(this,request.build(),new CoreListener<String>(){
@Override
public void onResult(String data,CoreError error){
        System.out.println("DATA: "+data);
        }

        },3000,false,true);

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
        super.onActivityResult(requestCode,resultCode,data);
        if(requestCode == 3000){
        if(resultCode == RESULT_OK){
        String balanceId = data.getStringExtra(BalanceTapSDK.BALANCE_ID);
        Toast.makeText(this,
        "Balance Retrieval Successful! Here is the balance id: "+balanceId,
        Toast.LENGTH_SHORT).show();
        }
        else{
        String error = data.getStringExtra(BalanceTapSDK.ERROR);
        String errorCode = data.getStringExtra(BalanceTapSDK.ERROR_CODE);
        Toast.makeText(this,error+" "+errorCode,Toast.LENGTH_LONG).show();
        }
        }
}

If the internal WebView is opted not to be used (showInBrowser is false), do not forget to call _terminate() _function to ensure previous Tap session is closed

The isAutoConsent in the checkout function is set to false by default. To enable its usage, just set the 2nd to the last parameter to true

The useRememberMe in the checkout function is set to false by default. To enable 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