Android
Adding the ReadyRemit SDK Package to Your Android Project
In this guide, you will learn how to integrate the ReadyRemit SDK into your Android app.
Step 1 - Prepare for the ReadyRemit SDK
-
Make sure that your app's minimum Android API level is 26 or higher. This can be found in the
build.gradle
file. Depending on your setup this might be defined in thebuild.gradle
file at the Module level or at the Project level.android { .. compileSdkVersion 33 defaultConfig { .. minSdkVersion 26 targetSdkVersion 33 } }
-
Add classpath dependencies to the
build.gradle
at the Project levelbuildscript { .. ext { .. kotlinVersion = "1.6.0" } dependencies { .. classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") classpath "com.google.dagger:hilt-android-gradle-plugin:2.28-alpha" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3" } } allprojects { repositories { google() mavenCentral() jcenter() maven { url 'https://maven.google.com' } maven { url "https://jitpack.io" } } }
Newer Gradle versions 8.0 or above.
if you are using a newer gradle structure of 8.0 or above, you should not add this segment of code.
allprojects { repositories { google() mavenCentral() jcenter() maven { url 'https://maven.google.com' } maven { url "https://jitpack.io" } } }
instead open your settings.gradle and add the following:
dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() jcenter() maven { url 'https://maven.google.com' } maven { url "https://jitpack.io" } } }
also in your gradle.properties add this line:
android.enableJetifier=true
- Add the following
apply
statements to the top of yourbuild.gradle
file at the Module level:
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
Step 2 - Install the ReadyRemit SDK
Version specification
You will find two versions of ReadyRemitSDK
• readyremit.aar - This is the full version that includes the KYC feature
• readyremitlite.aar - This is the version, that does not include the KYC feature
You should implement only one of these into your project
- Download the
readyremit.aar
orreadyremitlite.aar
from the Releases page on Github - Add the .aar file to the folder your_app_root/app/libs
- Add the path as a dependency to your app's
build.gradle
file a the Module level:
dependencies {
..
// ReadyRemit SDK
implementation files('libs/readyremit.aar')
// ReadyRemit SDK Lite (Without KYC)
implementation files('libs/readyremitlite.aar')
}
- Add missing third-party dependencies to your app's
build.gradle
file at the Module level:
dependencies {
..
// Android / Material
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
// OkHttp
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
implementation 'com.localebro:okhttpprofiler:1.0.8'
// Retrofit
def retrofit_version = '2.9.0'
implementation "com.squareup.retrofit2:retrofit:${retrofit_version}"
implementation "com.squareup.retrofit2:converter-gson:${retrofit_version}"
implementation "com.squareup.retrofit2:converter-moshi:${retrofit_version}"
// Moshi
def moshi_version = '1.13.0'
implementation "com.squareup.moshi:moshi:${moshi_version}"
implementation "com.squareup.moshi:moshi-adapters:${moshi_version}"
kapt "com.squareup.moshi:moshi-kotlin-codegen:${moshi_version}"
// Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
kapt 'com.github.bumptech.glide:compiler:4.12.0'
// Dagger
def dagger_version = '2.34'
implementation "com.google.dagger:dagger:2.37"
annotationProcessor "com.google.dagger:dagger-compiler:2.37"
kapt "com.google.dagger:dagger-compiler:2.37"
// AndroidSupportInjection
implementation "com.google.dagger:dagger-android:2.37"
implementation "com.google.dagger:dagger-android-support:2.37"
annotationProcessor "com.google.dagger:dagger-android-processor:2.37"
kapt "com.google.dagger:dagger-android-processor:2.37"
// PDF Viewer
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
}
- Set view binding to true in build features to your app's
build.gradle
file at the Module level:
android {
..
buildFeatures {
dataBinding true
viewBinding true
}
}
Step 3 - Install required Visa sensory branding libraries
- Download visa-sensory-branding-sdk from Github
- Add the .aar file to the folder your_app_root/app/libs
- Add the path as a dependency to your app's
build.gradle
file a the Module level:
dependencies {
..
implementation files ('libs/visa-sensory-branding-2.0.aar')
}
Step 4 - Initialize the SDK
SDK initialization needs to happen before it can be launched. Initialization can be done in your Application onCreate method, or in any activity, as long as you pass your Application object to it.
The ReadyRemit SDK initialization requires three parameters:
- Environment: Choose between PRODUCTION and SANDBOX
- A callback to get the authentication token
- A callback to submit the transfer
ReadyRemit.initialize(
ReadyRemit.Config.Builder(application) // Application object returned by 'getApplication()' method
.useEnvironment(Environment.SANDBOX) // Selected environment
.useAuthProvider { callback -> requestReadyRemitAccessToken(callback) } // Your Access Token callback
.useTransferSubmitProvider { request, callback -> submitReadyRemitTransfer(request, callback) } // Your Submit Transfer callback
.useDefaultTheme(R.style.ReadyRemit)
.useLanguage("es") // Language code can also be specified in ReadyRemit.remitFrom() function.
.build()
)
Step 5 - Retrieve an auth token and submit a transfer
The access token callback should return a ReadyRemitAuth object that includes the access token. The access should be obtained by your server (see Server side integration for more details) and provided to your app.
To request an Auth Token, use the following code.
private fun requestReadyRemitAccessToken(callback: ReadyRemitAuthCallback) {
// On success
callback.onAuthSucceeded(
ReadyRemitAuth(
// Access token from an API call to your backend, or from memory storage
accessToken,
"" // Empty String
)
)
// On failure (error code should be returned from your server if the submission fails)
callback.onAuthFailed()
}
The submit transfer callback operation performs a call to request the transfer. If successful, it will return a transfer id to your server.
To submit a transfer, use the following code.
private suspend fun submitReadyRemitTransfer(
request: ReadyRemitTransferRequest,
callback: ReadyRemitTransferCallback
) {
// Call to your server to submit the transfer
// Example: response = api.SubmitTransfer(request);
// On success (transfer ID should be returned from your server)
callback.onTransferSucceeded(transferId)
// On failure (error code should be returned from your server if the submission fails)
callback.onTransferFailed(errorCode)
}
SECURITY WARNING
We strongly recommend not storing the access token in any long-term storage. If obtained maliciously, this token can be used to view your user's confidential financial information.
Step 6 - Launch SDK
To launch the ReadyRemit SDK, use the following code. It should be triggered from an Activity typically inside a button's OnClick Listener.
/**
* Launch ReadyRemitSDK
*
* @param1 'this' is the current Activity object.
* @param2 The request code can be any Int value.
* @param3'theme' is your custom theme(R.style.sample_theme), you will see how to create one on the following section.
$ @param4 'languageCode' is the locale code.
*/
ReadyRemit.remitFrom(this, REQUEST_CODE, theme, languageCode)
(Optional) Style the ReadyRemit SDK
- In the root of your Android project create a new "Values Resource File" (ex: theme_readyremit.xml).
- Use the following code as a template and fill in any colors you'd like to override:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ReadyRemit" parent="Theme.ReadyRemit.Light">
<item name="rrmBackgroundColor">#FEE598</item>
<item name="rrmForegroundColor">#B7D7A9</item>
<item name="rrmButtonTextColor">#D5A6BD</item>
<item name="rrmButtonColor">#558CF4</item>
<item name="rrmDangerColor">#44808E</item>
<item name="rrmDangerLightColor">#6FA8DC</item>
<item name="rrmDividerColor">#660000</item>
<item name="rrmIconColor">#FE0100</item>
<item name="rrmInputLineColor">#008761</item>
<item name="rrmPrimaryColor">#9801FF</item>
<item name="rrmPrimaryLightColor">#9801FF</item>
<item name="rrmSuccessColor">#B55F07</item>
<item name="rrmTextColor">#0100FE</item>
<item name="rrmTextSecondaryColor">#00FEFE</item>
</style>
</resources>
- Navigate to the project's resource folder. The path should be something like: MyProject/app/src/main/res
- Ensure that there is a folder named "values-night". If this folder doesn't exist, create it.
- Inside the "values-night" folder, create an XML file with the exact same name as the original theme used for the light mode.
- Open the project in Android Studio. In the res/values directory, you will find a directory for these themes. There will be one for light mode and one for dark mode (indicated by "night" tag).
- In the dark mode theme file, add the following structure:
Important
• Make sure to set the parent attribute to Theme.ReadyRemit.Dark.
• If you're only using the light mode in your application, you can copy the same colors from the theme used for the light mode. If you're using the dark mode, make the necessary color modifications here.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ReadyRemit" parent="Theme.ReadyRemit.Dark">
<item name="rrmBackgroundColor">#111111</item>
<item name="rrmForegroundColor">#1F1F1F</item>
<item name="rrmButtonTextColor">#FFFFFF</item>
<item name="rrmButtonColor">#558CF4</item>
<item name="rrmDangerColor">#AA220F</item>
<item name="rrmDangerLightColor">#201311</item>
<item name="rrmDividerColor">#313131</item>
<item name="rrmIconColor">#7E7E7E</item>
<item name="rrmInputLineColor">#505050</item>
<item name="rrmPrimaryColor">#558CF4</item>
<item name="rrmPrimaryLightColor">#83ACF7</item>
<item name="rrmSuccessColor">#008761</item>
<item name="rrmTextColor">#E3E3E3</item>
<item name="rrmTextSecondaryColor">#B0B0B0</item>
</style>
</resources>
- Update the launch function to use the new theme.
ReadyRemit.remitFrom(currentActivity!!, REQUEST_CODE, R.style.ReadyRemit, language)
(Optional) Closing ReadyRemitSDK
If you wish to gracefully close the ReadyRemitSDK at any point in your code, you can achieve this with the following method:
fun closeReadyRemitSDK() {
ReadyRemit.close()
}
(Optional) Inactivity Detector
If you prefer to automatically close the ReadyRemitSDK when your users are inactive, you can use the following snippet. Place it in your activity where you launch the SDK.
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.yourcompany.ReadyRemitSDK
class YourActivity : AppCompatActivity() {
private val REQUEST_CODE = 1 // Replace with your actual request code
private val theme = "your_theme" // Replace with your actual theme
private val languageCode = "your_language_code" // Replace with your actual language code
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Launch ReadyRemitSDK
ReadyRemit.remitFrom(this, REQUEST_CODE, theme, languageCode)
// Set inactivity timeout (e.g., 60 seconds)
ReadyRemit.close(60)
}
}
(For KYC users only) Implement KYC
If you wish to use the ReadyRemitSDK with the KYC feature, these are the steps required to implement additional libraries.
- Download scanforensics.aar from Github
- Add the .aar file to the folder your_app_root/app/libs
- Add the path as a dependency to your app's
build.gradle
file a the Module level:
dependencies {
..
implementation files('libs/scanforensicsplus.aar')
}
- Add the required third-party dependencies to your app's
build.gradle
file at the Module level:
dependencies {
..
implementation 'com.acuant:acuantcommon:11.5.4'
implementation 'com.acuant:acuantcamera:11.5.4'
implementation 'com.acuant:acuantimagepreparation:11.5.4'
implementation 'com.acuant:acuantfacecapture:11.5.4'
implementation 'com.acuant:acuantpassiveliveness:11.5.4'
implementation 'com.github.smart-fun:XmlToJson:1.5.1'
}
- Add the required maven repositories to your app's
build.gradle
file at the Project Level:
allprojects {
repositories {
..
maven { url 'https://raw.githubusercontent.com/Acuant/AndroidSdkMaven/main/maven/' }
maven { url 'https://raw.githubusercontent.com/iProov/android/master/maven/' }
}
}
- Enable camera permission into your Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.your.package">
..
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Updated 3 months ago