@stripe/stripe-react-native 0.57.0 → 0.57.2

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 (324) hide show
  1. package/README.md +0 -8
  2. package/android/.idea/AndroidProjectSystem.xml +6 -0
  3. package/android/.idea/caches/deviceStreaming.xml +1029 -0
  4. package/android/.idea/compiler.xml +6 -0
  5. package/android/.idea/gradle.xml +19 -0
  6. package/android/.idea/migrations.xml +10 -0
  7. package/android/.idea/misc.xml +10 -0
  8. package/android/.idea/runConfigurations.xml +17 -0
  9. package/android/.idea/vcs.xml +6 -0
  10. package/android/build.gradle +76 -118
  11. package/android/gradle.properties +1 -1
  12. package/android/local.properties +8 -0
  13. package/android/settings.gradle +2 -0
  14. package/android/spotless.gradle +1 -1
  15. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +20 -17
  16. package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +13 -11
  17. package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +17 -21
  18. package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherManager.kt +2 -0
  19. package/android/src/main/java/com/reactnativestripesdk/CustomPaymentMethodActivity.kt +2 -0
  20. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +53 -11
  21. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +105 -117
  22. package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -8
  23. package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +154 -0
  24. package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetManager.kt +13 -15
  25. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
  26. package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +1 -1
  27. package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +7 -5
  28. package/android/src/main/java/com/reactnativestripesdk/NavigationBarManager.kt +31 -0
  29. package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +120 -0
  30. package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +228 -0
  31. package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherManager.kt +1 -0
  32. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +3 -0
  33. package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
  34. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +73 -30
  35. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +19 -245
  36. package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
  37. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +52 -14
  38. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
  39. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +4 -4
  40. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
  41. package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +15 -35
  42. package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -1
  43. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +5 -10
  44. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +90 -77
  45. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +6 -4
  46. package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +13 -3
  47. package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +41 -0
  48. package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
  49. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +92 -44
  50. package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +3 -0
  51. package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +2 -0
  52. package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +118 -0
  53. package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -0
  54. package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +922 -0
  55. package/android/src/test/java/com/facebook/testutils/shadows/ShadowArguments.kt +29 -0
  56. package/android/src/test/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManagerTest.kt +163 -0
  57. package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +976 -0
  58. package/android/src/test/java/com/reactnativestripesdk/PaymentSheetAppearanceTest.kt +801 -0
  59. package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +523 -0
  60. package/android/src/test/java/com/reactnativestripesdk/addresssheet/AddressSheetViewTest.kt +551 -0
  61. package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +567 -0
  62. package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +456 -0
  63. package/android/src/test/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +43 -0
  64. package/android/src/test/resources/robolectric.properties +2 -0
  65. package/ios/AddressSheet/AddressSheetUtils.swift +3 -3
  66. package/ios/AddressSheet/AddressSheetView.swift +25 -25
  67. package/ios/AddressSheet/AddressSheetViewManager.swift +2 -2
  68. package/ios/ApplePayButtonManager.swift +1 -1
  69. package/ios/ApplePayButtonView.swift +9 -10
  70. package/ios/ApplePayUtils.swift +51 -51
  71. package/ios/ApplePayViewController.swift +25 -29
  72. package/ios/AuBECSDebitFormManager.swift +1 -1
  73. package/ios/AuBECSDebitFormView.swift +13 -15
  74. package/ios/CardFieldManager.swift +4 -4
  75. package/ios/CardFieldView.swift +9 -9
  76. package/ios/CardFormManager.swift +3 -3
  77. package/ios/CardFormView.swift +28 -28
  78. package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +97 -0
  79. package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +133 -0
  80. package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.m +16 -0
  81. package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.swift +17 -0
  82. package/ios/CustomerSheet/CustomerSheetUtils.swift +15 -16
  83. package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +19 -19
  84. package/ios/EmbeddedPaymentElementView.swift +2 -2
  85. package/ios/Errors.swift +22 -23
  86. package/ios/FinancialConnections.swift +37 -37
  87. package/ios/Mappers.swift +210 -71
  88. package/ios/NavigationBarManager.m +13 -0
  89. package/ios/NavigationBarManager.swift +17 -0
  90. package/ios/NavigationBarView.swift +65 -0
  91. package/ios/NewArch/NavigationBarComponentView.h +10 -0
  92. package/ios/NewArch/NavigationBarComponentView.mm +86 -0
  93. package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
  94. package/ios/OldArch/StripeSdkEventEmitterCompat.m +7 -1
  95. package/ios/PaymentMethodFactory.swift +24 -24
  96. package/ios/PaymentOptionDisplayData+ReactNative.swift +4 -4
  97. package/ios/PaymentPassFinder.swift +9 -10
  98. package/ios/PaymentSheetAppearance.swift +137 -138
  99. package/ios/PushProvisioning/AddToWalletButtonManager.swift +2 -2
  100. package/ios/PushProvisioning/AddToWalletButtonView.swift +15 -17
  101. package/ios/PushProvisioning/PushProvisioningUtils.swift +11 -11
  102. package/ios/StripeContainerManager.swift +1 -1
  103. package/ios/StripeContainerView.swift +3 -3
  104. package/ios/StripeOnrampSdk.h +17 -0
  105. package/ios/StripeOnrampSdk.mm +158 -0
  106. package/ios/StripeSdk.mm +8 -0
  107. package/ios/StripeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  108. package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcuserdata/tianzhao.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  109. package/ios/StripeSdk.xcodeproj/xcuserdata/tianzhao.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
  110. package/ios/StripeSdkEmitter.swift +4 -0
  111. package/ios/StripeSdkImpl+CustomerSheet.swift +30 -25
  112. package/ios/StripeSdkImpl+Embedded.swift +11 -9
  113. package/ios/StripeSdkImpl+PaymentSheet.swift +36 -34
  114. package/ios/StripeSdkImpl.swift +913 -185
  115. package/ios/UIColorExtension.swift +72 -0
  116. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  117. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  118. package/lib/commonjs/components/AddressSheet.js +1 -1
  119. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  120. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  121. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  122. package/lib/commonjs/components/CardField.js +1 -1
  123. package/lib/commonjs/components/CardField.js.map +1 -1
  124. package/lib/commonjs/components/CardForm.js +1 -1
  125. package/lib/commonjs/components/CardForm.js.map +1 -1
  126. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  127. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  128. package/lib/commonjs/components/StripeContainer.js +1 -1
  129. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  130. package/lib/commonjs/components/StripeProvider.js +1 -1
  131. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  132. package/lib/commonjs/connect/Components.js +2 -0
  133. package/lib/commonjs/connect/Components.js.map +1 -0
  134. package/lib/commonjs/connect/ConnectComponentsProvider.js +2 -0
  135. package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -0
  136. package/lib/commonjs/connect/EmbeddedComponent.js +19 -0
  137. package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -0
  138. package/lib/commonjs/connect/ModalCloseButton.js +2 -0
  139. package/lib/commonjs/connect/ModalCloseButton.js.map +1 -0
  140. package/lib/commonjs/connect/NavigationBar.js +2 -0
  141. package/lib/commonjs/connect/NavigationBar.js.map +1 -0
  142. package/lib/commonjs/connect/connectTypes.js +2 -0
  143. package/lib/commonjs/connect/connectTypes.js.map +1 -0
  144. package/lib/commonjs/events.js +1 -1
  145. package/lib/commonjs/events.js.map +1 -1
  146. package/lib/commonjs/helpers.js +1 -1
  147. package/lib/commonjs/helpers.js.map +1 -1
  148. package/lib/commonjs/hooks/useOnramp.js +2 -0
  149. package/lib/commonjs/hooks/useOnramp.js.map +1 -0
  150. package/lib/commonjs/index.js +1 -1
  151. package/lib/commonjs/index.js.map +1 -1
  152. package/lib/commonjs/plugin/withStripe.js +1 -1
  153. package/lib/commonjs/plugin/withStripe.js.map +1 -1
  154. package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
  155. package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -1
  156. package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
  157. package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -1
  158. package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
  159. package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -1
  160. package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
  161. package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -1
  162. package/lib/commonjs/specs/NativeCardField.js +1 -1
  163. package/lib/commonjs/specs/NativeCardField.js.map +1 -1
  164. package/lib/commonjs/specs/NativeCardForm.js +1 -1
  165. package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
  166. package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +2 -0
  167. package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js.map +1 -0
  168. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
  169. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  170. package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
  171. package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -1
  172. package/lib/commonjs/specs/NativeNavigationBar.js +2 -0
  173. package/lib/commonjs/specs/NativeNavigationBar.js.map +1 -0
  174. package/lib/commonjs/specs/NativeOnrampSdkModule.js +2 -0
  175. package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -0
  176. package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
  177. package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -1
  178. package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
  179. package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
  180. package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
  181. package/lib/commonjs/types/Errors.js +1 -1
  182. package/lib/commonjs/types/Errors.js.map +1 -1
  183. package/lib/commonjs/types/Onramp.js +2 -0
  184. package/lib/commonjs/types/Onramp.js.map +1 -0
  185. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  186. package/lib/commonjs/types/index.js +1 -1
  187. package/lib/commonjs/types/index.js.map +1 -1
  188. package/lib/module/components/AddToWalletButton.js +1 -1
  189. package/lib/module/components/AddToWalletButton.js.map +1 -1
  190. package/lib/module/components/AddressSheet.js +1 -1
  191. package/lib/module/components/AddressSheet.js.map +1 -1
  192. package/lib/module/components/AuBECSDebitForm.js +1 -1
  193. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  194. package/lib/module/components/CardField.js +1 -1
  195. package/lib/module/components/CardField.js.map +1 -1
  196. package/lib/module/components/CardForm.js +1 -1
  197. package/lib/module/components/CardForm.js.map +1 -1
  198. package/lib/module/components/PlatformPayButton.js +1 -1
  199. package/lib/module/components/PlatformPayButton.js.map +1 -1
  200. package/lib/module/components/StripeContainer.js +1 -1
  201. package/lib/module/components/StripeContainer.js.map +1 -1
  202. package/lib/module/components/StripeProvider.js +1 -1
  203. package/lib/module/components/StripeProvider.js.map +1 -1
  204. package/lib/module/connect/Components.js +2 -0
  205. package/lib/module/connect/Components.js.map +1 -0
  206. package/lib/module/connect/ConnectComponentsProvider.js +2 -0
  207. package/lib/module/connect/ConnectComponentsProvider.js.map +1 -0
  208. package/lib/module/connect/EmbeddedComponent.js +19 -0
  209. package/lib/module/connect/EmbeddedComponent.js.map +1 -0
  210. package/lib/module/connect/ModalCloseButton.js +2 -0
  211. package/lib/module/connect/ModalCloseButton.js.map +1 -0
  212. package/lib/module/connect/NavigationBar.js +2 -0
  213. package/lib/module/connect/NavigationBar.js.map +1 -0
  214. package/lib/module/connect/connectTypes.js +2 -0
  215. package/lib/module/connect/connectTypes.js.map +1 -0
  216. package/lib/module/events.js +1 -1
  217. package/lib/module/events.js.map +1 -1
  218. package/lib/module/helpers.js +1 -1
  219. package/lib/module/helpers.js.map +1 -1
  220. package/lib/module/hooks/useOnramp.js +2 -0
  221. package/lib/module/hooks/useOnramp.js.map +1 -0
  222. package/lib/module/index.js +1 -1
  223. package/lib/module/index.js.map +1 -1
  224. package/lib/module/plugin/withStripe.js +1 -1
  225. package/lib/module/plugin/withStripe.js.map +1 -1
  226. package/lib/module/specs/NativeAddToWalletButton.js +1 -1
  227. package/lib/module/specs/NativeAddToWalletButton.js.map +1 -1
  228. package/lib/module/specs/NativeAddressSheet.js +1 -1
  229. package/lib/module/specs/NativeAddressSheet.js.map +1 -1
  230. package/lib/module/specs/NativeApplePayButton.js +1 -1
  231. package/lib/module/specs/NativeApplePayButton.js.map +1 -1
  232. package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
  233. package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -1
  234. package/lib/module/specs/NativeCardField.js +1 -1
  235. package/lib/module/specs/NativeCardField.js.map +1 -1
  236. package/lib/module/specs/NativeCardForm.js +1 -1
  237. package/lib/module/specs/NativeCardForm.js.map +1 -1
  238. package/lib/module/specs/NativeConnectAccountOnboardingView.js +2 -0
  239. package/lib/module/specs/NativeConnectAccountOnboardingView.js.map +1 -0
  240. package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
  241. package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  242. package/lib/module/specs/NativeGooglePayButton.js +1 -1
  243. package/lib/module/specs/NativeGooglePayButton.js.map +1 -1
  244. package/lib/module/specs/NativeNavigationBar.js +2 -0
  245. package/lib/module/specs/NativeNavigationBar.js.map +1 -0
  246. package/lib/module/specs/NativeOnrampSdkModule.js +2 -0
  247. package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -0
  248. package/lib/module/specs/NativeStripeContainer.js +1 -1
  249. package/lib/module/specs/NativeStripeContainer.js.map +1 -1
  250. package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
  251. package/lib/module/types/EmbeddedPaymentElement.js +1 -1
  252. package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
  253. package/lib/module/types/Errors.js +1 -1
  254. package/lib/module/types/Errors.js.map +1 -1
  255. package/lib/module/types/Onramp.js +2 -0
  256. package/lib/module/types/Onramp.js.map +1 -0
  257. package/lib/module/types/PaymentSheet.js.map +1 -1
  258. package/lib/module/types/index.js +1 -1
  259. package/lib/module/types/index.js.map +1 -1
  260. package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
  261. package/lib/typescript/src/connect/Components.d.ts +23 -0
  262. package/lib/typescript/src/connect/Components.d.ts.map +1 -0
  263. package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +22 -0
  264. package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -0
  265. package/lib/typescript/src/connect/EmbeddedComponent.d.ts +18 -0
  266. package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -0
  267. package/lib/typescript/src/connect/ModalCloseButton.d.ts +7 -0
  268. package/lib/typescript/src/connect/ModalCloseButton.d.ts.map +1 -0
  269. package/lib/typescript/src/connect/NavigationBar.d.ts +8 -0
  270. package/lib/typescript/src/connect/NavigationBar.d.ts.map +1 -0
  271. package/lib/typescript/src/connect/connectTypes.d.ts +464 -0
  272. package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -0
  273. package/lib/typescript/src/events.d.ts +4 -0
  274. package/lib/typescript/src/events.d.ts.map +1 -1
  275. package/lib/typescript/src/functions.d.ts.map +1 -1
  276. package/lib/typescript/src/helpers.d.ts.map +1 -1
  277. package/lib/typescript/src/hooks/useOnramp.d.ts +158 -0
  278. package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -0
  279. package/lib/typescript/src/index.d.ts +4 -0
  280. package/lib/typescript/src/index.d.ts.map +1 -1
  281. package/lib/typescript/src/plugin/withStripe.d.ts +15 -0
  282. package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
  283. package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts +14 -0
  284. package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts.map +1 -0
  285. package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +1 -0
  286. package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -1
  287. package/lib/typescript/src/specs/NativeNavigationBar.d.ts +11 -0
  288. package/lib/typescript/src/specs/NativeNavigationBar.d.ts.map +1 -0
  289. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +28 -0
  290. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -0
  291. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -0
  292. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
  293. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
  294. package/lib/typescript/src/types/Errors.d.ts +5 -0
  295. package/lib/typescript/src/types/Errors.d.ts.map +1 -1
  296. package/lib/typescript/src/types/Onramp.d.ts +275 -0
  297. package/lib/typescript/src/types/Onramp.d.ts.map +1 -0
  298. package/lib/typescript/src/types/PaymentSheet.d.ts +7 -0
  299. package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
  300. package/lib/typescript/src/types/index.d.ts +7 -1
  301. package/lib/typescript/src/types/index.d.ts.map +1 -1
  302. package/package.json +25 -14
  303. package/src/components/StripeProvider.tsx +5 -0
  304. package/src/connect/Components.tsx +279 -0
  305. package/src/connect/ConnectComponentsProvider.tsx +93 -0
  306. package/src/connect/EmbeddedComponent.tsx +407 -0
  307. package/src/connect/ModalCloseButton.tsx +44 -0
  308. package/src/connect/NavigationBar.tsx +29 -0
  309. package/src/connect/connectTypes.ts +626 -0
  310. package/src/events.ts +23 -0
  311. package/src/hooks/useOnramp.tsx +334 -0
  312. package/src/index.tsx +13 -0
  313. package/src/plugin/withStripe.ts +104 -7
  314. package/src/specs/NativeConnectAccountOnboardingView.ts +19 -0
  315. package/src/specs/NativeEmbeddedPaymentElement.ts +5 -1
  316. package/src/specs/NativeNavigationBar.ts +16 -0
  317. package/src/specs/NativeOnrampSdkModule.ts +47 -0
  318. package/src/specs/NativeStripeSdkModule.ts +5 -0
  319. package/src/types/EmbeddedPaymentElement.tsx +24 -3
  320. package/src/types/Errors.ts +6 -0
  321. package/src/types/Onramp.ts +317 -0
  322. package/src/types/PaymentSheet.ts +7 -0
  323. package/src/types/index.ts +8 -0
  324. package/stripe-react-native.podspec +20 -7
@@ -0,0 +1,334 @@
1
+ import { EventSubscription } from 'react-native';
2
+ import NativeOnrampSdk from '../specs/NativeOnrampSdkModule';
3
+ import { Onramp, OnrampError, StripeError } from '../types';
4
+ import type { Address, PlatformPay } from '../types';
5
+ import { useCallback } from 'react';
6
+ import { addOnrampListener } from '../events';
7
+ import { CryptoPaymentToken } from '../types/Onramp';
8
+
9
+ let onCheckoutClientSecretRequestedSubscription: EventSubscription | null =
10
+ null;
11
+
12
+ /**
13
+ * useOnramp hook
14
+ */
15
+ export function useOnramp() {
16
+ const _configure = useCallback(
17
+ async (
18
+ config: Onramp.Configuration
19
+ ): Promise<{ error?: StripeError<OnrampError> }> => {
20
+ return NativeOnrampSdk.configureOnramp(config);
21
+ },
22
+ []
23
+ );
24
+
25
+ const _hasLinkAccount = useCallback(
26
+ async (email: string): Promise<Onramp.HasLinkAccountResult> => {
27
+ return NativeOnrampSdk.hasLinkAccount(email);
28
+ },
29
+ []
30
+ );
31
+
32
+ const _registerLinkUser = useCallback(
33
+ async (
34
+ info: Onramp.LinkUserInfo
35
+ ): Promise<Onramp.RegisterLinkUserResult> => {
36
+ return NativeOnrampSdk.registerLinkUser(info);
37
+ },
38
+ []
39
+ );
40
+
41
+ const _registerWalletAddress = useCallback(
42
+ async (
43
+ walletAddress: string,
44
+ network: Onramp.CryptoNetwork
45
+ ): Promise<{ error?: StripeError<OnrampError> }> => {
46
+ return NativeOnrampSdk.registerWalletAddress(walletAddress, network);
47
+ },
48
+ []
49
+ );
50
+
51
+ const _attachKycInfo = useCallback(
52
+ async (
53
+ kycInfo: Onramp.KycInfo
54
+ ): Promise<{ error?: StripeError<OnrampError> }> => {
55
+ return NativeOnrampSdk.attachKycInfo(kycInfo);
56
+ },
57
+ []
58
+ );
59
+
60
+ const _presentKycInfoVerification = useCallback(
61
+ async (updatedAddress: Address | null): Promise<Onramp.VerifyKycResult> => {
62
+ return NativeOnrampSdk.presentKycInfoVerification(updatedAddress);
63
+ },
64
+ []
65
+ );
66
+
67
+ const _authenticateUserWithToken = useCallback(
68
+ async (
69
+ linkAuthTokenClientSecret: string
70
+ ): Promise<{ error?: StripeError<OnrampError> }> => {
71
+ return NativeOnrampSdk.authenticateUserWithToken(
72
+ linkAuthTokenClientSecret
73
+ );
74
+ },
75
+ []
76
+ );
77
+
78
+ const _updatePhoneNumber = useCallback(
79
+ async (phone: string): Promise<{ error?: StripeError<OnrampError> }> => {
80
+ return NativeOnrampSdk.updatePhoneNumber(phone);
81
+ },
82
+ []
83
+ );
84
+
85
+ const _authenticateUser =
86
+ useCallback(async (): Promise<Onramp.AuthenticateUserResult> => {
87
+ return NativeOnrampSdk.authenticateUser();
88
+ }, []);
89
+
90
+ const _verifyIdentity = useCallback(async (): Promise<{
91
+ error?: StripeError<OnrampError>;
92
+ }> => {
93
+ return NativeOnrampSdk.verifyIdentity();
94
+ }, []);
95
+
96
+ /**
97
+ * The set of payment methods supported by crypto onramp collection.
98
+ * - 'Card' and 'BankAccount' present Link for collection.
99
+ * - 'PlatformPay' presents Apple Pay / Google Pay using provided params.
100
+ */
101
+ type OnrampPaymentMethod = 'Card' | 'BankAccount' | 'PlatformPay';
102
+
103
+ // Overloads for stronger type-safety at call-sites
104
+ const _collectPaymentMethod: {
105
+ (
106
+ paymentMethod: 'Card' | 'BankAccount',
107
+ platformPayParams?: undefined
108
+ ): Promise<Onramp.CollectPaymentMethodResult>;
109
+ (
110
+ paymentMethod: 'PlatformPay',
111
+ platformPayParams: PlatformPay.PaymentMethodParams
112
+ ): Promise<Onramp.CollectPaymentMethodResult>;
113
+ } = useCallback(
114
+ async (
115
+ paymentMethod: OnrampPaymentMethod,
116
+ platformPayParams?:
117
+ | PlatformPay.PaymentMethodParams
118
+ | Record<string, never>
119
+ ): Promise<Onramp.CollectPaymentMethodResult> => {
120
+ return NativeOnrampSdk.collectPaymentMethod(
121
+ paymentMethod,
122
+ (platformPayParams ?? {}) as any
123
+ );
124
+ },
125
+ []
126
+ );
127
+
128
+ const _createCryptoPaymentToken =
129
+ useCallback(async (): Promise<Onramp.CreateCryptoPaymentTokenResult> => {
130
+ return NativeOnrampSdk.createCryptoPaymentToken();
131
+ }, []);
132
+
133
+ const _performCheckout = useCallback(
134
+ async (
135
+ onrampSessionId: string,
136
+ provideCheckoutClientSecret: () => Promise<string | null>
137
+ ): Promise<{ error?: StripeError<OnrampError> }> => {
138
+ onCheckoutClientSecretRequestedSubscription?.remove();
139
+ onCheckoutClientSecretRequestedSubscription = addOnrampListener(
140
+ 'onCheckoutClientSecretRequested',
141
+ async () => {
142
+ try {
143
+ const clientSecret = await provideCheckoutClientSecret();
144
+ NativeOnrampSdk.provideCheckoutClientSecret(clientSecret);
145
+ } catch (error: any) {
146
+ NativeOnrampSdk.provideCheckoutClientSecret(null);
147
+ }
148
+ }
149
+ );
150
+ return NativeOnrampSdk.performCheckout(onrampSessionId);
151
+ },
152
+ []
153
+ );
154
+
155
+ const _authorize = useCallback(
156
+ async (linkAuthIntentId: string): Promise<Onramp.AuthorizeResult> => {
157
+ return NativeOnrampSdk.onrampAuthorize(linkAuthIntentId);
158
+ },
159
+ []
160
+ );
161
+
162
+ const _getCryptoTokenDisplayData = useCallback(
163
+ async (
164
+ token: CryptoPaymentToken
165
+ ): Promise<Onramp.PaymentDisplayDataResult> => {
166
+ return NativeOnrampSdk.getCryptoTokenDisplayData(token);
167
+ },
168
+ []
169
+ );
170
+
171
+ const _logOut = useCallback(async (): Promise<{
172
+ error?: StripeError<OnrampError>;
173
+ }> => {
174
+ return NativeOnrampSdk.logout();
175
+ }, []);
176
+
177
+ const _isAuthError = (error: any): boolean => {
178
+ const stripeErrorCode = error?.stripeErrorCode;
179
+ const authErrorCodes = [
180
+ 'consumer_session_credentials_invalid',
181
+ 'consumer_session_expired',
182
+ ];
183
+ return authErrorCodes.includes(stripeErrorCode);
184
+ };
185
+
186
+ return {
187
+ /**
188
+ * Creates a `CryptoOnrampCoordinator` to facilitate authentication, identity verification, payment collection, and checkouts.
189
+ *
190
+ * @param config Configuration object containing merchant display name and appearance settings
191
+ * @returns Promise that resolves to an object with an optional error property
192
+ */
193
+ configure: _configure,
194
+
195
+ /**
196
+ * Whether or not the provided email is associated with an existing Link consumer.
197
+ *
198
+ * @param email The email address to look up
199
+ * @returns Promise that resolves to an object with hasLinkAccount boolean or error
200
+ */
201
+ hasLinkAccount: _hasLinkAccount,
202
+
203
+ /**
204
+ * Registers a new Link user with the provided details.
205
+ *
206
+ * @param info User information including email, phone, country, and optional full name
207
+ * @returns Promise that resolves to an object with customerId or error
208
+ */
209
+ registerLinkUser: _registerLinkUser,
210
+
211
+ /**
212
+ * Registers the given crypto wallet address to the current Link account.
213
+ * Requires an authenticated Link user.
214
+ *
215
+ * @param walletAddress The crypto wallet address to register
216
+ * @param network The crypto network for the wallet address
217
+ * @returns Promise that resolves to an object with an optional error property
218
+ */
219
+ registerWalletAddress: _registerWalletAddress,
220
+
221
+ /**
222
+ * Attaches the specific KYC info to the current Link user. Requires an authenticated Link user.
223
+ *
224
+ * @param kycInfo The KYC info to attach to the Link user
225
+ * @returns Promise that resolves to an object with an optional error property
226
+ */
227
+ attachKycInfo: _attachKycInfo,
228
+
229
+ /**
230
+ * Presents UI to verify KYC information for the current Link user.
231
+ * Requires the user to be authenticated with prior calls to either `authenticateUser` or `authorize`, and also requires prior KYC info attachement via `attachKycInfo`.
232
+ *
233
+ * @param updatedAddress: An optional updated address. Specify this parameter if the user has elected to change the address after a prior call to this API returned `UpdateAddress`. Otherwise, specify `null` to show the user's existing KYC information on the presented flow.
234
+ *
235
+ * @returns Promise that resolves to an instance of `VerifyKycResult` indicating whether the user confirmed their address, elected to update their address, cancelled the flow, or an error occurred.
236
+ */
237
+ presentKycInfoVerification: _presentKycInfoVerification,
238
+
239
+ /**
240
+ * Updates the user's phone number in their Link account.
241
+ *
242
+ * @param phone The new phone number to set for the user in E.164 format (e.g., +12125551234)
243
+ * @returns Promise that resolves to an object with an optional error property
244
+ */
245
+ updatePhoneNumber: _updatePhoneNumber,
246
+
247
+ /**
248
+ * Presents Link UI to authenticate an existing Link user.
249
+ * `hasLinkAccount` must be called before this.
250
+ *
251
+ * @returns Promise that resolves to an object with customerId or error
252
+ */
253
+ authenticateUser: _authenticateUser,
254
+
255
+ /**
256
+ * Authenticates the user with an encrypted Link auth token.
257
+ * This token can be obtained by exchanging a previously consented Link OAuth token from your backend using Stripe's /v1/link/auth_token API. The response of this backend API includes information on token expiry.
258
+ *
259
+ * @param linkAuthTokenClientSecret An encrypted one-time-use auth token that, upon successful validation, leaves the Link account’s consumer session in an already-verified state, allowing the client to skip verification.
260
+ * @returns Promise that resolves to an object with an optional error property if authentication fails due to an invalid token that is expired, already used, revoked, or not found, or if a network error occurs.
261
+ */
262
+ authenticateUserWithToken: _authenticateUserWithToken,
263
+
264
+ /**
265
+ * Creates an identity verification session and launches the document verification flow.
266
+ * Requires an authenticated Link user.
267
+ *
268
+ * @returns Promise that resolves to an object with an optional error property
269
+ */
270
+ verifyIdentity: _verifyIdentity,
271
+
272
+ /**
273
+ * Presents UI to collect/select a payment method of the given type.
274
+ *
275
+ * @param paymentMethod The payment method type to collect.
276
+ * - 'Card' and 'BankAccount' present Link for collection.
277
+ * - 'PlatformPay' presents Apple Pay / Google Pay using the provided parameters.
278
+ * @param platformPayParams Platform-specific parameters (required when `paymentMethod` is 'PlatformPay').
279
+ * - iOS: provide `applePay` params
280
+ * - Android: provide `googlePay` params
281
+ * @returns Promise that resolves to an object with displayData or error
282
+ */
283
+ collectPaymentMethod: _collectPaymentMethod,
284
+
285
+ /**
286
+ * Creates a crypto payment token for the payment method currently selected on the coordinator.
287
+ * Call after a successful `collectPaymentMethod(...)`.
288
+ *
289
+ * @returns Promise that resolves to an object with cryptoPaymentToken or error
290
+ */
291
+ createCryptoPaymentToken: _createCryptoPaymentToken,
292
+
293
+ /**
294
+ * Performs the checkout flow for a crypto onramp session, handling any required authentication steps.
295
+ *
296
+ * @param onrampSessionId The onramp session identifier
297
+ * @returns Promise that resolves to an object with an optional error property
298
+ */
299
+ performCheckout: _performCheckout,
300
+
301
+ /**
302
+ * Authorizes a Link auth intent and authenticates the user if necessary.
303
+ *
304
+ * @param linkAuthIntentId The Link auth intent ID to authorize
305
+ * @returns Promise that resolves to an object with status and customerId or error
306
+ */
307
+ authorize: _authorize,
308
+
309
+ /**
310
+ * Retrieves display data (icon, label, sublabel) for the given payment method details.
311
+ * Suitable for rendering in the UI to summarize the selected payment method.
312
+ *
313
+ * @param token The token containing payment method details (card or bank account) to get display data for
314
+ * @returns Promise that resolves to an object with displayData or error
315
+ */
316
+ getCryptoTokenDisplayData: _getCryptoTokenDisplayData,
317
+
318
+ /**
319
+ * Logs out the current user from their Link account.
320
+ *
321
+ * @returns Promise that resolves to an object with an optional error property
322
+ */
323
+ logOut: _logOut,
324
+
325
+ /**
326
+ * Determines whether an error is an authentication-related error that requires re-authentication.
327
+ * Useful for implementing automatic re-authentication flows when sessions expire or become invalid.
328
+ *
329
+ * @param error The error object to check, typically from onramp method calls
330
+ * @returns True if the error indicates an authentication issue, false otherwise
331
+ */
332
+ isAuthError: _isAuthError,
333
+ };
334
+ }
package/src/index.tsx CHANGED
@@ -5,6 +5,7 @@ export { useStripe } from './hooks/useStripe';
5
5
  export { usePlatformPay } from './hooks/usePlatformPay';
6
6
  export { usePaymentSheet } from './hooks/usePaymentSheet';
7
7
  export { useFinancialConnectionsSheet } from './hooks/useFinancialConnectionsSheet';
8
+ export { useOnramp } from './hooks/useOnramp';
8
9
 
9
10
  //components
10
11
  export { initStripe, StripeProvider } from './components/StripeProvider';
@@ -34,3 +35,15 @@ export type { Props as CustomerSheetProps } from './components/CustomerSheet';
34
35
  export * from './types/EmbeddedPaymentElement';
35
36
  export * from './types/PaymentSheet';
36
37
  export * from './types/ConfirmationToken';
38
+
39
+ //connect components
40
+ export {
41
+ ConnectComponentsProvider,
42
+ loadConnectAndInitialize,
43
+ } from './connect/ConnectComponentsProvider';
44
+ export type {
45
+ StripeConnectInstance,
46
+ StripeConnectInitParams,
47
+ StripeConnectUpdateParams,
48
+ } from './connect/connectTypes';
49
+ export * from './connect/Components';
@@ -5,7 +5,10 @@ import {
5
5
  IOSConfig,
6
6
  withAndroidManifest,
7
7
  withEntitlementsPlist,
8
+ withGradleProperties,
9
+ withPodfile,
8
10
  } from '@expo/config-plugins';
