This page will help you get started with TRANSACTION VIEW CARD91 SDK.
Card91 Transaction Android Library
Card91 Transaction List Android Library Integration with Native Android Apps
Description
Purpose of this document is to illustrate the method to add Card91 ‘cardtransaction’ library to any android native application written in Kotlin invoked either from a fragment or an activity.
Card91 cardtransaction 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 transactions and its detail.
Installation (Gradle and Manifest Configuration)
Android Minimum Requirements :
Gradle Version - 7.3.3
minSdkVersion - 21
compileSdkVersion - 32
targetSdkVersion - 32
Android Permission on Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
</application>
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.7.0'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.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. cardtransaction.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/cardtransaction.aar')
or
implementation(name: 'cardtransaction', ext: 'aar' )
Note
Clean and Build the android app to get the dependencies added on to the application
ADD CARD91 TRANSACTION LIST COMPONENT ON LAYOUT
Library class will be ready to use after their adding on gradle.
Add Card91ResetAtmPin 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.transaction.Card91Transactions
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/transaction_page"/>
</androidx.constraintlayout.widget.ConstraintLayout>
SETUP TRANSACTION COMPONENT
Get the instance of the added Card91Transactions onto your activity or fragment.
As shown in the example below .
Set the Listener as given below
private lateinit var mWebView: Card91Transactions
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_transaction_list)
mWebView = findViewById<Card91Transactions>(R.id.transaction_page)
mWebView.setListener(this, this)
val cardId = "220919093445618ID1CARD7087328" // Card holder card id for which details needs to be shown
val token = "C91CHl9lLt4uIqSxMqeGhZ9dj9FyiMWMJgYK97lVgiE8gtaY=" // Authorization token eg: C91CHbBZSkkyIFUjJ/2022mjyPOVm34sI0jfkeGjYgYZipvk=
val env="PROD_SANDBOX" // "PROD" in case of production and "PROD_SANDBOX" on sandbox environment
val templateId= "xoltt" // Template id by default its "xoltt" or "default"
mWebView.init(this,cardId, token, env, templateId)
}
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 onTransactionEvent(type: String?) {
Log.w("Page transaction 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.
onTransactionEvent is called when transaction is initialised, detail is show, error or success event has happened.
DIFFERENT CALLBACLK EVENTS
The events are as follows:
Event Name | Description |
---|---|
c91_TXN_SCREEN_SUCCESS | Called when the server-side APIs load data successfully. |
C91_TXN_AUTHENTICATION_FAILURE | Call back event type when client is passing incorrect or expired auth token. |
C91_TXN_MISSING_PARAMETER | Call back event type when client is not passing any required/blank parameter . |
C91_TXN_SERVER_FAILURE | Call back event type when there is server service exception with error code 500 to 599 |
C91_TXN_SCREEN_INITIALISED | Called when the transaction list is initialized. |
C91_TXN_API_FAILURE | Called when the server-side api failed. |