@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
@@ -0,0 +1,120 @@
1
+ package com.reactnativestripesdk
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.graphics.Color
5
+ import android.view.Gravity
6
+ import android.widget.FrameLayout
7
+ import android.widget.ImageButton
8
+ import android.widget.TextView
9
+ import androidx.appcompat.widget.Toolbar
10
+ import com.facebook.react.bridge.Arguments
11
+ import com.facebook.react.uimanager.ThemedReactContext
12
+ import com.facebook.react.uimanager.UIManagerHelper
13
+ import com.facebook.react.uimanager.events.Event
14
+
15
+ @SuppressLint("ViewConstructor")
16
+ class NavigationBarView(
17
+ context: ThemedReactContext,
18
+ ) : FrameLayout(context) {
19
+ private val toolbar: Toolbar
20
+ private val titleTextView: TextView
21
+ private var titleText: String? = null
22
+
23
+ init {
24
+ // Create Toolbar
25
+ toolbar =
26
+ Toolbar(context).apply {
27
+ layoutParams =
28
+ LayoutParams(
29
+ LayoutParams.MATCH_PARENT,
30
+ LayoutParams.WRAP_CONTENT,
31
+ )
32
+ setBackgroundColor(Color.WHITE)
33
+ elevation = 4f
34
+ }
35
+
36
+ // Create title TextView
37
+ titleTextView =
38
+ TextView(context).apply {
39
+ textSize = 17f
40
+ setTextColor(Color.BLACK)
41
+ gravity = Gravity.CENTER
42
+ }
43
+
44
+ // Add title to toolbar
45
+ val titleParams =
46
+ Toolbar
47
+ .LayoutParams(
48
+ Toolbar.LayoutParams.WRAP_CONTENT,
49
+ Toolbar.LayoutParams.WRAP_CONTENT,
50
+ ).apply {
51
+ gravity = Gravity.CENTER
52
+ }
53
+ toolbar.addView(titleTextView, titleParams)
54
+
55
+ // Create close button
56
+ val closeButton =
57
+ ImageButton(context).apply {
58
+ setImageDrawable(
59
+ context.resources.getDrawable(
60
+ android.R.drawable.ic_menu_close_clear_cancel,
61
+ null,
62
+ ),
63
+ )
64
+ setBackgroundColor(Color.TRANSPARENT)
65
+ setOnClickListener {
66
+ dispatchCloseButtonPress()
67
+ }
68
+ }
69
+
70
+ // Add close button to toolbar
71
+ val buttonParams =
72
+ Toolbar
73
+ .LayoutParams(
74
+ Toolbar.LayoutParams.WRAP_CONTENT,
75
+ Toolbar.LayoutParams.WRAP_CONTENT,
76
+ ).apply {
77
+ gravity = Gravity.END or Gravity.CENTER_VERTICAL
78
+ marginEnd = 16
79
+ }
80
+ toolbar.addView(closeButton, buttonParams)
81
+
82
+ // Add toolbar to this view
83
+ addView(toolbar)
84
+ }
85
+
86
+ fun setTitle(title: String?) {
87
+ titleText = title
88
+ titleTextView.text = title
89
+ }
90
+
91
+ private fun dispatchCloseButtonPress() {
92
+ val reactContext = context as ThemedReactContext
93
+ val event =
94
+ CloseButtonPressEvent(
95
+ UIManagerHelper.getSurfaceId(reactContext),
96
+ id,
97
+ )
98
+ UIManagerHelper.getEventDispatcherForReactTag(reactContext, id)?.dispatchEvent(event)
99
+ }
100
+
101
+ override fun onMeasure(
102
+ widthMeasureSpec: Int,
103
+ heightMeasureSpec: Int,
104
+ ) {
105
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec)
106
+ // Set a fixed height for the navigation bar
107
+ val desiredHeight = (56 * resources.displayMetrics.density).toInt()
108
+ val newHeightMeasureSpec = MeasureSpec.makeMeasureSpec(desiredHeight, MeasureSpec.EXACTLY)
109
+ super.onMeasure(widthMeasureSpec, newHeightMeasureSpec)
110
+ }
111
+
112
+ private class CloseButtonPressEvent(
113
+ surfaceId: Int,
114
+ viewId: Int,
115
+ ) : Event<CloseButtonPressEvent>(surfaceId, viewId) {
116
+ override fun getEventName() = "onCloseButtonPress"
117
+
118
+ override fun getEventData() = Arguments.createMap()
119
+ }
120
+ }
@@ -0,0 +1,228 @@
1
+ package com.reactnativestripesdk
2
+
3
+ import com.facebook.react.bridge.ReadableMap
4
+ import com.reactnativestripesdk.utils.PaymentSheetException
5
+ import com.reactnativestripesdk.utils.getBooleanOr
6
+ import com.reactnativestripesdk.utils.getIntOr
7
+ import com.reactnativestripesdk.utils.getLongOr
8
+ import com.reactnativestripesdk.utils.getStringList
9
+ import com.reactnativestripesdk.utils.isEmpty
10
+ import com.stripe.android.paymentelement.PaymentMethodOptionsSetupFutureUsagePreview
11
+ import com.stripe.android.paymentsheet.PaymentSheet
12
+
13
+ @Throws(PaymentSheetException::class)
14
+ internal fun buildIntentConfiguration(intentConfigurationParams: ReadableMap?): PaymentSheet.IntentConfiguration? {
15
+ if (intentConfigurationParams == null) {
16
+ return null
17
+ }
18
+ val modeParams =
19
+ intentConfigurationParams.getMap("mode")
20
+ ?: throw PaymentSheetException(
21
+ "If `intentConfiguration` is provided, `intentConfiguration.mode` is required",
22
+ )
23
+
24
+ return PaymentSheet.IntentConfiguration(
25
+ mode = buildIntentConfigurationMode(modeParams),
26
+ paymentMethodTypes =
27
+ intentConfigurationParams.getStringList("paymentMethodTypes")?.toList()
28
+ ?: emptyList(),
29
+ onBehalfOf = intentConfigurationParams.getString("onBehalfOf"),
30
+ )
31
+ }
32
+
33
+ @OptIn(PaymentMethodOptionsSetupFutureUsagePreview::class)
34
+ private fun buildIntentConfigurationMode(modeParams: ReadableMap): PaymentSheet.IntentConfiguration.Mode =
35
+ if (modeParams.hasKey("amount")) {
36
+ val currencyCode =
37
+ modeParams.getString("currencyCode")
38
+ ?: throw PaymentSheetException(
39
+ "You must provide a value to intentConfiguration.mode.currencyCode",
40
+ )
41
+ PaymentSheet.IntentConfiguration.Mode.Payment(
42
+ amount = modeParams.getLongOr("amount", 0),
43
+ currency = currencyCode,
44
+ setupFutureUse = mapToSetupFutureUse(modeParams.getString("setupFutureUsage")),
45
+ captureMethod = mapToCaptureMethod(modeParams.getString("captureMethod")),
46
+ paymentMethodOptions = mapToPaymentMethodOptions(modeParams.getMap("paymentMethodOptions")),
47
+ )
48
+ } else {
49
+ val setupFutureUsage =
50
+ mapToSetupFutureUse(modeParams.getString("setupFutureUsage"))
51
+ ?: throw PaymentSheetException(
52
+ "You must provide a value to intentConfiguration.mode.setupFutureUsage",
53
+ )
54
+ PaymentSheet.IntentConfiguration.Mode.Setup(
55
+ currency = modeParams.getString("currencyCode"),
56
+ setupFutureUse = setupFutureUsage,
57
+ )
58
+ }
59
+
60
+ internal fun buildLinkConfig(params: ReadableMap?): PaymentSheet.LinkConfiguration {
61
+ if (params == null) {
62
+ return PaymentSheet.LinkConfiguration()
63
+ }
64
+
65
+ val display = mapStringToLinkDisplay(params.getString("display"))
66
+
67
+ return PaymentSheet.LinkConfiguration(
68
+ display = display,
69
+ )
70
+ }
71
+
72
+ private fun mapStringToLinkDisplay(value: String?): PaymentSheet.LinkConfiguration.Display =
73
+ when (value) {
74
+ "automatic" -> PaymentSheet.LinkConfiguration.Display.Automatic
75
+ "never" -> PaymentSheet.LinkConfiguration.Display.Never
76
+ else -> PaymentSheet.LinkConfiguration.Display.Automatic
77
+ }
78
+
79
+ private val mapIntToButtonType =
80
+ mapOf(
81
+ 1 to PaymentSheet.GooglePayConfiguration.ButtonType.Buy,
82
+ 6 to PaymentSheet.GooglePayConfiguration.ButtonType.Book,
83
+ 5 to PaymentSheet.GooglePayConfiguration.ButtonType.Checkout,
84
+ 4 to PaymentSheet.GooglePayConfiguration.ButtonType.Donate,
85
+ 11 to PaymentSheet.GooglePayConfiguration.ButtonType.Order,
86
+ 1000 to PaymentSheet.GooglePayConfiguration.ButtonType.Pay,
87
+ 7 to PaymentSheet.GooglePayConfiguration.ButtonType.Subscribe,
88
+ 1001 to PaymentSheet.GooglePayConfiguration.ButtonType.Plain,
89
+ )
90
+
91
+ internal fun buildGooglePayConfig(params: ReadableMap?): PaymentSheet.GooglePayConfiguration? {
92
+ if (params == null || params.isEmpty()) {
93
+ return null
94
+ }
95
+
96
+ val countryCode = params.getString("merchantCountryCode").orEmpty()
97
+ val currencyCode = params.getString("currencyCode").orEmpty()
98
+ val testEnv = params.getBooleanOr("testEnv", false)
99
+ val amount = params.getString("amount")?.toLongOrNull()
100
+ val label = params.getString("label")
101
+ val buttonType =
102
+ mapIntToButtonType[params.getIntOr("buttonType", 0)]
103
+ ?: PaymentSheet.GooglePayConfiguration.ButtonType.Pay
104
+
105
+ return PaymentSheet.GooglePayConfiguration(
106
+ environment =
107
+ if (testEnv) {
108
+ PaymentSheet.GooglePayConfiguration.Environment.Test
109
+ } else {
110
+ PaymentSheet.GooglePayConfiguration.Environment.Production
111
+ },
112
+ countryCode = countryCode,
113
+ currencyCode = currencyCode,
114
+ amount = amount,
115
+ label = label,
116
+ buttonType = buttonType,
117
+ )
118
+ }
119
+
120
+ @Throws(PaymentSheetException::class)
121
+ internal fun buildCustomerConfiguration(map: ReadableMap?): PaymentSheet.CustomerConfiguration? {
122
+ val customerId = map?.getString("customerId").orEmpty()
123
+ val customerEphemeralKeySecret = map?.getString("customerEphemeralKeySecret").orEmpty()
124
+ val customerSessionClientSecret = map?.getString("customerSessionClientSecret").orEmpty()
125
+ return if (customerSessionClientSecret.isNotEmpty() &&
126
+ customerEphemeralKeySecret.isNotEmpty()
127
+ ) {
128
+ throw PaymentSheetException(
129
+ "`customerEphemeralKeySecret` and `customerSessionClientSecret` cannot both be set",
130
+ )
131
+ } else if (customerId.isNotEmpty() && customerSessionClientSecret.isNotEmpty()) {
132
+ PaymentSheet.CustomerConfiguration.createWithCustomerSession(
133
+ id = customerId,
134
+ clientSecret = customerSessionClientSecret,
135
+ )
136
+ } else if (customerId.isNotEmpty() && customerEphemeralKeySecret.isNotEmpty()) {
137
+ PaymentSheet.CustomerConfiguration(
138
+ id = customerId,
139
+ ephemeralKeySecret = customerEphemeralKeySecret,
140
+ )
141
+ } else {
142
+ null
143
+ }
144
+ }
145
+
146
+ internal fun buildBillingDetails(map: ReadableMap?): PaymentSheet.BillingDetails? {
147
+ if (map == null) {
148
+ return null
149
+ }
150
+ val addressMap = map.getMap("address")
151
+ val address =
152
+ PaymentSheet.Address(
153
+ addressMap?.getString("city"),
154
+ addressMap?.getString("country"),
155
+ addressMap?.getString("line1"),
156
+ addressMap?.getString("line2"),
157
+ addressMap?.getString("postalCode"),
158
+ addressMap?.getString("state"),
159
+ )
160
+ return PaymentSheet.BillingDetails(
161
+ address,
162
+ map.getString("email"),
163
+ map.getString("name"),
164
+ map.getString("phone"),
165
+ )
166
+ }
167
+
168
+ internal fun buildBillingDetailsCollectionConfiguration(map: ReadableMap?): PaymentSheet.BillingDetailsCollectionConfiguration =
169
+ PaymentSheet.BillingDetailsCollectionConfiguration(
170
+ name = mapToCollectionMode(map?.getString("name")),
171
+ phone = mapToCollectionMode(map?.getString("phone")),
172
+ email = mapToCollectionMode(map?.getString("email")),
173
+ address = mapToAddressCollectionMode(map?.getString("address")),
174
+ attachDefaultsToPaymentMethod = map.getBooleanOr("attachDefaultsToPaymentMethod", false),
175
+ )
176
+
177
+ internal fun mapToCollectionMode(str: String?): PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode =
178
+ when (str) {
179
+ "automatic" -> PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Automatic
180
+ "never" -> PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Never
181
+ "always" -> PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Always
182
+ else -> PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Automatic
183
+ }
184
+
185
+ internal fun mapToAddressCollectionMode(str: String?): PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode =
186
+ when (str) {
187
+ "automatic" ->
188
+ PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic
189
+
190
+ "never" -> PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Never
191
+ "full" -> PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Full
192
+ else -> PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic
193
+ }
194
+
195
+ internal fun mapToCardBrandAcceptance(params: ReadableMap?): PaymentSheet.CardBrandAcceptance {
196
+ val cardBrandAcceptanceParams = params?.getMap("cardBrandAcceptance") ?: return PaymentSheet.CardBrandAcceptance.all()
197
+ val filter = cardBrandAcceptanceParams.getString("filter") ?: return PaymentSheet.CardBrandAcceptance.all()
198
+
199
+ return when (filter) {
200
+ "all" -> PaymentSheet.CardBrandAcceptance.all()
201
+ "allowed" -> {
202
+ val brands = cardBrandAcceptanceParams.getStringList("brands") ?: return PaymentSheet.CardBrandAcceptance.all()
203
+ val brandCategories = brands.mapNotNull { mapToCardBrandCategory(it) }
204
+ if (brandCategories.isEmpty()) {
205
+ return PaymentSheet.CardBrandAcceptance.all()
206
+ }
207
+ PaymentSheet.CardBrandAcceptance.allowed(brandCategories)
208
+ }
209
+ "disallowed" -> {
210
+ val brands = cardBrandAcceptanceParams.getStringList("brands") ?: return PaymentSheet.CardBrandAcceptance.all()
211
+ val brandCategories = brands.mapNotNull { mapToCardBrandCategory(it) }
212
+ if (brandCategories.isEmpty()) {
213
+ return PaymentSheet.CardBrandAcceptance.all()
214
+ }
215
+ PaymentSheet.CardBrandAcceptance.disallowed(brandCategories)
216
+ }
217
+ else -> PaymentSheet.CardBrandAcceptance.all()
218
+ }
219
+ }
220
+
221
+ internal fun mapToCardBrandCategory(brand: String): PaymentSheet.CardBrandAcceptance.BrandCategory? =
222
+ when (brand) {
223
+ "visa" -> PaymentSheet.CardBrandAcceptance.BrandCategory.Visa
224
+ "mastercard" -> PaymentSheet.CardBrandAcceptance.BrandCategory.Mastercard
225
+ "amex" -> PaymentSheet.CardBrandAcceptance.BrandCategory.Amex
226
+ "discover" -> PaymentSheet.CardBrandAcceptance.BrandCategory.Discover
227
+ else -> null
228
+ }