@stripe/stripe-react-native 0.56.0 → 0.57.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.
Files changed (328) hide show
  1. package/android/build.gradle +76 -118
  2. package/android/gradle.properties +1 -1
  3. package/android/settings.gradle +2 -0
  4. package/android/spotless.gradle +1 -1
  5. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +24 -20
  6. package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +20 -17
  7. package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +28 -32
  8. package/android/src/main/java/com/reactnativestripesdk/{CollectBankAccountLauncherFragment.kt → CollectBankAccountLauncherManager.kt} +23 -44
  9. package/android/src/main/java/com/reactnativestripesdk/CustomPaymentMethodActivity.kt +2 -0
  10. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +4 -11
  11. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +52 -132
  12. package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +0 -8
  13. package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +154 -0
  14. package/android/src/main/java/com/reactnativestripesdk/{FinancialConnectionsSheetFragment.kt → FinancialConnectionsSheetManager.kt} +43 -92
  15. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
  16. package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +107 -0
  17. package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherManager.kt +37 -0
  18. package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +7 -5
  19. package/android/src/main/java/com/reactnativestripesdk/NavigationBarManager.kt +31 -0
  20. package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +120 -0
  21. package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +228 -0
  22. package/android/src/main/java/com/reactnativestripesdk/{PaymentLauncherFragment.kt → PaymentLauncherManager.kt} +40 -77
  23. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +11 -20
  24. package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
  25. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +409 -483
  26. package/android/src/main/java/com/reactnativestripesdk/{PaymentSheetFragment.kt → PaymentSheetManager.kt} +65 -300
  27. package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
  28. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +227 -232
  29. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
  30. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt +78 -0
  31. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +52 -39
  32. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
  33. package/android/src/main/java/com/reactnativestripesdk/customersheet/{CustomerSheetFragment.kt → CustomerSheetManager.kt} +64 -99
  34. package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -3
  35. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +5 -10
  36. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +90 -77
  37. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +6 -4
  38. package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +13 -3
  39. package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +87 -11
  40. package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
  41. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +178 -185
  42. package/android/src/main/java/com/reactnativestripesdk/utils/StripeUIManager.kt +62 -0
  43. package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +118 -0
  44. package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -0
  45. package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +922 -0
  46. package/android/src/test/java/com/facebook/testutils/shadows/ShadowArguments.kt +29 -0
  47. package/android/src/test/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManagerTest.kt +163 -0
  48. package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +976 -0
  49. package/android/src/test/java/com/reactnativestripesdk/PaymentSheetAppearanceTest.kt +801 -0
  50. package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +523 -0
  51. package/android/src/test/java/com/reactnativestripesdk/addresssheet/AddressSheetViewTest.kt +551 -0
  52. package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +567 -0
  53. package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +456 -0
  54. package/android/src/test/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +43 -0
  55. package/android/src/test/resources/robolectric.properties +2 -0
  56. package/ios/AddressSheet/AddressSheetUtils.swift +3 -3
  57. package/ios/AddressSheet/AddressSheetView.swift +26 -26
  58. package/ios/AddressSheet/AddressSheetViewManager.swift +2 -2
  59. package/ios/ApplePayButtonManager.swift +1 -1
  60. package/ios/ApplePayButtonView.swift +9 -10
  61. package/ios/ApplePayUtils.swift +51 -51
  62. package/ios/ApplePayViewController.swift +25 -29
  63. package/ios/AuBECSDebitFormManager.swift +1 -1
  64. package/ios/AuBECSDebitFormView.swift +13 -15
  65. package/ios/CardFieldManager.swift +4 -4
  66. package/ios/CardFieldView.swift +9 -9
  67. package/ios/CardFormManager.swift +3 -3
  68. package/ios/CardFormView.swift +28 -28
  69. package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +97 -0
  70. package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +133 -0
  71. package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.m +16 -0
  72. package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.swift +17 -0
  73. package/ios/CustomerSheet/CustomerSheetUtils.swift +15 -16
  74. package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +19 -19
  75. package/ios/EmbeddedPaymentElementView.swift +2 -2
  76. package/ios/Errors.swift +22 -23
  77. package/ios/FinancialConnections.swift +37 -37
  78. package/ios/Mappers.swift +212 -75
  79. package/ios/NavigationBarManager.m +13 -0
  80. package/ios/NavigationBarManager.swift +17 -0
  81. package/ios/NavigationBarView.swift +65 -0
  82. package/ios/NewArch/NavigationBarComponentView.h +10 -0
  83. package/ios/NewArch/NavigationBarComponentView.mm +86 -0
  84. package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
  85. package/ios/OldArch/StripeSdkEventEmitterCompat.m +7 -1
  86. package/ios/PaymentMethodFactory.swift +24 -41
  87. package/ios/PaymentOptionDisplayData+ReactNative.swift +4 -4
  88. package/ios/PaymentPassFinder.swift +9 -10
  89. package/ios/PaymentSheetAppearance.swift +137 -138
  90. package/ios/PushProvisioning/AddToWalletButtonManager.swift +2 -2
  91. package/ios/PushProvisioning/AddToWalletButtonView.swift +16 -18
  92. package/ios/PushProvisioning/PushProvisioningUtils.swift +11 -11
  93. package/ios/StripeContainerManager.swift +1 -1
  94. package/ios/StripeContainerView.swift +3 -3
  95. package/ios/StripeOnrampSdk.h +17 -0
  96. package/ios/StripeOnrampSdk.mm +158 -0
  97. package/ios/StripeSdk.mm +8 -0
  98. package/ios/StripeSdkEmitter.swift +4 -0
  99. package/ios/StripeSdkImpl+CustomerSheet.swift +31 -26
  100. package/ios/StripeSdkImpl+Embedded.swift +11 -9
  101. package/ios/StripeSdkImpl+PaymentSheet.swift +51 -42
  102. package/ios/StripeSdkImpl.swift +919 -191
  103. package/ios/UIColorExtension.swift +72 -0
  104. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  105. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  106. package/lib/commonjs/components/AddressSheet.js +1 -1
  107. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  108. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  109. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  110. package/lib/commonjs/components/CardField.js +1 -1
  111. package/lib/commonjs/components/CardField.js.map +1 -1
  112. package/lib/commonjs/components/CardForm.js +1 -1
  113. package/lib/commonjs/components/CardForm.js.map +1 -1
  114. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  115. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  116. package/lib/commonjs/components/StripeContainer.js +1 -1
  117. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  118. package/lib/commonjs/components/StripeProvider.js +1 -1
  119. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  120. package/lib/commonjs/connect/Components.js +2 -0
  121. package/lib/commonjs/connect/Components.js.map +1 -0
  122. package/lib/commonjs/connect/ConnectComponentsProvider.js +2 -0
  123. package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -0
  124. package/lib/commonjs/connect/EmbeddedComponent.js +19 -0
  125. package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -0
  126. package/lib/commonjs/connect/ModalCloseButton.js +2 -0
  127. package/lib/commonjs/connect/ModalCloseButton.js.map +1 -0
  128. package/lib/commonjs/connect/NavigationBar.js +2 -0
  129. package/lib/commonjs/connect/NavigationBar.js.map +1 -0
  130. package/lib/commonjs/connect/connectTypes.js +2 -0
  131. package/lib/commonjs/connect/connectTypes.js.map +1 -0
  132. package/lib/commonjs/events.js +1 -1
  133. package/lib/commonjs/events.js.map +1 -1
  134. package/lib/commonjs/helpers.js +1 -1
  135. package/lib/commonjs/helpers.js.map +1 -1
  136. package/lib/commonjs/hooks/useOnramp.js +2 -0
  137. package/lib/commonjs/hooks/useOnramp.js.map +1 -0
  138. package/lib/commonjs/index.js +1 -1
  139. package/lib/commonjs/index.js.map +1 -1
  140. package/lib/commonjs/plugin/withStripe.js +1 -1
  141. package/lib/commonjs/plugin/withStripe.js.map +1 -1
  142. package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
  143. package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -1
  144. package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
  145. package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -1
  146. package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
  147. package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -1
  148. package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
  149. package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -1
  150. package/lib/commonjs/specs/NativeCardField.js +1 -1
  151. package/lib/commonjs/specs/NativeCardField.js.map +1 -1
  152. package/lib/commonjs/specs/NativeCardForm.js +1 -1
  153. package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
  154. package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +2 -0
  155. package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js.map +1 -0
  156. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
  157. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  158. package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
  159. package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -1
  160. package/lib/commonjs/specs/NativeNavigationBar.js +2 -0
  161. package/lib/commonjs/specs/NativeNavigationBar.js.map +1 -0
  162. package/lib/commonjs/specs/NativeOnrampSdkModule.js +2 -0
  163. package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -0
  164. package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
  165. package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -1
  166. package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
  167. package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
  168. package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
  169. package/lib/commonjs/types/Errors.js +1 -1
  170. package/lib/commonjs/types/Errors.js.map +1 -1
  171. package/lib/commonjs/types/Onramp.js +2 -0
  172. package/lib/commonjs/types/Onramp.js.map +1 -0
  173. package/lib/commonjs/types/PaymentIntent.js.map +1 -1
  174. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  175. package/lib/commonjs/types/index.js +1 -1
  176. package/lib/commonjs/types/index.js.map +1 -1
  177. package/lib/module/components/AddToWalletButton.js +1 -1
  178. package/lib/module/components/AddToWalletButton.js.map +1 -1
  179. package/lib/module/components/AddressSheet.js +1 -1
  180. package/lib/module/components/AddressSheet.js.map +1 -1
  181. package/lib/module/components/AuBECSDebitForm.js +1 -1
  182. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  183. package/lib/module/components/CardField.js +1 -1
  184. package/lib/module/components/CardField.js.map +1 -1
  185. package/lib/module/components/CardForm.js +1 -1
  186. package/lib/module/components/CardForm.js.map +1 -1
  187. package/lib/module/components/PlatformPayButton.js +1 -1
  188. package/lib/module/components/PlatformPayButton.js.map +1 -1
  189. package/lib/module/components/StripeContainer.js +1 -1
  190. package/lib/module/components/StripeContainer.js.map +1 -1
  191. package/lib/module/components/StripeProvider.js +1 -1
  192. package/lib/module/components/StripeProvider.js.map +1 -1
  193. package/lib/module/connect/Components.js +2 -0
  194. package/lib/module/connect/Components.js.map +1 -0
  195. package/lib/module/connect/ConnectComponentsProvider.js +2 -0
  196. package/lib/module/connect/ConnectComponentsProvider.js.map +1 -0
  197. package/lib/module/connect/EmbeddedComponent.js +19 -0
  198. package/lib/module/connect/EmbeddedComponent.js.map +1 -0
  199. package/lib/module/connect/ModalCloseButton.js +2 -0
  200. package/lib/module/connect/ModalCloseButton.js.map +1 -0
  201. package/lib/module/connect/NavigationBar.js +2 -0
  202. package/lib/module/connect/NavigationBar.js.map +1 -0
  203. package/lib/module/connect/connectTypes.js +2 -0
  204. package/lib/module/connect/connectTypes.js.map +1 -0
  205. package/lib/module/events.js +1 -1
  206. package/lib/module/events.js.map +1 -1
  207. package/lib/module/helpers.js +1 -1
  208. package/lib/module/helpers.js.map +1 -1
  209. package/lib/module/hooks/useOnramp.js +2 -0
  210. package/lib/module/hooks/useOnramp.js.map +1 -0
  211. package/lib/module/index.js +1 -1
  212. package/lib/module/index.js.map +1 -1
  213. package/lib/module/plugin/withStripe.js +1 -1
  214. package/lib/module/plugin/withStripe.js.map +1 -1
  215. package/lib/module/specs/NativeAddToWalletButton.js +1 -1
  216. package/lib/module/specs/NativeAddToWalletButton.js.map +1 -1
  217. package/lib/module/specs/NativeAddressSheet.js +1 -1
  218. package/lib/module/specs/NativeAddressSheet.js.map +1 -1
  219. package/lib/module/specs/NativeApplePayButton.js +1 -1
  220. package/lib/module/specs/NativeApplePayButton.js.map +1 -1
  221. package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
  222. package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -1
  223. package/lib/module/specs/NativeCardField.js +1 -1
  224. package/lib/module/specs/NativeCardField.js.map +1 -1
  225. package/lib/module/specs/NativeCardForm.js +1 -1
  226. package/lib/module/specs/NativeCardForm.js.map +1 -1
  227. package/lib/module/specs/NativeConnectAccountOnboardingView.js +2 -0
  228. package/lib/module/specs/NativeConnectAccountOnboardingView.js.map +1 -0
  229. package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
  230. package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  231. package/lib/module/specs/NativeGooglePayButton.js +1 -1
  232. package/lib/module/specs/NativeGooglePayButton.js.map +1 -1
  233. package/lib/module/specs/NativeNavigationBar.js +2 -0
  234. package/lib/module/specs/NativeNavigationBar.js.map +1 -0
  235. package/lib/module/specs/NativeOnrampSdkModule.js +2 -0
  236. package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -0
  237. package/lib/module/specs/NativeStripeContainer.js +1 -1
  238. package/lib/module/specs/NativeStripeContainer.js.map +1 -1
  239. package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
  240. package/lib/module/types/EmbeddedPaymentElement.js +1 -1
  241. package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
  242. package/lib/module/types/Errors.js +1 -1
  243. package/lib/module/types/Errors.js.map +1 -1
  244. package/lib/module/types/Onramp.js +2 -0
  245. package/lib/module/types/Onramp.js.map +1 -0
  246. package/lib/module/types/PaymentIntent.js.map +1 -1
  247. package/lib/module/types/PaymentSheet.js.map +1 -1
  248. package/lib/module/types/index.js +1 -1
  249. package/lib/module/types/index.js.map +1 -1
  250. package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
  251. package/lib/typescript/src/connect/Components.d.ts +23 -0
  252. package/lib/typescript/src/connect/Components.d.ts.map +1 -0
  253. package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +22 -0
  254. package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -0
  255. package/lib/typescript/src/connect/EmbeddedComponent.d.ts +18 -0
  256. package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -0
  257. package/lib/typescript/src/connect/ModalCloseButton.d.ts +7 -0
  258. package/lib/typescript/src/connect/ModalCloseButton.d.ts.map +1 -0
  259. package/lib/typescript/src/connect/NavigationBar.d.ts +8 -0
  260. package/lib/typescript/src/connect/NavigationBar.d.ts.map +1 -0
  261. package/lib/typescript/src/connect/connectTypes.d.ts +464 -0
  262. package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -0
  263. package/lib/typescript/src/events.d.ts +3 -0
  264. package/lib/typescript/src/events.d.ts.map +1 -1
  265. package/lib/typescript/src/functions.d.ts.map +1 -1
  266. package/lib/typescript/src/helpers.d.ts.map +1 -1
  267. package/lib/typescript/src/hooks/useOnramp.d.ts +158 -0
  268. package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -0
  269. package/lib/typescript/src/index.d.ts +4 -0
  270. package/lib/typescript/src/index.d.ts.map +1 -1
  271. package/lib/typescript/src/plugin/withStripe.d.ts +15 -0
  272. package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
  273. package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts +14 -0
  274. package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts.map +1 -0
  275. package/lib/typescript/src/specs/NativeNavigationBar.d.ts +11 -0
  276. package/lib/typescript/src/specs/NativeNavigationBar.d.ts.map +1 -0
  277. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +28 -0
  278. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -0
  279. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -0
  280. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
  281. package/lib/typescript/src/types/Errors.d.ts +5 -0
  282. package/lib/typescript/src/types/Errors.d.ts.map +1 -1
  283. package/lib/typescript/src/types/Onramp.d.ts +275 -0
  284. package/lib/typescript/src/types/Onramp.d.ts.map +1 -0
  285. package/lib/typescript/src/types/PaymentIntent.d.ts +1 -9
  286. package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
  287. package/lib/typescript/src/types/PaymentMethod.d.ts +2 -8
  288. package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -1
  289. package/lib/typescript/src/types/PaymentSheet.d.ts +7 -0
  290. package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
  291. package/lib/typescript/src/types/index.d.ts +7 -1
  292. package/lib/typescript/src/types/index.d.ts.map +1 -1
  293. package/package.json +24 -12
  294. package/src/components/StripeProvider.tsx +5 -0
  295. package/src/connect/Components.tsx +279 -0
  296. package/src/connect/ConnectComponentsProvider.tsx +93 -0
  297. package/src/connect/EmbeddedComponent.tsx +407 -0
  298. package/src/connect/ModalCloseButton.tsx +44 -0
  299. package/src/connect/NavigationBar.tsx +29 -0
  300. package/src/connect/connectTypes.ts +626 -0
  301. package/src/events.ts +22 -0
  302. package/src/hooks/useOnramp.tsx +334 -0
  303. package/src/index.tsx +13 -0
  304. package/src/plugin/withStripe.ts +104 -7
  305. package/src/specs/NativeConnectAccountOnboardingView.ts +19 -0
  306. package/src/specs/NativeNavigationBar.ts +16 -0
  307. package/src/specs/NativeOnrampSdkModule.ts +47 -0
  308. package/src/specs/NativeStripeSdkModule.ts +5 -0
  309. package/src/types/Errors.ts +6 -0
  310. package/src/types/Onramp.ts +317 -0
  311. package/src/types/PaymentIntent.ts +0 -10
  312. package/src/types/PaymentMethod.ts +0 -9
  313. package/src/types/PaymentSheet.ts +7 -0
  314. package/src/types/index.ts +8 -0
  315. package/stripe-react-native.podspec +21 -8
  316. package/android/.idea/AndroidProjectSystem.xml +0 -6
  317. package/android/.idea/caches/deviceStreaming.xml +0 -703
  318. package/android/.idea/compiler.xml +0 -6
  319. package/android/.idea/gradle.xml +0 -18
  320. package/android/.idea/migrations.xml +0 -10
  321. package/android/.idea/misc.xml +0 -10
  322. package/android/.idea/runConfigurations.xml +0 -17
  323. package/android/.idea/vcs.xml +0 -6
  324. package/android/local.properties +0 -8
  325. package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +0 -146
  326. package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +0 -68
  327. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +0 -102
  328. package/android/src/main/java/com/reactnativestripesdk/utils/StripeFragment.kt +0 -52