11
+ import path from 'path';
9
12
 
10
13
  const {
11
14
  addMetaDataItemToMainApplication,
@@ -22,6 +25,13 @@ type StripePluginProps = {
22
25
  */
23
26
  merchantIdentifier: string | string[];
24
27
  enableGooglePay: boolean;
28
+ /**
29
+ * Whether to include Onramp functionality in the build.
30
+ * When true, adds StripeSdk_includeOnramp=true to gradle.properties for Android
31
+ * and includes the Onramp pod for iOS.
32
+ * Defaults to false.
33
+ */
34
+ includeOnramp?: boolean;
25
35
  };
26
36
 
27
37
  const withStripe: ConfigPlugin<StripePluginProps> = (config, props) => {
@@ -33,15 +43,48 @@ const withStripe: ConfigPlugin<StripePluginProps> = (config, props) => {
33
43
 
34
44
  const withStripeIos: ConfigPlugin<StripePluginProps> = (
35
45
  expoConfig,
36
- { merchantIdentifier }
46
+ { merchantIdentifier, includeOnramp = false }
37
47
  ) => {
38
- return withEntitlementsPlist(expoConfig, (config) => {
39
- config.modResults = setApplePayEntitlement(
48
+ let resultConfig = withEntitlementsPlist(expoConfig, (entitlementsConfig) => {
49
+ entitlementsConfig.modResults = setApplePayEntitlement(
40
50
  merchantIdentifier,
41
- config.modResults
51
+ entitlementsConfig.modResults
42
52
  );
43
- return config;
53
+ return entitlementsConfig;
44
54
  });
55
+
56
+ // Conditionally include Onramp pod for iOS.
57
+ if (includeOnramp) {
58
+ resultConfig = withPodfile(resultConfig, (config) => {
59
+ const podfile = config.modResults.contents;
60
+
61
+ const localPodPath = path.dirname(
62
+ require.resolve('@stripe/stripe-react-native/package.json', {
63
+ paths: [config.modRequest.projectRoot],
64
+ })
65
+ );
66
+ const relativePodPath = path.relative(
67
+ path.join(config.modRequest.projectRoot, 'ios'),
68
+ localPodPath
69
+ );
70
+
71
+ // Using Expo BuildProperties with `extraPods` unfortunately results in
72
+ // an empty pod, so we're modifying the Podfile directly. The pod line
73
+ // *must* come after the use_native_modules! call.
74
+ const podLine = ` pod 'stripe-react-native/Onramp', :path => '${relativePodPath}'`;
75
+
76
+ if (!podfile.includes(podLine)) {
77
+ config.modResults.contents = podfile.replace(
78
+ 'config = use_native_modules!(config_command)',
79
+ (match) => `${match}\n${podLine}`
80
+ );
81
+ }
82
+
83
+ return config;
84
+ });
85
+ }
86
+
87
+ return resultConfig;
45
88
  };
46
89
 
47
90
  /**
@@ -94,9 +137,9 @@ export const withNoopSwiftFile: ConfigPlugin = (config) => {
94
137
 
95
138
  const withStripeAndroid: ConfigPlugin<StripePluginProps> = (
96
139
  expoConfig,
97
- { enableGooglePay = false }
140
+ { enableGooglePay = false, includeOnramp = false }
98
141
  ) => {
99
- return withAndroidManifest(expoConfig, (config) => {
142
+ let resultConfig = withAndroidManifest(expoConfig, (config) => {
100
143
  config.modResults = setGooglePayMetaData(
101
144
  enableGooglePay,
102
145
  config.modResults
@@ -104,6 +147,17 @@ const withStripeAndroid: ConfigPlugin<StripePluginProps> = (
104
147
 
105
148
  return config;
106
149
  });
150
+
151
+ resultConfig = withGradleProperties(resultConfig, (config) => {
152
+ config.modResults = setOnrampGradleProperty(
153
+ includeOnramp,
154
+ config.modResults
155
+ );
156
+
157
+ return config;
158
+ });
159
+
160
+ return resultConfig;
107
161
  };
108
162
 
109
163
  /**
@@ -138,4 +192,47 @@ export function setGooglePayMetaData(
138
192
  return modResults;
139
193
  }
140
194
 
195
+ /**
196
+ * Adds or removes the StripeSdk_includeOnramp property in gradle.properties.
197
+ *
198
+ * @param includeOnramp Whether to include Onramp functionality
199
+ * @param modResults The current gradle.properties as PropertiesItem array
200
+ * @returns Modified PropertiesItem array
201
+ */
202
+ export function setOnrampGradleProperty(
203
+ includeOnramp: boolean,
204
+ modResults: AndroidConfig.Properties.PropertiesItem[]
205
+ ): AndroidConfig.Properties.PropertiesItem[] {
206
+ const ONRAMP_PROPERTY_KEY = 'StripeSdk_includeOnramp';
207
+
208
+ // Find existing property if it exists
209
+ const existingPropertyIndex = modResults.findIndex(
210
+ (item) => item.type === 'property' && item.key === ONRAMP_PROPERTY_KEY
211
+ );
212
+
213
+ if (includeOnramp) {
214
+ // Add or update the property to true
215
+ const propertyItem = {
216
+ type: 'property' as const,
217
+ key: ONRAMP_PROPERTY_KEY,
218
+ value: 'true',
219
+ };
220
+
221
+ if (existingPropertyIndex >= 0) {
222
+ // Update existing property
223
+ modResults[existingPropertyIndex] = propertyItem;
224
+ } else {
225
+ // Add new property at the end
226
+ modResults.push(propertyItem);
227
+ }
228
+ } else {
229
+ // Remove the property if it exists
230
+ if (existingPropertyIndex >= 0) {
231
+ modResults.splice(existingPropertyIndex, 1);
232
+ }
233
+ }
234
+
235
+ return modResults;
236
+ }
237
+
141
238
  export default createRunOncePlugin(withStripe, pkg.name, pkg.version);
@@ -0,0 +1,19 @@
1
+ import type { HostComponent, ViewProps } from 'react-native';
2
+ import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
3
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
4
+
5
+ type OnExitActionEvent = Readonly<{}>;
6
+
7
+ export interface NativeProps extends ViewProps {
8
+ visible: boolean;
9
+ title?: string;
10
+ backgroundColor?: string;
11
+ textColor?: string;
12
+ onExitAction: DirectEventHandler<OnExitActionEvent>;
13
+ }
14
+
15
+ type ComponentType = HostComponent<NativeProps>;
16
+
17
+ export default codegenNativeComponent<NativeProps>(
18
+ 'ConnectAccountOnboardingView'
19
+ ) as ComponentType;
@@ -15,10 +15,14 @@ export interface NativeCommands {
15
15
  clearPaymentOption: (
16
16
  viewRef: React.ElementRef<HostComponent<NativeProps>>
17
17
  ) => void;
18
+ update: (
19
+ viewRef: React.ElementRef<HostComponent<NativeProps>>,
20
+ intentConfigurationJson: string
21
+ ) => void;
18
22
  }
19
23
 
20
24
  export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
21
- supportedCommands: ['confirm', 'clearPaymentOption'],
25
+ supportedCommands: ['confirm', 'clearPaymentOption', 'update'],
22
26
  });
23
27
 
24
28
  type ComponentType = HostComponent<NativeProps>;
@@ -0,0 +1,16 @@
1
+ import type { HostComponent, ViewProps } from 'react-native';
2
+ import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
3
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
4
+
5
+ export type CloseButtonPressEvent = Readonly<{}>;
6
+
7
+ export interface NativeProps extends ViewProps {
8
+ title?: string;
9
+ onCloseButtonPress?: DirectEventHandler<CloseButtonPressEvent>;
10
+ }
11
+
12
+ type ComponentType = HostComponent<NativeProps>;
13
+
14
+ export default codegenNativeComponent<NativeProps>(
15
+ 'NavigationBar'
16
+ ) as ComponentType;
@@ -0,0 +1,47 @@
1
+ import { TurboModuleRegistry } from 'react-native';
2
+ import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
3
+ import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
4
+ import type { Address, InitialiseParams, Onramp } from '../types';
5
+ import type { UnsafeObject } from './utils';
6
+
7
+ export interface Spec extends TurboModule {
8
+ initialise(params: UnsafeObject<InitialiseParams>): Promise<void>;
9
+ configureOnramp(
10
+ config: UnsafeObject<Onramp.Configuration>
11
+ ): Promise<Onramp.VoidResult>;
12
+ hasLinkAccount(email: string): Promise<Onramp.HasLinkAccountResult>;
13
+ registerLinkUser(
14
+ info: UnsafeObject<Onramp.LinkUserInfo>
15
+ ): Promise<Onramp.RegisterLinkUserResult>;
16
+ registerWalletAddress(
17
+ walletAddress: string,
18
+ network: string
19
+ ): Promise<Onramp.VoidResult>;
20
+ attachKycInfo(
21
+ kycInfo: UnsafeObject<Onramp.KycInfo>
22
+ ): Promise<Onramp.VoidResult>;
23
+ presentKycInfoVerification: (
24
+ updatedAddress: UnsafeObject<Address> | null
25
+ ) => Promise<Onramp.VerifyKycResult>;
26
+ updatePhoneNumber(phone: string): Promise<Onramp.VoidResult>;
27
+ authenticateUser(): Promise<Onramp.AuthenticateUserResult>;
28
+ authenticateUserWithToken(
29
+ linkAuthTokenClientSecret: string
30
+ ): Promise<Onramp.VoidResult>;
31
+ verifyIdentity(): Promise<Onramp.VoidResult>;
32
+ collectPaymentMethod(
33
+ paymentMethod: string,
34
+ platformPayParams: UnsafeObject<any>
35
+ ): Promise<Onramp.CollectPaymentMethodResult>;
36
+ provideCheckoutClientSecret(clientSecret: string | null): void;
37
+ onCheckoutClientSecretRequested: EventEmitter<UnsafeObject<any>>;
38
+ createCryptoPaymentToken(): Promise<Onramp.CreateCryptoPaymentTokenResult>;
39
+ performCheckout(onrampSessionId: string): Promise<Onramp.VoidResult>;
40
+ onrampAuthorize(linkAuthIntentId: string): Promise<Onramp.AuthorizeResult>;
41
+ getCryptoTokenDisplayData(
42
+ token: UnsafeObject<Onramp.CryptoPaymentToken>
43
+ ): Promise<Onramp.PaymentDisplayDataResult>;
44
+ logout(): Promise<Onramp.VoidResult>;
45
+ }
46
+
47
+ export default TurboModuleRegistry.getEnforcing<Spec>('OnrampSdk');
@@ -196,6 +196,11 @@ export interface Spec extends TurboModule {
196
196
 
197
197
  setFinancialConnectionsForceNativeFlow(enabled: boolean): Promise<void>;
198
198
 
199
+ openAuthenticatedWebView(
200
+ id: string,
201
+ url: string
202
+ ): Promise<{ url?: string } | null>;
203
+
199
204
  // Events
200
205
  addListener: (eventType: string) => void;
201
206
  removeListeners: (count: number) => void;
@@ -550,9 +550,30 @@ export function useEmbeddedPaymentElement(
550
550
  return getElementOrThrow(elementRef).confirm();
551
551
  }, [isAndroid]);
552
552
  const update = useCallback(
553
- (cfg: PaymentSheetTypes.IntentConfiguration) =>
554
- getElementOrThrow(elementRef).update(cfg),
555
- []
553
+ (cfg: PaymentSheetTypes.IntentConfiguration) => {
554
+ if (isAndroid) {
555
+ const currentRef = viewRef.current;
556
+ if (currentRef) {
557
+ return new Promise<{ status: string } | null>((resolve) => {
558
+ const sub = addListener(
559
+ 'embeddedPaymentElementUpdateComplete',
560
+ (result: { status: string } | null) => {
561
+ sub.remove();
562
+ resolve(result);
563
+ }
564
+ );
565
+ Commands.update(currentRef, JSON.stringify(cfg));
566
+ });
567
+ }
568
+ return Promise.reject(
569
+ new Error('Unable to find Android embedded payment element view!')
570
+ );
571
+ }
572
+
573
+ // iOS: use native module directly
574
+ return getElementOrThrow(elementRef).update(cfg);
575
+ },
576
+ [isAndroid]
556
577
  );
557
578
  const clearPaymentOption = useCallback((): Promise<void> => {
558
579
  if (isAndroid) {
@@ -44,6 +44,12 @@ export enum PaymentSheetError {
44
44
  Timeout = 'Timeout',
45
45
  }
46
46
 
47
+ export enum OnrampError {
48
+ Failed = 'Failed',
49
+ Canceled = 'Canceled',
50
+ Unknown = 'Unknown',
51
+ }
52
+
47
53
  export type ErrorType =
48
54
  | 'api_connection_error'
49
55
  | 'api_error'