Card91 SERVICES Android Library
This Library is used to access the bunch of Card91 fintech services from login with auth token to card setting and transferring money
Features
Library directly communicate with Card91 services.
Getting started
Add Card91 SERVICES library into your application and call the required functions.
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.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
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.constraintlayout:constraintlayout:2.1.4'
//Add the CARD91 sdk
implementation files('../app/libs/card91Sdk.aar')
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
implementation 'com.squareup.okhttp3:okhttp: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 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
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 card91 team 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/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
SUPPORTED SERVICE METHOD
Name | Description |
---|---|
loginWithAuthToken | Service return the card holder details with its card information. |
getCardFlags | Service return the card holder a particular card flags informations. Eg ATM transaction is enabled or not |
updateCardFlags | Service update the card holder a particular card flags informations.Eg ATM transaction is enabled or disable |
lockCard | Service freeze a particular card activity |
blockCardOTP | Service initiate the card permanent block with OTP generation . |
blockCardConfirmation | Service completes the card permanent block with OTP validation. |
getCardLimit | Service return the card holder a particular card setting limit information. |
setCardLimit | Service update the card holder a particular card setting limit information. |
IMPLEMENTATION
Create a kotlin activity from where the service functions will be called.
Remember to implement "Card91EventListener" interface to listen the call back event response.
Implemented method of Card91EventListener are onEvent and onEventException, Card91RemoteResponse is the response data model class which contains response body, header and response code which is directly passed on to overridden methods (call backs)
import com.card91.common.Card91RemoteServices
import com.card91.common.interfaces.Card91EventListener
import com.card91.common.models.Card91RemoteResponse
class MainActivity : AppCompatActivity(), Card91EventListener {
override fun onEvent(response: Card91RemoteResponse?) {
Log.e("onEvent Response --",response?.responseCode.toString() +response?.responseBody.toString()+response?.responseHeader.toString() )
}
override fun onEventException(type: String?, responseBody: String?, code: String?) {
Log.e("onEventException --",responseBody +type+code )
}
}
For call different service function, first instantiate the instance of Card91RemoteServices by passing the environment ("PROD" for production and "PROD_SANDBOX" for sandbox production) , card holder auth token into the constructor.
val card91service:Card91RemoteServices = Card91RemoteServices("PROD_SANDBOX" , "C91CHhFl0TpR5lfLl5t0XrH/+ZohqqwvEJFVsPPg5fCfcUh4=",this)
After invoking the constructor call individual function and get the response in overridden functions.
Example for loginWithAuthToken
val card91service:Card91RemoteServices = Card91RemoteServices("PROD_SANDBOX" , this)
val jsonString = "{" +
" \"mobile\": \"917096482153\",\n" +
" \"sdkAuthToken\": \"1\",\n" +
" \"primaryOrgId\": \"230705103219705ID1OID1317188\"\n" +
"}"
val jsonObject = JSONObject(jsonString)
card91service.loginWithAuthToken(jsonObject);
Example for getCardFlags
val card91service: Card91RemoteServices = Card91RemoteServices("PROD_SANDBOX", "C91CHk6uZV+HZ/InkHb8hZQzlS6EhKB0naYrMgn3ZPKpGnrw=", this)
card91service.getCardFlags("230705103521821ID1CARD0150896");
Example for updateCardFlags
val card91service:Card91RemoteServices = Card91RemoteServices("PROD_SANDBOX" , "C91CHhFl0TpR5lfLl5t0XrH/+ZohqqwvEJFVsPPg5fCfcUh4=",this)
val requestBody = JSONObject()
try {
requestBody.put("cardId", "230705103521821ID1CARD0150896")// Card holder cardId
val requestBodyInside = JSONObject()
requestBodyInside.put("ATM_ENABLED", false) // ATM Flag
requestBodyInside.put("POS_ENABLED", false)// POS Flag
requestBodyInside.put("ECOM_ENABLED", false)// ECOM Flag
requestBodyInside.put("CL_ENABLED", false)// CL Flag
requestBody.put("cardFlags", requestBodyInside)
} catch (e: JSONException) {
e.printStackTrace()
}
card91service.updateCardFlags(requestBody);
Example for lockCard
val card91service: Card91RemoteServices = Card91RemoteServices("PROD_SANDBOX", "C91CHk6uZV+HZ/InkHb8hZQzlS6EhKB0naYrMgn3ZPKpGnrw=", this)
val requestBody = JSONObject()
try {
requestBody.put("cardId", "230705103521821ID1CARD0150896")// Card Holder Card ID
requestBody.put("lock", true)
} catch (e: JSONException) {
e.printStackTrace()
}
card91service.lockCard(requestBody);
Example for blockCardOTP
val card91service:Card91RemoteServices = Card91RemoteServices("PROD_SANDBOX" , "C91CHhFl0TpR5lfLl5t0XrH/+ZohqqwvEJFVsPPg5fCfcUh4=",this)
val requestObject = JSONObject();
requestObject.put("cardId","230530100608159ID1CARD5790474")//Card holder card ID
card91service.blockCardOTP(requestObject);
Example for blockCardConfirmation
val card91service:Card91RemoteServices = Card91RemoteServices("PROD_SANDBOX" , "C91CHhFl0TpR5lfLl5t0XrH/+ZohqqwvEJFVsPPg5fCfcUh4=",this)
val requestObject = JSONObject();
requestObject.put("cardId","230530100608159ID1CARD5790474")
requestObject.put("reason","LOST")
requestObject.put("sessionId","DUMMY-ID")
requestObject.put("otp","121212")
card91service.blockCardConfirmation(requestObject);
Example for getCardLimit
try {
val card91service:Card91RemoteServices = Card91RemoteServices("PROD_SANDBOX" , "C91CHhFl0TpR5lfLl5t0XrH/+ZohqqwvEJFVsPPg5fCfcUh4=",this)
card91service.getCardLimit("230705103521821ID1CARD0150896");// card holder card Id
} catch (e: JSONException) {
e.printStackTrace()
}
Example for setCardLimit
val card91service:Card91RemoteServices = Card91RemoteServices("PROD_SANDBOX" , "C91CHhFl0TpR5lfLl5t0XrH/+ZohqqwvEJFVsPPg5fCfcUh4=",this)
val requestBody = JSONArray()
val requestObjectATM = JSONObject()
requestObjectATM.put("txnType", "ATM")
requestObjectATM.put("maxLimit", "10000")
requestObjectATM.put("userLimit", "5000")
requestObjectATM.put("period", "M")
requestBody.put(requestObjectATM);
val requestObjectCL = JSONObject()
requestObjectCL.put("txnType", "ECOM")
requestObjectCL.put("maxLimit", "10000")
requestObjectCL.put("userLimit", "7000")
requestObjectCL.put("period", "M")
requestBody.put(requestObjectCL);
card91service.setCardLimit(requestBody, "230705103521821ID1CARD0150896");// card holder card Id
SERVICE RESPONSE CODE DESCRIPTION
Response can be traced on the call back event object Card91RemoteResponse
Response code | Description |
---|---|
200-299 | Between 200-299 is considered as success response. |
400-499 | 401 Invalid auth token, 403 Forbidden, 400 Request structure is malformed or incorrect 415 Missing header request etc |
500-599 | Server Error |