react-native-unit-components 1.0.4 → 1.1.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.
Files changed (249) hide show
  1. package/README.md +39 -8
  2. package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt +6 -1
  3. package/android/src/main/java/com/unitreactnativecomponents/getapplicationid/UNAppInfoModule.kt +35 -0
  4. package/lib/commonjs/assets/images/index.js +0 -2
  5. package/lib/commonjs/assets/images/index.js.map +1 -1
  6. package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js +64 -0
  7. package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -0
  8. package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.utils.js +31 -0
  9. package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.utils.js.map +1 -0
  10. package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js +108 -0
  11. package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -0
  12. package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.utils.js +58 -0
  13. package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.utils.js.map +1 -0
  14. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +3 -29
  15. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
  16. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js +0 -11
  17. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
  18. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +2 -22
  19. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  20. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +0 -8
  21. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  22. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +2 -23
  23. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  24. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +3 -9
  25. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
  26. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
  27. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +4 -59
  28. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  29. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js +0 -3
  30. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js.map +1 -1
  31. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +0 -10
  32. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
  33. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +2 -24
  34. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -1
  35. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +0 -3
  36. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -1
  37. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +13 -41
  38. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
  39. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +3 -17
  40. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  41. package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js +0 -2
  42. package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -1
  43. package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +2 -9
  44. package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -1
  45. package/lib/commonjs/components/index.js +22 -10
  46. package/lib/commonjs/components/index.js.map +1 -1
  47. package/lib/commonjs/helpers/BottomSheet/BottomSheet.js +5 -47
  48. package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -1
  49. package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js +0 -5
  50. package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
  51. package/lib/commonjs/helpers/EventBus.js +4 -17
  52. package/lib/commonjs/helpers/EventBus.js.map +1 -1
  53. package/lib/commonjs/hooks/listenerToBus.js +14 -14
  54. package/lib/commonjs/hooks/listenerToBus.js.map +1 -1
  55. package/lib/commonjs/hooks/useAppStateListener.js +1 -6
  56. package/lib/commonjs/hooks/useAppStateListener.js.map +1 -1
  57. package/lib/commonjs/index.js +0 -5
  58. package/lib/commonjs/index.js.map +1 -1
  59. package/lib/commonjs/messages/nativeMessages/cardMessage.js +0 -5
  60. package/lib/commonjs/messages/nativeMessages/cardMessage.js.map +1 -1
  61. package/lib/commonjs/messages/nativeMessages/sdkMessage.js +0 -1
  62. package/lib/commonjs/messages/nativeMessages/sdkMessage.js.map +1 -1
  63. package/lib/commonjs/messages/webMessages/achCreditMessage.js +6 -0
  64. package/lib/commonjs/messages/webMessages/achCreditMessage.js.map +1 -0
  65. package/lib/commonjs/messages/webMessages/bookPaymentMessage.js +0 -7
  66. package/lib/commonjs/messages/webMessages/bookPaymentMessage.js.map +1 -1
  67. package/lib/commonjs/messages/webMessages/cardMessage.js +0 -1
  68. package/lib/commonjs/messages/webMessages/cardMessage.js.map +1 -1
  69. package/lib/commonjs/messages/webMessages/index.js.map +1 -1
  70. package/lib/commonjs/messages/webMessages/pageMessage.js +0 -1
  71. package/lib/commonjs/messages/webMessages/pageMessage.js.map +1 -1
  72. package/lib/commonjs/messages/webMessages/paymentsMessage.js +12 -0
  73. package/lib/commonjs/messages/webMessages/paymentsMessage.js.map +1 -0
  74. package/lib/commonjs/messages/webMessages/unitMessages.js +3 -1
  75. package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
  76. package/lib/commonjs/nativeComponent/UnitAddToWalletButton.js +0 -2
  77. package/lib/commonjs/nativeComponent/UnitAddToWalletButton.js.map +1 -1
  78. package/lib/commonjs/scripts/html/bodyHtml.js +0 -8
  79. package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -1
  80. package/lib/commonjs/scripts/html/bodyScript.js +24 -6
  81. package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
  82. package/lib/commonjs/sharedTypes/achCredit.types.js +6 -0
  83. package/lib/commonjs/sharedTypes/achCredit.types.js.map +1 -0
  84. package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -1
  85. package/lib/commonjs/sharedTypes/index.js +22 -6
  86. package/lib/commonjs/sharedTypes/index.js.map +1 -1
  87. package/lib/commonjs/sharedTypes/payments.types.js +12 -0
  88. package/lib/commonjs/sharedTypes/payments.types.js.map +1 -0
  89. package/lib/commonjs/sharedTypes/wallet.types.js +0 -3
  90. package/lib/commonjs/sharedTypes/wallet.types.js.map +1 -1
  91. package/lib/commonjs/styles/variables.js.map +1 -1
  92. package/lib/commonjs/unitSdkManager/UnitSdk.api.js +1 -15
  93. package/lib/commonjs/unitSdkManager/UnitSdk.api.js.map +1 -1
  94. package/lib/commonjs/unitSdkManager/UnitSdkManager.js +3 -20
  95. package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
  96. package/lib/commonjs/webComponent/WebComponent.js +7 -36
  97. package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
  98. package/lib/commonjs/webComponent/WebComponent.utils.js +0 -7
  99. package/lib/commonjs/webComponent/WebComponent.utils.js.map +1 -1
  100. package/lib/commonjs/webComponent/html.js +7 -8
  101. package/lib/commonjs/webComponent/html.js.map +1 -1
  102. package/lib/module/assets/images/index.js.map +1 -1
  103. package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js +55 -0
  104. package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -0
  105. package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.utils.js +23 -0
  106. package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.utils.js.map +1 -0
  107. package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js +99 -0
  108. package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -0
  109. package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.utils.js +48 -0
  110. package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.utils.js.map +1 -0
  111. package/lib/module/components/UNAccountComponent/UNAccountComponent.js +3 -11
  112. package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
  113. package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
  114. package/lib/module/components/UNActivityComponent/UNActivityComponent.js +2 -9
  115. package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  116. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  117. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +2 -11
  118. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  119. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +3 -3
  120. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
  121. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
  122. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +4 -35
  123. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  124. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js.map +1 -1
  125. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
  126. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +2 -7
  127. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -1
  128. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -1
  129. package/lib/module/components/UNCardComponent/UNCardComponent.js +13 -20
  130. package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
  131. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +3 -1
  132. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  133. package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -1
  134. package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +1 -2
  135. package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -1
  136. package/lib/module/components/index.js +2 -0
  137. package/lib/module/components/index.js.map +1 -1
  138. package/lib/module/helpers/BottomSheet/BottomSheet.js +5 -31
  139. package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -1
  140. package/lib/module/helpers/BottomSheet/BottomSheet.styles.js +2 -1
  141. package/lib/module/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
  142. package/lib/module/helpers/EventBus.js +4 -15
  143. package/lib/module/helpers/EventBus.js.map +1 -1
  144. package/lib/module/hooks/listenerToBus.js +14 -10
  145. package/lib/module/hooks/listenerToBus.js.map +1 -1
  146. package/lib/module/hooks/useAppStateListener.js +0 -2
  147. package/lib/module/hooks/useAppStateListener.js.map +1 -1
  148. package/lib/module/index.js.map +1 -1
  149. package/lib/module/messages/nativeMessages/cardMessage.js +0 -5
  150. package/lib/module/messages/nativeMessages/cardMessage.js.map +1 -1
  151. package/lib/module/messages/nativeMessages/sdkMessage.js +0 -1
  152. package/lib/module/messages/nativeMessages/sdkMessage.js.map +1 -1
  153. package/lib/module/messages/webMessages/achCreditMessage.js +2 -0
  154. package/lib/module/messages/webMessages/achCreditMessage.js.map +1 -0
  155. package/lib/module/messages/webMessages/bookPaymentMessage.js +1 -5
  156. package/lib/module/messages/webMessages/bookPaymentMessage.js.map +1 -1
  157. package/lib/module/messages/webMessages/cardMessage.js +0 -1
  158. package/lib/module/messages/webMessages/cardMessage.js.map +1 -1
  159. package/lib/module/messages/webMessages/index.js.map +1 -1
  160. package/lib/module/messages/webMessages/pageMessage.js +0 -1
  161. package/lib/module/messages/webMessages/pageMessage.js.map +1 -1
  162. package/lib/module/messages/webMessages/paymentsMessage.js +5 -0
  163. package/lib/module/messages/webMessages/paymentsMessage.js.map +1 -0
  164. package/lib/module/messages/webMessages/unitMessages.js +3 -1
  165. package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
  166. package/lib/module/nativeComponent/UnitAddToWalletButton.js.map +1 -1
  167. package/lib/module/scripts/html/bodyHtml.js +0 -7
  168. package/lib/module/scripts/html/bodyHtml.js.map +1 -1
  169. package/lib/module/scripts/html/bodyScript.js +22 -1
  170. package/lib/module/scripts/html/bodyScript.js.map +1 -1
  171. package/lib/module/sharedTypes/achCredit.types.js +2 -0
  172. package/lib/module/sharedTypes/achCredit.types.js.map +1 -0
  173. package/lib/module/sharedTypes/bookPayment.types.js.map +1 -1
  174. package/lib/module/sharedTypes/index.js +2 -0
  175. package/lib/module/sharedTypes/index.js.map +1 -1
  176. package/lib/module/sharedTypes/payments.types.js +5 -0
  177. package/lib/module/sharedTypes/payments.types.js.map +1 -0
  178. package/lib/module/sharedTypes/wallet.types.js +0 -3
  179. package/lib/module/sharedTypes/wallet.types.js.map +1 -1
  180. package/lib/module/styles/variables.js.map +1 -1
  181. package/lib/module/unitSdkManager/UnitSdk.api.js +1 -6
  182. package/lib/module/unitSdkManager/UnitSdk.api.js.map +1 -1
  183. package/lib/module/unitSdkManager/UnitSdkManager.js +3 -12
  184. package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
  185. package/lib/module/webComponent/WebComponent.js +7 -18
  186. package/lib/module/webComponent/WebComponent.js.map +1 -1
  187. package/lib/module/webComponent/WebComponent.utils.js +0 -1
  188. package/lib/module/webComponent/WebComponent.utils.js.map +1 -1
  189. package/lib/module/webComponent/html.js +7 -5
  190. package/lib/module/webComponent/html.js.map +1 -1
  191. package/lib/typescript/components/UNACHCreditComponent/UNACHCreditComponent.d.ts +11 -0
  192. package/lib/typescript/components/UNACHCreditComponent/UNACHCreditComponent.utils.d.ts +3 -0
  193. package/lib/typescript/components/UNACHDebitComponent/UNACHDebitComponent.d.ts +11 -0
  194. package/lib/typescript/components/UNACHDebitComponent/UNACHDebitComponent.utils.d.ts +7 -0
  195. package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.d.ts +1 -1
  196. package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +4 -1
  197. package/lib/typescript/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.d.ts +1 -1
  198. package/lib/typescript/components/index.d.ts +2 -0
  199. package/lib/typescript/helpers/EventBus.d.ts +1 -1
  200. package/lib/typescript/hooks/listenerToBus.d.ts +2 -2
  201. package/lib/typescript/messages/nativeMessages/cardMessage.d.ts +1 -1
  202. package/lib/typescript/messages/nativeMessages/index.d.ts +2 -2
  203. package/lib/typescript/messages/nativeMessages/sdkMessage.d.ts +1 -1
  204. package/lib/typescript/messages/webMessages/achCreditMessage.d.ts +5 -0
  205. package/lib/typescript/messages/webMessages/bookPaymentMessage.d.ts +1 -4
  206. package/lib/typescript/messages/webMessages/cardMessage.d.ts +1 -1
  207. package/lib/typescript/messages/webMessages/index.d.ts +5 -3
  208. package/lib/typescript/messages/webMessages/pageMessage.d.ts +1 -1
  209. package/lib/typescript/messages/webMessages/paymentsMessage.d.ts +3 -0
  210. package/lib/typescript/messages/webMessages/unitMessages.d.ts +20 -2
  211. package/lib/typescript/nativeComponent/UnitAddToWalletButton.d.ts +1 -1
  212. package/lib/typescript/scripts/html/bodyScript.d.ts +3 -0
  213. package/lib/typescript/sharedTypes/achCredit.types.d.ts +31 -0
  214. package/lib/typescript/sharedTypes/bookPayment.types.d.ts +3 -4
  215. package/lib/typescript/sharedTypes/card.types.d.ts +4 -4
  216. package/lib/typescript/sharedTypes/index.d.ts +2 -0
  217. package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +3 -3
  218. package/lib/typescript/sharedTypes/payments.types.d.ts +12 -0
  219. package/lib/typescript/sharedTypes/types.d.ts +6 -6
  220. package/lib/typescript/webComponent/WebComponent.d.ts +3 -1
  221. package/package.json +4 -2
  222. package/src/components/UNACHCreditComponent/UNACHCreditComponent.tsx +73 -0
  223. package/src/components/UNACHCreditComponent/UNACHCreditComponent.utils.ts +26 -0
  224. package/src/components/UNACHDebitComponent/UNACHDebitComponent.tsx +117 -0
  225. package/src/components/UNACHDebitComponent/UNACHDebitComponent.utils.ts +48 -0
  226. package/src/components/UNAccountComponent/UNAccountComponent.tsx +2 -4
  227. package/src/components/UNActivityComponent/UNActivityComponent.tsx +1 -3
  228. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +3 -2
  229. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +3 -3
  230. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +2 -4
  231. package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.tsx +1 -3
  232. package/src/components/UNCardComponent/UNCardComponent.tsx +14 -7
  233. package/src/components/UNCardComponent/UNCardComponent.utils.ts +3 -0
  234. package/src/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.ts +1 -1
  235. package/src/components/index.ts +2 -0
  236. package/src/helpers/BottomSheet/BottomSheet.tsx +3 -7
  237. package/src/hooks/listenerToBus.ts +15 -10
  238. package/src/messages/webMessages/achCreditMessage.ts +8 -0
  239. package/src/messages/webMessages/bookPaymentMessage.ts +0 -4
  240. package/src/messages/webMessages/index.ts +7 -2
  241. package/src/messages/webMessages/paymentsMessage.ts +3 -0
  242. package/src/messages/webMessages/unitMessages.ts +25 -1
  243. package/src/scripts/html/bodyScript.ts +23 -1
  244. package/src/sharedTypes/achCredit.types.ts +32 -0
  245. package/src/sharedTypes/bookPayment.types.ts +2 -3
  246. package/src/sharedTypes/index.ts +2 -0
  247. package/src/sharedTypes/payments.types.ts +14 -0
  248. package/src/webComponent/WebComponent.tsx +5 -5
  249. package/src/webComponent/html.ts +7 -5
