be-components 0.4.9 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/ApiOverrides/index.js +12 -3
- package/lib/commonjs/ApiOverrides/index.js.map +1 -1
- package/lib/commonjs/Checkout/api/index.js +254 -0
- package/lib/commonjs/Checkout/api/index.js.map +1 -0
- package/lib/commonjs/Checkout/components/AccountSummaryCard.js +274 -0
- package/lib/commonjs/Checkout/components/AccountSummaryCard.js.map +1 -0
- package/lib/commonjs/Checkout/components/ItemSummaryCard.js +56 -0
- package/lib/commonjs/Checkout/components/ItemSummaryCard.js.map +1 -0
- package/lib/commonjs/Checkout/components/OrderSummaryCard.js +84 -0
- package/lib/commonjs/Checkout/components/OrderSummaryCard.js.map +1 -0
- package/lib/commonjs/Checkout/index.js +590 -0
- package/lib/commonjs/Checkout/index.js.map +1 -0
- package/lib/commonjs/Components/Button.js +11 -3
- package/lib/commonjs/Components/Button.js.map +1 -1
- package/lib/commonjs/Components/Checkbox.js +6 -2
- package/lib/commonjs/Components/Checkbox.js.map +1 -1
- package/lib/commonjs/Components/Icons.js +441 -4
- package/lib/commonjs/Components/Icons.js.map +1 -1
- package/lib/commonjs/Components/Spring.js +6 -5
- package/lib/commonjs/Components/Spring.js.map +1 -1
- package/lib/commonjs/LocationTracker/LocationStatus.js +95 -0
- package/lib/commonjs/LocationTracker/LocationStatus.js.map +1 -0
- package/lib/commonjs/LocationTracker/api/index.js +124 -0
- package/lib/commonjs/LocationTracker/api/index.js.map +1 -0
- package/lib/commonjs/LocationTracker/index.js +207 -0
- package/lib/commonjs/LocationTracker/index.js.map +1 -0
- package/lib/commonjs/Observer/Observer.js +2 -0
- package/lib/commonjs/Observer/Observer.js.map +1 -1
- package/lib/commonjs/Wallet/api/index.js +621 -0
- package/lib/commonjs/Wallet/api/index.js.map +1 -0
- package/lib/commonjs/Wallet/components/ACHAdd.js +63 -0
- package/lib/commonjs/Wallet/components/ACHAdd.js.map +1 -0
- package/lib/commonjs/Wallet/components/AccountCard.js +137 -0
- package/lib/commonjs/Wallet/components/AccountCard.js.map +1 -0
- package/lib/commonjs/Wallet/components/AccountLimitManager.js +321 -0
- package/lib/commonjs/Wallet/components/AccountLimitManager.js.map +1 -0
- package/lib/commonjs/Wallet/components/AccountManager.js +202 -0
- package/lib/commonjs/Wallet/components/AccountManager.js.map +1 -0
- package/lib/commonjs/Wallet/components/AccountSnoozeManager.js +263 -0
- package/lib/commonjs/Wallet/components/AccountSnoozeManager.js.map +1 -0
- package/lib/commonjs/Wallet/components/AddressCard.js +56 -0
- package/lib/commonjs/Wallet/components/AddressCard.js.map +1 -0
- package/lib/commonjs/Wallet/components/AddressManager.js +365 -0
- package/lib/commonjs/Wallet/components/AddressManager.js.map +1 -0
- package/lib/commonjs/Wallet/components/DepositCard.js +195 -0
- package/lib/commonjs/Wallet/components/DepositCard.js.map +1 -0
- package/lib/commonjs/Wallet/components/LinkAccountManager.js +167 -0
- package/lib/commonjs/Wallet/components/LinkAccountManager.js.map +1 -0
- package/lib/commonjs/Wallet/components/ManageAccountCard.js +216 -0
- package/lib/commonjs/Wallet/components/ManageAccountCard.js.map +1 -0
- package/lib/commonjs/Wallet/components/ManualACHAdd.js +270 -0
- package/lib/commonjs/Wallet/components/ManualACHAdd.js.map +1 -0
- package/lib/commonjs/Wallet/components/ManualCardAdd.js +337 -0
- package/lib/commonjs/Wallet/components/ManualCardAdd.js.map +1 -0
- package/lib/commonjs/Wallet/components/MyBalance.js +73 -0
- package/lib/commonjs/Wallet/components/MyBalance.js.map +1 -0
- package/lib/commonjs/Wallet/components/PayPalOrderCapture.js +68 -0
- package/lib/commonjs/Wallet/components/PayPalOrderCapture.js.map +1 -0
- package/lib/commonjs/Wallet/components/RemoveAccount.js +108 -0
- package/lib/commonjs/Wallet/components/RemoveAccount.js.map +1 -0
- package/lib/commonjs/Wallet/components/VerifyACHAccount.js +196 -0
- package/lib/commonjs/Wallet/components/VerifyACHAccount.js.map +1 -0
- package/lib/commonjs/Wallet/components/WalletSetup.js +316 -0
- package/lib/commonjs/Wallet/components/WalletSetup.js.map +1 -0
- package/lib/commonjs/Wallet/components/WithdrawCard.js +336 -0
- package/lib/commonjs/Wallet/components/WithdrawCard.js.map +1 -0
- package/lib/commonjs/Wallet/index.js +221 -0
- package/lib/commonjs/Wallet/index.js.map +1 -0
- package/lib/commonjs/constants/colors.js +3 -0
- package/lib/commonjs/constants/colors.js.map +1 -1
- package/lib/commonjs/index.js +21 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/ApiOverrides/index.js +12 -3
- package/lib/module/ApiOverrides/index.js.map +1 -1
- package/lib/module/Checkout/api/index.js +248 -0
- package/lib/module/Checkout/api/index.js.map +1 -0
- package/lib/module/Checkout/components/AccountSummaryCard.js +267 -0
- package/lib/module/Checkout/components/AccountSummaryCard.js.map +1 -0
- package/lib/module/Checkout/components/ItemSummaryCard.js +49 -0
- package/lib/module/Checkout/components/ItemSummaryCard.js.map +1 -0
- package/lib/module/Checkout/components/OrderSummaryCard.js +77 -0
- package/lib/module/Checkout/components/OrderSummaryCard.js.map +1 -0
- package/lib/module/Checkout/index.js +581 -0
- package/lib/module/Checkout/index.js.map +1 -0
- package/lib/module/Components/Button.js +11 -3
- package/lib/module/Components/Button.js.map +1 -1
- package/lib/module/Components/Checkbox.js +6 -2
- package/lib/module/Components/Checkbox.js.map +1 -1
- package/lib/module/Components/Icons.js +441 -4
- package/lib/module/Components/Icons.js.map +1 -1
- package/lib/module/Components/Spring.js +6 -5
- package/lib/module/Components/Spring.js.map +1 -1
- package/lib/module/LocationTracker/LocationStatus.js +88 -0
- package/lib/module/LocationTracker/LocationStatus.js.map +1 -0
- package/lib/module/LocationTracker/api/index.js +118 -0
- package/lib/module/LocationTracker/api/index.js.map +1 -0
- package/lib/module/LocationTracker/index.js +200 -0
- package/lib/module/LocationTracker/index.js.map +1 -0
- package/lib/module/Observer/Observer.js +2 -0
- package/lib/module/Observer/Observer.js.map +1 -1
- package/lib/module/Wallet/api/index.js +615 -0
- package/lib/module/Wallet/api/index.js.map +1 -0
- package/lib/module/Wallet/components/ACHAdd.js +56 -0
- package/lib/module/Wallet/components/ACHAdd.js.map +1 -0
- package/lib/module/Wallet/components/AccountCard.js +130 -0
- package/lib/module/Wallet/components/AccountCard.js.map +1 -0
- package/lib/module/Wallet/components/AccountLimitManager.js +312 -0
- package/lib/module/Wallet/components/AccountLimitManager.js.map +1 -0
- package/lib/module/Wallet/components/AccountManager.js +195 -0
- package/lib/module/Wallet/components/AccountManager.js.map +1 -0
- package/lib/module/Wallet/components/AccountSnoozeManager.js +254 -0
- package/lib/module/Wallet/components/AccountSnoozeManager.js.map +1 -0
- package/lib/module/Wallet/components/AddressCard.js +49 -0
- package/lib/module/Wallet/components/AddressCard.js.map +1 -0
- package/lib/module/Wallet/components/AddressManager.js +356 -0
- package/lib/module/Wallet/components/AddressManager.js.map +1 -0
- package/lib/module/Wallet/components/DepositCard.js +186 -0
- package/lib/module/Wallet/components/DepositCard.js.map +1 -0
- package/lib/module/Wallet/components/LinkAccountManager.js +158 -0
- package/lib/module/Wallet/components/LinkAccountManager.js.map +1 -0
- package/lib/module/Wallet/components/ManageAccountCard.js +207 -0
- package/lib/module/Wallet/components/ManageAccountCard.js.map +1 -0
- package/lib/module/Wallet/components/ManualACHAdd.js +261 -0
- package/lib/module/Wallet/components/ManualACHAdd.js.map +1 -0
- package/lib/module/Wallet/components/ManualCardAdd.js +328 -0
- package/lib/module/Wallet/components/ManualCardAdd.js.map +1 -0
- package/lib/module/Wallet/components/MyBalance.js +66 -0
- package/lib/module/Wallet/components/MyBalance.js.map +1 -0
- package/lib/module/Wallet/components/PayPalOrderCapture.js +61 -0
- package/lib/module/Wallet/components/PayPalOrderCapture.js.map +1 -0
- package/lib/module/Wallet/components/RemoveAccount.js +100 -0
- package/lib/module/Wallet/components/RemoveAccount.js.map +1 -0
- package/lib/module/Wallet/components/VerifyACHAccount.js +187 -0
- package/lib/module/Wallet/components/VerifyACHAccount.js.map +1 -0
- package/lib/module/Wallet/components/WalletSetup.js +307 -0
- package/lib/module/Wallet/components/WalletSetup.js.map +1 -0
- package/lib/module/Wallet/components/WithdrawCard.js +327 -0
- package/lib/module/Wallet/components/WithdrawCard.js.map +1 -0
- package/lib/module/Wallet/index.js +212 -0
- package/lib/module/Wallet/index.js.map +1 -0
- package/lib/module/constants/colors.js +3 -0
- package/lib/module/constants/colors.js.map +1 -1
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/ApiOverrides/index.d.ts.map +1 -1
- package/lib/typescript/src/Checkout/api/index.d.ts +49 -0
- package/lib/typescript/src/Checkout/api/index.d.ts.map +1 -0
- package/lib/typescript/src/Checkout/components/AccountSummaryCard.d.ts +18 -0
- package/lib/typescript/src/Checkout/components/AccountSummaryCard.d.ts.map +1 -0
- package/lib/typescript/src/Checkout/components/ItemSummaryCard.d.ts +8 -0
- package/lib/typescript/src/Checkout/components/ItemSummaryCard.d.ts.map +1 -0
- package/lib/typescript/src/Checkout/components/OrderSummaryCard.d.ts +8 -0
- package/lib/typescript/src/Checkout/components/OrderSummaryCard.d.ts.map +1 -0
- package/lib/typescript/src/Checkout/index.d.ts +12 -0
- package/lib/typescript/src/Checkout/index.d.ts.map +1 -0
- package/lib/typescript/src/Components/Button.d.ts.map +1 -1
- package/lib/typescript/src/Components/Checkbox.d.ts +3 -1
- package/lib/typescript/src/Components/Checkbox.d.ts.map +1 -1
- package/lib/typescript/src/Components/Icons.d.ts +8 -1
- package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/src/Components/Spring.d.ts.map +1 -1
- package/lib/typescript/src/LocationTracker/LocationStatus.d.ts +21 -0
- package/lib/typescript/src/LocationTracker/LocationStatus.d.ts.map +1 -0
- package/lib/typescript/src/LocationTracker/api/index.d.ts +19 -0
- package/lib/typescript/src/LocationTracker/api/index.d.ts.map +1 -0
- package/lib/typescript/src/LocationTracker/index.d.ts +22 -0
- package/lib/typescript/src/LocationTracker/index.d.ts.map +1 -0
- package/lib/typescript/src/Observer/Observer.d.ts.map +1 -1
- package/lib/typescript/src/Wallet/api/index.d.ts +94 -0
- package/lib/typescript/src/Wallet/api/index.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/ACHAdd.d.ts +13 -0
- package/lib/typescript/src/Wallet/components/ACHAdd.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/AccountCard.d.ts +10 -0
- package/lib/typescript/src/Wallet/components/AccountCard.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/AccountLimitManager.d.ts +10 -0
- package/lib/typescript/src/Wallet/components/AccountLimitManager.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/AccountManager.d.ts +13 -0
- package/lib/typescript/src/Wallet/components/AccountManager.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/AccountSnoozeManager.d.ts +10 -0
- package/lib/typescript/src/Wallet/components/AccountSnoozeManager.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/AddressCard.d.ts +10 -0
- package/lib/typescript/src/Wallet/components/AddressCard.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/AddressManager.d.ts +23 -0
- package/lib/typescript/src/Wallet/components/AddressManager.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/DepositCard.d.ts +14 -0
- package/lib/typescript/src/Wallet/components/DepositCard.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/LinkAccountManager.d.ts +10 -0
- package/lib/typescript/src/Wallet/components/LinkAccountManager.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/ManageAccountCard.d.ts +17 -0
- package/lib/typescript/src/Wallet/components/ManageAccountCard.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/ManualACHAdd.d.ts +11 -0
- package/lib/typescript/src/Wallet/components/ManualACHAdd.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/ManualCardAdd.d.ts +11 -0
- package/lib/typescript/src/Wallet/components/ManualCardAdd.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/MyBalance.d.ts +14 -0
- package/lib/typescript/src/Wallet/components/MyBalance.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/PayPalOrderCapture.d.ts +16 -0
- package/lib/typescript/src/Wallet/components/PayPalOrderCapture.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/RemoveAccount.d.ts +10 -0
- package/lib/typescript/src/Wallet/components/RemoveAccount.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/VerifyACHAccount.d.ts +10 -0
- package/lib/typescript/src/Wallet/components/VerifyACHAccount.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/WalletSetup.d.ts +11 -0
- package/lib/typescript/src/Wallet/components/WalletSetup.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/components/WithdrawCard.d.ts +16 -0
- package/lib/typescript/src/Wallet/components/WithdrawCard.d.ts.map +1 -0
- package/lib/typescript/src/Wallet/index.d.ts +10 -0
- package/lib/typescript/src/Wallet/index.d.ts.map +1 -0
- package/lib/typescript/src/constants/colors.d.ts +3 -0
- package/lib/typescript/src/constants/colors.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +4 -1
- package/src/ApiOverrides/index.ts +13 -3
- package/src/Checkout/api/index.tsx +199 -0
- package/src/Checkout/components/AccountSummaryCard.tsx +169 -0
- package/src/Checkout/components/ItemSummaryCard.tsx +34 -0
- package/src/Checkout/components/OrderSummaryCard.tsx +40 -0
- package/src/Checkout/index.tsx +398 -0
- package/src/Components/Button.tsx +5 -4
- package/src/Components/Checkbox.tsx +5 -2
- package/src/Components/Icons.tsx +196 -3
- package/src/Components/Spring.tsx +4 -3
- package/src/LocationTracker/LocationStatus.tsx +96 -0
- package/src/LocationTracker/api/index.tsx +114 -0
- package/src/LocationTracker/index.tsx +130 -0
- package/src/Observer/Observer.tsx +2 -1
- package/src/Wallet/api/index.ts +461 -0
- package/src/Wallet/components/ACHAdd.tsx +49 -0
- package/src/Wallet/components/AccountCard.tsx +92 -0
- package/src/Wallet/components/AccountLimitManager.tsx +212 -0
- package/src/Wallet/components/AccountManager.tsx +103 -0
- package/src/Wallet/components/AccountSnoozeManager.tsx +153 -0
- package/src/Wallet/components/AddressCard.tsx +31 -0
- package/src/Wallet/components/AddressManager.tsx +203 -0
- package/src/Wallet/components/DepositCard.tsx +107 -0
- package/src/Wallet/components/LinkAccountManager.tsx +119 -0
- package/src/Wallet/components/ManageAccountCard.tsx +146 -0
- package/src/Wallet/components/ManualACHAdd.tsx +164 -0
- package/src/Wallet/components/ManualCardAdd.tsx +185 -0
- package/src/Wallet/components/MyBalance.tsx +64 -0
- package/src/Wallet/components/PayPalOrderCapture.tsx +59 -0
- package/src/Wallet/components/RemoveAccount.tsx +68 -0
- package/src/Wallet/components/VerifyACHAccount.tsx +140 -0
- package/src/Wallet/components/WalletSetup.tsx +197 -0
- package/src/Wallet/components/WithdrawCard.tsx +145 -0
- package/src/Wallet/index.tsx +229 -0
- package/src/constants/colors.ts +3 -0
- package/src/index.tsx +7 -2
- package/src/types.d.ts +296 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import type { ItemOrderProps } from "../../types";
|
|
4
|
+
import Colors from '../../constants/colors';
|
|
5
|
+
import { Text } from '../../Components';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
type OrderSummaryCardProps = {
|
|
9
|
+
item_order:ItemOrderProps
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const OrderSummaryCard = ({ item_order }:OrderSummaryCardProps) => {
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<View>
|
|
16
|
+
<View style={{ flexDirection:'row', padding:5, paddingRight:10, paddingLeft:10 }}>
|
|
17
|
+
<Text style={{ flex:1 }} size={14} color={Colors.brand.midnight}>Subtotal</Text>
|
|
18
|
+
<Text size={14} color={Colors.brand.midnight}>${item_order.amount}</Text>
|
|
19
|
+
</View>
|
|
20
|
+
{item_order.fee_1 ?
|
|
21
|
+
<View style={{ flexDirection:'row', padding:5, paddingRight:10, paddingLeft:10 }}>
|
|
22
|
+
<Text style={{ flex:1 }} size={14} color={Colors.brand.midnight}>{item_order.fee_1}</Text>
|
|
23
|
+
<Text size={14} color={Colors.brand.midnight}>${item_order.fee_1_amount}</Text>
|
|
24
|
+
</View>
|
|
25
|
+
:<></>}
|
|
26
|
+
{item_order.fee_2 ?
|
|
27
|
+
<View style={{ flexDirection:'row', padding:5, paddingRight:10, paddingLeft:10 }}>
|
|
28
|
+
<Text style={{ flex:1 }} size={14} color={Colors.brand.midnight}>{item_order.fee_2}</Text>
|
|
29
|
+
<Text size={14} color={Colors.brand.midnight}>${item_order.fee_2_amount}</Text>
|
|
30
|
+
</View>
|
|
31
|
+
:<></>}
|
|
32
|
+
<View style={{ flexDirection:'row', padding:5, paddingRight:10, paddingLeft:10 }}>
|
|
33
|
+
<Text style={{ flex:1 }} size={14} color={Colors.brand.midnight} weight='bold'>Total</Text>
|
|
34
|
+
<Text size={14} color={Colors.brand.midnight} weight='bold'>${item_order.total_amount}</Text>
|
|
35
|
+
</View>
|
|
36
|
+
</View>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default OrderSummaryCard
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { View, StyleSheet, Linking } from "react-native";
|
|
3
|
+
import type { AccountProps, ItemOrderProps, ItemProps, PlayerAddressProps, TransactionProps } from '../types';
|
|
4
|
+
import { Button, Icons, Text } from '../Components';
|
|
5
|
+
import { CheckoutApi, CheckoutHelpers } from './api';
|
|
6
|
+
import ItemSummaryCard from './components/ItemSummaryCard';
|
|
7
|
+
import OrderSummaryCard from './components/OrderSummaryCard';
|
|
8
|
+
import AccountSummaryCard from './components/AccountSummaryCard';
|
|
9
|
+
import Colors from '../constants/colors';
|
|
10
|
+
import AddressManager from '../Wallet/components/AddressManager';
|
|
11
|
+
import type { MyPlayerProps } from '../ProfileManager/api/types';
|
|
12
|
+
import { PayPalScriptProvider } from '@paypal/react-paypal-js';
|
|
13
|
+
import PayPalOrderCapture from '../Wallet/components/PayPalOrderCapture';
|
|
14
|
+
import SpringView from '../Components/Spring';
|
|
15
|
+
import { usePlayerLocation } from '../LocationTracker/LocationStatus';
|
|
16
|
+
import LocationTracker from '../LocationTracker';
|
|
17
|
+
import { view_styles } from '../constants/styles';
|
|
18
|
+
import { WalletApi } from '../Wallet/api';
|
|
19
|
+
|
|
20
|
+
type CheckoutProps = {
|
|
21
|
+
item_order:ItemOrderProps,
|
|
22
|
+
account_id?:string,
|
|
23
|
+
onRequestNewAccount:() => void,
|
|
24
|
+
onCompleteOrder:(item_order:ItemOrderProps, transaction:TransactionProps) => void,
|
|
25
|
+
onCancel:() => void
|
|
26
|
+
}
|
|
27
|
+
const Checkout = ({ item_order, account_id, onCancel, onCompleteOrder, onRequestNewAccount }:CheckoutProps) => {
|
|
28
|
+
const [ loading, setLoading ] = useState(false);
|
|
29
|
+
const [ completing, setCompleting ] = useState(false);
|
|
30
|
+
const [ show_addresses, setShowAddresses ] = useState(false);
|
|
31
|
+
const [ cvv, setCVV ] = useState<string>();
|
|
32
|
+
const [ show_location, setShowLocation ] = useState(false);
|
|
33
|
+
const { permission, location, getLocation, checkPermissions } = usePlayerLocation();
|
|
34
|
+
const [ checkout_data, setCheckoutData ] = useState<{
|
|
35
|
+
loaded:boolean,
|
|
36
|
+
player?:MyPlayerProps,
|
|
37
|
+
accounts:AccountProps[],
|
|
38
|
+
player_addresses:PlayerAddressProps[],
|
|
39
|
+
selected_account?:AccountProps
|
|
40
|
+
billing_address?:PlayerAddressProps,
|
|
41
|
+
items:ItemProps[]
|
|
42
|
+
}>({
|
|
43
|
+
loaded:false,
|
|
44
|
+
items:[],
|
|
45
|
+
player_addresses: [],
|
|
46
|
+
accounts:[]
|
|
47
|
+
})
|
|
48
|
+
const [ checkout, setCheckout ] = useState<{
|
|
49
|
+
ip_item_order?:ItemOrderProps,
|
|
50
|
+
ip_transaction?:TransactionProps
|
|
51
|
+
}>({});
|
|
52
|
+
const [ draft_order, setDraftOrder ] = useState<ItemOrderProps>();
|
|
53
|
+
const { player, accounts, items, player_addresses , selected_account, billing_address} = checkout_data;
|
|
54
|
+
const { ip_item_order, ip_transaction } = checkout;
|
|
55
|
+
|
|
56
|
+
//const shipping_address_required = CheckoutHelpers.isShippingRequired(items);
|
|
57
|
+
const billing_address_required = CheckoutHelpers.isBillingAddressRequired(items, selected_account);
|
|
58
|
+
|
|
59
|
+
//const isLocationRequired = CheckoutHelpers.isLocationRequired(items);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
CheckoutApi.setEnvironment();
|
|
63
|
+
WalletApi.setEnvironment();
|
|
64
|
+
if(!item_order){ return setDraftOrder(undefined) }
|
|
65
|
+
getDetailsFromServer(item_order, account_id);
|
|
66
|
+
},[item_order])
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if(!permission.checked){ return }
|
|
70
|
+
if(permission.permission != 'granted'){ return setShowLocation(true) }
|
|
71
|
+
},[permission])
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get all necessary checkout data from the server
|
|
75
|
+
* @param item_order
|
|
76
|
+
* @param account_id
|
|
77
|
+
*/
|
|
78
|
+
const getDetailsFromServer = async(item_order:ItemOrderProps, account_id?:string) => {
|
|
79
|
+
checkPermissions({ auto_on_granted:true });
|
|
80
|
+
const player = await CheckoutApi.getMyDetails();
|
|
81
|
+
const order_items = await CheckoutApi.getItemsByIds(item_order.items.map(i => i.item_id));
|
|
82
|
+
const accounts = await CheckoutApi.getMyAccounts();
|
|
83
|
+
let eligible_accounts = CheckoutHelpers.filterMyPurchaseAccounts(accounts, order_items)
|
|
84
|
+
const addresses = await CheckoutApi.getMyAddresses();
|
|
85
|
+
let a = eligible_accounts.find(a => a.account_id == account_id)
|
|
86
|
+
if(!a){
|
|
87
|
+
a = eligible_accounts.find(a => a.default_account);
|
|
88
|
+
}
|
|
89
|
+
let ba:PlayerAddressProps | undefined = addresses.find(addy => addy.player_address_id == a?.default_billing_address_id);
|
|
90
|
+
|
|
91
|
+
if(a){ item_order = CheckoutHelpers.genItemOrder(item_order, order_items, a) }
|
|
92
|
+
|
|
93
|
+
setDraftOrder(item_order);
|
|
94
|
+
|
|
95
|
+
setCheckoutData({
|
|
96
|
+
loaded:true,
|
|
97
|
+
player,
|
|
98
|
+
selected_account:a,
|
|
99
|
+
player_addresses: addresses,
|
|
100
|
+
billing_address: ba,
|
|
101
|
+
items: order_items,
|
|
102
|
+
accounts: accounts
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const order_errors = !draft_order ? [] : CheckoutHelpers.isOrderValid(draft_order, items, selected_account, cvv, billing_address, undefined, location.location, location.coordinates);
|
|
107
|
+
const handleConfirm = async() => {
|
|
108
|
+
if(!draft_order || order_errors.length > 0){ return }
|
|
109
|
+
setLoading(true);
|
|
110
|
+
const draft_transaction = CheckoutHelpers.genTransactionFromItemOrder(draft_order, items, selected_account?.account_id, cvv);
|
|
111
|
+
const resp = await CheckoutApi.createOrder({ ...draft_order, region:location.region, location: location.coordinates }, { ...draft_transaction, billing_address_id: billing_address?.player_address_id });
|
|
112
|
+
setCheckout({
|
|
113
|
+
ip_item_order: resp.item_order,
|
|
114
|
+
ip_transaction: resp.transaction
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const handleCancel = async() => {
|
|
119
|
+
if(!ip_transaction){ return onCancel() }
|
|
120
|
+
await CheckoutApi.cancelTransaction(ip_transaction.transaction_id);
|
|
121
|
+
setCheckout({});
|
|
122
|
+
onCancel();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const checkTransactionStatus = async() => {
|
|
126
|
+
if(!ip_transaction){ return }
|
|
127
|
+
const resp = await CheckoutApi.getTransactionById(ip_transaction.transaction_id);
|
|
128
|
+
setCheckout({ ...checkout, ip_transaction:resp.transaction })
|
|
129
|
+
if(resp.transaction.status == 'redirect'){
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
console.log('checking tran status')
|
|
132
|
+
checkTransactionStatus()
|
|
133
|
+
}, 2000);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const handleChangeAccount = async(account:AccountProps) => {
|
|
139
|
+
let new_address = player_addresses.find(pa => pa.player_address_id == account.default_billing_address_id);
|
|
140
|
+
setCheckoutData({
|
|
141
|
+
...checkout_data,
|
|
142
|
+
selected_account: account,
|
|
143
|
+
billing_address: new_address ? new_address : billing_address
|
|
144
|
+
|
|
145
|
+
})
|
|
146
|
+
if(draft_order){
|
|
147
|
+
let new_draft_order = CheckoutHelpers.genItemOrder(draft_order, items, account)
|
|
148
|
+
setDraftOrder(new_draft_order)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const handleChangeBillingAddress = async(address:PlayerAddressProps) => {
|
|
153
|
+
if(selected_account){
|
|
154
|
+
await CheckoutApi.updateAccountDefaultAddress(selected_account.account_id, address.player_address_id)
|
|
155
|
+
}
|
|
156
|
+
setCheckoutData({ ...checkout_data, billing_address: address, player_addresses: player_addresses.filter(pa => pa.player_address_id != address.player_address_id).concat(address) })
|
|
157
|
+
setShowAddresses(false)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const handleRedirect = async() => {
|
|
161
|
+
if(!ip_transaction?.redirect_url){ return }
|
|
162
|
+
if(completing){ return }
|
|
163
|
+
setCompleting(true);
|
|
164
|
+
Linking.openURL(ip_transaction.redirect_url)
|
|
165
|
+
setTimeout(() => {
|
|
166
|
+
console.log('checking tran status!')
|
|
167
|
+
checkTransactionStatus()
|
|
168
|
+
}, 5000);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if(!draft_order || !player){ return <></> }
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
|
|
175
|
+
<View style={{ flex:1 }}>
|
|
176
|
+
<View style={{ flex:1 }}>
|
|
177
|
+
<View nativeID='items' style={{ ...local_styles.section, borderBottomWidth:1, borderBottomColor:Colors.shades.shade600}}>
|
|
178
|
+
<ItemSummaryCard
|
|
179
|
+
items={items}
|
|
180
|
+
/>
|
|
181
|
+
</View>
|
|
182
|
+
<View nativeID='order_summary' style={{ ...local_styles.section, borderBottomWidth:1, borderBottomColor:Colors.shades.shade600}}>
|
|
183
|
+
<OrderSummaryCard
|
|
184
|
+
item_order={draft_order}
|
|
185
|
+
/>
|
|
186
|
+
</View>
|
|
187
|
+
<View nativeID='account_summary' style={{ ...local_styles.section, borderBottomWidth:1, borderBottomColor:Colors.shades.shade600}}>
|
|
188
|
+
<AccountSummaryCard
|
|
189
|
+
accounts={accounts}
|
|
190
|
+
items={items}
|
|
191
|
+
selected_account={selected_account}
|
|
192
|
+
player_address={billing_address}
|
|
193
|
+
billing_address_required={billing_address_required}
|
|
194
|
+
cvv={cvv}
|
|
195
|
+
onRequestNewAccount={onRequestNewAccount}
|
|
196
|
+
onCVVChange={(new_cvv) => setCVV(new_cvv)}
|
|
197
|
+
onAccountsUpdate={(accts) => {
|
|
198
|
+
setCheckoutData({
|
|
199
|
+
...checkout_data,
|
|
200
|
+
selected_account: accts.find(a => a.account_id == selected_account?.account_id),
|
|
201
|
+
accounts: accounts.filter(a => !accts.find(na => na.account_id == a.account_id)).concat(accts)
|
|
202
|
+
})
|
|
203
|
+
}}
|
|
204
|
+
onChangeAddress={() => setShowAddresses(true)}
|
|
205
|
+
onSelectAccount={(account) => handleChangeAccount(account)}
|
|
206
|
+
/>
|
|
207
|
+
</View>
|
|
208
|
+
</View>
|
|
209
|
+
{order_errors.length > 0 ?
|
|
210
|
+
<View style={{ margin:10, borderRadius:4, padding:10, backgroundColor:Colors.shades.white, ...view_styles.float }}>
|
|
211
|
+
<Text style={{ marginBottom:5 }} size={14} color={Colors.brand.midnight} weight='semibold'>Please fix the following before continuing</Text>
|
|
212
|
+
{order_errors.map(e => {
|
|
213
|
+
return (
|
|
214
|
+
<Text style={{ padding:4 }} size={12} color={Colors.utility.warning} weight='bold'>{e}</Text>
|
|
215
|
+
)
|
|
216
|
+
})}
|
|
217
|
+
</View>
|
|
218
|
+
:<></>}
|
|
219
|
+
<PayPalScriptProvider
|
|
220
|
+
options={{
|
|
221
|
+
clientId: CheckoutApi.getPayPalClientId(),
|
|
222
|
+
}}>
|
|
223
|
+
<View style={{ padding:20 }}>
|
|
224
|
+
{!ip_transaction ?
|
|
225
|
+
<View nativeID='action_row' style={{ flexDirection:'row', alignItems:'center' }}>
|
|
226
|
+
<Button
|
|
227
|
+
style={{ flex:1, marginRight:5, opacity:loading?0.5:1 }}
|
|
228
|
+
title='CANCEL'
|
|
229
|
+
disabled={loading}
|
|
230
|
+
title_color={Colors.utility.error}
|
|
231
|
+
borderWidth={1}
|
|
232
|
+
borderColor={Colors.utility.error}
|
|
233
|
+
padding={15}
|
|
234
|
+
onPress={() => handleCancel()}
|
|
235
|
+
/>
|
|
236
|
+
{selected_account?.account_type == 'paypal' ?
|
|
237
|
+
<PayPalOrderCapture
|
|
238
|
+
draft_item_order={draft_order}
|
|
239
|
+
paypal_account={selected_account}
|
|
240
|
+
region={location.region}
|
|
241
|
+
coordinates={location.coordinates}
|
|
242
|
+
button_height={48}
|
|
243
|
+
items={items}
|
|
244
|
+
order_valid={order_errors.length == 0 ? true : false}
|
|
245
|
+
onOrderUpdate={(item_order, transaction) => setCheckout({ ip_item_order: item_order, ip_transaction: transaction })}
|
|
246
|
+
onCancel={() => console.log('DONE!')}
|
|
247
|
+
/>
|
|
248
|
+
:
|
|
249
|
+
<Button
|
|
250
|
+
style={{ flex:3, opacity:loading || order_errors.length > 0 ? 0.5 : 1 }}
|
|
251
|
+
loading={loading || location.loading}
|
|
252
|
+
disabled={loading || order_errors.length > 0}
|
|
253
|
+
title={location.loading ?'VERIFYING LOCATION':'CONFIRM & CONTINUE'}
|
|
254
|
+
title_color={Colors.shades.white}
|
|
255
|
+
backgroundColor={Colors.brand.electric}
|
|
256
|
+
padding={15}
|
|
257
|
+
onPress={() => handleConfirm()}
|
|
258
|
+
/>
|
|
259
|
+
}
|
|
260
|
+
</View>
|
|
261
|
+
: <></>}
|
|
262
|
+
</View>
|
|
263
|
+
</PayPalScriptProvider>
|
|
264
|
+
|
|
265
|
+
{show_addresses ?
|
|
266
|
+
<View style={{ position:'absolute', top:0, bottom:0, left:0, right:0, backgroundColor:Colors.shades.black_faded, justifyContent:'flex-end' }}>
|
|
267
|
+
<SpringView
|
|
268
|
+
to={0}
|
|
269
|
+
from={500}
|
|
270
|
+
slide='vertical'
|
|
271
|
+
style={{ backgroundColor:Colors.shades.white, borderTopRightRadius:40, borderTopLeftRadius:40 }}
|
|
272
|
+
>
|
|
273
|
+
<AddressManager
|
|
274
|
+
player={player}
|
|
275
|
+
player_addresses={player_addresses}
|
|
276
|
+
location={location}
|
|
277
|
+
onCancel={() => setShowAddresses(false)}
|
|
278
|
+
onRemoveAddress={(addy) => {
|
|
279
|
+
let selected_addy = billing_address && billing_address.player_address_id == addy.player_address_id ? undefined : billing_address
|
|
280
|
+
setCheckoutData({ ...checkout_data, billing_address: selected_addy, player_addresses: player_addresses.filter(pa => pa.player_address_id != addy.player_address_id) })
|
|
281
|
+
}}
|
|
282
|
+
onAddAddress={(addy) => handleChangeBillingAddress(addy)}
|
|
283
|
+
onSelect={(addy) => handleChangeBillingAddress(addy)}
|
|
284
|
+
/>
|
|
285
|
+
</SpringView>
|
|
286
|
+
</View>
|
|
287
|
+
:<></>}
|
|
288
|
+
|
|
289
|
+
{ip_item_order && ip_transaction ?
|
|
290
|
+
<View style={{ position:'absolute', top:0, left:0, right:0, bottom:0, backgroundColor:Colors.shades.black_faded, justifyContent:'flex-end' }}>
|
|
291
|
+
<SpringView
|
|
292
|
+
slide='vertical'
|
|
293
|
+
from={500}
|
|
294
|
+
to={0}
|
|
295
|
+
style={{ borderTopRightRadius:40, borderTopLeftRadius:40, backgroundColor:Colors.shades.white }}>
|
|
296
|
+
{ip_transaction.status == 'posted' ?
|
|
297
|
+
<View style={{ flex:1, padding:10, paddingTop:30, paddingBottom:30, justifyContent:'center', alignItems:'center' }}>
|
|
298
|
+
<Icons.TransactionSuccessIcon size={150} />
|
|
299
|
+
<View style={{ padding:20, borderRadius:8, borderWidth:1, borderColor:Colors.utility.success, marginTop:20 }}>
|
|
300
|
+
<Text size={20} color={Colors.utility.success} weight='bold' textAlign='center'>Order Successful</Text>
|
|
301
|
+
<Text style={{ marginTop:10 }} size={16} color={Colors.brand.cobalt} weight='regular' textAlign='center'>Your order was successfully processed. An email confirmation has been sent. Please select close below to continue.</Text>
|
|
302
|
+
</View>
|
|
303
|
+
</View>
|
|
304
|
+
: ip_transaction.status == 'failed' ?
|
|
305
|
+
<View style={{ flex:1, padding:10, paddingTop:30, paddingBottom:30, justifyContent:'center', alignItems:'center' }}>
|
|
306
|
+
<Icons.TransactionErrorIcon size={150} />
|
|
307
|
+
<View style={{ padding:20, borderRadius:8, borderWidth:1, borderColor:Colors.utility.error, marginTop:20 }}>
|
|
308
|
+
<Text size={20} color={Colors.utility.error} weight='bold' textAlign='center'>Order Failed</Text>
|
|
309
|
+
<Text style={{ marginTop:10 }} size={16} color={Colors.brand.cobalt} weight='regular' textAlign='center'>Sorry, we were unable to process your order at this time. Please try again or reach out to support for help.</Text>
|
|
310
|
+
</View>
|
|
311
|
+
</View>
|
|
312
|
+
:ip_transaction.status == 'cancelled' ?
|
|
313
|
+
<View style={{ flex:1, padding:10, paddingTop:30, paddingBottom:30, justifyContent:'center', alignItems:'center' }}>
|
|
314
|
+
<Icons.TransactionErrorIcon size={150} />
|
|
315
|
+
<View style={{ padding:20, borderRadius:8, borderWidth:1, borderColor:Colors.utility.error, marginTop:20 }}>
|
|
316
|
+
<Text size={20} color={Colors.utility.error} weight='bold' textAlign='center'>Order Cancelled</Text>
|
|
317
|
+
<Text style={{ marginTop:10 }} size={16} color={Colors.brand.cobalt} weight='regular' textAlign='center'>Your order was cancelled. Please try again.</Text>
|
|
318
|
+
</View>
|
|
319
|
+
</View>
|
|
320
|
+
: ip_transaction.status == 'redirect' ?
|
|
321
|
+
<View style={{ flex:1, padding:10, paddingTop:30, paddingBottom:30, justifyContent:'center', alignItems:'center' }}>
|
|
322
|
+
<Icons.IBTFLowIcon size={300} />
|
|
323
|
+
<View style={{ padding:20, borderRadius:8, borderWidth:1, borderColor:Colors.shades.shade600, marginTop:20 }}>
|
|
324
|
+
<Text size={20} color={Colors.brand.cobalt} weight='bold' textAlign='center'>Finish With Plaid</Text>
|
|
325
|
+
<Text style={{ marginTop:10 }} size={16} color={Colors.brand.cobalt} weight='regular' textAlign='center'>Select Complete Order below to complete the transaction through Plaid</Text>
|
|
326
|
+
</View>
|
|
327
|
+
</View>
|
|
328
|
+
:<></>
|
|
329
|
+
}
|
|
330
|
+
<View nativeID='action_row' style={{ flexDirection:'row', padding:20 }}>
|
|
331
|
+
{ip_transaction.status == 'redirect' || ip_transaction.status == 'pending' ?
|
|
332
|
+
<Button
|
|
333
|
+
style={{ flex:1, marginRight:5, opacity:1 }}
|
|
334
|
+
title='CANCEL'
|
|
335
|
+
//disabled={loading}
|
|
336
|
+
title_color={Colors.utility.error}
|
|
337
|
+
borderWidth={1}
|
|
338
|
+
borderColor={Colors.utility.error}
|
|
339
|
+
padding={15}
|
|
340
|
+
onPress={() => handleCancel()}
|
|
341
|
+
/>
|
|
342
|
+
:
|
|
343
|
+
<Button
|
|
344
|
+
style={{ flex:1, opacity:1 }}
|
|
345
|
+
title='CLOSE'
|
|
346
|
+
//disabled={loading}
|
|
347
|
+
title_color={Colors.utility.error}
|
|
348
|
+
borderWidth={1}
|
|
349
|
+
borderColor={Colors.utility.error}
|
|
350
|
+
padding={15}
|
|
351
|
+
onPress={() => onCompleteOrder(ip_item_order, ip_transaction)}
|
|
352
|
+
/>
|
|
353
|
+
}
|
|
354
|
+
{ip_transaction.status == 'redirect' ?
|
|
355
|
+
<Button
|
|
356
|
+
style={{ flex:3, opacity:completing?0.5:1 }}
|
|
357
|
+
loading={completing}
|
|
358
|
+
disabled={completing}
|
|
359
|
+
title='COMPLETE ORDER'
|
|
360
|
+
title_color={Colors.shades.white}
|
|
361
|
+
backgroundColor={Colors.brand.electric}
|
|
362
|
+
padding={15}
|
|
363
|
+
onPress={() => handleRedirect()}
|
|
364
|
+
/>
|
|
365
|
+
:<></>}
|
|
366
|
+
</View>
|
|
367
|
+
</SpringView>
|
|
368
|
+
</View>
|
|
369
|
+
:<></>}
|
|
370
|
+
{show_location ?
|
|
371
|
+
<View style={{ position:'absolute', top:0, bottom:0, left:0, right:0, backgroundColor:Colors.shades.black_faded, justifyContent:'flex-end' }}>
|
|
372
|
+
<SpringView
|
|
373
|
+
to={0}
|
|
374
|
+
from={500}
|
|
375
|
+
slide='vertical'
|
|
376
|
+
style={{ backgroundColor:Colors.shades.white, borderTopRightRadius:40, borderTopLeftRadius:40 }}
|
|
377
|
+
>
|
|
378
|
+
<LocationTracker
|
|
379
|
+
location={location}
|
|
380
|
+
permission={permission}
|
|
381
|
+
onGetLocation={getLocation}
|
|
382
|
+
onClose={() => setShowLocation(false)}
|
|
383
|
+
/>
|
|
384
|
+
</SpringView>
|
|
385
|
+
</View>
|
|
386
|
+
:<></>}
|
|
387
|
+
</View>
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const local_styles = StyleSheet.create({
|
|
392
|
+
section: {
|
|
393
|
+
padding: 10,
|
|
394
|
+
margin:5
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
|
|
398
|
+
export default Checkout
|
|
@@ -48,11 +48,12 @@ const Button = ({ title, style, title_weight, disabled, loading, title_size, pad
|
|
|
48
48
|
|
|
49
49
|
{title ?
|
|
50
50
|
<View style={{ flex:1, marginLeft:5, marginRight:5 }}>
|
|
51
|
-
{!loading ?
|
|
52
51
|
<Text size={title_size??14} weight={title_weight ?? 'bold'} textAlign="center" color={title_color??Colors.brand.midnight}>{title}</Text>
|
|
53
|
-
|
|
54
|
-
<
|
|
55
|
-
|
|
52
|
+
{loading ?
|
|
53
|
+
<View style={{ position:'absolute', top:0, bottom:0, left:0, right:0 }}>
|
|
54
|
+
<ActivityIndicator style={{ alignSelf:'center' }} size='small' color={title_color??Colors.brand.midnight} />
|
|
55
|
+
</View>
|
|
56
|
+
:<></>}
|
|
56
57
|
</View>
|
|
57
58
|
:<></>}
|
|
58
59
|
|
|
@@ -6,20 +6,23 @@ type CheckBoxProps = {
|
|
|
6
6
|
checked?:boolean,
|
|
7
7
|
size?:number
|
|
8
8
|
color?:string,
|
|
9
|
+
disabled?:boolean,
|
|
9
10
|
style?: any,
|
|
11
|
+
fill_style?:any
|
|
10
12
|
onSelect:(checked:boolean) => void
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
const Checkbox = ({ checked, size, color, onSelect, style }:CheckBoxProps) => {
|
|
15
|
+
const Checkbox = ({ checked, size, disabled, color, onSelect, style, fill_style }:CheckBoxProps) => {
|
|
14
16
|
const box_size = size ?? 20
|
|
15
17
|
const box_color = color ?? Colors.brand.midnight
|
|
16
18
|
return (
|
|
17
19
|
<TouchableOpacity
|
|
20
|
+
disabled={disabled}
|
|
18
21
|
style={{ height:box_size, width:box_size, borderWidth:1, borderRadius:4, borderColor:box_color, justifyContent:'center', alignItems:'center', ...style }}
|
|
19
22
|
onPress={() => onSelect(checked ? false : true)}
|
|
20
23
|
>
|
|
21
24
|
{checked ?
|
|
22
|
-
<View style={{ height:box_size*0.75, width:box_size*0.75, backgroundColor:box_color }} />
|
|
25
|
+
<View style={{ height:box_size*0.75, width:box_size*0.75, backgroundColor:box_color, ...fill_style }} />
|
|
23
26
|
:<></>}
|
|
24
27
|
</TouchableOpacity>
|
|
25
28
|
)
|