Android Client

FinBox Lending SDK is a drop-in module that can add a digital lending journey to any mobile application.

Requirements#

FinBox Lending SDK works on Android 5.0+ (API level 21+), Java 8+ and AndroidX. In addition to the changes, enable desugaring to support older versions.

android {
...
defaultConfig {
...
// Minimum 5.0+ devices
minSdkVersion(21)
...
}
...
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled = true
// Sets Java compatibility to Java 8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
// For Kotlin projects
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")
}

Adding Dependency#

Add the repository url to allprojects in the project build.gradle file.

maven {
setUrl("s3://risk-manager-android-sdk/artifacts")
credentials(AwsCredentials::class) {
accessKey = <ACCESS_KEY>
secretKey = <SECRET_KEY>
}
content {
includeGroup("in.finbox")
includeGroup("in.finbox.lending")
}
}

Add the Lending SDK dependency to the module build.gradle file

implementation ("in.finbox.lending:onboarding:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox", "mobileriskmanager")
exclude("in.finbox", "common")
exclude("in.finbox", "logger")
isTransitive = true
}
implementation ("in.finbox.lending:preloan:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox.lending", "core")
isTransitive = true
}
implementation ("in.finbox.lending:dashboard:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox.lending", "core")
isTransitive = true
}
implementation ("in.finbox.lending:kyc:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox.lending", "core")
isTransitive = true
}
implementation ("in.finbox.lending:loan:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox.lending", "core")
isTransitive = true
}
implementation ("in.finbox.lending:esign:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox.lending", "core")
isTransitive = true
}
implementation ("in.finbox.lending:enach:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox.lending", "core")
isTransitive = true
}
implementation ("in.finbox.lending:payment:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox.lending", "core")
isTransitive = true
}
implementation ("in.finbox.lending:bankconnect:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox.lending", "core")
exclude("in.finbox", "bankconnect")
isTransitive = true
}
implementation ("in.finbox.lending:pennydrop:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox.lending", "core")
isTransitive = true
}
implementation ("in.finbox.lending:gst:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox.lending", "core")
isTransitive = true
}
implementation ("in.finbox.lending:videokyc:<LENDING_SDK_VERSION>:release@aar") {
exclude("in.finbox.lending", "core")
isTransitive = true
}
implementation ("in.finbox.lending:core:<LENDING_SDK_VERSION>:release@aar") {
isTransitive = true
}
implementation('in.finbox:mobileriskmanager:<DC_SDK_VERSION>:parent-release@aar') {
isTransitive = true
}
implementation('in.finbox:common:<COMMON_SDK_VERSION>:<PLATFORM_NAME>-release@aar') {
isTransitive = true
}
implementation("in.finbox:logger:<LOGGER_SDK_VERSION>:parent-release@aar") {
isTransitive = true
}
implementation('in.finbox:bankconnect:<BC_SDK_VERSION>:release@aar') {
isTransitive = true
}
Note

Find a full list of keys required to integrate on mobile here

Permissions#

Lending SDK requires SMS and Location permission as mandatory. Make sure you dont have any node markers that remove these permissions in your manifest file

Manifest should not have any of the following

<uses-permission
android:name="android.permission.RECEIVE_SMS"
tools:node="remove" />
<uses-permission
android:name="android.permission.READ_SMS"
tools:node="remove" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
tools:node="remove" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
tools:node="remove" />
ProGuard

While generating a signed application, make sure ProGuard file uses proguard-android.txt not proguard-android-optimize.txt, i.e. make sure it is:

proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")

Start SDK flow#

Once all dependencies are added, SDK requires 3 inputs: CUSTOMER_ID, USER_TOKEN and CLIENT_API_KEY. ENVIRONMENT is an optional field. Default value of environment is PROD.

Note

USER_TOKEN needs to be generated against a CUSTOMER_ID on backend before starting the SDK. Refer here

ENVIRONMENT needs to be updated to PROD when migrating application to production.

In the onCreate of your application class initialize dependencies required by the SDK:

CoreApp.initDi(this)

Now that all required parameters are available, we can start the SDK flow as follows:

val REQUEST_CODE_ONBOARDING = 101
val builder = FinBoxLending.Builder(context)
.setLendingEnvironment("<ENVIRONMENT>")
.setCustomerId("<CUSTOMER_ID>")
.setFinBoxApiKey("<CLIENT_API_KEY>")
.setUserToken("<USER_TOKEN>")
.setSplashIcon(<DRAWABLE>)
.setToolbarIcon(<DRAWABLE>)
.build()
startActivityForResult(
builder.getLendingIntent(context),
REQUEST_CODE_ONBOARDING
)
  • setSplashIcon is the optional method that will contain the drawable (in Int) that can be used to show icon on the splash screen.
  • setToolbarIcon is the optional method that will contain the drawable (in Int) that can be used to show the icon on the toolbar.

Credit Line#

For credit line journey, include the following dependency in the module build.gradle file:

implementation("in.finbox.lending:creditline:<LENDING_SDK_VERSION>:uat@aar") {
exclude("in.finbox.lending", "core")
isTransitive = true
}

In case of credit line product, once the lending journey is completed, user can opt-in for a credit while doing a transaction. For such a case use following method to start the credit line withdrawl journey:

