react-native-unit-components 1.0.4 → 1.2.0
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/README.md +108 -8
- package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt +6 -1
- package/android/src/main/java/com/unitreactnativecomponents/getapplicationid/UNAppInfoModule.kt +35 -0
- package/lib/commonjs/assets/images/index.js +0 -2
- package/lib/commonjs/assets/images/index.js.map +1 -1
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js +64 -0
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -0
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.utils.js +31 -0
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.utils.js.map +1 -0
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js +108 -0
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -0
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.utils.js +58 -0
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.utils.js.map +1 -0
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +11 -29
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js +0 -11
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +14 -22
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +0 -8
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +2 -23
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +3 -9
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +8 -59
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js +0 -3
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +0 -10
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +8 -29
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +0 -3
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +13 -41
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +3 -17
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js +0 -2
- package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +2 -9
- package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -1
- package/lib/commonjs/components/index.js +22 -10
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js +5 -47
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js +0 -5
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
- package/lib/commonjs/helpers/EventBus.js +4 -17
- package/lib/commonjs/helpers/EventBus.js.map +1 -1
- package/lib/commonjs/hooks/listenerToBus.js +14 -14
- package/lib/commonjs/hooks/listenerToBus.js.map +1 -1
- package/lib/commonjs/hooks/useAppStateListener.js +1 -6
- package/lib/commonjs/hooks/useAppStateListener.js.map +1 -1
- package/lib/commonjs/index.js +0 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/cardMessage.js +1 -18
- package/lib/commonjs/messages/nativeMessages/cardMessage.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/sdkMessage.js +0 -1
- package/lib/commonjs/messages/nativeMessages/sdkMessage.js.map +1 -1
- package/lib/commonjs/messages/webMessages/accountMessage.js +12 -0
- package/lib/commonjs/messages/webMessages/accountMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/achCreditMessage.js +6 -0
- package/lib/commonjs/messages/webMessages/achCreditMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/bookPaymentMessage.js +0 -7
- package/lib/commonjs/messages/webMessages/bookPaymentMessage.js.map +1 -1
- package/lib/commonjs/messages/webMessages/cardMessage.js +0 -1
- package/lib/commonjs/messages/webMessages/cardMessage.js.map +1 -1
- package/lib/commonjs/messages/webMessages/index.js.map +1 -1
- package/lib/commonjs/messages/webMessages/pageMessage.js +0 -1
- package/lib/commonjs/messages/webMessages/pageMessage.js.map +1 -1
- package/lib/commonjs/messages/webMessages/paymentsMessage.js +12 -0
- package/lib/commonjs/messages/webMessages/paymentsMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/unitMessages.js +3 -1
- package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/commonjs/nativeComponent/UnitAddToWalletButton.js +0 -2
- package/lib/commonjs/nativeComponent/UnitAddToWalletButton.js.map +1 -1
- package/lib/commonjs/scripts/html/bodyHtml.js +0 -8
- package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -1
- package/lib/commonjs/scripts/html/bodyScript.js +35 -6
- package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
- package/lib/commonjs/sharedTypes/account.types.js +31 -0
- package/lib/commonjs/sharedTypes/account.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/achCredit.types.js +6 -0
- package/lib/commonjs/sharedTypes/achCredit.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/index.js +33 -6
- package/lib/commonjs/sharedTypes/index.js.map +1 -1
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/payments.types.js +12 -0
- package/lib/commonjs/sharedTypes/payments.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/types.js.map +1 -1
- package/lib/commonjs/sharedTypes/wallet.types.js +13 -4
- package/lib/commonjs/sharedTypes/wallet.types.js.map +1 -1
- package/lib/commonjs/styles/variables.js.map +1 -1
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js +1 -15
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js.map +1 -1
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js +3 -20
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.js +7 -36
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.utils.js +0 -7
- package/lib/commonjs/webComponent/WebComponent.utils.js.map +1 -1
- package/lib/commonjs/webComponent/html.js +9 -8
- package/lib/commonjs/webComponent/html.js.map +1 -1
- package/lib/module/assets/images/index.js.map +1 -1
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js +55 -0
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -0
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.utils.js +23 -0
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.utils.js.map +1 -0
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js +99 -0
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -0
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.utils.js +48 -0
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.utils.js.map +1 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js +11 -11
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
- package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +13 -9
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +2 -11
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +3 -3
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +8 -35
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +9 -13
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.js +13 -20
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +3 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -1
- package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +1 -2
- package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -1
- package/lib/module/components/index.js +2 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/helpers/BottomSheet/BottomSheet.js +5 -31
- package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js +2 -1
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
- package/lib/module/helpers/EventBus.js +4 -15
- package/lib/module/helpers/EventBus.js.map +1 -1
- package/lib/module/hooks/listenerToBus.js +14 -10
- package/lib/module/hooks/listenerToBus.js.map +1 -1
- package/lib/module/hooks/useAppStateListener.js +0 -2
- package/lib/module/hooks/useAppStateListener.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/messages/nativeMessages/cardMessage.js +0 -16
- package/lib/module/messages/nativeMessages/cardMessage.js.map +1 -1
- package/lib/module/messages/nativeMessages/sdkMessage.js +0 -1
- package/lib/module/messages/nativeMessages/sdkMessage.js.map +1 -1
- package/lib/module/messages/webMessages/accountMessage.js +5 -0
- package/lib/module/messages/webMessages/accountMessage.js.map +1 -0
- package/lib/module/messages/webMessages/achCreditMessage.js +2 -0
- package/lib/module/messages/webMessages/achCreditMessage.js.map +1 -0
- package/lib/module/messages/webMessages/bookPaymentMessage.js +1 -5
- package/lib/module/messages/webMessages/bookPaymentMessage.js.map +1 -1
- package/lib/module/messages/webMessages/cardMessage.js +0 -1
- package/lib/module/messages/webMessages/cardMessage.js.map +1 -1
- package/lib/module/messages/webMessages/index.js.map +1 -1
- package/lib/module/messages/webMessages/pageMessage.js +0 -1
- package/lib/module/messages/webMessages/pageMessage.js.map +1 -1
- package/lib/module/messages/webMessages/paymentsMessage.js +5 -0
- package/lib/module/messages/webMessages/paymentsMessage.js.map +1 -0
- package/lib/module/messages/webMessages/unitMessages.js +3 -1
- package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/module/nativeComponent/UnitAddToWalletButton.js.map +1 -1
- package/lib/module/scripts/html/bodyHtml.js +0 -7
- package/lib/module/scripts/html/bodyHtml.js.map +1 -1
- package/lib/module/scripts/html/bodyScript.js +33 -1
- package/lib/module/scripts/html/bodyScript.js.map +1 -1
- package/lib/module/sharedTypes/account.types.js +23 -0
- package/lib/module/sharedTypes/account.types.js.map +1 -0
- package/lib/module/sharedTypes/achCredit.types.js +2 -0
- package/lib/module/sharedTypes/achCredit.types.js.map +1 -0
- package/lib/module/sharedTypes/bookPayment.types.js.map +1 -1
- package/lib/module/sharedTypes/card.types.js.map +1 -1
- package/lib/module/sharedTypes/index.js +3 -0
- package/lib/module/sharedTypes/index.js.map +1 -1
- package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -1
- package/lib/module/sharedTypes/payments.types.js +5 -0
- package/lib/module/sharedTypes/payments.types.js.map +1 -0
- package/lib/module/sharedTypes/types.js.map +1 -1
- package/lib/module/sharedTypes/wallet.types.js +11 -3
- package/lib/module/sharedTypes/wallet.types.js.map +1 -1
- package/lib/module/styles/variables.js.map +1 -1
- package/lib/module/unitSdkManager/UnitSdk.api.js +1 -6
- package/lib/module/unitSdkManager/UnitSdk.api.js.map +1 -1
- package/lib/module/unitSdkManager/UnitSdkManager.js +3 -12
- package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/module/webComponent/WebComponent.js +7 -18
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/module/webComponent/WebComponent.utils.js +0 -1
- package/lib/module/webComponent/WebComponent.utils.js.map +1 -1
- package/lib/module/webComponent/html.js +9 -5
- package/lib/module/webComponent/html.js.map +1 -1
- package/lib/typescript/components/UNACHCreditComponent/UNACHCreditComponent.d.ts +11 -0
- package/lib/typescript/components/UNACHCreditComponent/UNACHCreditComponent.utils.d.ts +3 -0
- package/lib/typescript/components/UNACHDebitComponent/UNACHDebitComponent.d.ts +11 -0
- package/lib/typescript/components/UNACHDebitComponent/UNACHDebitComponent.utils.d.ts +7 -0
- package/lib/typescript/components/UNAccountComponent/UNAccountComponent.d.ts +4 -2
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +2 -2
- package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -2
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.d.ts +1 -1
- package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +5 -2
- package/lib/typescript/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.d.ts +1 -1
- package/lib/typescript/components/index.d.ts +2 -0
- package/lib/typescript/helpers/EventBus.d.ts +1 -1
- package/lib/typescript/hooks/listenerToBus.d.ts +2 -2
- package/lib/typescript/messages/nativeMessages/cardMessage.d.ts +4 -13
- package/lib/typescript/messages/nativeMessages/index.d.ts +2 -2
- package/lib/typescript/messages/nativeMessages/sdkMessage.d.ts +1 -1
- package/lib/typescript/messages/webMessages/accountMessage.d.ts +8 -0
- package/lib/typescript/messages/webMessages/achCreditMessage.d.ts +5 -0
- package/lib/typescript/messages/webMessages/bookPaymentMessage.d.ts +1 -4
- package/lib/typescript/messages/webMessages/cardMessage.d.ts +1 -1
- package/lib/typescript/messages/webMessages/index.d.ts +6 -3
- package/lib/typescript/messages/webMessages/pageMessage.d.ts +1 -1
- package/lib/typescript/messages/webMessages/paymentsMessage.d.ts +3 -0
- package/lib/typescript/messages/webMessages/unitMessages.d.ts +21 -3
- package/lib/typescript/nativeComponent/UnitAddToWalletButton.d.ts +1 -1
- package/lib/typescript/scripts/html/bodyScript.d.ts +4 -0
- package/lib/typescript/sharedTypes/account.types.d.ts +114 -0
- package/lib/typescript/sharedTypes/achCredit.types.d.ts +31 -0
- package/lib/typescript/sharedTypes/bookPayment.types.d.ts +12 -13
- package/lib/typescript/sharedTypes/card.types.d.ts +18 -18
- package/lib/typescript/sharedTypes/index.d.ts +3 -0
- package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +3 -3
- package/lib/typescript/sharedTypes/payments.types.d.ts +12 -0
- package/lib/typescript/sharedTypes/types.d.ts +7 -7
- package/lib/typescript/sharedTypes/wallet.types.d.ts +11 -2
- package/lib/typescript/webComponent/WebComponent.d.ts +3 -1
- package/package.json +4 -2
- package/src/components/UNACHCreditComponent/UNACHCreditComponent.tsx +73 -0
- package/src/components/UNACHCreditComponent/UNACHCreditComponent.utils.ts +26 -0
- package/src/components/UNACHDebitComponent/UNACHDebitComponent.tsx +117 -0
- package/src/components/UNACHDebitComponent/UNACHDebitComponent.utils.ts +48 -0
- package/src/components/UNAccountComponent/UNAccountComponent.tsx +13 -7
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +16 -7
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +6 -5
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +3 -3
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +13 -5
- package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.tsx +9 -10
- package/src/components/UNCardComponent/UNCardComponent.tsx +18 -11
- package/src/components/UNCardComponent/UNCardComponent.utils.ts +3 -0
- package/src/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.ts +1 -1
- package/src/components/index.ts +2 -0
- package/src/helpers/BottomSheet/BottomSheet.tsx +3 -7
- package/src/hooks/listenerToBus.ts +15 -10
- package/src/messages/nativeMessages/cardMessage.ts +5 -15
- package/src/messages/webMessages/accountMessage.ts +12 -0
- package/src/messages/webMessages/achCreditMessage.ts +8 -0
- package/src/messages/webMessages/bookPaymentMessage.ts +0 -4
- package/src/messages/webMessages/index.ts +10 -2
- package/src/messages/webMessages/paymentsMessage.ts +3 -0
- package/src/messages/webMessages/unitMessages.ts +27 -3
- package/src/scripts/html/bodyScript.ts +36 -2
- package/src/sharedTypes/account.types.ts +117 -0
- package/src/sharedTypes/achCredit.types.ts +32 -0
- package/src/sharedTypes/bookPayment.types.ts +11 -12
- package/src/sharedTypes/card.types.ts +18 -18
- package/src/sharedTypes/index.ts +3 -0
- package/src/sharedTypes/onLoadResponse.types.ts +5 -5
- package/src/sharedTypes/payments.types.ts +14 -0
- package/src/sharedTypes/types.ts +8 -8
- package/src/sharedTypes/wallet.types.ts +13 -3
- package/src/webComponent/WebComponent.tsx +5 -5
- package/src/webComponent/html.ts +9 -5
- package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/xcuserdata/alonshprung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/UnitReactNativeComponents.xcodeproj/xcuserdata/alonshprung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { UNRelationship, UNTags } from './types';
|
|
2
|
+
export type UNAccountData = UNDepositAccount | UNBatchAccount | UNCreditAccount;
|
|
3
|
+
declare enum UNAccountStatus {
|
|
4
|
+
Open = "Open",
|
|
5
|
+
Closed = "Closed",
|
|
6
|
+
Frozen = "Frozen"
|
|
7
|
+
}
|
|
8
|
+
export declare enum UNCloseReason {
|
|
9
|
+
Fraud = "Fraud",
|
|
10
|
+
ByCustomer = "ByCustomer"
|
|
11
|
+
}
|
|
12
|
+
export declare enum UNFraudReason {
|
|
13
|
+
ACHActivity = "ACHActivity",
|
|
14
|
+
CardActivity = "CardActivity",
|
|
15
|
+
CheckActivity = "CheckActivity",
|
|
16
|
+
ApplicationHistory = "ApplicationHistory",
|
|
17
|
+
AccountActivity = "AccountActivity",
|
|
18
|
+
ClientIdentified = "ClientIdentified",
|
|
19
|
+
IdentityTheft = "IdentityTheft",
|
|
20
|
+
LinkedToFraudulentCustomer = "LinkedToFraudulentCustomer"
|
|
21
|
+
}
|
|
22
|
+
export type UNDepositAccount = {
|
|
23
|
+
id: string;
|
|
24
|
+
type: "depositAccount";
|
|
25
|
+
attributes: {
|
|
26
|
+
createdAt: string;
|
|
27
|
+
updatedAt?: string;
|
|
28
|
+
name: string;
|
|
29
|
+
depositProduct: string;
|
|
30
|
+
routingNumber: string;
|
|
31
|
+
accountNumber: string;
|
|
32
|
+
maskedAccountNumber?: string;
|
|
33
|
+
secondaryAccountNumber?: {
|
|
34
|
+
routingNumber: string;
|
|
35
|
+
accountNumber: string;
|
|
36
|
+
};
|
|
37
|
+
balance: number;
|
|
38
|
+
hold: number;
|
|
39
|
+
reserve: number;
|
|
40
|
+
available: number;
|
|
41
|
+
overdraftLimit?: number;
|
|
42
|
+
currency: string;
|
|
43
|
+
tags: UNTags;
|
|
44
|
+
status: UNAccountStatus;
|
|
45
|
+
closeReason?: string;
|
|
46
|
+
fraudReason?: UNFraudReason;
|
|
47
|
+
closeReasonText?: string;
|
|
48
|
+
freezeReason?: string;
|
|
49
|
+
isOverdrawnWithinLimit?: boolean;
|
|
50
|
+
};
|
|
51
|
+
relationships: {
|
|
52
|
+
customer?: UNRelationship;
|
|
53
|
+
customers?: UNRelationship;
|
|
54
|
+
org: UNRelationship;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export type UNBatchAccount = {
|
|
58
|
+
id: string;
|
|
59
|
+
type: "batchAccount";
|
|
60
|
+
attributes: {
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
updatedAt?: Date;
|
|
63
|
+
name: string;
|
|
64
|
+
depositProduct: string;
|
|
65
|
+
routingNumber: string;
|
|
66
|
+
accountNumber: string;
|
|
67
|
+
maskedAccountNumber?: string;
|
|
68
|
+
balance: number;
|
|
69
|
+
hold: number;
|
|
70
|
+
reserve: number;
|
|
71
|
+
available: number;
|
|
72
|
+
currency: string;
|
|
73
|
+
status: "Open" | "Closed";
|
|
74
|
+
closeReason?: string;
|
|
75
|
+
fraudReason?: UNFraudReason;
|
|
76
|
+
closeReasonText?: string;
|
|
77
|
+
freezeReason?: string;
|
|
78
|
+
tags?: {
|
|
79
|
+
[key: string]: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
relationships: {
|
|
83
|
+
org: UNRelationship;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export type UNCreditAccount = {
|
|
87
|
+
id: string;
|
|
88
|
+
type: "creditAccount";
|
|
89
|
+
attributes: {
|
|
90
|
+
createdAt: Date;
|
|
91
|
+
updatedAt?: Date;
|
|
92
|
+
name: string;
|
|
93
|
+
creditTerms: string;
|
|
94
|
+
balance: number;
|
|
95
|
+
hold: number;
|
|
96
|
+
reserve: number;
|
|
97
|
+
available: number;
|
|
98
|
+
creditLimit: number;
|
|
99
|
+
currency: string;
|
|
100
|
+
tags: {
|
|
101
|
+
[key: string]: string;
|
|
102
|
+
};
|
|
103
|
+
status: UNAccountStatus;
|
|
104
|
+
closeReason?: UNCloseReason;
|
|
105
|
+
fraudReason?: UNFraudReason;
|
|
106
|
+
closeReasonText?: string;
|
|
107
|
+
freezeReason?: string;
|
|
108
|
+
};
|
|
109
|
+
relationships: {
|
|
110
|
+
customer: UNRelationship;
|
|
111
|
+
org: UNRelationship;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { UNAchCounterparty, UNCounterpartyVerificationMethod, UNPaymentStatus } from './payments.types';
|
|
2
|
+
import type { UNTags, UNRelationship } from './types';
|
|
3
|
+
export type UNACHData = {
|
|
4
|
+
type: 'achPayment';
|
|
5
|
+
id: string;
|
|
6
|
+
attributes: {
|
|
7
|
+
createdAt: string | Date;
|
|
8
|
+
status: UNPaymentStatus;
|
|
9
|
+
settlementDate?: Date;
|
|
10
|
+
reason: string;
|
|
11
|
+
direction: 'Debit' | 'Credit';
|
|
12
|
+
description: string;
|
|
13
|
+
transactionSummaryOverride?: string;
|
|
14
|
+
amount: string;
|
|
15
|
+
tags: UNTags;
|
|
16
|
+
addenda?: string;
|
|
17
|
+
counterparty: UNAchCounterparty;
|
|
18
|
+
expectedCompletionDate?: Date;
|
|
19
|
+
counterpartyVerificationMethod?: keyof typeof UNCounterpartyVerificationMethod;
|
|
20
|
+
sameDay?: boolean;
|
|
21
|
+
};
|
|
22
|
+
relationships: {
|
|
23
|
+
account: UNRelationship;
|
|
24
|
+
customer?: UNRelationship;
|
|
25
|
+
customers?: UNRelationship;
|
|
26
|
+
counterpartyAccount: UNRelationship;
|
|
27
|
+
counterpartyCustomer: UNRelationship;
|
|
28
|
+
transaction: UNRelationship;
|
|
29
|
+
recurringPayment: UNRelationship;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import type { UNPaymentStatus } from './payments.types';
|
|
2
|
+
import type { UNTags, UNRelationship } from './types';
|
|
3
|
+
export type UNBookPaymentData = {
|
|
4
4
|
type: 'bookPayment';
|
|
5
5
|
id: string;
|
|
6
6
|
attributes: {
|
|
7
7
|
createdAt: string | Date;
|
|
8
|
-
status:
|
|
8
|
+
status: UNPaymentStatus;
|
|
9
9
|
reason: string;
|
|
10
10
|
direction: 'Debit' | 'Credit';
|
|
11
11
|
description: string;
|
|
12
12
|
transactionSummaryOverride?: string;
|
|
13
13
|
amount: string;
|
|
14
|
-
tags:
|
|
14
|
+
tags: UNTags;
|
|
15
15
|
};
|
|
16
16
|
relationships: {
|
|
17
|
-
account:
|
|
18
|
-
customer?:
|
|
19
|
-
customers?:
|
|
20
|
-
counterpartyAccount:
|
|
21
|
-
counterpartyCustomer:
|
|
22
|
-
transaction:
|
|
23
|
-
recurringPayment:
|
|
17
|
+
account: UNRelationship;
|
|
18
|
+
customer?: UNRelationship;
|
|
19
|
+
customers?: UNRelationship;
|
|
20
|
+
counterpartyAccount: UNRelationship;
|
|
21
|
+
counterpartyCustomer: UNRelationship;
|
|
22
|
+
transaction: UNRelationship;
|
|
23
|
+
recurringPayment: UNRelationship;
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
export {};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
import type { UNAddress, UNFullName, UNLimits, UNRelationship, UNTags } from './types';
|
|
2
|
+
export type UNCardData = UNIndividualDebitCard | UNBusinessDebitCard;
|
|
3
|
+
type UNCardStatus = 'Active' | 'Inactive' | 'Stolen' | 'Lost' | 'Frozen' | 'ClosedByCustomer' | 'SuspectedFraud';
|
|
4
|
+
export type UNIndividualDebitCard = {
|
|
5
5
|
id: string;
|
|
6
6
|
type: 'individualDebitCard' | 'individualVirtualDebitCard';
|
|
7
7
|
attributes: {
|
|
8
8
|
createdAt: string;
|
|
9
9
|
last4Digits: string;
|
|
10
10
|
expirationDate: string;
|
|
11
|
-
status:
|
|
12
|
-
shippingAddress?:
|
|
11
|
+
status: UNCardStatus;
|
|
12
|
+
shippingAddress?: UNAddress;
|
|
13
13
|
updatedAt?: string;
|
|
14
14
|
design?: string;
|
|
15
15
|
additionalEmbossedText?: string;
|
|
16
16
|
idempotencyKey?: string;
|
|
17
|
-
tags?:
|
|
18
|
-
limits?:
|
|
17
|
+
tags?: UNTags;
|
|
18
|
+
limits?: UNLimits;
|
|
19
19
|
printOnlyBusinessName?: boolean;
|
|
20
20
|
};
|
|
21
21
|
relationships: {
|
|
22
|
-
account:
|
|
23
|
-
customer:
|
|
22
|
+
account: UNRelationship;
|
|
23
|
+
customer: UNRelationship;
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export type UNBusinessDebitCard = {
|
|
27
27
|
id: string;
|
|
28
28
|
type: 'businessDebitCard' | 'businessVirtualDebitCard';
|
|
29
29
|
attributes: {
|
|
30
|
-
fullName:
|
|
30
|
+
fullName: UNFullName;
|
|
31
31
|
dateOfBirth: string;
|
|
32
|
-
address:
|
|
33
|
-
shippingAddress?:
|
|
32
|
+
address: UNAddress;
|
|
33
|
+
shippingAddress?: UNAddress;
|
|
34
34
|
phone: string;
|
|
35
35
|
email: string;
|
|
36
36
|
createdAt: string;
|
|
37
37
|
last4Digits: string;
|
|
38
38
|
expirationDate: string;
|
|
39
|
-
status:
|
|
39
|
+
status: UNCardStatus;
|
|
40
40
|
updatedAt?: string;
|
|
41
41
|
ssn?: string;
|
|
42
42
|
passport?: string;
|
|
@@ -45,12 +45,12 @@ export declare type BusinessDebitCard = {
|
|
|
45
45
|
additionalEmbossedText?: string;
|
|
46
46
|
idempotencyKey?: string;
|
|
47
47
|
tags?: Record<string, string>;
|
|
48
|
-
limits?:
|
|
48
|
+
limits?: UNLimits;
|
|
49
49
|
printOnlyBusinessName?: boolean;
|
|
50
50
|
};
|
|
51
51
|
relationships: {
|
|
52
|
-
account:
|
|
53
|
-
customer:
|
|
52
|
+
account: UNRelationship;
|
|
53
|
+
customer: UNRelationship;
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { UNCardData } from '../sharedTypes';
|
|
2
|
-
export
|
|
2
|
+
export type UNSuccessResponseUnitOnLoad = {
|
|
3
3
|
data: UNCardData | Object;
|
|
4
4
|
included: [Object];
|
|
5
5
|
errors: null;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type UNErrorResponseUnitOnLoad = {
|
|
8
8
|
errors: [
|
|
9
9
|
{
|
|
10
10
|
status: string;
|
|
@@ -15,4 +15,4 @@ export declare type ErrorResponseUnitOnLoad = {
|
|
|
15
15
|
}
|
|
16
16
|
];
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type UNResponseUnitOnLoadEvent = UNSuccessResponseUnitOnLoad | UNErrorResponseUnitOnLoad;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type UNPaymentStatus = 'Sent' | 'Rejected';
|
|
2
|
+
export type UNAchCounterparty = {
|
|
3
|
+
name: string;
|
|
4
|
+
accountNumber: string;
|
|
5
|
+
routingNumber: string;
|
|
6
|
+
accountType: UNAccountType;
|
|
7
|
+
};
|
|
8
|
+
type UNAccountType = 'Savings' | 'Checking';
|
|
9
|
+
export declare enum UNCounterpartyVerificationMethod {
|
|
10
|
+
Plaid = "Plaid"
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type UNAddress = {
|
|
2
2
|
street: string;
|
|
3
3
|
street2?: string;
|
|
4
4
|
city: string;
|
|
@@ -6,22 +6,22 @@ export declare type Address = {
|
|
|
6
6
|
postalCode: string;
|
|
7
7
|
country: string;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type UNLimits = {
|
|
10
10
|
dailyWithdrawal?: string | number;
|
|
11
11
|
dailyPurchase?: string | number;
|
|
12
12
|
monthlyWithdrawal?: string | number;
|
|
13
13
|
monthlyPurchase?: string | number;
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
type UNData = {
|
|
16
16
|
type: string;
|
|
17
17
|
id: string;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
20
|
-
data: null | [] |
|
|
19
|
+
export type UNRelationship = {
|
|
20
|
+
data: null | [] | UNData | UNData[];
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export type UNFullName = {
|
|
23
23
|
first: string;
|
|
24
24
|
last: string;
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export type UNTags = Record<string, string>;
|
|
27
27
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CardAddToWalletStatus } from 'src/messages/nativeMessages/cardMessage';
|
|
2
1
|
export declare enum UNWalletCode {
|
|
3
2
|
Apple = "ApplePayPushProvision",
|
|
4
3
|
Google = "GooglePayPushProvision"
|
|
@@ -10,5 +9,15 @@ export declare enum UNWalletName {
|
|
|
10
9
|
export interface UNWallet {
|
|
11
10
|
name: string;
|
|
12
11
|
code: string;
|
|
13
|
-
status:
|
|
12
|
+
status: UNCardAddToWalletStatus;
|
|
13
|
+
}
|
|
14
|
+
export declare enum UNCardAddToWalletStatus {
|
|
15
|
+
pending = 0,
|
|
16
|
+
readyToProvisioning = "ReadyToProvision",
|
|
17
|
+
addedToWallet = "AlreadyProvisioned",
|
|
18
|
+
iosProvisionedInCurrentDevice = "ProvisionedInCurrentDevice",
|
|
19
|
+
iosProvisionedInPairedDevice = "ProvisionedInPairedDevice",
|
|
20
|
+
androidNotInstalled = "NotInstalled",
|
|
21
|
+
androidWalletSetupNotCompleted = "WalletSetupNotCompleted",
|
|
22
|
+
androidWalletAppUpdateAvailable = "WalletAppUpdateAvailable"
|
|
14
23
|
}
|
|
@@ -19,6 +19,8 @@ export declare enum WebComponentType {
|
|
|
19
19
|
bookPayment = "unit-elements-book-payment",
|
|
20
20
|
activity = "unit-elements-activity",
|
|
21
21
|
slot = "unit-elements-sdk-slot",
|
|
22
|
-
account = "unit-elements-account"
|
|
22
|
+
account = "unit-elements-account",
|
|
23
|
+
achDebitPayment = "unit-elements-ach-debit-payment",
|
|
24
|
+
achCreditPayment = "unit-elements-ach-credit-payment"
|
|
23
25
|
}
|
|
24
26
|
export declare const WebComponent: React.ForwardRefExoticComponent<WebComponentProps & React.RefAttributes<WebView<{}>>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-unit-components",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Unit React Native components",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -74,10 +74,12 @@
|
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"react": "*",
|
|
76
76
|
"react-native": "*",
|
|
77
|
-
"react-native-webview": "*"
|
|
77
|
+
"react-native-webview": "*",
|
|
78
|
+
"react-native-plaid-link-sdk": "*"
|
|
78
79
|
},
|
|
79
80
|
"dependencies": {
|
|
80
81
|
"axios": "^1.3.3",
|
|
82
|
+
"react-native-plaid-link-sdk": "^9.0.1",
|
|
81
83
|
"react-native-webview": "11.23.1"
|
|
82
84
|
},
|
|
83
85
|
"jest": {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
3
|
+
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
4
|
+
import type { WebViewMessage } from '../../messages/webMessages';
|
|
5
|
+
import type { UNResponseUnitOnLoadEvent, UNACHData } from '../../sharedTypes';
|
|
6
|
+
import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
|
|
7
|
+
import { View } from 'react-native';
|
|
8
|
+
import { UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
9
|
+
import { getACHCreditParams, getACHCreditScript } from './UNACHCreditComponent.utils';
|
|
10
|
+
import { PaymentMessage } from '../../messages/webMessages/paymentsMessage';
|
|
11
|
+
import type { ACHEvent } from '../../messages/webMessages/achCreditMessage';
|
|
12
|
+
|
|
13
|
+
export interface UNACHCreditComponentProps {
|
|
14
|
+
accountId: string;
|
|
15
|
+
customerToken: string;
|
|
16
|
+
theme?: string;
|
|
17
|
+
isAutoFocus?: boolean;
|
|
18
|
+
fee?: number;
|
|
19
|
+
onPaymentCreated?: (data: UNACHData) => void;
|
|
20
|
+
onLoad?: (response: UNResponseUnitOnLoadEvent) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const UNACHCreditComponent = (props: UNACHCreditComponentProps) => {
|
|
24
|
+
const [height, setHeight] = useState<number>(0);
|
|
25
|
+
const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);
|
|
26
|
+
|
|
27
|
+
const handleWebViewMessage = (message: WebViewMessage) => {
|
|
28
|
+
if (!message || !message.details) return;
|
|
29
|
+
|
|
30
|
+
switch (message.type) {
|
|
31
|
+
case PaymentMessage.PAYMENT_CREATED: {
|
|
32
|
+
const achCreditEvent = message.details as ACHEvent;
|
|
33
|
+
props.onPaymentCreated && props.onPaymentCreated(achCreditEvent.data as UNACHData);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case UnitMessage.UNIT_ON_LOAD:
|
|
37
|
+
props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
|
|
38
|
+
break;
|
|
39
|
+
case PageMessage.PAGE_HEIGHT: {
|
|
40
|
+
const currentHeight = (message.details as HeightEvent).height;
|
|
41
|
+
setHeight(currentHeight);
|
|
42
|
+
if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {
|
|
43
|
+
setPresentationMode(PresentationMode.Default);
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const renderACHCreditWebView = () => {
|
|
51
|
+
return (
|
|
52
|
+
<WebComponent
|
|
53
|
+
type={WebComponentType.achCreditPayment}
|
|
54
|
+
presentationMode={presentationMode}
|
|
55
|
+
params={getACHCreditParams(props)}
|
|
56
|
+
script={getACHCreditScript()}
|
|
57
|
+
onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}
|
|
58
|
+
isScrollable={false}
|
|
59
|
+
theme={props.theme}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
if (presentationMode === PresentationMode.Inherit) {
|
|
65
|
+
return renderACHCreditWebView();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<View style={{ height: height }}>
|
|
70
|
+
{renderACHCreditWebView()}
|
|
71
|
+
</View>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { UNACHCreditComponentProps } from './UNACHCreditComponent';
|
|
2
|
+
|
|
3
|
+
import { PaymentMessage } from '../../messages/webMessages/paymentsMessage';
|
|
4
|
+
|
|
5
|
+
export const getACHCreditParams = (props: UNACHCreditComponentProps) => {
|
|
6
|
+
return `
|
|
7
|
+
account-id="${props.accountId}"
|
|
8
|
+
customer-token="${props.customerToken}"
|
|
9
|
+
is-auto-focus="${props.isAutoFocus ?? false}"
|
|
10
|
+
${props.fee ? `fee="${props.fee}"` : ''}
|
|
11
|
+
style="height: 100%"
|
|
12
|
+
`;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const getACHCreditScript = () => {
|
|
16
|
+
return `
|
|
17
|
+
window.addEventListener("${PaymentMessage.PAYMENT_CREATED}", (e) => {
|
|
18
|
+
const response = e.detail
|
|
19
|
+
response.then((data) => {
|
|
20
|
+
postMessageToSDK({ type: "${PaymentMessage.PAYMENT_CREATED}", details: { data: JSON.stringify(data.data) }})
|
|
21
|
+
}).catch((e) => {
|
|
22
|
+
console.log(e)
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
`;
|
|
26
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
3
|
+
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
4
|
+
import type { WebViewMessage } from '../../messages/webMessages';
|
|
5
|
+
import type { UNResponseUnitOnLoadEvent, UNACHData } from '../../sharedTypes';
|
|
6
|
+
import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
|
|
7
|
+
import { Platform, View } from 'react-native';
|
|
8
|
+
import { PlaidLinkTokenData, PlaidTokenCreatedEvent, RequestExternalSdkEvent, UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
9
|
+
import { getACHDebitParams, getACHDebitScript, getAndroidPackageName, injectUnitPlaidResponse } from './UNACHDebitComponent.utils';
|
|
10
|
+
|
|
11
|
+
import { LinkSuccess, openLink } from 'react-native-plaid-link-sdk';
|
|
12
|
+
import type WebView from 'react-native-webview';
|
|
13
|
+
|
|
14
|
+
import { PaymentMessage } from '../../messages/webMessages/paymentsMessage';
|
|
15
|
+
import type { ACHEvent } from '../../messages/webMessages/achCreditMessage';
|
|
16
|
+
|
|
17
|
+
export interface UNACHDebitComponentProps {
|
|
18
|
+
accountId: string;
|
|
19
|
+
customerToken: string;
|
|
20
|
+
theme?: string;
|
|
21
|
+
isAutoFocus?: boolean;
|
|
22
|
+
fee?: number;
|
|
23
|
+
onPaymentCreated?: (data: UNACHData) => void;
|
|
24
|
+
onLoad?: (response: UNResponseUnitOnLoadEvent) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const UNACHDebitComponent = (props: UNACHDebitComponentProps) => {
|
|
28
|
+
const [height, setHeight] = useState<number>(0);
|
|
29
|
+
const [appPackageName, setAppPackageName] = useState<string>('');
|
|
30
|
+
const [linkToken, setLinkToken] = useState<string>('');
|
|
31
|
+
const webRef = useRef<WebView>(null);
|
|
32
|
+
const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const setPackageNameForAndroid = async () => {
|
|
36
|
+
if (Platform.OS === 'android') {
|
|
37
|
+
const packageName = await getAndroidPackageName();
|
|
38
|
+
setAppPackageName(packageName);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
setPackageNameForAndroid();
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
const dispatchUnitPlaidResponse = (success: LinkSuccess) => {
|
|
45
|
+
injectUnitPlaidResponse(webRef.current, success);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const handleWebViewMessage = (message: WebViewMessage) => {
|
|
49
|
+
if (!message || !message.details) return;
|
|
50
|
+
|
|
51
|
+
switch (message.type) {
|
|
52
|
+
case PaymentMessage.PAYMENT_CREATED: {
|
|
53
|
+
const achDebitEvent = message.details as ACHEvent;
|
|
54
|
+
props.onPaymentCreated && props.onPaymentCreated(achDebitEvent.data as UNACHData);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case UnitMessage.UNIT_ON_LOAD:
|
|
58
|
+
props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
|
|
59
|
+
break;
|
|
60
|
+
case PageMessage.PAGE_HEIGHT: {
|
|
61
|
+
const currentHeight = (message.details as HeightEvent).height;
|
|
62
|
+
setHeight(currentHeight);
|
|
63
|
+
if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {
|
|
64
|
+
setPresentationMode(PresentationMode.Default);
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case UnitMessage.UNIT_PLAID_TOKEN_CREATED: {
|
|
69
|
+
const linkTokenEvent = message.details as PlaidTokenCreatedEvent;
|
|
70
|
+
const linkTokenData = linkTokenEvent.linkToken as PlaidLinkTokenData;
|
|
71
|
+
setLinkToken(linkTokenData.attributes.linkToken);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
case UnitMessage.UNIT_REQUEST_EXTERNAL_SDK: {
|
|
76
|
+
const externalSdkType = (message.details as RequestExternalSdkEvent).type;
|
|
77
|
+
if (externalSdkType !== 'plaid') return;
|
|
78
|
+
linkToken && openLink({
|
|
79
|
+
tokenConfig: { noLoadingState: false, token: linkToken},
|
|
80
|
+
onSuccess: (success) => {
|
|
81
|
+
dispatchUnitPlaidResponse(success);
|
|
82
|
+
},
|
|
83
|
+
onExit: exit => { console.log(exit); }
|
|
84
|
+
}).catch(e => {
|
|
85
|
+
console.error(e);
|
|
86
|
+
});
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const renderACHDebitWebView = () => {
|
|
93
|
+
return (
|
|
94
|
+
<WebComponent
|
|
95
|
+
ref={webRef}
|
|
96
|
+
type={WebComponentType.achDebitPayment}
|
|
97
|
+
presentationMode={presentationMode}
|
|
98
|
+
params={getACHDebitParams(props)}
|
|
99
|
+
script={getACHDebitScript(appPackageName)}
|
|
100
|
+
onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}
|
|
101
|
+
isScrollable={false}
|
|
102
|
+
theme={props.theme}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
if (presentationMode === PresentationMode.Inherit) {
|
|
108
|
+
return renderACHDebitWebView();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<View style={{ height: height }}>
|
|
113
|
+
{renderACHDebitWebView()}
|
|
114
|
+
</View>
|
|
115
|
+
|
|
116
|
+
);
|
|
117
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DISPATCH_PLAID_RESPONSE, LISTENERS } from './../../scripts/html/bodyScript';
|
|
2
|
+
import type { UNACHDebitComponentProps } from './UNACHDebitComponent';
|
|
3
|
+
|
|
4
|
+
import type WebView from 'react-native-webview';
|
|
5
|
+
import type { LinkSuccess } from 'react-native-plaid-link-sdk';
|
|
6
|
+
import { NativeModules } from 'react-native';
|
|
7
|
+
const { RNAppInfoModule } = NativeModules;
|
|
8
|
+
import { UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
9
|
+
|
|
10
|
+
export const getACHDebitParams = (props: UNACHDebitComponentProps) => {
|
|
11
|
+
return `
|
|
12
|
+
account-id="${props.accountId}"
|
|
13
|
+
customer-token="${props.customerToken}"
|
|
14
|
+
is-auto-focus="${props.isAutoFocus ?? false}"
|
|
15
|
+
${props.fee ? `fee="${props.fee}"` : ''}
|
|
16
|
+
style="height: 100%"
|
|
17
|
+
`;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const getAndroidPackageName = async () => {
|
|
21
|
+
try {
|
|
22
|
+
const response = await RNAppInfoModule.getAppPackageName();
|
|
23
|
+
return response;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error(error);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const getACHDebitScript = (androidPackageName?: string) => {
|
|
30
|
+
return `
|
|
31
|
+
window.addEventListener("${UnitMessage.UNIT_PLAID_TOKEN_CREATED}", (e) => {
|
|
32
|
+
const response = e.detail
|
|
33
|
+
response.then((data) => {
|
|
34
|
+
postMessageToSDK({ type: "${UnitMessage.UNIT_PLAID_TOKEN_CREATED}", details: { linkToken: data.data }})
|
|
35
|
+
}).catch((e) => {
|
|
36
|
+
console.log(e)
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
${androidPackageName && `window.UnitMobileSDKConfig.androidPackageName='${androidPackageName}'`}
|
|
40
|
+
${LISTENERS.unitPaymentCreated}
|
|
41
|
+
${DISPATCH_PLAID_RESPONSE}
|
|
42
|
+
`;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const injectUnitPlaidResponse = (currentWeb: WebView | null, success: LinkSuccess) => {
|
|
46
|
+
const successObj = {data: { publicToken: success.publicToken, metadata: success.metadata}};
|
|
47
|
+
currentWeb?.injectJavaScript(`dispatchPlaidEvent(${JSON.stringify(successObj)})`);
|
|
48
|
+
};
|