Android
Lean's Link Android SDK is a Kotlin library, distributed as a AAR/JAR and distributed via Jitpack.
To get started update your project level build.gradle
to include jitpack:
repositories {
maven { url 'https://jitpack.io'}
}
Next, add this dependency code to your module's build.gradle
file:
dependencies {
implementation "me.leantech:link-sdk-android:X.X.X"
}
Usage
Create a new lean instance with the .Builder()
method and pass your app token and list of permissions that you want your user to grant.
These two parameters are necessary and Lean will not be initialised without these.
showLogs()
is used to show some basic logs such as which step the user reached etc.
val lean = Lean.Builder()
.setAppToken("YOUR_APP_TOKEN")
.setVersion("latest")
.showLogs()
.sandbox(true)
.build()
LeanListener
Each call to lean's method requires passing a LeanListener object which notifies you if the process finished successfully or failed somewhere in between.
lean.link(requireActivity(), "customer_id", "bank_identifier", ArrayOf[Lean.UserPermissions], object : LeanListener {
override fun onSuccess() {
}
override fun onFailure(lastStep: StepCompleted) {
}
})
onSuccess()
is called when the user has successfully has finished all the steps and has logged into their bank account. Once this is complete, your backend has to call lean api the token associated with this user to fetch their bank account details.
onFailure()
is called if for any reason the user was unable to finish the process. This method returns lastStep enum value which tells the last step at which the flow was quit.
lastStep
is an enum and can have the following values:
Init & Reconnect
START | SDK initialisation had started |
APPLICATION_INFO | Application info screen was shown |
PERMISSION_SELECTION | Permissions screen was shown and user selected some permissions and proceeded to the bank list screen |
BANK_LIST | Last shown screen was bank list |
BANK_CHOSEN | Bank was chosen |
BANK_LOGIN_FAIL | Bank login failed due to wrong creditials |
OTP | Bank login was success and otp screen was last screen shown |
OTP_FAIL | OTP entry failed due to incorrect OTP |
ERROR_MFA_REQUEST_ID | This is a special case which ideally should not happen. This happens when in the collectOtp flow, the passed mfaRequestId is incorrect. |
Payment Source
SOURCE_BANK_LIST | List of banks for payment source adding process was shown |
SOURCE_LOGIN_MFA | Login OTP screen shown |
SOURCE_BENEFICIARY_MFA | Beneficiary OTP screen shown |
SOURCE_ADDING_COMPLETE | Adding the beneficiary was successful |
SOURCE_ADDING_FAILED | Payment source adding failed |
SOURCE_OTP_FAILED | OTP entry failed due to incorrect OTP |
SOURCE_BANK_LOGIN_FAILED | Credentials provided by the user for bank login was incorrect |
Payment Source
PAYMENT_SOURCE_LIST | List of bank accounts to pay from shown |
PAYMENT_LOGIN_MFA | Login OTP screen shown |
PAYMENT_MFA | Payment OTP screen shown |
PAYMENT_OTP_FAILED | OTP entry failed due to incorrect OTP |
INITIATING_PAYMENT_FAILED | Confirming payment failed |
PAYMENT_FAILED | Either the payment failed or was rejected by the bank |
PAYMENT_CONFIRM | Confirm payment screen last shown |
PAYMENT_COMPLETE | Payment was successful |
Available Methods
.connect()
The connect
method is used to enable a customer to use a single log in to create and Entity and a PaymentSource for use with the Data API and Payments API respectively.
lean.connect(
Activity, customer_id, bankId, paymentDestinationId, userPermissionsArray, customization, new Lean.LeanListener() {
@Override
public void onSuccess() {
Log.d("LEAN_SDK", "SUCCESS");
}
@Override
public void onFailure(@NotNull Lean.StepCompleted lastStep) {
Log.e("LEAN_SDK", "FAILED -> " + lastStep.toString());
}
});
.reconnect()
The reconnect
method is used to re-authenticate a customer account with the Data API.
lean.reconnect(
Activity, reconnect_id, customization, new Lean.LeanListener() {
@Override
public void onSuccess() {
Log.d("LEAN_SDK", "SUCCESS");
}
@Override
public void onFailure(@NotNull Lean.StepCompleted lastStep) {
Log.e("LEAN_SDK", "FAILED -> " + lastStep.toString());
}
});
.createBeneficiary()
The createBeneficiary
method is used to authorize an additional payment destination for an existing payment source in the Payments API.
NOTE: We have renamed the updatePaymentSource() method on the Link SDK. It will now be called createBeneficiary(). The updatePaymentSource() method is now deprecated. Please use the new link method as detailed below.
lean.createBeneficiary(
Activity, customer_id, payment_source_id, payment_destination_id, customization, new Lean.LeanListener() {
@Override
public void onSuccess() {
Log.d("LEAN_SDK", "SUCCESS");
}
@Override
public void onFailure(@NotNull Lean.StepCompleted lastStep) {
Log.e("LEAN_SDK", "FAILED -> " + lastStep.toString());
}
});
.pay()
The pay
method is used to make a bank to bank transfer from your customer's account to your account in the Payments API.
lean.pay(
Activity, payment_intent_id, showBalances, account_id, customization, new Lean.LeanListener() {
@Override
public void onSuccess() {
Log.d("LEAN_SDK", "SUCCESS");
}
@Override
public void onFailure(@NotNull Lean.StepCompleted lastStep) {
Log.e("LEAN_SDK", "FAILED -> " + lastStep.toString());
}
});
The show_balances
parameter is optional and allows you to show/hide the balances of bank accounts when an end user is going through the payment authorization flow. It's RECOMMENDED to always "HIDE" the balances.
Attention!
The authorize() method only applies to the Corporate Payment flow.
.authorize()
lean.authorize(
Activity, customer_id, end_user_id, payment_intent_id, customization, new Lean.LeanListener() {
@Override
public void onSuccess() {
Log.d("LEAN_SDK", "SUCCESS");
}
@Override
public void onFailure(@NotNull Lean.StepCompleted lastStep) {
Log.e("LEAN_SDK", "FAILED -> " + lastStep.toString());
}
});
Changing the SDK language
Link SDK is available in English and Arabic, fully supported with a right-to-left UI, including text alignment, icons and images. If no language is provided the default is English. The language parameter is provided to the Lean.Builder()
val lean = Lean.Builder()
.setLanguage("ar")
...
Language option
language enum
en | English |
ar | Arabic |
Customizing Link SDK
We are progressively releasing customization capabilities to the Link SDK to match its UI with your application branding style. This allows customers to programmatically theme the Link SDK directly from any of the methods.
For more detailed documentation on how best to use the customization feature see our guides.
Presentation options
dialog_mode string
Presents the Link SDK with or without a containing modal.
"contained"
for modal (default), or "uncontained"
for no modal.
button_border_radius string
Change the shape of the main button on each step. See guidance for examples.
A unitless number as a String. Options:
Value | Style |
---|---|
"4" | default |
"8" | Border radius of 8px |
"0" | Rectangle button |
"pill" | Always pill shaped, whatever the button height |
Color options
theme_color string
Buttons background color, active input borders, and loading spinners.
button_text_color string
Elements inside any primary button such as the text, icons and the loading spinner. It is useful to boost readability of the button color.
link_color string
CTAs and helpers.
overlay_color string
Overlay containing the Link SDK dialog box.
The following color formats are supported:
Example | Format |
---|---|
"#000000" | Hex |
"#000" | Shorthand hex |
"#000000FF" | Hex with alpha |
"rgb(0, 0, 0)" | Comma separated RGB |
"rgba(0, 0, 0, 0.5)" | Comma separated RGB with Alpha |
"black" | Color name |
Example
Lean.Customization linkCustomization = new Lean.Customization();
linkCustomization.setThemeColor("#0080ff");
linkCustomization.setButtonTextColor("#ffffff");
linkCustomization.setLinkColor("#0080ff");
linkCustomization.setOverlayColor("rgba(0, 0, 0, 0.8)");
linkCustomization.setButtonBorderRadius("8");
linkCustomization.setDialogMode("uncontained");
lean.connect(
Activity,
customer_id,
bankId,
paymentDestinationId,
userPermissionsArray,
linkCustomization,
new Lean.LeanListener() {}
);
Updated about 1 month ago