import React, {useRef, useState} from 'react'; import { Alert, SafeAreaView, ScrollView, StyleSheet, Switch, Text, TextInput, TouchableOpacity, View, } from 'react-native'; import LinkSDK from './components/LinkSDK'; interface LeanMethods { link: (p: object) => void; connect: (p: object) => void; reconnect: (p: object) => void; createPaymentSource: (p: object) => void; updatePaymentSource: (p: object) => void; pay: (p: object) => void; } const App = () => { // Create a ref so we can use the SDK component const Lean = useRef(); const [appToken, updateAppToken] = useState(''); // Link const [link_customerID, updateLinkCustomerID] = useState(''); const [link_bankIdentifier, updateLinkBankIdentifier] = useState(''); // Connect const [connect_customerID, updateConnectCustomerID] = useState(''); const [connect_bankIdentifier, updateConnectBankIdentifier] = useState(''); const [connect_paymentDestinationID, updateConnectPaymentDestinationID] = useState(''); // Reconnect const [reconnectID, updateReconnectID] = useState(''); // Create Beneficiary const [customerID, updateCustomerID] = useState(''); const [paymentSourceID, updatePaymentSourceID] = useState(''); const [paymentDestinationID, updatePaymentDestinationID] = useState(''); // Pay const [isShowBalances, setIsShowBalances] = useState(false); const [accountId, updateAccountId] = useState(''); const [paymentIntentID, updatePaymentIntentID] = useState(''); return ( LeanSDK React Native Demo Lean?.current?.link({ customer_id: link_customerID, permissions: [ 'identity', 'accounts', 'balance', 'transactions', ], bank_identifier: link_bankIdentifier, success_redirect_url: 'https://www.google.com', fail_redirect_url: 'https://www.twitter.com', }) }> Link Lean?.current?.connect({ customer_id: connect_customerID, permissions: [ 'identity', 'accounts', 'balance', 'transactions', 'payments', ], bank_identifier: connect_bankIdentifier, payment_destination_id: connect_paymentDestinationID, }) }> Connect Lean?.current?.reconnect({ reconnect_id: reconnectID, }) }> Reconnect Lean?.current?.updatePaymentSource({ customer_id: customerID, payment_source_id: paymentSourceID, payment_destination_id: paymentDestinationID, }) }> Create Beneficiary Show Balances setIsShowBalances(previousState => !previousState) } id="showBalancesToggle" value={isShowBalances} /> Lean?.current?.pay({ account_id: accountId, show_balances: isShowBalances, payment_intent_id: paymentIntentID, }) }> Pay {/* The actual component that will need to be present for end users */} { console.log('DATA SENT TO CALLBACK:', data); Alert.alert('Callback data', `${JSON.stringify(data)}`); }} showLogs customization={{ // dialog_mode: 'uncontained', theme_color: 'rgb(0,152,172)', button_text_color: 'white', button_border_radius: '15', link_color: 'rgb(0,152,172)', overlay_color: 'rgb(175,182,182)', }} sandbox env="staging" // version="latest" // country="ae | sa" /> ); }; const styles = StyleSheet.create({ wrapper: { flex: 1, }, container: { flex: 1, padding: 20, }, group: { padding: 20, backgroundColor: '#F4F5F5', marginBottom: 14, }, cta_container: { backgroundColor: '#0080FF', padding: 8, paddingLeft: 16, paddingRight: 16, borderRadius: 6, }, cta_text: { color: '#ffffff', fontSize: 18, textAlign: 'center', }, text: { fontSize: 20, marginBottom: 24, }, text_input: { fontSize: 16, marginBottom: 16, borderStyle: 'solid', borderBottomColor: 'gray', borderBottomWidth: 1, }, switchContainer: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8, }, switch: { transform: [{scaleX: 0.7}, {scaleY: 0.7}], }, }); export default App;