@@ -6,7 +6,7 @@ export declare enum ScrollState {
6
6
  onlyWebView = "webViewScroll",
7
7
  onlyBottomSheet = "onlyBottomSheet"
8
8
  }
9
- export declare type BottomSheetSlotData = {
9
+ export type BottomSheetSlotData = {
10
10
  componentName?: WebComponentType;
11
11
  componentResourceId?: string;
12
12
  requestRenderingEvent: RequestRenderingEvent;
@@ -4,8 +4,11 @@ export interface UNCardComponentProps {
4
4
  cardId: string;
5
5
  customerToken: string;
6
6
  theme?: string;
7
+ hideActionsMenuButton?: boolean;
8
+ hideCardTitle?: boolean;
9
+ hideSensitiveDataButton?: boolean;
10
+ onLoad?: (response: ResponseUnitOnLoadEvent) => void;
7
11
  onStatusChanged?: (card: UNCardData) => void;
8
12
  pushProvisioningModule?: typeof NativeModules;
9
- onLoad?: (response: ResponseUnitOnLoadEvent) => void;
10
13
  }
11
14
  export declare const UNCardComponent: (props: UNCardComponentProps) => JSX.Element;
@@ -1,2 +1,2 @@
1
- import { UNEnvironment } from 'react-native-unit-components';
1
+ import { UNEnvironment } from '../../../../unitSdkManager/UnitSdkManager';
2
2
  export declare const getMobileWalletPayload: (customerToken: string, cardId: string, env: UNEnvironment) => Promise<any>;
@@ -3,3 +3,5 @@ export * from './UNBottomSheetComponent/UNBottomSheetComponent';
3
3
  export * from './UNBookPaymentComponent/UNBookPaymentComponent';
4
4
  export * from './UNActivityComponent/UNActivityComponent';
5
5
  export * from './UNAccountComponent/UNAccountComponent';
6
+ export * from './UNACHDebitComponent/UNACHDebitComponent';
7
+ export * from './UNACHCreditComponent/UNACHCreditComponent';
@@ -1,6 +1,6 @@
1
1
  import type { NativeMessageType } from '../messages/nativeMessages';
2
2
  import type { WebViewMessageType } from '../messages/webMessages';
3
- export declare type BusEventKey = NativeMessageType | WebViewMessageType;
3
+ export type BusEventKey = NativeMessageType | WebViewMessageType;
4
4
  export default class EventBus {
5
5
  private static _instance;
6
6
  private eventListeners;
@@ -1,7 +1,7 @@
1
1
  import { BusEventKey } from '../helpers/EventBus';
2
- declare type Listener = {
2
+ type Listener = {
3
3
  busEventKey: BusEventKey;
4
4
  action: (data: any) => void;
5
5
  };
6
- export declare const useListenerToBus: (listeners: Listener[]) => void;
6
+ export declare const useListenerToBus: (listener: Listener) => void;
7
7
  export {};
@@ -25,4 +25,4 @@ export interface CardGetAddToWalletStatusEvent {
25
25
  export interface CardStartPushProvisioningEvent {
26
26
  cardId: string;
27
27
  }
28
- export declare type CardNativeEvent = CardAddToWalletStatusEvent | CardGetAddToWalletStatusEvent | CardStartPushProvisioningEvent;
28
+ export type CardNativeEvent = CardAddToWalletStatusEvent | CardGetAddToWalletStatusEvent | CardStartPushProvisioningEvent;
@@ -1,7 +1,7 @@
1
1
  import type { CardNativeEvent, CardNativeMessage } from './cardMessage';
2
2
  import type { SDKEvent, SDKMessage } from './sdkMessage';
3
- export declare type NativeMessageType = SDKMessage | CardNativeMessage;
4
- export declare type NativeEvent = CardNativeEvent | SDKEvent;
3
+ export type NativeMessageType = SDKMessage | CardNativeMessage;
4
+ export type NativeEvent = CardNativeEvent | SDKEvent;
5
5
  export interface NativeMessage {
6
6
  type: NativeMessageType;
7
7
  details?: NativeEvent;
@@ -5,4 +5,4 @@ export declare enum SDKMessage {
5
5
  export interface SdkScriptFetched {
6
6
  unitScript: string;
7
7
  }
8
- export declare type SDKEvent = SdkScriptFetched;
8
+ export type SDKEvent = SdkScriptFetched;
@@ -0,0 +1,5 @@
1
+ import type { UNACHData } from '../../sharedTypes';
2
+ export interface PaymentCreatedEvent {
3
+ data: UNACHData;
4
+ }
5
+ export type ACHEvent = PaymentCreatedEvent;
@@ -1,8 +1,5 @@
1
1
  import type { UNBookPaymentData } from '../../sharedTypes';
2
- export declare enum BookPaymentMessage {
3
- PAYMENT_CREATED = "unitPaymentCreated"
4
- }
5
2
  export interface PaymentCreatedEvent {
6
3
  data: UNBookPaymentData;
7
4
  }
8
- export declare type BookPaymentEvent = PaymentCreatedEvent;
5
+ export type BookPaymentEvent = PaymentCreatedEvent;
@@ -5,4 +5,4 @@ export declare enum CardMessage {
5
5
  export interface CardStatusChangedEvent {
6
6
  card: UNCardData;
7
7
  }
8
- export declare type CardEvent = CardStatusChangedEvent;
8
+ export type CardEvent = CardStatusChangedEvent;
@@ -1,9 +1,11 @@
1
- import type { BookPaymentEvent, BookPaymentMessage } from './bookPaymentMessage';
1
+ import type { ACHEvent } from './achCreditMessage';
2
+ import type { BookPaymentEvent } from './bookPaymentMessage';
2
3
  import type { CardEvent, CardMessage } from './cardMessage';
3
4
  import type { PageEvent, PageMessage } from './pageMessage';
5
+ import type { PaymentMessage } from './paymentsMessage';
4
6
  import type { UnitEvent, UnitMessage } from './unitMessages';
5
- export declare type WebViewMessageType = PageMessage | CardMessage | UnitMessage | BookPaymentMessage;
6
- declare type WebViewEvent = PageEvent | UnitEvent | CardEvent | BookPaymentEvent;
7
+ export type WebViewMessageType = PageMessage | CardMessage | UnitMessage | PaymentMessage;
8
+ type WebViewEvent = PageEvent | UnitEvent | CardEvent | BookPaymentEvent | PaymentMessage | ACHEvent;
7
9
  export interface WebViewMessage {
8
10
  type: WebViewMessageType;
9
11
  details?: WebViewEvent;
@@ -5,4 +5,4 @@ export declare enum PageMessage {
5
5
  export interface HeightEvent {
6
6
  height: number;
7
7
  }
8
- export declare type PageEvent = HeightEvent;
8
+ export type PageEvent = HeightEvent;
@@ -0,0 +1,3 @@
1
+ export declare enum PaymentMessage {
2
+ PAYMENT_CREATED = "unitPaymentCreated"
3
+ }
@@ -5,7 +5,10 @@ export declare enum UnitMessage {
5
5
  UNIT_REQUEST_CLOSE_FLOW = "unitRequestCloseFlow",
6
6
  UNIT_REQUEST_OPEN_LINK = "unitRequestOpenLink",
7
7
  UNIT_ON_LOAD = "unitOnLoad",
8
- UNIT_REQUEST_DOWNLOAD = "unitRequestDownload"
8
+ UNIT_REQUEST_DOWNLOAD = "unitRequestDownload",
9
+ UNIT_PLAID_TOKEN_CREATED = "unitPlaidLinkTokenCreated",
10
+ UNIT_REQUEST_EXTERNAL_SDK = "unitRequestExternalSdk",
11
+ UNIT_PLAID_RESPONSE = "unitPlaidResponse"
9
12
  }
10
13
  export interface RequestRenderingEvent {
11
14
  data: RequestRenderingEventData;
@@ -31,4 +34,19 @@ export interface RequestDownloadEvent {
31
34
  responseType: string;
32
35
  fileName: string;
33
36
  }
34
- export declare type UnitEvent = RequestRenderingEvent | RequestRefreshEvent | RequestOpenLinkEvent | ResponseUnitOnLoadEvent | RequestDownloadEvent;
37
+ export interface PlaidTokenCreatedEvent {
38
+ linkToken: PlaidLinkTokenData;
39
+ }
40
+ export interface PlaidLinkTokenData {
41
+ type: string;
42
+ attributes: PlaidLinkTokenAttributes;
43
+ }
44
+ interface PlaidLinkTokenAttributes {
45
+ linkToken: string;
46
+ expiration: string;
47
+ }
48
+ export interface RequestExternalSdkEvent {
49
+ type: string;
50
+ }
51
+ export type UnitEvent = RequestRenderingEvent | RequestRefreshEvent | RequestOpenLinkEvent | ResponseUnitOnLoadEvent | RequestDownloadEvent | PlaidTokenCreatedEvent | RequestExternalSdkEvent;
52
+ export {};
@@ -1,4 +1,4 @@
1
- declare type UnitAddToWalletButtonViewProps = {
1
+ type UnitAddToWalletButtonViewProps = {
2
2
  style: object;
3
3
  onAddToWalletClicked: () => void;
4
4
  };
@@ -9,6 +9,9 @@ export declare const LISTENERS: {
9
9
  requestOpenLink: string;
10
10
  unitRequestDownload: string;
11
11
  cardStatusChange: string;
12
+ unitRequestExternalSdk: string;
13
+ unitPaymentCreated: string;
12
14
  };
13
15
  export declare const DISPATCH_RENDERING_EVENT: string;
14
16
  export declare const DISPATCH_REQUEST_REFRESH: string;
17
+ export declare const DISPATCH_PLAID_RESPONSE: string;
@@ -0,0 +1,31 @@
1
+ import type { AchCounterparty, CounterpartyVerificationMethod, PaymentStatus } from './payments.types';
2
+ import type { Tags, Relationship } from './types';
3
+ export type UNACHData = {
4
+ type: 'achPayment';
5
+ id: string;
6
+ attributes: {
7
+ createdAt: string | Date;
8
+ status: PaymentStatus;
9
+ settlementDate?: Date;
10
+ reason: string;
11
+ direction: 'Debit' | 'Credit';
12
+ description: string;
13
+ transactionSummaryOverride?: string;
14
+ amount: string;
15
+ tags: Tags;
16
+ addenda?: string;
17
+ counterparty: AchCounterparty;
18
+ expectedCompletionDate?: Date;
19
+ counterpartyVerificationMethod?: keyof typeof CounterpartyVerificationMethod;
20
+ sameDay?: boolean;
21
+ };
22
+ relationships: {
23
+ account: Relationship;
24
+ customer?: Relationship;
25
+ customers?: Relationship;
26
+ counterpartyAccount: Relationship;
27
+ counterpartyCustomer: Relationship;
28
+ transaction: Relationship;
29
+ recurringPayment: Relationship;
30
+ };
31
+ };
@@ -1,11 +1,11 @@
1
+ import type { PaymentStatus } from './payments.types';
1
2
  import type { Tags, Relationship } from './types';
2
- declare type BookPaymentStatus = 'Sent' | 'Rejected';
3
- export declare type UNBookPaymentData = {
3
+ export type UNBookPaymentData = {
4
4
  type: 'bookPayment';
5
5
  id: string;
6
6
  attributes: {
7
7
  createdAt: string | Date;
8
- status: BookPaymentStatus;
8
+ status: PaymentStatus;
9
9
  reason: string;
10
10
  direction: 'Debit' | 'Credit';
11
11
  description: string;
@@ -23,4 +23,3 @@ export declare type UNBookPaymentData = {
23
23
  recurringPayment: Relationship;
24
24
  };
25
25
  };
26
- export {};
@@ -1,7 +1,7 @@
1
1
  import type { Address, FullName, Limits, Relationship, Tags } from './types';
2
- export declare type UNCardData = IndividualDebitCard | BusinessDebitCard;
3
- declare type CardStatus = 'Active' | 'Inactive' | 'Stolen' | 'Lost' | 'Frozen' | 'ClosedByCustomer' | 'SuspectedFraud';
4
- export declare type IndividualDebitCard = {
2
+ export type UNCardData = IndividualDebitCard | BusinessDebitCard;
3
+ type CardStatus = 'Active' | 'Inactive' | 'Stolen' | 'Lost' | 'Frozen' | 'ClosedByCustomer' | 'SuspectedFraud';
4
+ export type IndividualDebitCard = {
5
5
  id: string;
6
6
  type: 'individualDebitCard' | 'individualVirtualDebitCard';
7
7
  attributes: {
@@ -23,7 +23,7 @@ export declare type IndividualDebitCard = {
23
23
  customer: Relationship;
24
24
  };
25
25
  };
26
- export declare type BusinessDebitCard = {
26
+ export type BusinessDebitCard = {
27
27
  id: string;
28
28
  type: 'businessDebitCard' | 'businessVirtualDebitCard';
29
29
  attributes: {
@@ -1,3 +1,5 @@
1
1
  export * from './bookPayment.types';
2
2
  export * from './card.types';
3
3
  export * from './onLoadResponse.types';
4
+ export * from './achCredit.types';
5
+ export * from './payments.types';
@@ -1,10 +1,10 @@
1
1
  import type { UNCardData } from '../sharedTypes';
2
- export declare type SuccessResponseUnitOnLoad = {
2
+ export type SuccessResponseUnitOnLoad = {
3
3
  data: UNCardData | Object;
4
4
  included: [Object];
5
5
  errors: null;
6
6
  };
7
- export declare type ErrorResponseUnitOnLoad = {
7
+ export type ErrorResponseUnitOnLoad = {
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 declare type ResponseUnitOnLoadEvent = SuccessResponseUnitOnLoad | ErrorResponseUnitOnLoad;
18
+ export type ResponseUnitOnLoadEvent = SuccessResponseUnitOnLoad | ErrorResponseUnitOnLoad;
@@ -0,0 +1,12 @@
1
+ export type PaymentStatus = 'Sent' | 'Rejected';
2
+ export type AchCounterparty = {
3
+ name: string;
4
+ accountNumber: string;
5
+ routingNumber: string;
6
+ accountType: AccountType;
7
+ };
8
+ type AccountType = 'Savings' | 'Checking';
9
+ export declare enum CounterpartyVerificationMethod {
10
+ Plaid = "Plaid"
11
+ }
12
+ export {};
@@ -1,4 +1,4 @@
1
- export declare type Address = {
1
+ export type Address = {
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 declare type Limits = {
9
+ export type Limits = {
10
10
  dailyWithdrawal?: string | number;
11
11
  dailyPurchase?: string | number;
12
12
  monthlyWithdrawal?: string | number;
13
13
  monthlyPurchase?: string | number;
14
14
  };
15
- declare type Data = {
15
+ type Data = {
16
16
  type: string;
17
17
  id: string;
18
18
  };
19
- export declare type Relationship = {
19
+ export type Relationship = {
20
20
  data: null | [] | Data | Data[];
21
21
  };
22
- export declare type FullName = {
22
+ export type FullName = {
23
23
  first: string;
24
24
  last: string;
25
25
  };
26
- export declare type Tags = Record<string, string>;
26
+ export type Tags = Record<string, string>;
27
27
  export {};
@@ -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.4",
3
+ "version": "1.1.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 { ResponseUnitOnLoadEvent, 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: ResponseUnitOnLoadEvent) => 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 ResponseUnitOnLoadEvent);
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 { ResponseUnitOnLoadEvent, 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: ResponseUnitOnLoadEvent) => 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 ResponseUnitOnLoadEvent);
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
+ };