val REQUEST_CODE_ONBOARDING = 101
val builder = FinBoxLending.Builder(context)
.setLendingEnvironment(<ENVIRONMENT>)
.setCustomerId("<CUSTOMER_ID>")
.setFinBoxApiKey("<CLIENT_API_KEY>")
.setUserToken("<USER_TOKEN>")
.setSplashIcon(<DRAWABLE>)
.setToolbarIcon(<DRAWABLE>)
.setCreditLineAmount(<WITHDRAW_AMOUNT>)
.setCreditLineTransactionId("<TRANSACTION_ID>")
.build()
startActivityForResult(
builder.getLendingIntent(context),
REQUEST_CODE_ONBOARDING
)
  • setCreditLineAmount is the method that will contain the amount (in Float) that a user is trying to withdraw
  • setCreditLineTransactionId will hold the transaction id (in String) for the withdrawal flow

Callback#

The callback will be provided when the user exits the SDK. You can track the status of user exit actions in the onActivityResult callback function

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == REQUEST_CODE_ONBOARDING) {
val result = data.extras.getParcelable<FinBoxJourneyResult>(FINBOX_JOURNEY_RESULT)
// callback when user exits the flow, intent data has information holding users state
}
}

FinBoxJourneyResult has the following values:

  • resultCode: Status code for the journey.
  • screen: Name of the last screen in the journey
  • message: Any additional message to describe the resultCode

Possible values for resultCode are as follows:

Result CodeDescription
MW200Journey is completed successfully
MW500User exits the journey
MW400Some error occurred in the SDK
CL200Credit line withdrawal success
CL500Credit line withdrawal failed

Possible values for screen are as follows:

ScreenDescription
LauncherThe base screen (Hidden Activity)
PermissionsPermission list screen
ProfileBasic profile screen
PAN ConsentPAN consent screen
DashboardDashboard screen
Loan FormLoan application screen
KYCKYC screen
Bank VerificationBank verification screen
Loan OfferLoan details screen
Sign AgreementSign agreement screen

Notifications#

FinBox Lending SDK sends notifications of its own for mandatory events. It is expected that the client app has Firebase configured and can forward the notification payload to the SDK. In order for SDK to capture the notifications add the following:

  1. implement FinBoxLendingMessagingImpl interface
  2. Override getLendingIntent & getRepayLendingIntent to provide intent to open the SDK
  3. initialize the lending messaging service
  4. forwardToFinBoxLendingSDK will check if the notification payload was triggered by FinBox lending team
  5. buildLendingNotification will build the notification and show it to the user
class SampleMessService: FirebaseMessagingService(), FinBoxLendingMessagingImpl {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
FinBoxLendingMessagingService.initLendingMessagingService(this)
//.... Client app level logic
if (remoteMessage.data.isNotEmpty()) {
if (FinBoxLendingMessagingService.forwardToFinBoxLendingSDK(remoteMessage.data)) {
FinBoxLendingMessagingService.buildLendingNotification(applicationContext, remoteMessage)
} else {
// Show client app notification
}
}
}
override fun getLendingIntent(): PendingIntent {
val intent = generateFinBoxLending().getLendingIntent(applicationContext)
// Create the TaskStackBuilder
return PendingIntent.getActivity(
this,
REQUEST_CODE_NOTIFICATION_LOAN_STATUS,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
)
}
override fun getRepayLendingIntent(): PendingIntent {
val intent = generateFinBoxLending().getRepayLendingIntent(applicationContext)
// Create the TaskStackBuilder
return PendingIntent.getActivity(
this,
REQUEST_CODE_NOTIFICATION_LOAN_REPAY_STATUS,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
)
}
//Common builder object to start lending SDK
private fun generateFinBoxLending(): FinBoxLending {
val builder = FinBoxLending.Builder(applicationContext)
.setLendingEnvironment(<ENVIRONMENT>)
.setFinBoxApiKey("<CLIENT_API_KEY>")
.setCustomerId("<CUSTOMER_ID>")
.setUserToken("<USER_TOKEN>")
.build()
return builder
}
}
## Customizations
  1. The privacy policy URL needs to be updated to the company policy. The default privacy policy is pointing to FinBox privacy. Add a String resource to specify the policy URL.
<string name="finbox_lending_privacy_policy_url">https://finbox.in/about/privacy</string>
Note

Make sure the value passed is a valid URL

  1. The toolbar title can be updated which will be visible in the Dashboard module. In order to update the toolbar just add a String resource for the same.
<string name="finbox_appbar_title">My App</string>
  1. SDK fonts can be customised to match the parent application. The SDK used 3 main fonts as mentioned below:
<style name="FBLendingAppTheme.FinBox.TextPrimary" parent="TextAppearance.AppCompat">
<item name="fontFamily">bold-font</item>
</style>
<style name="FBLendingAppTheme.FinBox.TextSecondary" parent="TextAppearance.AppCompat">
<item name="fontFamily">regular-font</item>
</style>
<style name="FBLendingAppTheme.FinBox.TextSubHead" parent="TextAppearance.AppCompat">
<item name="fontFamily">semibold-font</item>
</style>
  • FBLendingAppTheme.FinBox.TextPrimary is used for all buttons and bold headers
  • FBLendingAppTheme.FinBox.TextSecondary is the regular font that is used for regular text
  • FBLendingAppTheme.FinBox.TextSubHead is the medium bold font that is used for Sections or subheadings

Customize the SDK font by adding the application fontFamily in the styles.

  1. SDK Buttons can be customized by overriding FBLendingAppTheme
<style name="FBLendingAppTheme.FinBox.Button" parent="Widget.MaterialComponents.Button">
<item name="cornerRadius">16dp</item>
<item name="fontFamily">button-font</item>
</style>
<style name="FBLendingAppTheme.FinBox.TextButton" parent="Widget.MaterialComponents.Button.TextButton"></style>

Change button corner radius and text font as per your application theme.