Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lean-react-native

Package Overview
Dependencies
Maintainers
0
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lean-react-native

A React Native wrapper for Lean's LinkSDK

  • 3.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
588
decreased by-10.23%
Maintainers
0
Weekly downloads
 
Created
Source

The React Native Wrapper for LinkSDK allows you to do all the functions that can be achieved with the LinkSDK on web, from linking bank accounts to initiating payments.

Installation

Install lean-react-native

npm install --save lean-react-native

If you don't already have react-native-webview added to your project you should also install this

npm install --save react-native-webview

Go to your ios folder and run

pod install

Usage

The Wrapper uses a ref to access internal functions.

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

API Reference

PropRequiredDescription
refTrueThe reference for the LinkSDK component
appTokenTrueThe App Token can be retrieved from your Lean App Dashboard
callbackFalseA function that you want the SDK to callback to upon closing of the SDK (whether successful or failed)
versionFalseWhich version of the LinkSDK you want to load (defaults to @latest)
countryFalseWhich country you are operating in (defaults to ArabEmirates) (options are SaudiArabia and ArabEmirates)
sandboxFalseWhether the LinkSDK is in sandbox or not (defaults to False)

Methods

The LinkSDK supports 6 methods. link, connect, reconnect, createPaymentSource, updatePaymentSource, and pay.

Use link when you want to create an Entity for use with the Data API.

    Lean.current.link({
        customer_id: "YOUR_CUSTOMER_ID",
        permissions: ["identity","accounts","balance","transactions"],
        bank_identifier: "LEAN_MB1", //optional
        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
    })
ParameterRequiredDescription
customer_idTrueThe Customer you want to connect
bank_identifierFalseSkips the bank selection screen
permissionsTrueAn array of permissions can be identity, balance, accounts, transactions
success_redirect_urlFalseThe URI you want to redirect to after an open banking connection has been completed
fail_redirect_urlFalseThe URI you want to redirect to after an open banking connection has failed

connect

Use connect when you want to create an Entity and a Payment Source for use with the Data and Payments APIs.

    Lean.current.connect({
        customer_id: "YOUR_CUSTOMER_ID",
        permissions: ["identity","accounts","balance","transactions", "payments"],
        bank_identifier: "LEAN_MB1",
        payment_destination_id: "PAYMENT_DEST_ID",
        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
    })
ParameterRequiredDescription
customer_idTrueThe Customer you want to connect
bank_identifierFalseSkips the bank selection screen
permissionsTrueAn array of permissions can be identity, balance, accounts, transactions or payments
payment_destination_idFalseThe payment destination you want to create a beneficiary with
success_redirect_urlFalseThe URI you want to redirect to after an open banking connection has been completed
fail_redirect_urlFalseThe URI you want to redirect to after an open banking connection has failed

reconnect

Use reconnect when a call to an Entity returns RECONNECT_REQUIRED.

    Lean.current.reconnect({
        reconnect_id: "RECONNECT_ID"
    })
ParameterRequiredDescription
reconnect_idTrueThe reconnect_id returned from the Lean API
success_redirect_urlFalseThe URI you want to redirect to after an open banking connection has been completed
fail_redirect_urlFalseThe URI you want to redirect to after an open banking connection has failed

createPaymentSource

Use createPaymentSource to create a Payment Source for use 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
    })
ParameterRequiredDescription
customer_idTrueThe Customer you want to create a payment source for
bank_identifierFalseSkips the bank selection screen
success_redirect_urlFalseThe URI you want to redirect to after an open banking connection has been completed
fail_redirect_urlFalseThe URI you want to redirect to after an open banking connection has failed

updatePaymentSource

Use updatePaymentSource to create a new beneficiary within an existing Payment Source.

    Lean.current.updatePaymentSource({ 
        customer_id: "CUSTOMER_ID",
        payment_source_id: "PAYMENT_SOURCE_ID",
        payment_destination_id: "PAYMENT_DESTINATION_ID"
    })
ParameterRequiredDescription
customer_idTrueThe Customer you want to create a payment source for
payment_source_idTrueThe Payment Source you want to update
payment_destination_idTrueThe Payment Destination you want to add

pay

Use pay to initiate a payment against a Payment Intent.

    Lean.current.pay({ 
        payment_intent_id: "PAYMENT_INTENT_ID",
        account_id: "ACCOUNT_ID"
    })
ParameterRequiredDescription
payment_intent_idTrueThe Customer you want to create a payment source for
account_idFalseAllows you to use a specific account for a customer payment source (available at payment_source.account[n].id)

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
    }
}
AttributeTypeDescription
methodENUMThe flow that initiated the call. LINK, RECONNECT, CREATE_PAYMENT_SOURCE and PAY
statusENUMThe status of the SDK at close. SUCCESS - completed successfully. CANCELLED - user cancelled the flow. ERROR - something went wrong
messagestringFurther details on the status
exit_pointStringThe screen the user was on when they closed the SDK
secondary_statusStringUseful when ERROR is the status - correlates to the ERROR reason if known.
bank.bank_identifierStringThe Lean identifier for the bank the user was trying to connect to
bank.is_supportedBoolWhether the bank is supported by Lean

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 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"

Keywords

FAQs

Package last updated on 10 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc