@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
@@ -7,6 +7,7 @@ import android.content.Intent
7
7
  import android.os.Bundle
8
8
  import android.util.Log
9
9
  import android.view.ViewGroup
10
+ import androidx.browser.customtabs.CustomTabsIntent
10
11
  import androidx.fragment.app.FragmentActivity
11
12
  import com.facebook.react.ReactActivity
12
13
  import com.facebook.react.bridge.Arguments
@@ -18,23 +19,23 @@ import com.facebook.react.bridge.ReadableArray
18
19
  import com.facebook.react.bridge.ReadableMap
19
20
  import com.facebook.react.bridge.UiThreadUtil
20
21
  import com.facebook.react.bridge.WritableMap
21
- import com.facebook.react.bridge.WritableNativeMap
22
22
  import com.facebook.react.module.annotations.ReactModule
23
- import com.reactnativestripesdk.addresssheet.AddressLauncherFragment
24
- import com.reactnativestripesdk.customersheet.CustomerSheetFragment
23
+ import com.reactnativestripesdk.addresssheet.AddressLauncherManager
24
+ import com.reactnativestripesdk.customersheet.CustomerSheetManager
25
25
  import com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy
26
26
  import com.reactnativestripesdk.utils.ConfirmPaymentErrorType
27
27
  import com.reactnativestripesdk.utils.CreateTokenErrorType
28
28
  import com.reactnativestripesdk.utils.ErrorType
29
29
  import com.reactnativestripesdk.utils.GooglePayErrorType
30
+ import com.reactnativestripesdk.utils.StripeUIManager
30
31
  import com.reactnativestripesdk.utils.createCanAddCardResult
31
32
  import com.reactnativestripesdk.utils.createError
32
33
  import com.reactnativestripesdk.utils.createMissingActivityError
33
34
  import com.reactnativestripesdk.utils.createMissingInitError
34
35
  import com.reactnativestripesdk.utils.createResult
35
36
  import com.reactnativestripesdk.utils.getBooleanOr
36
- import com.reactnativestripesdk.utils.getBooleanOrFalse
37
- import com.reactnativestripesdk.utils.getMapOrNull
37
+ import com.reactnativestripesdk.utils.getIntOrNull
38
+ import com.reactnativestripesdk.utils.getLongOrNull
38
39
  import com.reactnativestripesdk.utils.getValOr
39
40
  import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
40
41
  import com.reactnativestripesdk.utils.mapFromPaymentMethod
@@ -46,8 +47,6 @@ import com.reactnativestripesdk.utils.mapToPaymentMethodType
46
47
  import com.reactnativestripesdk.utils.mapToReturnURL
47
48
  import com.reactnativestripesdk.utils.mapToShippingDetails
48
49
  import com.reactnativestripesdk.utils.mapToUICustomization
49
- import com.reactnativestripesdk.utils.removeFragment
50
- import com.reactnativestripesdk.utils.toBundleObject
51
50
  import com.stripe.android.ApiResultCallback
52
51
  import com.stripe.android.GooglePayJsonFactory
53
52
  import com.stripe.android.PaymentAuthConfig
@@ -55,6 +54,7 @@ import com.stripe.android.PaymentConfiguration
55
54
  import com.stripe.android.Stripe
56
55
  import com.stripe.android.core.ApiVersion
57
56
  import com.stripe.android.core.AppInfo
57
+ import com.stripe.android.core.reactnative.ReactNativeSdkInternal
58
58
  import com.stripe.android.customersheet.CustomerSheet
59
59
  import com.stripe.android.googlepaylauncher.GooglePayLauncher
60
60
  import com.stripe.android.model.BankAccountTokenParams
@@ -66,7 +66,6 @@ import com.stripe.android.model.PaymentMethod
66
66
  import com.stripe.android.model.SetupIntent
67
67
  import com.stripe.android.model.Token
68
68
  import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
69
- import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi
70
69
  import com.stripe.android.paymentsheet.PaymentSheet
71
70
  import kotlinx.coroutines.CompletableDeferred
72
71
  import kotlinx.coroutines.CoroutineScope
@@ -75,6 +74,7 @@ import kotlinx.coroutines.launch
75
74
  import org.json.JSONObject
76
75
 
77
76
  @ReactModule(name = StripeSdkModule.NAME)