@@ -2,12 +2,11 @@ package com.reactnativestripesdk
2
2
 
3
3
  import android.annotation.SuppressLint
4
4
  import android.content.res.ColorStateList
5
- import android.graphics.Color
6
5
  import android.os.Build
7
6
  import android.text.InputFilter
8
7
  import android.view.View
9
- import android.view.View.OnFocusChangeListener
10
8
  import android.widget.FrameLayout
9
+ import androidx.core.graphics.toColorInt
11
10
  import androidx.core.view.setMargins
12
11
  import com.facebook.react.bridge.ReadableMap
13
12
  import com.facebook.react.uimanager.PixelUtil
@@ -18,6 +17,7 @@ import com.google.android.material.shape.CornerFamily
18
17
  import com.google.android.material.shape.MaterialShapeDrawable
19
18
  import com.google.android.material.shape.ShapeAppearanceModel
20
19
  import com.reactnativestripesdk.utils.PostalCodeUtilities
20
+ import com.reactnativestripesdk.utils.getIntOr
21
21
  import com.reactnativestripesdk.utils.getIntOrNull
22
22
  import com.reactnativestripesdk.utils.getValOr
23
23
  import com.reactnativestripesdk.utils.hideSoftKeyboard
@@ -36,6 +36,7 @@ import com.stripe.android.view.CardInputListener
36
36
  class CardFormView(
37
37
  private val context: ThemedReactContext,
38
38
  ) : FrameLayout(context) {
39
+ @SuppressLint("PrivateResource")
39
40
  private var cardForm: CardFormView =
40
41
  CardFormView(context, null, com.stripe.android.R.style.StripeCardFormView_Borderless)
41
42
  private var dangerouslyGetFullCardDetails: Boolean = false
@@ -77,7 +78,7 @@ class CardFormView(
77
78
  cardForm.setPreferredNetworks(mapToPreferredNetworks(preferredNetworks))
78
79
  }
79
80
 
80
- @SuppressLint("RestrictedApi")
81
+ @SuppressLint("RestrictedApi", "VisibleForTests")
81
82
  private fun setCountry(countryString: String?) {
82
83
  if (countryString != null) {
83
84
  cardFormViewBinding.countryLayout.setSelectedCountryCode(CountryCode(countryString))
@@ -126,27 +127,20 @@ class CardFormView(
126
127
  cardNumberEditText.clearFocus()
127
128
  }
128
129
 
129
- fun requestClearFromJS() {
130
- multilineWidgetBinding.etCardNumber.setText("")
131
- multilineWidgetBinding.etCvc.setText("")
132
- multilineWidgetBinding.etExpiry.setText("")
133
- cardFormViewBinding.postalCode.setText("")
134
- }
135
-
136
130
  private fun onChangeFocus() {
137
131
  UIManagerHelper
138
132
  .getEventDispatcherForReactTag(context, id)
139
133
  ?.dispatchEvent(CardFocusChangeEvent(context.surfaceId, id, currentFocusedField))
140
134
  }
141
135
 
142
- @SuppressLint("RestrictedApi")
136
+ @SuppressLint("RestrictedApi", "VisibleForTests")
143
137
  fun setCardStyle(value: ReadableMap?) {
144
138
  val backgroundColor = getValOr(value, "backgroundColor", null)
145
139
  val textColor = getValOr(value, "textColor", null)
146
- val borderWidth = getIntOrNull(value, "borderWidth")
140
+ val borderWidth = value.getIntOrNull("borderWidth")
147
141
  val borderColor = getValOr(value, "borderColor", null)
148
- val borderRadius = getIntOrNull(value, "borderRadius") ?: 0
149
- val fontSize = getIntOrNull(value, "fontSize")
142
+ val borderRadius = value.getIntOr("borderRadius", 0)
143
+ val fontSize = value.getIntOrNull("fontSize")
150
144
  val fontFamily = getValOr(value, "fontFamily")
151
145
  val placeholderColor = getValOr(value, "placeholderColor", null)
152
146
  val textErrorColor = getValOr(value, "textErrorColor", null)
@@ -169,19 +163,19 @@ class CardFormView(
169
163
 
170
164
  textColor?.let {
171
165
  for (binding in editTextBindings) {
172
- binding.setTextColor(Color.parseColor(it))
166
+ binding.setTextColor(it.toColorInt())
173
167
  }
174
- cardFormViewBinding.countryLayout.countryAutocomplete.setTextColor(Color.parseColor(it))
168
+ cardFormViewBinding.countryLayout.countryAutocomplete.setTextColor(it.toColorInt())
175
169
  }
176
170
  textErrorColor?.let {
177
171
  for (binding in editTextBindings) {
178
- binding.setErrorColor(Color.parseColor(it))
179
- cardFormViewBinding.postalCode.setErrorColor(Color.parseColor(it))
172
+ binding.setErrorColor(it.toColorInt())
173
+ cardFormViewBinding.postalCode.setErrorColor(it.toColorInt())
180
174
  }
181
175
  }
182
176
  placeholderColor?.let {
183
177
  for (binding in placeholderTextBindings) {
184
- binding.defaultHintTextColor = ColorStateList.valueOf(Color.parseColor(it))
178
+ binding.defaultHintTextColor = ColorStateList.valueOf(it.toColorInt())
185
179
  }
186
180
  }
187
181
  fontSize?.let {
@@ -205,7 +199,7 @@ class CardFormView(
205
199
  }
206
200
  cursorColor?.let {
207
201
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
208
- val color = Color.parseColor(it)
202
+ val color = it.toColorInt()
209
203
  for (binding in editTextBindings) {
210
204
  binding.textCursorDrawable?.setTint(color)
211
205
  binding.textSelectHandle?.setTint(color)
@@ -224,16 +218,16 @@ class CardFormView(
224
218
  .build(),
225
219
  ).also { shape ->
226
220
  shape.strokeWidth = 0.0f
227
- shape.strokeColor = ColorStateList.valueOf(Color.parseColor("#000000"))
228
- shape.fillColor = ColorStateList.valueOf(Color.parseColor("#FFFFFF"))
221
+ shape.strokeColor = ColorStateList.valueOf("#000000".toColorInt())
222
+ shape.fillColor = ColorStateList.valueOf("#FFFFFF".toColorInt())
229
223
  borderWidth?.let {
230
224
  shape.strokeWidth = PixelUtil.toPixelFromDIP(it.toDouble())
231
225
  }
232
226
  borderColor?.let {
233
- shape.strokeColor = ColorStateList.valueOf(Color.parseColor(it))
227
+ shape.strokeColor = ColorStateList.valueOf(it.toColorInt())
234
228
  }
235
229
  backgroundColor?.let {
236
- shape.fillColor = ColorStateList.valueOf(Color.parseColor(it))
230
+ shape.fillColor = ColorStateList.valueOf(it.toColorInt())
237
231
  }
238
232
  }
239
233
  }
@@ -245,16 +239,18 @@ class CardFormView(
245
239
  private fun setListeners() {
246
240
  cardForm.setCardValidCallback { isValid, _ ->
247
241
  if (isValid) {
248
- cardForm.cardParams?.let {
242
+ cardForm.paymentMethodCreateParams?.let {
249
243
  val cardParamsMap = it.toParamMap()["card"] as HashMap<*, *>
244
+
245
+ @SuppressLint("RestrictedApi")
250
246
  val cardDetails: MutableMap<String, Any> =
251
247
  mutableMapOf(
252
248
  "expiryMonth" to cardParamsMap["exp_month"] as Int,
253
249
  "expiryYear" to cardParamsMap["exp_year"] as Int,
254
- "last4" to it.last4,
255
- "brand" to mapCardBrand(it.brand),
256
- "postalCode" to (it.address?.postalCode ?: ""),
257
- "country" to (it.address?.country ?: ""),
250
+ "last4" to (it.cardLast4() ?: ""),
251
+ "brand" to mapCardBrand(cardForm.brand),
252
+ "postalCode" to (it.billingDetails?.address?.postalCode ?: ""),
253
+ "country" to (it.billingDetails?.address?.country ?: ""),
258
254
  )
259
255
 
260
256
  if (dangerouslyGetFullCardDetails) {
@@ -277,8 +273,8 @@ class CardFormView(
277
273
  cardAddress =
278
274
  Address
279
275
  .Builder()
280
- .setPostalCode(it.address?.postalCode)
281
- .setCountry(it.address?.country)
276
+ .setPostalCode(it.billingDetails?.address?.postalCode)
277
+ .setCountry(it.billingDetails?.address?.country)
282
278
  .build()
283
279
 
284
280
  cardFormViewBinding.cardMultilineWidget.paymentMethodCard?.let { params ->
@@ -340,7 +336,7 @@ class CardFormView(
340
336
  )
341
337
  }
342
338
 
343
- @SuppressLint("RestrictedApi")
339
+ @SuppressLint("RestrictedApi", "VisibleForTests")
344
340
  private fun createPostalCodeInputFilter(): InputFilter {
345
341
  return InputFilter { charSequence, start, end, _, _, _ ->
346
342
  if (cardFormViewBinding.countryLayout.getSelectedCountryCode() == CountryCode.US) {
@@ -1,15 +1,16 @@
1
1
  package com.reactnativestripesdk
2
2
 
3
- import com.facebook.react.bridge.Promise
3
+ import android.annotation.SuppressLint
4
+ import androidx.activity.ComponentActivity
4
5
  import com.facebook.react.bridge.ReactApplicationContext
5
6
  import com.reactnativestripesdk.utils.ErrorType
6
- import com.reactnativestripesdk.utils.StripeFragment
7
+ import com.reactnativestripesdk.utils.StripeUIManager
7
8
  import com.reactnativestripesdk.utils.createError
8
9
  import com.reactnativestripesdk.utils.createResult
9
10
  import com.reactnativestripesdk.utils.mapFromFinancialConnectionsEvent
10
11
  import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
11
12
  import com.reactnativestripesdk.utils.mapFromSetupIntentResult
12
- import com.reactnativestripesdk.utils.removeFragment
13
+ import com.stripe.android.core.reactnative.ReactNativeSdkInternal
13
14
  import com.stripe.android.financialconnections.FinancialConnections
14
15
  import com.stripe.android.model.PaymentIntent
15
16
  import com.stripe.android.model.SetupIntent
@@ -18,18 +19,20 @@ import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
18
19
  import com.stripe.android.payments.bankaccount.CollectBankAccountLauncher
19
20
  import com.stripe.android.payments.bankaccount.navigation.CollectBankAccountResult
20
21
 
21
- class CollectBankAccountLauncherFragment : StripeFragment() {
22
- private lateinit var context: ReactApplicationContext
23
- private lateinit var publishableKey: String
24
- private var stripeAccountId: String? = null
25
- private lateinit var clientSecret: String
26
- private var isPaymentIntent: Boolean = false
27
- private lateinit var collectParams: CollectBankAccountConfiguration.USBankAccount
28
- private lateinit var promise: Promise
22
+ @OptIn(ReactNativeSdkInternal::class)
23
+ class CollectBankAccountLauncherManager(
24
+ context: ReactApplicationContext,
25
+ private val publishableKey: String,
26
+ private val stripeAccountId: String? = null,
27
+ private val clientSecret: String,
28
+ private val isPaymentIntent: Boolean,
29
+ private val collectParams: CollectBankAccountConfiguration.USBankAccount,
30
+ ) : StripeUIManager(context) {
29
31
  private lateinit var collectBankAccountLauncher: CollectBankAccountLauncher
30
32
 
31
- override fun prepare() {
32
- collectBankAccountLauncher = createBankAccountLauncher()
33
+ override fun onPresent() {
34
+ val activity = getCurrentActivityOrResolveWithError(promise) ?: return
35
+ collectBankAccountLauncher = createBankAccountLauncher(activity)
33
36
 
34
37
  val stripeSdkModule: StripeSdkModule? = context.getNativeModule(StripeSdkModule::class.java)
35
38
  if (stripeSdkModule != null) {
@@ -63,17 +66,18 @@ class CollectBankAccountLauncherFragment : StripeFragment() {
63
66
  FinancialConnections.clearEventListener()
64
67
  }
65
68
 
66
- private fun createBankAccountLauncher(): CollectBankAccountLauncher =
67
- CollectBankAccountLauncher.create(this) { result ->
69
+ private fun createBankAccountLauncher(activity: ComponentActivity): CollectBankAccountLauncher =
70
+ @SuppressLint("RestrictedApi")
71
+ CollectBankAccountLauncher.create(activity, signal) { result ->
68
72
  when (result) {
69
73
  is CollectBankAccountResult.Completed -> {
70
74
  val intent = result.response.intent
71
75
  if (intent.status === StripeIntent.Status.RequiresPaymentMethod) {
72
- promise.resolve(
76
+ promise?.resolve(
73
77
  createError(ErrorType.Canceled.toString(), "Bank account collection was canceled."),
74
78
  )
75
79
  } else if (intent.status === StripeIntent.Status.RequiresConfirmation) {
76
- promise.resolve(
80
+ promise?.resolve(
77
81
  if (isPaymentIntent) {
78
82
  createResult(
79
83
  "paymentIntent",
@@ -87,39 +91,14 @@ class CollectBankAccountLauncherFragment : StripeFragment() {
87
91
  }
88
92
 
89
93
  is CollectBankAccountResult.Cancelled -> {
90
- promise.resolve(
94
+ promise?.resolve(
91
95
  createError(ErrorType.Canceled.toString(), "Bank account collection was canceled."),
92
96
  )
93
97
  }
94
98
 
95
99
  is CollectBankAccountResult.Failed -> {
96
- promise.resolve(createError(ErrorType.Failed.toString(), result.error))
100
+ promise?.resolve(createError(ErrorType.Failed.toString(), result.error))
97
101
  }
98
102
  }
99
- removeFragment(context)
100
103
  }
101
-
102
- companion object {
103
- internal const val TAG = "collect_bank_account_launcher_fragment"
104
-
105
- fun create(
106
- context: ReactApplicationContext,
107
- publishableKey: String,
108
- stripeAccountId: String? = null,
109
- clientSecret: String,
110
- isPaymentIntent: Boolean,
111
- collectParams: CollectBankAccountConfiguration.USBankAccount,
112
- promise: Promise,
113
- ): CollectBankAccountLauncherFragment {
114
- val instance = CollectBankAccountLauncherFragment()
115
- instance.context = context
116
- instance.publishableKey = publishableKey
117
- instance.stripeAccountId = stripeAccountId
118
- instance.clientSecret = clientSecret
119
- instance.isPaymentIntent = isPaymentIntent
120
- instance.collectParams = collectParams
121
- instance.promise = promise
122
- return instance
123
- }
124
- }
125
104
  }
@@ -22,6 +22,7 @@ import java.lang.ref.WeakReference
22
22
  class CustomPaymentMethodActivity : ReactActivity() {
23
23
  override fun onCreate(savedInstanceState: Bundle?) {
24
24
  // Disable the transition animation to make it truly invisible
25
+ @Suppress("DEPRECATION")
25
26
  overridePendingTransition(0, 0)
26
27
  super.onCreate(savedInstanceState)
27
28
  }
@@ -53,6 +54,7 @@ class CustomPaymentMethodActivity : ReactActivity() {
53
54
  override fun finish() {
54
55
  super.finish()
55
56
  // Disable the exit animation as well
57
+ @Suppress("DEPRECATION")
56
58
  overridePendingTransition(0, 0)
57
59
 
58
60
  // Clear the weak reference when finished
@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.requiredHeight
9
9
  import androidx.compose.runtime.Composable
10
10
  import androidx.compose.runtime.LaunchedEffect
11
11
  import androidx.compose.runtime.getValue
12
- import androidx.compose.runtime.mutableIntStateOf
13
12
  import androidx.compose.runtime.mutableStateOf
14
13
  import androidx.compose.runtime.remember
15
14
  import androidx.compose.runtime.rememberCoroutineScope
@@ -22,7 +21,6 @@ import androidx.compose.ui.unit.IntOffset
22
21
  import androidx.compose.ui.unit.dp
23
22
  import com.facebook.react.bridge.Arguments
24
23
  import com.facebook.react.uimanager.ThemedReactContext
25
- import com.reactnativestripesdk.toWritableMap
26
24
  import com.reactnativestripesdk.utils.KeepJsAwakeTask
27
25
  import com.reactnativestripesdk.utils.mapFromConfirmationToken
28
26
  import com.reactnativestripesdk.utils.mapFromCustomPaymentMethod
@@ -196,7 +194,7 @@ class EmbeddedPaymentElementView(
196
194
  val stripeSdkModule =
197
195
  try {
198
196
  requireStripeSdkModule()
199
- } catch (ex: IllegalArgumentException) {
197
+ } catch (_: IllegalArgumentException) {
200
198
  return@Builder CreateIntentResult.Failure(
201
199
  cause =
202
200
  Exception(
@@ -242,7 +240,7 @@ class EmbeddedPaymentElementView(
242
240
  val stripeSdkModule =
243
241
  try {
244
242
  requireStripeSdkModule()
245
- } catch (ex: IllegalArgumentException) {
243
+ } catch (_: IllegalArgumentException) {
246
244
  return@Builder CreateIntentResult.Failure(
247
245
  cause =
248
246
  Exception(
@@ -295,9 +293,6 @@ class EmbeddedPaymentElementView(
295
293
  }
296
294
 
297
295
  val embedded = rememberEmbeddedPaymentElement(builder)
298
- var height by remember {
299
- mutableIntStateOf(0)
300
- }
301
296
 
302
297
  // collect events: configure, confirm, clear
303
298
  LaunchedEffect(Unit) {
@@ -348,10 +343,8 @@ class EmbeddedPaymentElementView(
348
343
  }
349
344
  }
350
345
 
351
- val density = LocalDensity.current
352
-
353
346
  Box {
354
- measuredEmbeddedElement(
347
+ MeasuredEmbeddedElement(
355
348
  reportHeightChange = { h -> reportHeightChange(h) },
356
349
  ) {
357
350
  embedded.Content()
@@ -360,7 +353,7 @@ class EmbeddedPaymentElementView(
360
353
  }
361
354
 
362
355
  @Composable
363
- private fun measuredEmbeddedElement(
356
+ private fun MeasuredEmbeddedElement(
364
357
  reportHeightChange: (Float) -> Unit,
365
358
  content: @Composable () -> Unit,
366
359
  ) {
@@ -3,24 +3,22 @@ package com.reactnativestripesdk
3
3
  import android.annotation.SuppressLint
4
4
  import android.content.Context
5
5
  import com.facebook.react.bridge.Dynamic
6
- import com.facebook.react.bridge.ReadableArray
7
6
  import com.facebook.react.bridge.ReadableMap
8
- import com.facebook.react.bridge.ReadableType
9
7
  import com.facebook.react.module.annotations.ReactModule
10
8
  import com.facebook.react.uimanager.ThemedReactContext
11
9
  import com.facebook.react.uimanager.ViewGroupManager
12
10
  import com.facebook.react.uimanager.annotations.ReactProp
13
11
  import com.facebook.react.viewmanagers.EmbeddedPaymentElementViewManagerDelegate
14
12
  import com.facebook.react.viewmanagers.EmbeddedPaymentElementViewManagerInterface
15
- import com.reactnativestripesdk.PaymentSheetFragment.Companion.buildCustomerConfiguration
16
- import com.reactnativestripesdk.PaymentSheetFragment.Companion.buildGooglePayConfig
17
13
  import com.reactnativestripesdk.addresssheet.AddressSheetView
18
14
  import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
19
15
  import com.reactnativestripesdk.utils.PaymentSheetException
16
+ import com.reactnativestripesdk.utils.asMapOrNull
20
17
  import com.reactnativestripesdk.utils.getBooleanOr
18
+ import com.reactnativestripesdk.utils.getIntegerList
19
+ import com.reactnativestripesdk.utils.getStringList
21
20
  import com.reactnativestripesdk.utils.mapToPreferredNetworks
22
21
  import com.reactnativestripesdk.utils.parseCustomPaymentMethods
23
- import com.reactnativestripesdk.utils.toBundleObject
24
22
  import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi
25
23
  import com.stripe.android.paymentelement.EmbeddedPaymentElement
26
24
  import com.stripe.android.paymentelement.ExperimentalCustomPaymentMethodsApi
@@ -55,10 +53,10 @@ class EmbeddedPaymentElementViewManager :
55
53
  view: EmbeddedPaymentElementView,
56
54
  cfg: Dynamic,
57
55
  ) {
58
- val readableMap = cfg.asMap()
56
+ val readableMap = cfg.asMapOrNull()
59
57
  if (readableMap == null) return
60
58
 
61
- val rowSelectionBehaviorType = parseRowSelectionBehavior(readableMap)
59
+ val rowSelectionBehaviorType = mapToRowSelectionBehaviorType(readableMap)
62
60
  view.rowSelectionBehaviorType.value = rowSelectionBehaviorType
63
61
 
64
62
  val elementConfig = parseElementConfiguration(readableMap, view.context)
@@ -78,7 +76,7 @@ class EmbeddedPaymentElementViewManager :
78
76
  view: EmbeddedPaymentElementView,
79
77
  cfg: Dynamic,
80
78
  ) {
81
- val readableMap = cfg.asMap()
79
+ val readableMap = cfg.asMapOrNull()
82
80
  if (readableMap == null) return
83
81
 
84
82
  // Detect which callback type to use based on the presence of the confirmation token handler
@@ -102,91 +100,43 @@ class EmbeddedPaymentElementViewManager :
102
100
  context: Context,
103
101
  ): EmbeddedPaymentElement.Configuration {
104
102
  val merchantDisplayName = map.getString("merchantDisplayName").orEmpty()
105
- val allowsDelayedPaymentMethods: Boolean =
106
- if (map.hasKey("allowsDelayedPaymentMethods") &&
107
- map.getType("allowsDelayedPaymentMethods") == ReadableType.Boolean
108
- ) {
109
- map.getBoolean("allowsDelayedPaymentMethods")
110
- } else {
111
- false // default
112
- }
113
- var defaultBillingDetails: PaymentSheet.BillingDetails? = null
114
- val billingDetailsMap = map.getMap("defaultBillingDetails")
115
- if (billingDetailsMap != null) {
116
- val addressBundle = billingDetailsMap.getMap("address")
117
- val address =
118
- PaymentSheet.Address(
119
- addressBundle?.getString("city"),
120
- addressBundle?.getString("country"),
121
- addressBundle?.getString("line1"),
122
- addressBundle?.getString("line2"),
123
- addressBundle?.getString("postalCode"),
124
- addressBundle?.getString("state"),
125
- )
126
- defaultBillingDetails =
127
- PaymentSheet.BillingDetails(
128
- address,
129
- billingDetailsMap.getString("email"),
130
- billingDetailsMap.getString("name"),
131
- billingDetailsMap.getString("phone"),
132
- )
133
- }
103
+ val allowsDelayedPaymentMethods = map.getBooleanOr("allowsDelayedPaymentMethods", false)
104
+ val defaultBillingDetails = buildBillingDetails(map.getMap("defaultBillingDetails"))
134
105
 
135
106
  val customerConfiguration =
136
107
  try {
137
- buildCustomerConfiguration(toBundleObject(map))
138
- } catch (error: PaymentSheetException) {
108
+ buildCustomerConfiguration(map)
109
+ } catch (_: PaymentSheetException) {
139
110
  throw Error() // TODO handle error
140
111
  }
141
112
 
142
- val googlePayConfig = buildGooglePayConfig(toBundleObject(map.getMap("googlePay")))
143
- val linkConfig = PaymentSheetFragment.buildLinkConfig(toBundleObject(map.getMap("link")))
113
+ val googlePayConfig = buildGooglePayConfig(map.getMap("googlePay"))
114
+ val linkConfig = buildLinkConfig(map.getMap("link"))
144
115
  val shippingDetails =
145
116
  map.getMap("defaultShippingDetails")?.let {
146
117
  AddressSheetView.buildAddressDetails(it)
147
118
  }
148
119
  val appearance =
149
120
  try {
150
- buildPaymentSheetAppearance(toBundleObject(map.getMap("appearance")), context)
151
- } catch (error: PaymentSheetAppearanceException) {
121
+ buildPaymentSheetAppearance(map.getMap("appearance"), context)
122
+ } catch (_: PaymentSheetAppearanceException) {
152
123
  throw Error() // TODO handle error
153
124
  }
154
- val billingConfigParams = map.getMap("billingDetailsCollectionConfiguration")
155
125
  val billingDetailsConfig =
156
- PaymentSheet.BillingDetailsCollectionConfiguration(
157
- name = mapToCollectionMode(billingConfigParams?.getString("name")),
158
- phone = mapToCollectionMode(billingConfigParams?.getString("phone")),
159
- email = mapToCollectionMode(billingConfigParams?.getString("email")),
160
- address = mapToAddressCollectionMode(billingConfigParams?.getString("address")),
161
- attachDefaultsToPaymentMethod =
162
- billingConfigParams?.getBooleanOr("attachDefaultsToPaymentMethod", false) ?: false,
126
+ buildBillingDetailsCollectionConfiguration(
127
+ map.getMap("billingDetailsCollectionConfiguration"),
163
128
  )
164
- val allowsRemovalOfLastSavedPaymentMethod =
165
- if (map.hasKey("allowsRemovalOfLastSavedPaymentMethod")) {
166
- map.getBoolean("allowsRemovalOfLastSavedPaymentMethod")
167
- } else {
168
- true
169
- }
129
+ val allowsRemovalOfLastSavedPaymentMethod = map.getBooleanOr("allowsRemovalOfLastSavedPaymentMethod", true)
170
130
  val primaryButtonLabel = map.getString("primaryButtonLabel")
171
- val paymentMethodOrder = map.getStringArrayList("paymentMethodOrder")
131
+ val paymentMethodOrder = map.getStringList("paymentMethodOrder")
172
132
 
173
- val formSheetAction =
174
- map
175
- .getMap("formSheetAction")
176
- ?.getString("type")
177
- ?.let { type ->
178
- when (type) {
179
- "confirm" -> EmbeddedPaymentElement.FormSheetAction.Confirm
180
- else -> EmbeddedPaymentElement.FormSheetAction.Continue
181
- }
182
- }
183
- ?: EmbeddedPaymentElement.FormSheetAction.Continue
133
+ val formSheetAction = mapToFormSheetAction(map)
184
134
 
185
135
  val configurationBuilder =
186
136
  EmbeddedPaymentElement.Configuration
187
137
  .Builder(merchantDisplayName)
188
138
  .formSheetAction(formSheetAction)
189
- .allowsDelayedPaymentMethods(allowsDelayedPaymentMethods ?: false)
139
+ .allowsDelayedPaymentMethods(allowsDelayedPaymentMethods)
190
140
  .defaultBillingDetails(defaultBillingDetails)
191
141
  .customer(customerConfiguration)
192
142
  .googlePay(googlePayConfig)
@@ -197,28 +147,16 @@ class EmbeddedPaymentElementViewManager :
197
147
  .preferredNetworks(
198
148
  mapToPreferredNetworks(
199
149
  map
200
- .getIntegerArrayList("preferredNetworks")
150
+ .getIntegerList("preferredNetworks")
201
151
  ?.let { ArrayList(it) },
202
152
  ),
203
153
  ).allowsRemovalOfLastSavedPaymentMethod(allowsRemovalOfLastSavedPaymentMethod)
204
- .cardBrandAcceptance(mapToCardBrandAcceptance(toBundleObject(map)))
154
+ .cardBrandAcceptance(mapToCardBrandAcceptance(map))
205
155
  .embeddedViewDisplaysMandateText(
206
- if (map.hasKey("embeddedViewDisplaysMandateText") &&
207
- map.getType("embeddedViewDisplaysMandateText") == ReadableType.Boolean
208
- ) {
209
- map.getBoolean("embeddedViewDisplaysMandateText")
210
- } else {
211
- true // default value
212
- },
213
- )
214
- // Serialize original ReadableMap because toBundleObject cannot keep arrays of objects
215
- .customPaymentMethods(
156
+ map.getBooleanOr("embeddedViewDisplaysMandateText", true),
157
+ ).customPaymentMethods(
216
158
  parseCustomPaymentMethods(
217
- toBundleObject(map.getMap("customPaymentMethodConfiguration")).apply {
218
- map.getMap("customPaymentMethodConfiguration")?.let { readable ->
219
- putSerializable("customPaymentMethodConfigurationReadableMap", readable.toHashMap())
220
- }
221
- },
159
+ map.getMap("customPaymentMethodConfiguration"),
222
160
  ),
223
161
  )
224
162
 
@@ -228,23 +166,8 @@ class EmbeddedPaymentElementViewManager :
228
166
  return configurationBuilder.build()
229
167
  }
230
168
 
231
- private fun parseRowSelectionBehavior(map: ReadableMap): RowSelectionBehaviorType {
232
- val rowSelectionBehavior =
233
- map
234
- .getMap("rowSelectionBehavior")
235
- ?.getString("type")
236
- ?.let { type ->
237
- when (type) {
238
- "immediateAction" -> RowSelectionBehaviorType.ImmediateAction
239
- else -> RowSelectionBehaviorType.Default
240
- }
241
- }
242
- ?: RowSelectionBehaviorType.Default
243
- return rowSelectionBehavior
244
- }
245
-
246
169
  private fun parseIntentConfiguration(map: ReadableMap): PaymentSheet.IntentConfiguration {
247
- val intentConfig = PaymentSheetFragment.buildIntentConfiguration(toBundleObject(map))
170
+ val intentConfig = buildIntentConfiguration(map)
248
171
  return intentConfig ?: throw IllegalArgumentException("IntentConfiguration is null")
249
172
  }
250
173
 
@@ -257,35 +180,32 @@ class EmbeddedPaymentElementViewManager :
257
180
  }
258
181
  }
259
182
 
260
- /**
261
- * Returns a List of Strings if the key exists and points to an array of strings, or null otherwise.
262
- */
263
- fun ReadableMap.getStringArrayList(key: String): List<String>? {
264
- if (!hasKey(key) || getType(key) != ReadableType.Array) return null
265
- val array: ReadableArray = getArray(key) ?: return null
266
-
267
- val result = mutableListOf<String>()
268
- for (i in 0 until array.size()) {
269
- // getString returns null if the element isn't actually a string
270
- array.getString(i)?.let { result.add(it) }
271
- }
272
- return result
183
+ internal fun mapToRowSelectionBehaviorType(map: ReadableMap?): RowSelectionBehaviorType {
184
+ val rowSelectionBehavior =
185
+ map
186
+ ?.getMap("rowSelectionBehavior")
187
+ ?.getString("type")
188
+ ?.let { type ->
189
+ when (type) {
190
+ "immediateAction" -> RowSelectionBehaviorType.ImmediateAction
191
+ else -> RowSelectionBehaviorType.Default
192
+ }
193
+ }
194
+ ?: RowSelectionBehaviorType.Default
195
+ return rowSelectionBehavior
273
196
  }
274
197
 
275
- /**
276
- * Returns a List of Ints if the key exists and points to an array of numbers, or null otherwise.
277
- */
278
- fun ReadableMap.getIntegerArrayList(key: String): List<Int>? {
279
- if (!hasKey(key) || getType(key) != ReadableType.Array) return null
280
- val array: ReadableArray = getArray(key) ?: return null
281
-
282
- val result = mutableListOf<Int>()
283
- for (i in 0 until array.size()) {
284
- // getType check to skip non-number entries
285
- if (array.getType(i) == ReadableType.Number) {
286
- // if it's actually a float/double, this will truncate; adjust as needed
287
- result.add(array.getInt(i))
288
- }
289
- }
290
- return result
198
+ internal fun mapToFormSheetAction(map: ReadableMap?): EmbeddedPaymentElement.FormSheetAction {
199
+ val formSheetAction =
200
+ map
201
+ ?.getMap("formSheetAction")
202
+ ?.getString("type")
203
+ ?.let { type ->
204
+ when (type) {
205
+ "confirm" -> EmbeddedPaymentElement.FormSheetAction.Confirm
206
+ else -> EmbeddedPaymentElement.FormSheetAction.Continue
207
+ }
208
+ }
209
+ ?: EmbeddedPaymentElement.FormSheetAction.Continue
210
+ return formSheetAction
291
211
  }
@@ -32,10 +32,6 @@ class EventEmitterCompat(
32
32
  invoke("onFinancialConnectionsEvent", value)
33
33
  }
34
34
 
35
- fun emitOnOrderTrackingCallback() {
36
- invoke("onOrderTrackingCallback")
37
- }
38
-
39
35
  fun emitOnCustomerAdapterFetchPaymentMethodsCallback() {
40
36
  invoke("onCustomerAdapterFetchPaymentMethodsCallback")
41
37
  }
@@ -72,10 +68,6 @@ class EventEmitterCompat(
72
68
  invoke("embeddedPaymentElementDidUpdateHeight", value)
73
69
  }
74
70
 
75
- fun emitEmbeddedPaymentElementWillPresent() {
76
- invoke("embeddedPaymentElementWillPresent")
77
- }
78
-
79
71
  fun emitEmbeddedPaymentElementDidUpdatePaymentOption(value: ReadableMap?) {
80
72
  invoke("embeddedPaymentElementDidUpdatePaymentOption", value)
81
73
  }