1.0.1 • Published 3 years ago

lean-sdk-react-native v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Link SDK React Native Wrapper

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

Installation

Install lean-sdk-react-native

npm install --save lean-sdk-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}"
                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)
sandboxFalseWhether the LinkSDK is in sandbox or not (defaults to False)

Methods

The LinkSDK supports 4 methods. link, reconnect, createPaymentSource and pay.

link

    Lean.current.link({ 
        customer_id: "YOUR_CUSTOMER_ID",
        bank_identifier: "LEAN_MB1"
    })
ParameterRequiredDescription
customer_idTrueThe Customer you want to connect
bank_identifierFalseSkips the bank selection screen

Reconnect

    Lean.current.reconnect({ 
        reconnect_id: "RECONNECT_ID"
    })
ParameterRequiredDescription
reconnect_idTrueThe reconnect_id returned from the Lean API

createPaymentSource

    Lean.current.createPaymentSource({ 
        customer_id: "CUSTOMER_ID",
        bank_identifier: "LEAN_MB1"
    })
ParameterRequiredDescription
customer_idTrueThe Customer you want to create a payment source for
bank_identifierFalseSkips the bank selection screen

pay

    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.accountn.id)
1.0.1

3 years ago

1.0.0

3 years ago