77
+ @OptIn(ReactNativeSdkInternal::class)
78
78
  class StripeSdkModule(
79
79
  reactContext: ReactApplicationContext,
80
80
  ) : NativeStripeSdkModuleSpec(reactContext) {
@@ -89,11 +89,15 @@ class StripeSdkModule(
89
89
  private var createPlatformPayPaymentMethodPromise: Promise? = null
90
90
  private var platformPayUsesDeprecatedTokenFlow = false
91
91
 
92
- private var paymentSheetFragment: PaymentSheetFragment? = null
93
- private var paymentLauncherFragment: PaymentLauncherFragment? = null
94
- private var collectBankAccountLauncherFragment: CollectBankAccountLauncherFragment? = null
92
+ private val stripeUIManagers = mutableListOf<StripeUIManager>()
93
+ private var paymentSheetManager: PaymentSheetManager? = null
94
+ private var paymentLauncherManager: PaymentLauncherManager? = null
95
+ private var collectBankAccountLauncherManager: CollectBankAccountLauncherManager? = null
96
+ private var financialConnectionsSheetManager: FinancialConnectionsSheetManager? = null
97
+ private var googlePayLauncherManager: GooglePayLauncherManager? = null
98
+ private var googlePayPaymentMethodLauncherManager: GooglePayPaymentMethodLauncherManager? = null
95
99
 
96
- private var customerSheetFragment: CustomerSheetFragment? = null
100
+ private var customerSheetManager: CustomerSheetManager? = null
97
101
 
98
102
  internal var embeddedIntentCreationCallback = CompletableDeferred<ReadableMap>()
99
103
  internal var embeddedConfirmationTokenCreationCallback = CompletableDeferred<ReadableMap>()
@@ -104,20 +108,6 @@ class StripeSdkModule(
104
108
 
105
109
  val eventEmitter: EventEmitterCompat by lazy { EventEmitterCompat(reactApplicationContext) }
106
110
 
107
- // If you create a new Fragment, you must put the tag here, otherwise result callbacks for that
108
- // Fragment will not work on RN < 0.65
109
- private val allStripeFragmentTags: List<String>
110
- get() =
111
- listOf(
112
- PaymentSheetFragment.TAG,
113
- PaymentLauncherFragment.TAG,
114
- CollectBankAccountLauncherFragment.TAG,
115
- FinancialConnectionsSheetFragment.TAG,
116
- AddressLauncherFragment.TAG,
117
- GooglePayLauncherFragment.TAG,
118
- CustomerSheetFragment.TAG,
119
- )
120
-
121
111
  private val mActivityEventListener =
122
112
  object : BaseActivityEventListener() {
123
113
  override fun onActivityResult(
@@ -145,10 +135,6 @@ class StripeSdkModule(
145
135
  )
146
136
  }
147
137
  }
148
-
149
- else -> {
150
- dispatchActivityResultsToFragments(requestCode, resultCode, data)
151
- }
152
138
  }
153
139
  }
154
140
  }
@@ -158,24 +144,27 @@ class StripeSdkModule(
158
144
  reactContext.addActivityEventListener(mActivityEventListener)
159
145
  }
160
146
 
