Document explain the process of integrating the flutter card balance view SDK
Card Balance View Android Native SDK
This package is used to get the balance of the card associated with card91 card holders. This package directly communicates to Card91 SDK.
Description
Purpose of this document is to illustrate the method to add Card91 ‘card91Sdk’ library to any android native application written in Kotlin invoked either from a fragment or an activity.
Card91 card91Sdk library allows developers to add the custom webview component into their layout as per design.
Developers need to get the view onto their activity and through invoking the init() method with certain required parameters mentioned below and a library for checking the card wallet balance.
Installation (Gradle and Manifest Configuration)
Android Minimum Requirements
Gradle Version - 7.3.3
minSdkVersion - 21
compileSdkVersion - 33
targetSdkVersion - 33
Android Permission on Manifest:
<uses-permission android:name="android.permission.INTERNET" />
Update gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
Gradle dependencies
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.github.bumptech.glide:glide:4.12.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
implementation 'com.squareup.okhttp3:okhttp:4.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.5.0'
implementation 'com.github.bastiaanjansen:jwt-java:1.2.0'
implementation 'com.auth0:java-jwt:4.0.0'
implementation 'com.auth0.android:jwtdecode:2.0.1'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.android.material:material:1.9.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.4.0'
}
Also enable the binding on the same app gradle file under android tag if the binding has been used
buildFeatures {
viewBinding true
}
}
Usage
Below steps is defined to followed to integrate the Library
Add AAR (Android Library Files)
Add the .aar file provided by us at the libs folder on the project eg. card91Sdk.aar
Keep the aar file at location {Client project location}/app/src/main/libs
Add below line on the app gradle
implementation files('../app/src/main/libs/card91Sdk.aar')
or
implementation(name: 'card91Sdk', ext: 'aar' )
Note
Clean and Build the android app to get the dependencies added on to the application
ADD CARD91 WALLET BALANCE LIST COMPONENT ON LAYOUT
Library class will be ready to use after their adding on gradle.
Add Card91WalletBalance onto the layout where the developer wants to use it .
Make sure not to keep any background colour of the webview since it is supposed to be transparent.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RestAtmPinActivity">
<com.card91.common.Card91WalletBalance
android:id="@+id/card_balance"
android:layout_width="match_parent"
android:layout_height="50dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
SETUP CARD WALLET BALANCE COMPONENT
Get the instance of the added Card91WalletBalance onto your activity or fragment.
As shown in the example below .
Set the Listener as given below
private lateinit var cardBalance: Card91WalletBalance
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
cardBalance = findViewById<Card91WalletBalance>(R.id.card_balance);
cardBalance.setListener(this, this);
val cardId = "220701055006074ID1CARD3707480" // card id for which details needs to be shown eg:220909102312683ID1CARD8822222
val token = "C91CHcbTRjOnie8wurTH9/6XabOlQsOVNuf47FjTIsRb8Yko=" // Authorization token eg: C91CHbBZSkkyIFUjJ/2022mjyPOVm34sI0jfkeGjYgYZipvk=
val env="PROD_SANDBOX" // "PROD" in case of production and "PROD_SANDBOX" on sandbox environment
val templateId= "paulMerchant" // Template id by default its "xoltt" or "default"cardBalance.init()
cardBalance.init(this,cardId,templateId, token, env );
}
INPUT PARAMETER DETAILS
Call the init() method of the Card91ResetAtmPin with the below parameter .
Name | Type | Required | Description |
---|---|---|---|
context | Context | true | Activity context or Fragment activity context is passed here |
cardId | string | true | cardId which has been received form login token service (Card91 API) |
token | string | true | Auth Token received from the Card91 APIs |
templateId | string | true | Template id by default its "xoltt" or "default" |
env | string | true | "PROD" in case of production and "PROD_SANDBOX" on sandbox environment |
SUBSCRIBE FOR LISTENING CALLBACK EVENTS
Implement Interface Card91Transactions.Listener for listening to the call back event from the Reset Atm Pin library .
Interface has below and their usage .
override fun onPageStarted(url: String?) {
Log.w("Page Started", url.toString())
}
override fun onPageFinished(url: String?) {
Log.w("Page onPageFinished", url.toString())
}
override fun onPageError(errorCode: Int, description: String?, failingUrl: String?) {
Log.w("Page onPageError", description.toString())
}
override fun onCard91Event(type: String?) {
Log.w("Here we get call backs event ", type.toString())
}
onPageStarted is called when the webpage is loaded.
onPageFinished is called when webpage loading is finished .
onPageError is called when there is any error while loading the page.
onCard91Event is called when transaction is initialised, detail is show, error or success event has happened.
Basic call back event type
Event Name | Description |
---|---|
c91_WALLET_SCREEN_SUCCESS | Called when the server-side APIs load successfully and Card balance is show without any error |
C91_WALLET_AUTHENTICATION_FAILURE | Call back event type when client is passing incorrect or expired auth token. |
C91_WALLET_API_FAILURE | Call back event type when wallet api fails to get the successfully response |
C91_WALLET_MISSING_PARAMETER | Call back event type when client is not passing any required/blank parameter . |
C91_WALLET_SERVER_FAILURE | Call back event type when there is server service exception with error code 500 to 599 |
C91_WALLET_SCREEN_INITIALISED | Called when the server-side card view SDK loads successfully. |