Balance SDK Usage

A step-by-step guide on how to initialize Balance SDK on iOS.

👍

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

📘

Minimum Requirements

  1. Xcode 12 but preferably the latest version
  2. Minimum Target iOS Deployment: iOS 12
  3. Minimum Swift Tools Version: 5.3 but preferably the latest version

Installation & Updating

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

Initialization

  1. Call the initialize function from the BalanceTapFramework and pass the API Key provided by Brankas.
import BalanceTapFramework

BalanceTapSF.shared.initialize(apiKey: "apiKey")

📘

Before calling any function, it is important to call the initialize function first in order to gain access to the checkout function. Also, to use the Sandbox environment, set the isDebug variable to true

Usage

The Framework has a checkout function wherein it responds with a redirect url used to launch the Tap web application within built-in WKWebView or Safari Web Browser

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 Framework 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. browserMode - Safari (Tap Web Application is launched through Safari Web Browser) and WebView (Tap Web application is launched through the built-in WKWebView from the Framework)


    NOTE: When using the WebView BrowserMode, ensure that the ViewController to be passed in the checkout function is attached to a UINavigationController so that the Framework can provide a back button.

  9. dismissAlert - 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.

  10. isAutoConsent - refers to the automatic allowing of consent in behalf of the user of the Tap Web Application. Its default value is false

  11. useRememberMe - pertains to using the remember me feature of the Tap Web Application (default value is true and will not be showing up if set to false)

📘

When using the WebView BrowserMode, ensure that the ViewController to be passed in the checkout function is attached to a UINavigationController so that the Framework can provide a back button.

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

import UIKit
import BalanceTapFramework

class ViewController: UIViewController {
    typealias T = String
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        BalanceTapSF.shared.initialize(apiKey: "API KEY")

        let request = BalanceTapRequest(country: Country.PH, bankCodes: nil, externalId: "External ID", successURL: "https://google.com", failURL: "https://hello.com", organizationName: "Organization Name", redirectDuration: 60, browserMode: BalanceTapRequest.BrowserMode.WebView, isAutoConsent: false, dismissAlert: nil, useRememberMe: true)

        do {
            let retrieveBalances = { (data: Any?, error: String?) in
                if let str = data as? String {
            		if let err = error {
                		print("Balance ID: \(str)\nError: \(err)")
            		}
            		else {
                		print("Balance ID: \(str)")
            		}
        	}
        
        	else if let accounts = data as? [BalanceAccount] {
            		var message = "Accounts"
            		let dateFormatter = DateFormatter()
           	 	dateFormatter.dateFormat = "MM-dd-yyyy"
            
            		if accounts.isEmpty {
                		message += "\n\n\nList is Empty"
            		}
            		accounts.forEach { account in
			        message += "\n Account: \(account.holderName) (\(account.number))"
                		message += "\n Balance: \(account.balance.currency)\(Double(account.balance.numInCents) ?? 0 / 100)"
            		}
            		print(message)
        	}
        
        	else {
            		if let err = error {
                		showAlert(message: "Error: \(err)")
            		}
        	}
            }
            try BalanceTapSF.shared.checkout(balanceTapRequest: request, vc: self, closure: retrieveBalances, showBackButton: true)
        } catch {
            showAlert(message: "Error: \(error)")
        }
    }
}