161
- // Necessary on older versions of React Native (~0.65 and below)
162
- private fun dispatchActivityResultsToFragments(
163
- requestCode: Int,
164
- resultCode: Int,
165
- data: Intent?,
166
- ) {
167
- getCurrentActivityOrResolveWithError(null)?.supportFragmentManager?.let { fragmentManager ->
168
- for (tag in allStripeFragmentTags) {
169
- fragmentManager.findFragmentByTag(tag)?.let {
170
- it.activity?.activityResultRegistry?.dispatchResult(requestCode, resultCode, data)
171
- }
172
- }
173
- }
147
+ override fun invalidate() {
148
+ super.invalidate()
149
+
150
+ stripeUIManagers.forEach { it.destroy() }
151
+ stripeUIManagers.clear()
152
+ }
153
+
154
+ private fun registerStripeUIManager(uiManager: StripeUIManager) {
155
+ uiManager.create()
156
+ stripeUIManagers.add(uiManager)
157
+ }
158
+
159
+ private fun unregisterStripeUIManager(uiManager: StripeUIManager?) {
160
+ val uiManager = uiManager ?: return
161
+ uiManager.destroy()
162
+ stripeUIManagers.remove(uiManager)
174
163
  }
175
164
 
176
165
  private fun configure3dSecure(params: ReadableMap) {
177
166
  val stripe3dsConfigBuilder = PaymentAuthConfig.Stripe3ds2Config.Builder()
178
- if (params.hasKey("timeout")) stripe3dsConfigBuilder.setTimeout(params.getInt("timeout"))
167
+ params.getIntOrNull("timeout")?.let { stripe3dsConfigBuilder.setTimeout(it) }
179
168
  val uiCustomization = mapToUICustomization(params)
180
169
 
181
170
  PaymentAuthConfig.init(
@@ -205,18 +194,18 @@ class StripeSdkModule(
205
194
  promise: Promise,
206
195
  ) {
207
196
  val publishableKey = getValOr(params, "publishableKey", null) as String
208
- val appInfo = getMapOrNull(params, "appInfo") as ReadableMap
197
+ val appInfo = params.getMap("appInfo") as ReadableMap
209
198
  this.stripeAccountId = getValOr(params, "stripeAccountId", null)
210
199
  val urlScheme = getValOr(params, "urlScheme", null)
211
- val setReturnUrlSchemeOnAndroid = getBooleanOrFalse(params, "setReturnUrlSchemeOnAndroid")
200
+ val setReturnUrlSchemeOnAndroid = params.getBooleanOr("setReturnUrlSchemeOnAndroid", false)
212
201
  this.urlScheme = if (setReturnUrlSchemeOnAndroid) urlScheme else null
213
202
 
214
- getMapOrNull(params, "threeDSecureParams")?.let {
203
+ params.getMap("threeDSecureParams")?.let {
215
204
  configure3dSecure(it)
216
205
  }
217
206
 
218
207
  this.publishableKey = publishableKey
219
- AddressLauncherFragment.publishableKey = publishableKey
208
+ AddressLauncherManager.publishableKey = publishableKey
220
209
 
221
210
  val name = getValOr(appInfo, "name", "") as String
222
211
  val partnerId = getValOr(appInfo, "partnerId", "")
@@ -239,28 +228,11 @@ class StripeSdkModule(
239
228
  params: ReadableMap,
240
229
  promise: Promise,
241
230
  ) {
242
- getCurrentActivityOrResolveWithError(promise)?.let { activity ->
243
- paymentSheetFragment?.removeFragment(reactApplicationContext)
244
- val bundle = toBundleObject(params)
245
-
246
- // Handle custom payment methods separately since toBundleObject cannot handle arrays of objects
247
- val customPaymentMethodConfig = params.getMap("customPaymentMethodConfiguration")
248
- if (customPaymentMethodConfig != null) {
249
- // Store the original ReadableMap for custom payment methods
250
- bundle.putSerializable("customPaymentMethodConfigurationReadableMap", customPaymentMethodConfig.toHashMap())
231
+ unregisterStripeUIManager(paymentSheetManager)
232
+ paymentSheetManager =
233
+ PaymentSheetManager(reactApplicationContext, params, promise).also {
234
+ registerStripeUIManager(it)
251
235
  }
252
-
253
- paymentSheetFragment =
254
- PaymentSheetFragment.create(reactApplicationContext, bundle, promise)
255
- try {
256
- activity.supportFragmentManager
257
- .beginTransaction()
258
- .add(paymentSheetFragment!!, PaymentSheetFragment.TAG)
259
- .commit()
260
- } catch (error: IllegalStateException) {
261
- promise.resolve(createError(ErrorType.Failed.toString(), error.message))
262
- }
263
- }
264
236
  }
265
237
 
266
238
  @ReactMethod
@@ -268,30 +240,30 @@ class StripeSdkModule(
268
240
  options: ReadableMap,
269
241
  promise: Promise,
270
242
  ) {
271
- if (paymentSheetFragment == null) {
272
- promise.resolve(PaymentSheetFragment.createMissingInitError())
243
+ if (paymentSheetManager == null) {
244
+ promise.resolve(PaymentSheetManager.createMissingInitError())
273
245
  return
274
246
  }
275
247
 
276
- val timeoutKey = "timeout"
277
- if (options.hasKey(timeoutKey)) {
278
- paymentSheetFragment?.presentWithTimeout(
279
- options.getInt(timeoutKey).toLong(),
248
+ val timeout = options.getLongOrNull("timeout")
249
+ if (timeout != null) {
250
+ paymentSheetManager?.presentWithTimeout(
251
+ timeout,
280
252
  promise,
281
253
  )
282
254
  } else {
283
- paymentSheetFragment?.present(promise)
255
+ paymentSheetManager?.present(promise)
284
256
  }
285
257
  }
286
258
 
287
259
  @ReactMethod
288
260
  override fun confirmPaymentSheetPayment(promise: Promise) {
289
- if (paymentSheetFragment == null) {
290
- promise.resolve(PaymentSheetFragment.createMissingInitError())
261
+ if (paymentSheetManager == null) {
262
+ promise.resolve(PaymentSheetManager.createMissingInitError())
291
263
  return
292
264
  }
293
265
 
294
- paymentSheetFragment?.confirmPayment(promise)
266
+ paymentSheetManager?.confirmPayment(promise)
295
267
  }
296
268
 
297
269
  @ReactMethod
@@ -307,12 +279,12 @@ class StripeSdkModule(
307
279
  ) {
308
280
  embeddedIntentCreationCallback.complete(params)
309
281
 
310
- if (paymentSheetFragment == null) {
311
- promise.resolve(PaymentSheetFragment.createMissingInitError())
282
+ if (paymentSheetManager == null) {
283
+ promise.resolve(PaymentSheetManager.createMissingInitError())
312
284
  return
313
285
  }
314
286
 
315
- paymentSheetFragment?.paymentSheetIntentCreationCallback?.complete(params)
287
+ paymentSheetManager?.paymentSheetIntentCreationCallback?.complete(params)
316
288
  }
317
289
 
318
290
  @ReactMethod
@@ -335,12 +307,12 @@ class StripeSdkModule(
335
307
  embeddedConfirmationTokenCreationCallback.complete(params)
336
308
  paymentSheetConfirmationTokenCreationCallback.complete(params)
337
309
 
338
- if (paymentSheetFragment == null) {
339
- promise.resolve(PaymentSheetFragment.createMissingInitError())
310
+ if (paymentSheetManager == null) {
311
+ promise.resolve(PaymentSheetManager.createMissingInitError())
340
312
  return
341
313
  }
342
314
 
343
- paymentSheetFragment?.paymentSheetConfirmationTokenCreationCallback?.complete(params)
315
+ paymentSheetManager?.paymentSheetConfirmationTokenCreationCallback?.complete(params)
344
316
  }
345
317
 
346
318
  @ReactMethod
@@ -359,7 +331,7 @@ class StripeSdkModule(
359
331
  )
360
332
  return
361
333
  }
362
- val paymentMethodData = getMapOrNull(data, "paymentMethodData")
334
+ val paymentMethodData = data.getMap("paymentMethodData")
363
335
  val factory =
364
336
  PaymentMethodCreateParamsFactory(paymentMethodData, options, cardFieldView, cardFormView)
365
337
  try {
@@ -494,7 +466,7 @@ class StripeSdkModule(
494
466
  }
495
467
 
496
468
  val cardAddress = cardFieldView?.cardAddress ?: cardFormView?.cardAddress
497
- val address = getMapOrNull(params, "address")
469
+ val address = params.getMap("address")
498
470
  val cardParams =
499
471
  CardParams(
500
472
  number = cardParamsMap["number"] as String,
@@ -531,7 +503,7 @@ class StripeSdkModule(
531
503
  object : ApiResultCallback<Token> {
532
504
  override fun onSuccess(result: Token) {
533
505
  val tokenId = result.id
534
- val res = WritableNativeMap()
506
+ val res = Arguments.createMap()
535
507
  res.putString("tokenId", tokenId)
536
508
  promise.resolve(res)
537
509
  }
@@ -549,15 +521,19 @@ class StripeSdkModule(
549
521
  returnUrl: String?,
550
522
  promise: Promise,
551
523
  ) {
552
- paymentLauncherFragment =
553
- PaymentLauncherFragment.forNextActionPayment(
554
- context = reactApplicationContext,
555
- stripe,
556
- publishableKey,
557
- stripeAccountId,
558
- promise,
559
- paymentIntentClientSecret,
560
- )
524
+ unregisterStripeUIManager(paymentSheetManager)
525
+ paymentLauncherManager =
526
+ PaymentLauncherManager
527
+ .forNextActionPayment(
528
+ context = reactApplicationContext,
529
+ stripe,
530
+ publishableKey,
531
+ stripeAccountId,
532
+ paymentIntentClientSecret,
533
+ ).also {
534
+ registerStripeUIManager(it)
535
+ it.present(promise)
536
+ }
561
537
  }
562
538
 
563
539
  @ReactMethod
@@ -566,15 +542,19 @@ class StripeSdkModule(
566
542
  returnUrl: String?,
567
543
  promise: Promise,
568
544
  ) {
569
- paymentLauncherFragment =
570
- PaymentLauncherFragment.forNextActionSetup(
571
- context = reactApplicationContext,
572
- stripe,
573
- publishableKey,
574
- stripeAccountId,
575
- promise,
576
- setupIntentClientSecret,
577
- )
545
+ unregisterStripeUIManager(paymentLauncherManager)
546
+ paymentLauncherManager =
547
+ PaymentLauncherManager
548
+ .forNextActionSetup(
549
+ context = reactApplicationContext,
550
+ stripe,
551
+ publishableKey,
552
+ stripeAccountId,
553
+ setupIntentClientSecret,
554
+ ).also {
555
+ registerStripeUIManager(it)
556
+ it.present(promise)
557
+ }
578
558
  }
579
559
 
580
560
  // TODO: Uncomment when WeChat is re-enabled in stripe-ios
@@ -603,7 +583,7 @@ class StripeSdkModule(
603
583
  options: ReadableMap?,
604
584
  promise: Promise,
605
585
  ) {
606
- val paymentMethodData = getMapOrNull(params, "paymentMethodData")
586
+ val paymentMethodData = params?.getMap("paymentMethodData")
607
587
  val paymentMethodType =
608
588
  if (params != null) {
609
589
  mapToPaymentMethodType(params.getString("paymentMethodType")) ?: run {
@@ -643,17 +623,21 @@ class StripeSdkModule(
643
623
  confirmParams.returnUrl = mapToReturnURL(urlScheme)
644
624
  }
645
625
  confirmParams.shipping =
646
- mapToShippingDetails(getMapOrNull(paymentMethodData, "shippingDetails"))
647
- paymentLauncherFragment =
648
- PaymentLauncherFragment.forPayment(
649
- context = reactApplicationContext,
650
- stripe,
651
- publishableKey,
652
- stripeAccountId,
653
- promise,
654
- paymentIntentClientSecret,
655
- confirmParams,
656
- )
626
+ mapToShippingDetails(paymentMethodData?.getMap("shippingDetails"))
627
+ unregisterStripeUIManager(paymentLauncherManager)
628
+ paymentLauncherManager =
629
+ PaymentLauncherManager
630
+ .forPayment(
631
+ context = reactApplicationContext,
632
+ stripe,
633
+ publishableKey,
634
+ stripeAccountId,
635
+ paymentIntentClientSecret,
636
+ confirmParams,
637
+ ).also {
638
+ registerStripeUIManager(it)
639
+ it.present(promise)
640
+ }
657
641
  } catch (error: PaymentMethodCreateParamsException) {
658
642
  promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), error))
659
643
  }
@@ -701,7 +685,7 @@ class StripeSdkModule(
701
685
 
702
686
  val factory =
703
687
  PaymentMethodCreateParamsFactory(
704
- getMapOrNull(params, "paymentMethodData"),
688
+ params.getMap("paymentMethodData"),
705
689
  options,
706
690
  cardFieldView,
707
691
  cardFormView,
@@ -717,16 +701,20 @@ class StripeSdkModule(
717
701
  urlScheme?.let {
718
702
  confirmParams.returnUrl = mapToReturnURL(urlScheme)
719
703
  }
720
- paymentLauncherFragment =
721
- PaymentLauncherFragment.forSetup(
722
- context = reactApplicationContext,
723
- stripe,
724
- publishableKey,
725
- stripeAccountId,
726
- promise,
727
- setupIntentClientSecret,
728
- confirmParams,
729
- )
704
+ unregisterStripeUIManager(paymentLauncherManager)
705
+ paymentLauncherManager =
706
+ PaymentLauncherManager
707
+ .forSetup(
708
+ context = reactApplicationContext,
709
+ stripe,
710
+ publishableKey,
711
+ stripeAccountId,
712
+ setupIntentClientSecret,
713
+ confirmParams,
714
+ ).also {
715
+ registerStripeUIManager(it)
716
+ it.present(promise)
717
+ }
730
718
  } catch (error: PaymentMethodCreateParamsException) {
731
719
  promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), error))
732
720
  }
@@ -738,24 +726,16 @@ class StripeSdkModule(
738
726
  promise: Promise,
739
727
  ) {
740
728
  val googlePayParams = params?.getMap("googlePay")
741
- val fragment =
742
- GooglePayPaymentMethodLauncherFragment.create(
729
+ unregisterStripeUIManager(googlePayPaymentMethodLauncherManager)
730
+ googlePayPaymentMethodLauncherManager =
731
+ GooglePayPaymentMethodLauncherManager(
743
732
  reactApplicationContext,
744
- getBooleanOrFalse(googlePayParams, "testEnv"),
745
- getBooleanOrFalse(googlePayParams, "existingPaymentMethodRequired"),
746
- promise,
747
- )
748
-
749
- getCurrentActivityOrResolveWithError(promise)?.let {
750
- try {
751
- it.supportFragmentManager
752
- .beginTransaction()
753
- .add(fragment, GooglePayPaymentMethodLauncherFragment.TAG)
754
- .commit()
755
- } catch (error: IllegalStateException) {
756
- promise.resolve(createError(ErrorType.Failed.toString(), error.message))
733
+ googlePayParams?.getBooleanOr("testEnv", false) ?: false,
734
+ googlePayParams?.getBooleanOr("existingPaymentMethodRequired", false) ?: false,
735
+ ).also {
736
+ registerStripeUIManager(it)
737
+ it.present(promise)
757
738
  }
758
- }
759
739
  }
760
740
 
761
741
  @ReactMethod
@@ -781,12 +761,13 @@ class StripeSdkModule(
781
761
  return
782
762
  }
783
763
 
784
- GooglePayLauncherFragment().also {
785
- it.presentGooglePaySheet(
764
+ unregisterStripeUIManager(googlePayLauncherManager)
765
+ googlePayLauncherManager =
766
+ GooglePayLauncherManager(
767
+ reactApplicationContext,
786
768
  clientSecret,
787
- if (isPaymentIntent) GooglePayLauncherFragment.Mode.ForPayment else GooglePayLauncherFragment.Mode.ForSetup,
769
+ if (isPaymentIntent) GooglePayLauncherManager.Mode.ForPayment else GooglePayLauncherManager.Mode.ForSetup,
788
770
  googlePayParams,
789
- reactApplicationContext,
790
771
  ) { launcherResult, errorMap ->
791
772
  if (errorMap != null) {
792
773
  promise.resolve(errorMap)
@@ -800,7 +781,7 @@ class StripeSdkModule(
800
781
  expand = listOf("payment_method"),
801
782
  object : ApiResultCallback<PaymentIntent> {
802
783
  override fun onError(e: Exception) {
803
- promise.resolve(createResult("paymentIntent", WritableNativeMap()))
784
+ promise.resolve(createResult("paymentIntent", Arguments.createMap()))
804
785
  }
805
786
 
806
787
  override fun onSuccess(result: PaymentIntent) {
@@ -820,7 +801,7 @@ class StripeSdkModule(
820
801
  expand = listOf("payment_method"),
821
802
  object : ApiResultCallback<SetupIntent> {
822
803
  override fun onError(e: Exception) {
823
- promise.resolve(createResult("setupIntent", WritableNativeMap()))
804
+ promise.resolve(createResult("setupIntent", Arguments.createMap()))
824
805
  }
825
806
 
826
807
  override fun onSuccess(result: SetupIntent) {
@@ -850,8 +831,10 @@ class StripeSdkModule(
850
831
  }
851
832
  }
852
833
  }
834
+ }.also {
835
+ registerStripeUIManager(it)
836
+ it.present()
853
837
  }
854
- }
855
838
  }
856
839
 
857
840
  @ReactMethod
@@ -931,7 +914,7 @@ class StripeSdkModule(
931
914
  PushProvisioningProxy.isCardInWallet(it, last4) { isCardInWallet, token, error ->
932
915
  val result: WritableMap =
933
916
  error ?: run {
934
- val map = WritableNativeMap()
917
+ val map = Arguments.createMap()
935
918
  map.putBoolean("isInWallet", isCardInWallet)
936
919
  map.putMap("token", token)
937
920
  map
@@ -948,7 +931,7 @@ class StripeSdkModule(
948
931
  params: ReadableMap,
949
932
  promise: Promise,
950
933
  ) {
951
- val paymentMethodData = getMapOrNull(params, "paymentMethodData")
934
+ val paymentMethodData = params.getMap("paymentMethodData")
952
935
  val paymentMethodType = mapToPaymentMethodType(getValOr(params, "paymentMethodType", null))
953
936
  if (paymentMethodType != PaymentMethod.Type.USBankAccount) {
954
937
  promise.resolve(
@@ -960,7 +943,7 @@ class StripeSdkModule(
960
943
  return
961
944
  }
962
945
 
963
- val billingDetails = getMapOrNull(paymentMethodData, "billingDetails")
946
+ val billingDetails = paymentMethodData?.getMap("billingDetails")
964
947
 
965
948
  val name = billingDetails?.getString("name")
966
949
  if (name.isNullOrEmpty()) {
@@ -979,26 +962,19 @@ class StripeSdkModule(
979
962
  billingDetails.getString("email"),
980
963
  )
981
964
 
982
- collectBankAccountLauncherFragment =
983
- CollectBankAccountLauncherFragment.create(
965
+ unregisterStripeUIManager(collectBankAccountLauncherManager)
966
+ collectBankAccountLauncherManager =
967
+ CollectBankAccountLauncherManager(
984
968
  reactApplicationContext,
985
969
  publishableKey,
986
970
  stripeAccountId,
987
971
  clientSecret,
988
972
  isPaymentIntent,
989
973
  collectParams,
990
- promise,
991
- )
992
- getCurrentActivityOrResolveWithError(promise)?.let {
993
- try {
994
- it.supportFragmentManager
995
- .beginTransaction()
996
- .add(collectBankAccountLauncherFragment!!, "collect_bank_account_launcher_fragment")
997
- .commit()
998
- } catch (error: IllegalStateException) {
999
- promise.resolve(createError(ErrorType.Failed.toString(), error.message))
974
+ ).also {
975
+ registerStripeUIManager(it)
976
+ it.present(promise)
1000
977
  }
1001
- }
1002
978
  }
1003
979
 
1004
980
  @ReactMethod
@@ -1096,16 +1072,18 @@ class StripeSdkModule(
1096
1072
  promise.resolve(createMissingInitError())
1097
1073
  return
1098
1074
  }
1099
- FinancialConnectionsSheetFragment().also {
1100
- it.presentFinancialConnectionsSheet(
1075
+ unregisterStripeUIManager(financialConnectionsSheetManager)
1076
+ financialConnectionsSheetManager =
1077
+ FinancialConnectionsSheetManager(
1078
+ reactApplicationContext,
1101
1079
  clientSecret,
1102
- FinancialConnectionsSheetFragment.Mode.ForToken,
1080
+ FinancialConnectionsSheetManager.Mode.ForToken,
1103
1081
  publishableKey,
1104
1082
  stripeAccountId,
1105
- promise,
1106
- reactApplicationContext,
1107
- )
1108
- }
1083
+ ).also {
1084
+ registerStripeUIManager(it)
1085
+ it.present(promise)
1086
+ }
1109
1087
  }
1110
1088
 
1111
1089
  @ReactMethod
@@ -1118,16 +1096,19 @@ class StripeSdkModule(
1118
1096
  promise.resolve(createMissingInitError())
1119
1097
  return
1120
1098
  }
1121
- FinancialConnectionsSheetFragment().also {
1122
- it.presentFinancialConnectionsSheet(
1099
+
1100
+ unregisterStripeUIManager(financialConnectionsSheetManager)
1101
+ financialConnectionsSheetManager =
1102
+ FinancialConnectionsSheetManager(
1103
+ reactApplicationContext,
1123
1104
  clientSecret,
1124
- FinancialConnectionsSheetFragment.Mode.ForSession,
1105
+ FinancialConnectionsSheetManager.Mode.ForSession,
1125
1106
  publishableKey,
1126
1107
  stripeAccountId,
1127
- promise,
1128
- reactApplicationContext,
1129
- )
1130
- }
1108
+ ).also {
1109
+ registerStripeUIManager(it)
1110
+ it.present(promise)
1111
+ }
1131
1112
  }
1132
1113
 
1133
1114
  @ReactMethod
@@ -1141,25 +1122,11 @@ class StripeSdkModule(
1141
1122
  return
1142
1123
  }
1143
1124
 
1144
- getCurrentActivityOrResolveWithError(promise)?.let { activity ->
1145
- customerSheetFragment?.removeFragment(reactApplicationContext)
1146
- customerSheetFragment =
1147
- CustomerSheetFragment().also {
1148
- it.context = reactApplicationContext
1149
- it.initPromise = promise
1150
- val bundle = toBundleObject(params)
1151
- bundle.putBundle("customerAdapter", toBundleObject(customerAdapterOverrides))
1152
- it.arguments = bundle
1153
- }
1154
- try {
1155
- activity.supportFragmentManager
1156
- .beginTransaction()
1157
- .add(customerSheetFragment!!, CustomerSheetFragment.TAG)
1158
- .commit()
1159
- } catch (error: IllegalStateException) {
1160
- promise.resolve(createError(ErrorType.Failed.toString(), error.message))
1125
+ unregisterStripeUIManager(customerSheetManager)
1126
+ customerSheetManager =
1127
+ CustomerSheetManager(reactApplicationContext, params, customerAdapterOverrides, promise).also {
1128
+ registerStripeUIManager(it)
1161
1129
  }
1162
- }
1163
1130
  }
1164
1131
 
1165
1132
  @ReactMethod
@@ -1167,19 +1134,16 @@ class StripeSdkModule(
1167
1134
  params: ReadableMap,
1168
1135
  promise: Promise,
1169
1136
  ) {
1170
- var timeout: Long? = null
1171
- if (params.hasKey("timeout")) {
1172
- timeout = params.getInt("timeout").toLong()
1173
- }
1174
- customerSheetFragment?.present(timeout, promise) ?: run {
1175
- promise.resolve(CustomerSheetFragment.createMissingInitError())
1137
+ val timeout = params.getLongOrNull("timeout")
1138
+ customerSheetManager?.present(promise, timeout) ?: run {
1139
+ promise.resolve(CustomerSheetManager.createMissingInitError())
1176
1140
  }
1177
1141
  }
1178
1142
 
1179
1143
  @ReactMethod
1180
1144
  override fun retrieveCustomerSheetPaymentOptionSelection(promise: Promise) {
1181
- customerSheetFragment?.retrievePaymentOptionSelection(promise) ?: run {
1182
- promise.resolve(CustomerSheetFragment.createMissingInitError())
1145
+ customerSheetManager?.retrievePaymentOptionSelection(promise) ?: run {
1146
+ promise.resolve(CustomerSheetManager.createMissingInitError())
1183
1147
  }
1184
1148
  }
1185
1149
 
@@ -1188,7 +1152,7 @@ class StripeSdkModule(
1188
1152
  paymentMethodJsonObjects: ReadableArray,
1189
1153
  promise: Promise,
1190
1154
  ) {
1191
- customerSheetFragment?.let { fragment ->
1155
+ customerSheetManager?.let { fragment ->
1192
1156
  val paymentMethods = mutableListOf<PaymentMethod>()
1193
1157
  for (paymentMethodJson in paymentMethodJsonObjects.toArrayList()) {
1194
1158
  PaymentMethod.fromJson(JSONObject((paymentMethodJson as HashMap<*, *>)))?.let {
@@ -1202,7 +1166,7 @@ class StripeSdkModule(
1202
1166
  }
1203
1167
  fragment.customerAdapter?.fetchPaymentMethodsCallback?.complete(paymentMethods)
1204
1168
  } ?: run {
1205
- promise.resolve(CustomerSheetFragment.createMissingInitError())
1169
+ promise.resolve(CustomerSheetManager.createMissingInitError())
1206
1170
  return
1207
1171
  }
1208
1172
  }
@@ -1212,7 +1176,7 @@ class StripeSdkModule(
1212
1176
  paymentMethodJson: ReadableMap,
1213
1177
  promise: Promise,
1214
1178
  ) {
1215
- customerSheetFragment?.let {
1179
+ customerSheetManager?.let {
1216
1180
  val paymentMethod =
1217
1181
  PaymentMethod.fromJson(JSONObject(paymentMethodJson.toHashMap() as HashMap<*, *>))
1218
1182
  if (paymentMethod == null) {
@@ -1224,7 +1188,7 @@ class StripeSdkModule(
1224
1188
  }
1225
1189
  it.customerAdapter?.attachPaymentMethodCallback?.complete(paymentMethod)
1226
1190
  } ?: run {
1227
- promise.resolve(CustomerSheetFragment.createMissingInitError())
1191
+ promise.resolve(CustomerSheetManager.createMissingInitError())
1228
1192
  return
1229
1193
  }
1230
1194
  }
@@ -1234,7 +1198,7 @@ class StripeSdkModule(
1234
1198
  paymentMethodJson: ReadableMap,
1235
1199
  promise: Promise,
1236
1200
  ) {
1237
- customerSheetFragment?.let {
1201
+ customerSheetManager?.let {
1238
1202
  val paymentMethod =
1239
1203
  PaymentMethod.fromJson(JSONObject(paymentMethodJson.toHashMap() as HashMap<*, *>))
1240
1204
  if (paymentMethod == null) {
@@ -1246,17 +1210,17 @@ class StripeSdkModule(
1246
1210
  }
1247
1211
  it.customerAdapter?.detachPaymentMethodCallback?.complete(paymentMethod)
1248
1212
  } ?: run {
1249
- promise.resolve(CustomerSheetFragment.createMissingInitError())
1213
+ promise.resolve(CustomerSheetManager.createMissingInitError())
1250
1214
  return
1251
1215
  }
1252
1216
  }
1253
1217
 
1254
1218
  @ReactMethod
1255
1219
  override fun customerAdapterSetSelectedPaymentOptionCallback(promise: Promise) {
1256
- customerSheetFragment?.let {
1220
+ customerSheetManager?.let {
1257
1221
  it.customerAdapter?.setSelectedPaymentOptionCallback?.complete(Unit)
1258
1222
  } ?: run {
1259
- promise.resolve(CustomerSheetFragment.createMissingInitError())
1223
+ promise.resolve(CustomerSheetManager.createMissingInitError())
1260
1224
  return
1261
1225
  }
1262
1226
  }
@@ -1266,10 +1230,10 @@ class StripeSdkModule(
1266
1230
  paymentOption: String?,
1267
1231
  promise: Promise,
1268
1232
  ) {
1269
- customerSheetFragment?.let {
1233
+ customerSheetManager?.let {
1270
1234
  it.customerAdapter?.fetchSelectedPaymentOptionCallback?.complete(paymentOption)
1271
1235
  } ?: run {
1272
- promise.resolve(CustomerSheetFragment.createMissingInitError())
1236
+ promise.resolve(CustomerSheetManager.createMissingInitError())
1273
1237
  return
1274
1238
  }
1275
1239
  }
@@ -1279,29 +1243,27 @@ class StripeSdkModule(
1279
1243
  clientSecret: String,
1280
1244
  promise: Promise,
1281
1245
  ) {
1282
- customerSheetFragment?.let {
1246
+ customerSheetManager?.let {
1283
1247
  it.customerAdapter?.setupIntentClientSecretForCustomerAttachCallback?.complete(clientSecret)
1284
1248
  } ?: run {
1285
- promise.resolve(CustomerSheetFragment.createMissingInitError())
1249
+ promise.resolve(CustomerSheetManager.createMissingInitError())
1286
1250
  return
1287
1251
  }
1288
1252
  }
1289
1253
 
1290
- @OptIn(ExperimentalCustomerSessionApi::class)
1291
1254
  @ReactMethod
1292
1255
  override fun clientSecretProviderSetupIntentClientSecretCallback(
1293
1256
  setupIntentClientSecret: String,
1294
1257
  promise: Promise,
1295
1258
  ) {
1296
- customerSheetFragment?.let {
1259
+ customerSheetManager?.let {
1297
1260
  it.customerSessionProvider?.provideSetupIntentClientSecretCallback?.complete(setupIntentClientSecret)
1298
1261
  } ?: run {
1299
- promise.resolve(CustomerSheetFragment.createMissingInitError())
1262
+ promise.resolve(CustomerSheetManager.createMissingInitError())
1300
1263
  return
1301
1264
  }
1302
1265
  }
1303
1266
 
1304
- @OptIn(ExperimentalCustomerSessionApi::class)
1305
1267
  @ReactMethod
1306
1268
  override fun clientSecretProviderCustomerSessionClientSecretCallback(
1307
1269
  customerSessionClientSecretJson: ReadableMap,
@@ -1318,15 +1280,15 @@ class StripeSdkModule(
1318
1280
  return
1319
1281
  }
1320
1282
 
1321
- customerSheetFragment?.let {
1283
+ customerSheetManager?.let {
1322
1284
  it.customerSessionProvider?.providesCustomerSessionClientSecretCallback?.complete(
1323
1285
  CustomerSheet.CustomerSessionClientSecret.create(
1324
- customerId = customerId!!,
1325
- clientSecret = clientSecret!!,
1286
+ customerId = customerId,
1287
+ clientSecret = clientSecret,
1326
1288
  ),
1327
1289
  )
1328
1290
  } ?: run {
1329
- promise.resolve(CustomerSheetFragment.createMissingInitError())
1291
+ promise.resolve(CustomerSheetManager.createMissingInitError())
1330
1292
  return
1331
1293
  }
1332
1294
  }
@@ -1372,6 +1334,39 @@ class StripeSdkModule(
1372
1334
  // noop, iOS only
1373
1335
  }
1374
1336
 
1337
+ @ReactMethod
1338
+ override fun openAuthenticatedWebView(
1339
+ id: String,
1340
+ url: String,
1341
+ promise: Promise,
1342
+ ) {
1343
+ val activity = getCurrentActivityOrResolveWithError(promise) ?: return
1344
+
1345
+ UiThreadUtil.runOnUiThread {
1346
+ try {
1347
+ val uri = android.net.Uri.parse(url)
1348
+ val builder =
1349
+ androidx.browser.customtabs.CustomTabsIntent
1350
+ .Builder()
1351
+
1352
+ // Set toolbar color for better UX
1353
+ builder.setShowTitle(true)
1354
+ builder.setUrlBarHidingEnabled(true)
1355
+
1356
+ val customTabsIntent = builder.build()
1357
+
1358
+ // Note: Custom Tabs doesn't have built-in redirect handling like iOS ASWebAuthenticationSession.
1359
+ // The redirect will be handled via deep linking when the auth server redirects to stripe-connect://
1360
+ // The React Native Linking module will capture the deep link and pass it back to the JS layer.
1361
+ customTabsIntent.launchUrl(activity, uri)
1362
+
1363
+ promise.resolve(null)
1364
+ } catch (e: Exception) {
1365
+ promise.resolve(createError("Failed", e))
1366
+ }
1367
+ }
1368
+ }
1369
+
1375
1370
  override fun addListener(eventType: String?) {
1376
1371
  // noop, iOS only
1377
1372
  }
@@ -1419,7 +1414,7 @@ class StripeSdkModule(
1419
1414
  * provided will be resolved with an error message instructing the user to retry the method.
1420
1415
  */
1421
1416
  private fun getCurrentActivityOrResolveWithError(promise: Promise?): FragmentActivity? {
1422
- (currentActivity as? FragmentActivity)?.let {
1417
+ (reactApplicationContext.currentActivity as? FragmentActivity)?.let {
1423
1418
  return it
1424
1419
  }
1425
1420
  promise?.resolve(createMissingActivityError())
@@ -1473,14 +1468,14 @@ class StripeSdkModule(
1473
1468
  */
1474
1469
  private fun preventActivityRecreation() {
1475
1470
  isRecreatingReactActivity = false
1476
- currentActivity?.application?.unregisterActivityLifecycleCallbacks(activityLifecycleCallbacks)
1477
- currentActivity?.application?.registerActivityLifecycleCallbacks(activityLifecycleCallbacks)
1471
+ reactApplicationContext.currentActivity?.application?.unregisterActivityLifecycleCallbacks(activityLifecycleCallbacks)
1472
+ reactApplicationContext.currentActivity?.application?.registerActivityLifecycleCallbacks(activityLifecycleCallbacks)
1478
1473
  }
1479
1474
 
1480
1475
  private fun setupComposeCompatView() {
1481
1476
  UiThreadUtil.runOnUiThread {
1482
1477
  composeCompatView = composeCompatView ?: StripeAbstractComposeView.CompatView(context = reactApplicationContext).also {
1483
- currentActivity?.findViewById<ViewGroup>(android.R.id.content)?.addView(
1478
+ reactApplicationContext.currentActivity?.findViewById<ViewGroup>(android.R.id.content)?.addView(
1484
1479
  it,
1485
1480
  )
1486
1481
  }