React Native
How to integrate
Lean's React Native SDK is available as a package under the name lean-react-native
via npm or yarn
yarn add lean-react-native
npm install lean-react-native
If you don't already have react-native-webview
added to your project you should also install it:
yarn add react-native-webview
npm install --save react-native-webview
New you need to update your pods by navigating to the iOS folder:
cd ios
pod install
Usage
You need to create a ref
to the LinkSDK component in order to call any of the LinkSDK functions like so:
import React, { useRef } from 'react'
import { View, TouchableOpacity, Text } from 'react-native'
import LinkSDK from 'lean-react-native'
const App = () => {
const Lean = useRef(null)
return (
<View>
<TouchableOpacity
onPress={() => Lean.current.link({ customer_id: "CUSTOMER_ID" })}
>
<Text>Link Account</Text>
</TouchableOpacity>
<LinkSDK
ref={Lean}
appToken="MY_APP_TOKEN"
version="{version_number}"
country="{country_of_operation}"
sandbox
/>
</View>
)
}
export default App
Choosing a version
When calling Lean.manager.setup
a version is required.
Version takes a String and can point to either a specific SDK version i.e. "latest" or an alias i.e. "latest".
Lean.manager.setup(
appToken: String,
sandbox: true,
version: "latest"
)
We recommend passing in a specific version to ensure stability in the case that a change to the SDK breaks your application.
Available Versions
Specific Version semver
The current stable build is 1.25.0
latest alias
latest
is an alias for the current release. It is subject to change at relatively short notice - but does allow for any bug fixes to be shipped over the air - meaning fixes can be applied without the need to resubmit your application to the app store.
next-release alias
next-release
is a QA version of the SDK allowing you to test the next version that will become latest before we roll out the changes, this should only be used for development and QA purposes as it is subject to breakage without any warning.
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.current.connect({
customer_id: "YOUR_CUSTOMER_ID",
permissions: ["identity","accounts","balance","transactions", "payments"],
bank_identifier: "LEAN_MB1",
payment_destination_id: "PAYMENT_DEST_ID",
})
.reconnect()
The reconnect
method is used to re-authenticate a customer account with the Data API.
Lean.current.reconnect({
reconnect_id: "RECONNECT_ID"
})
.createPaymentSource()
The createPaymentSource
method is used to connect a bank account as a payment method to your application in the Payments API.
Lean.current.createPaymentSource({
customer_id: "CUSTOMER_ID",
bank_identifier: "LEAN_MB1",
success_redirect_url: "myapp://www.myapp.com/success", // required for Open Banking banks
fail_redirect_url: "myapp://www.myapp.com/success" // required for Open Banking banks
})
.updatePaymentSource()
The updatePaymentSource
method is used to authorise an additional payment destination for an existing payment source in the Payments API.
Lean.current.updatePaymentSource({
customer_id: "CUSTOMER_ID",
payment_source_id: "PAYMENT_SOURCE_ID",
payment_destination_id: "PAYMENT_DESTINATION_ID"
})
.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.current.pay({
payment_intent_id: "PAYMENT_INTENT_ID",
account_id: "ACCOUNT_ID"
})
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.
Callbacks
By providing a callback into the component, the LinkSDK will report back with an object in the following format:
{
method: "LINK",
status: "SUCCESS",
message: "Some message about the state of the application",
exit_point: "SUCCESS",
secondary_status: "SUCCESS",
bank: {
bank_identifier: "DIB_UAE",
is_supported: true
}
}
Troubleshooting
Webview crashes on Android
You can disable hardware acceleration on the webview by passing android specific props into the webview:
<LinkSDK
webViewProps={{
androidHardwareAccelerationDisabled: true,
}}
appToken: "YOUR_APP_TOKEN"
sandbox: false
>
JDK version issues on Android
You may get gradle errors if you have a different JDK on the development system compared to the local JDK delivered with the Android SDK. The solution is to set set JAVA_HOME in gradlew or gradlew.bat to point to the SDK JDK path. On Windows:
SET JAVA_HOME="\Program Files\Android\Android Studio\jre"
Updated about 2 months ago