MoneyKit Connect for Android is a quick and secure way to link bank accounts from within your Android app. The SDK handles connecting to a financial institution in your app (credential validation, multi-factor authentication, error handling, etc.) without passing sensitive information to your server.
This project provides a basic example of how to integrate the MoneyKit Connect Android SDK into an Android app.
Add the following line to your app's build.gradle file:
Legacy Dependency Declaration
implementation("com.moneykit:connect:0.4.2") New Gradle Version Catalog Declaration
For more information: https://developer.android.com/build/migrate-to-catalogs
Add these entries to gradle/libs.versions.toml:
[versions]
moneykitConnect = "0.4.2"
[libraries]
moneykit-connect = { group = "com.moneykit", name = "connect", version.ref = "moneykitConnect" } Then use the alias in app/build.gradle.kts:
```kotlin
implementation(libs.moneykit.connect)
See https://docs.moneykit.com/connect/android for documentation.
Follow the steps below to get started with a basic SDK integration.
Starting the MoneyKit Connect flow begins with creating a link_session_token. Once the
link_session_token is passed to your app, create an instance of MkConfiguration, then create an
instance of MkLinkHandler passing in the previously created MkConfiguration, and call
presentLinkFlow(context) on the handler. Note that each time you open MoneyKit
Connect, you will need to get a new link_session_token from your server and create a new
MkConfiguration with it.
val linkSessionToken = "your_link_session_token"
val configuration = MkConfiguration(
sessionToken = linkSession.linkSessionToken,
onSuccess = { successType ->
when (successType) {
is MkLinkSuccessType.Linked -> {
Timber.i("Linked - Token to exchange: ${successType.institution.token.value}")
}
is MkLinkSuccessType.Relinked -> {
Timber.i("Relinked")
}
}
},
onExit = { error ->
if (error != null) {
Timber.e(error.displayedMessage)
}
Timber.i("Exited Link")
},
)A Handler is a one-time use object used to open a MoneyKit Connect session. The Handler must be retained for the duration of the Connect flow. It will also be needed to respond to OAuth Universal Link redirects.
val linkHandler = MkLinkHandler(configuration)Finally, open Link by calling presentLinkFlow(context) on the Handler object.
This will usually be done in a button’s click handler. Context should be your current activity.
linkHandler.presentLinkFlow(this)