@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,523 @@
1
+ package com.reactnativestripesdk
2
+
3
+ import com.reactnativestripesdk.utils.readableArrayOf
4
+ import com.reactnativestripesdk.utils.readableMapOf
5
+ import com.stripe.android.paymentelement.PaymentMethodOptionsSetupFutureUsagePreview
6
+ import com.stripe.android.paymentsheet.PaymentSheet
7
+ import org.junit.Assert.assertEquals
8
+ import org.junit.Assert.assertNotNull
9
+ import org.junit.Test
10
+ import org.junit.runner.RunWith
11
+ import org.robolectric.RobolectricTestRunner
12
+
13
+ @RunWith(RobolectricTestRunner::class)
14
+ @OptIn(PaymentMethodOptionsSetupFutureUsagePreview::class)
15
+ class PaymentSheetManagerTest {
16
+ // ============================================
17
+ // mapToCollectionMode Tests
18
+ // ============================================
19
+
20
+ @Test
21
+ fun mapToCollectionMode_ValidValues() {
22
+ assertEquals(
23
+ PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Automatic,
24
+ mapToCollectionMode("automatic"),
25
+ )
26
+ assertEquals(
27
+ PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Never,
28
+ mapToCollectionMode("never"),
29
+ )
30
+ assertEquals(
31
+ PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Always,
32
+ mapToCollectionMode("always"),
33
+ )
34
+ }
35
+
36
+ @Test
37
+ fun mapToCollectionMode_InvalidValue_DefaultsToAutomatic() {
38
+ assertEquals(
39
+ PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Automatic,
40
+ mapToCollectionMode("invalid"),
41
+ )
42
+ assertEquals(
43
+ PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Automatic,
44
+ mapToCollectionMode(""),
45
+ )
46
+ }
47
+
48
+ @Test
49
+ fun mapToCollectionMode_NullValue_DefaultsToAutomatic() {
50
+ assertEquals(
51
+ PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Automatic,
52
+ mapToCollectionMode(null),
53
+ )
54
+ }
55
+
56
+ // ============================================
57
+ // mapToPaymentMethodLayout Tests
58
+ // ============================================
59
+
60
+ @Test
61
+ fun mapToPaymentMethodLayout_ValidValues() {
62
+ assertEquals(
63
+ PaymentSheet.PaymentMethodLayout.Horizontal,
64
+ mapToPaymentMethodLayout("Horizontal"),
65
+ )
66
+ assertEquals(
67
+ PaymentSheet.PaymentMethodLayout.Vertical,
68
+ mapToPaymentMethodLayout("Vertical"),
69
+ )
70
+ assertEquals(
71
+ PaymentSheet.PaymentMethodLayout.Automatic,
72
+ mapToPaymentMethodLayout("Automatic"),
73
+ )
74
+ }
75
+
76
+ @Test
77
+ fun mapToPaymentMethodLayout_InvalidValue_DefaultsToAutomatic() {
78
+ assertEquals(
79
+ PaymentSheet.PaymentMethodLayout.Automatic,
80
+ mapToPaymentMethodLayout("invalid"),
81
+ )
82
+ assertEquals(
83
+ PaymentSheet.PaymentMethodLayout.Automatic,
84
+ mapToPaymentMethodLayout(""),
85
+ )
86
+ }
87
+
88
+ @Test
89
+ fun mapToPaymentMethodLayout_NullValue_DefaultsToAutomatic() {
90
+ assertEquals(
91
+ PaymentSheet.PaymentMethodLayout.Automatic,
92
+ mapToPaymentMethodLayout(null),
93
+ )
94
+ }
95
+
96
+ // ============================================
97
+ // mapToAddressCollectionMode Tests
98
+ // ============================================
99
+
100
+ @Test
101
+ fun mapToAddressCollectionMode_ValidValues() {
102
+ assertEquals(
103
+ PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic,
104
+ mapToAddressCollectionMode("automatic"),
105
+ )
106
+ assertEquals(
107
+ PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Never,
108
+ mapToAddressCollectionMode("never"),
109
+ )
110
+ assertEquals(
111
+ PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Full,
112
+ mapToAddressCollectionMode("full"),
113
+ )
114
+ }
115
+
116
+ @Test
117
+ fun mapToAddressCollectionMode_InvalidValue_DefaultsToAutomatic() {
118
+ assertEquals(
119
+ PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic,
120
+ mapToAddressCollectionMode("invalid"),
121
+ )
122
+ assertEquals(
123
+ PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic,
124
+ mapToAddressCollectionMode(""),
125
+ )
126
+ }
127
+
128
+ @Test
129
+ fun mapToAddressCollectionMode_NullValue_DefaultsToAutomatic() {
130
+ assertEquals(
131
+ PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic,
132
+ mapToAddressCollectionMode(null),
133
+ )
134
+ }
135
+
136
+ // ============================================
137
+ // mapToCardBrandCategory Tests
138
+ // ============================================
139
+
140
+ @Test
141
+ fun mapToCardBrandCategory_ValidValues() {
142
+ assertEquals(
143
+ PaymentSheet.CardBrandAcceptance.BrandCategory.Visa,
144
+ mapToCardBrandCategory("visa"),
145
+ )
146
+ assertEquals(
147
+ PaymentSheet.CardBrandAcceptance.BrandCategory.Mastercard,
148
+ mapToCardBrandCategory("mastercard"),
149
+ )
150
+ assertEquals(
151
+ PaymentSheet.CardBrandAcceptance.BrandCategory.Amex,
152
+ mapToCardBrandCategory("amex"),
153
+ )
154
+ assertEquals(
155
+ PaymentSheet.CardBrandAcceptance.BrandCategory.Discover,
156
+ mapToCardBrandCategory("discover"),
157
+ )
158
+ }
159
+
160
+ @Test
161
+ fun mapToCardBrandCategory_InvalidValue_ReturnsNull() {
162
+ assertEquals(null, mapToCardBrandCategory("invalid"))
163
+ assertEquals(null, mapToCardBrandCategory(""))
164
+ assertEquals(null, mapToCardBrandCategory("unknown"))
165
+ }
166
+
167
+ // ============================================
168
+ // mapToCardBrandAcceptance Tests
169
+ // ============================================
170
+
171
+ @Test
172
+ fun mapToCardBrandAcceptance_NullParams_ReturnsAll() {
173
+ val result = mapToCardBrandAcceptance(null)
174
+ assertNotNull(result)
175
+ }
176
+
177
+ @Test
178
+ fun mapToCardBrandAcceptance_NoCardBrandAcceptanceKey_ReturnsAll() {
179
+ val params =
180
+ readableMapOf(
181
+ "someOtherKey" to "value",
182
+ )
183
+ val result = mapToCardBrandAcceptance(params)
184
+ assertNotNull(result)
185
+ }
186
+
187
+ @Test
188
+ fun mapToCardBrandAcceptance_FilterAll() {
189
+ val params =
190
+ readableMapOf(
191
+ "cardBrandAcceptance" to
192
+ readableMapOf(
193
+ "filter" to "all",
194
+ ),
195
+ )
196
+ val result = mapToCardBrandAcceptance(params)
197
+ assertNotNull(result)
198
+ }
199
+
200
+ @Test
201
+ fun mapToCardBrandAcceptance_FilterAllowed_WithBrands() {
202
+ val params =
203
+ readableMapOf(
204
+ "cardBrandAcceptance" to
205
+ readableMapOf(
206
+ "filter" to "allowed",
207
+ "brands" to readableArrayOf("visa", "mastercard"),
208
+ ),
209
+ )
210
+ val result = mapToCardBrandAcceptance(params)
211
+ assertNotNull(result)
212
+ }
213
+
214
+ @Test
215
+ fun mapToCardBrandAcceptance_FilterAllowed_EmptyBrands_ReturnsAll() {
216
+ val params =
217
+ readableMapOf(
218
+ "cardBrandAcceptance" to
219
+ readableMapOf(
220
+ "filter" to "allowed",
221
+ "brands" to readableArrayOf(),
222
+ ),
223
+ )
224
+ val result = mapToCardBrandAcceptance(params)
225
+ assertNotNull(result)
226
+ }
227
+
228
+ @Test
229
+ fun mapToCardBrandAcceptance_FilterAllowed_NullBrands_ReturnsAll() {
230
+ val params =
231
+ readableMapOf(
232
+ "cardBrandAcceptance" to
233
+ readableMapOf(
234
+ "filter" to "allowed",
235
+ ),
236
+ )
237
+ val result = mapToCardBrandAcceptance(params)
238
+ assertNotNull(result)
239
+ }
240
+
241
+ @Test
242
+ fun mapToCardBrandAcceptance_FilterAllowed_InvalidBrands_ReturnsAll() {
243
+ val params =
244
+ readableMapOf(
245
+ "cardBrandAcceptance" to
246
+ readableMapOf(
247
+ "filter" to "allowed",
248
+ "brands" to readableArrayOf("invalid", "unknown"),
249
+ ),
250
+ )
251
+ val result = mapToCardBrandAcceptance(params)
252
+ assertNotNull(result)
253
+ }
254
+
255
+ @Test
256
+ fun mapToCardBrandAcceptance_FilterAllowed_MixedValidInvalidBrands() {
257
+ val params =
258
+ readableMapOf(
259
+ "cardBrandAcceptance" to
260
+ readableMapOf(
261
+ "filter" to "allowed",
262
+ "brands" to readableArrayOf("visa", "invalid", "amex"),
263
+ ),
264
+ )
265
+ val result = mapToCardBrandAcceptance(params)
266
+ assertNotNull(result)
267
+ }
268
+
269
+ @Test
270
+ fun mapToCardBrandAcceptance_FilterDisallowed_WithBrands() {
271
+ val params =
272
+ readableMapOf(
273
+ "cardBrandAcceptance" to
274
+ readableMapOf(
275
+ "filter" to "disallowed",
276
+ "brands" to readableArrayOf("amex", "discover"),
277
+ ),
278
+ )
279
+ val result = mapToCardBrandAcceptance(params)
280
+ assertNotNull(result)
281
+ }
282
+
283
+ @Test
284
+ fun mapToCardBrandAcceptance_FilterDisallowed_EmptyBrands_ReturnsAll() {
285
+ val params =
286
+ readableMapOf(
287
+ "cardBrandAcceptance" to
288
+ readableMapOf(
289
+ "filter" to "disallowed",
290
+ "brands" to readableArrayOf(),
291
+ ),
292
+ )
293
+ val result = mapToCardBrandAcceptance(params)
294
+ assertNotNull(result)
295
+ }
296
+
297
+ @Test
298
+ fun mapToCardBrandAcceptance_FilterDisallowed_NullBrands_ReturnsAll() {
299
+ val params =
300
+ readableMapOf(
301
+ "cardBrandAcceptance" to
302
+ readableMapOf(
303
+ "filter" to "disallowed",
304
+ ),
305
+ )
306
+ val result = mapToCardBrandAcceptance(params)
307
+ assertNotNull(result)
308
+ }
309
+
310
+ @Test
311
+ fun mapToCardBrandAcceptance_FilterDisallowed_InvalidBrands_ReturnsAll() {
312
+ val params =
313
+ readableMapOf(
314
+ "cardBrandAcceptance" to
315
+ readableMapOf(
316
+ "filter" to "disallowed",
317
+ "brands" to readableArrayOf("invalid", "unknown"),
318
+ ),
319
+ )
320
+ val result = mapToCardBrandAcceptance(params)
321
+ assertNotNull(result)
322
+ }
323
+
324
+ @Test
325
+ fun mapToCardBrandAcceptance_FilterDisallowed_MixedValidInvalidBrands() {
326
+ val params =
327
+ readableMapOf(
328
+ "cardBrandAcceptance" to
329
+ readableMapOf(
330
+ "filter" to "disallowed",
331
+ "brands" to readableArrayOf("mastercard", "invalid", "discover"),
332
+ ),
333
+ )
334
+ val result = mapToCardBrandAcceptance(params)
335
+ assertNotNull(result)
336
+ }
337
+
338
+ @Test
339
+ fun mapToCardBrandAcceptance_InvalidFilter_ReturnsAll() {
340
+ val params =
341
+ readableMapOf(
342
+ "cardBrandAcceptance" to
343
+ readableMapOf(
344
+ "filter" to "invalid",
345
+ "brands" to readableArrayOf("visa"),
346
+ ),
347
+ )
348
+ val result = mapToCardBrandAcceptance(params)
349
+ assertNotNull(result)
350
+ }
351
+
352
+ @Test
353
+ fun mapToCardBrandAcceptance_NullFilter_ReturnsAll() {
354
+ val params =
355
+ readableMapOf(
356
+ "cardBrandAcceptance" to
357
+ readableMapOf(
358
+ "brands" to readableArrayOf("visa"),
359
+ ),
360
+ )
361
+ val result = mapToCardBrandAcceptance(params)
362
+ assertNotNull(result)
363
+ }
364
+
365
+ // ============================================
366
+ // mapToSetupFutureUse Tests
367
+ // ============================================
368
+
369
+ @Test
370
+ fun mapToSetupFutureUse_ValidValues() {
371
+ assertEquals(
372
+ PaymentSheet.IntentConfiguration.SetupFutureUse.OffSession,
373
+ mapToSetupFutureUse("OffSession"),
374
+ )
375
+ assertEquals(
376
+ PaymentSheet.IntentConfiguration.SetupFutureUse.OnSession,
377
+ mapToSetupFutureUse("OnSession"),
378
+ )
379
+ assertEquals(
380
+ PaymentSheet.IntentConfiguration.SetupFutureUse.None,
381
+ mapToSetupFutureUse("None"),
382
+ )
383
+ }
384
+
385
+ @Test
386
+ fun mapToSetupFutureUse_InvalidValue_ReturnsNull() {
387
+ assertEquals(null, mapToSetupFutureUse("Unknown"))
388
+ assertEquals(null, mapToSetupFutureUse("OneTime"))
389
+ assertEquals(null, mapToSetupFutureUse("invalid"))
390
+ assertEquals(null, mapToSetupFutureUse(""))
391
+ }
392
+
393
+ @Test
394
+ fun mapToSetupFutureUse_NullValue_ReturnsNull() {
395
+ assertEquals(null, mapToSetupFutureUse(null))
396
+ }
397
+
398
+ // ============================================
399
+ // mapToCaptureMethod Tests
400
+ // ============================================
401
+
402
+ @Test
403
+ fun mapToCaptureMethod_ValidValues() {
404
+ assertEquals(
405
+ PaymentSheet.IntentConfiguration.CaptureMethod.Automatic,
406
+ mapToCaptureMethod("Automatic"),
407
+ )
408
+ assertEquals(
409
+ PaymentSheet.IntentConfiguration.CaptureMethod.Manual,
410
+ mapToCaptureMethod("Manual"),
411
+ )
412
+ assertEquals(
413
+ PaymentSheet.IntentConfiguration.CaptureMethod.AutomaticAsync,
414
+ mapToCaptureMethod("AutomaticAsync"),
415
+ )
416
+ }
417
+
418
+ @Test
419
+ fun mapToCaptureMethod_InvalidValue_DefaultsToAutomatic() {
420
+ assertEquals(
421
+ PaymentSheet.IntentConfiguration.CaptureMethod.Automatic,
422
+ mapToCaptureMethod("invalid"),
423
+ )
424
+ assertEquals(
425
+ PaymentSheet.IntentConfiguration.CaptureMethod.Automatic,
426
+ mapToCaptureMethod(""),
427
+ )
428
+ }
429
+
430
+ @Test
431
+ fun mapToCaptureMethod_NullValue_DefaultsToAutomatic() {
432
+ assertEquals(
433
+ PaymentSheet.IntentConfiguration.CaptureMethod.Automatic,
434
+ mapToCaptureMethod(null),
435
+ )
436
+ }
437
+
438
+ // ============================================
439
+ // mapToPaymentMethodOptions Tests
440
+ // ============================================
441
+
442
+ @Test
443
+ fun mapToPaymentMethodOptions_NullOptions_ReturnsNull() {
444
+ assertEquals(null, mapToPaymentMethodOptions(null))
445
+ }
446
+
447
+ @Test
448
+ fun mapToPaymentMethodOptions_ValidOptions() {
449
+ val options =
450
+ readableMapOf(
451
+ "setupFutureUsageValues" to
452
+ readableMapOf(
453
+ "card" to "OffSession",
454
+ "us_bank_account" to "OnSession",
455
+ ),
456
+ )
457
+
458
+ val result = mapToPaymentMethodOptions(options)
459
+
460
+ assertNotNull(result)
461
+ }
462
+
463
+ @Test
464
+ fun mapToPaymentMethodOptions_EmptyMap_ReturnsNull() {
465
+ val options =
466
+ readableMapOf(
467
+ "setupFutureUsageValues" to readableMapOf(),
468
+ )
469
+
470
+ val result = mapToPaymentMethodOptions(options)
471
+
472
+ assertEquals(null, result)
473
+ }
474
+
475
+ @Test
476
+ fun mapToPaymentMethodOptions_InvalidPaymentMethodCodes_ReturnsNull() {
477
+ val options =
478
+ readableMapOf(
479
+ "setupFutureUsageValues" to
480
+ readableMapOf(
481
+ "invalid_code" to "OffSession",
482
+ "another_invalid" to "OnSession",
483
+ ),
484
+ )
485
+
486
+ val result = mapToPaymentMethodOptions(options)
487
+
488
+ assertEquals(null, result)
489
+ }
490
+
491
+ @Test
492
+ fun mapToPaymentMethodOptions_MixedValidInvalidCodes() {
493
+ val options =
494
+ readableMapOf(
495
+ "setupFutureUsageValues" to
496
+ readableMapOf(
497
+ "card" to "OffSession",
498
+ "invalid_code" to "OnSession",
499
+ "us_bank_account" to "None",
500
+ ),
501
+ )
502
+
503
+ val result = mapToPaymentMethodOptions(options)
504
+
505
+ assertNotNull(result)
506
+ }
507
+
508
+ @Test
509
+ fun mapToPaymentMethodOptions_InvalidSetupFutureUsageValue_SkipsThatEntry() {
510
+ val options =
511
+ readableMapOf(
512
+ "setupFutureUsageValues" to
513
+ readableMapOf(
514
+ "card" to "InvalidValue",
515
+ "us_bank_account" to "OnSession",
516
+ ),
517
+ )
518
+
519
+ val result = mapToPaymentMethodOptions(options)
520
+
521
+ assertNotNull(result)
522
+ }
523
+ }