@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,86 @@
1
+ #import "NavigationBarComponentView.h"
2
+
3
+ #import <react/renderer/components/rnstripe/ComponentDescriptors.h>
4
+ #import <react/renderer/components/rnstripe/EventEmitters.h>
5
+ #import <react/renderer/components/rnstripe/Props.h>
6
+ #import <react/renderer/components/rnstripe/RCTComponentViewHelpers.h>
7
+
8
+ #import <React/RCTConversions.h>
9
+ #import <React/RCTFabricComponentsPlugins.h>
10
+ #import "StripeNewArchConversions.h"
11
+ #import "StripeSwiftInterop.h"
12
+
13
+ using namespace facebook::react;
14
+ using namespace stripe::react;
15
+
16
+ @interface NavigationBarComponentView () <RCTNavigationBarViewProtocol>
17
+ @end
18
+
19
+ @implementation NavigationBarComponentView {
20
+ NavigationBarView *_view;
21
+ }
22
+
23
+ // Needed because of this: https://github.com/facebook/react-native/pull/37274
24
+ + (void)load
25
+ {
26
+ [super load];
27
+ }
28
+
29
+ - (instancetype)initWithFrame:(CGRect)frame
30
+ {
31
+ if (self = [super initWithFrame:frame]) {
32
+ static const auto defaultProps = std::make_shared<const NavigationBarProps>();
33
+ _props = defaultProps;
34
+ [self prepareView];
35
+ }
36
+
37
+ return self;
38
+ }
39
+
40
+ - (void)prepareView
41
+ {
42
+ _view = [[NavigationBarView alloc] initWithFrame:self.frame];
43
+ self.contentView = _view;
44
+
45
+ __weak __typeof(self) weakSelf = self;
46
+
47
+ _view.onCloseButtonPress = ^(NSDictionary *event) {
48
+ __typeof(self) strongSelf = weakSelf;
49
+ if (!strongSelf || !strongSelf->_eventEmitter) {
50
+ return;
51
+ }
52
+ NavigationBarEventEmitter::OnCloseButtonPress emitterEvent = {};
53
+ std::static_pointer_cast<const NavigationBarEventEmitter>(strongSelf->_eventEmitter)
54
+ ->onCloseButtonPress(std::move(emitterEvent));
55
+ };
56
+ }
57
+
58
+ - (void)updateProps:(const facebook::react::Props::Shared &)props
59
+ oldProps:(const facebook::react::Props::Shared &)oldProps
60
+ {
61
+ const auto &newViewProps = *std::static_pointer_cast<const NavigationBarProps>(props);
62
+
63
+ _view.title = RCTNSStringFromStringNilIfEmpty(newViewProps.title);
64
+
65
+ [super updateProps:props oldProps:oldProps];
66
+ }
67
+
68
+ #pragma mark - RCTComponentViewProtocol
69
+
70
+ + (ComponentDescriptorProvider)componentDescriptorProvider
71
+ {
72
+ return concreteComponentDescriptorProvider<NavigationBarComponentDescriptor>();
73
+ }
74
+
75
+ - (void)prepareForRecycle
76
+ {
77
+ [super prepareForRecycle];
78
+ [self prepareView];
79
+ }
80
+
81
+ @end
82
+
83
+ Class<RCTComponentViewProtocol> NavigationBarCls(void)
84
+ {
85
+ return NavigationBarComponentView.class;
86
+ }
@@ -23,5 +23,6 @@
23
23
  - (void)emitEmbeddedPaymentElementRowSelectionImmediateAction;
24
24
  - (void)emitEmbeddedPaymentElementLoadingFailed:(NSDictionary *)value;
25
25
  - (void)emitOnCustomPaymentMethodConfirmHandlerCallback:(NSDictionary *)value;
26
+ - (void)emitOnCheckoutClientSecretRequested:(NSDictionary *)value;
26
27
  @end
27
28
 
@@ -23,7 +23,8 @@
23
23
  @"embeddedPaymentElementFormSheetConfirmComplete",
24
24
  @"embeddedPaymentElementRowSelectionImmediateAction",
25
25
  @"embeddedPaymentElementLoadingFailed",
26
- @"onCustomPaymentMethodConfirmHandlerCallback"
26
+ @"onCustomPaymentMethodConfirmHandlerCallback",
27
+ @"onCheckoutClientSecretRequested"
27
28
  ];
28
29
  }
29
30
 
@@ -122,4 +123,9 @@
122
123
  [self sendEventWithName:@"onCustomPaymentMethodConfirmHandlerCallback" body:value];
123
124
  }
124
125
 
126
+ - (void)emitOnCheckoutClientSecretRequested:(NSDictionary *)value
127
+ {
128
+ [self sendEventWithName:@"onCheckoutClientSecretRequested" body:value];
129
+ }
130
+
125
131
  @end
@@ -2,12 +2,12 @@ import Foundation
2
2
  import Stripe
3
3
 
4
4
  class PaymentMethodFactory {
5
- var billingDetailsParams: STPPaymentMethodBillingDetails? = nil
6
- var paymentMethodData: NSDictionary? = nil
7
- var paymentMethodOptions: NSDictionary? = nil
8
- var cardFieldView: CardFieldView? = nil
9
- var cardFormView: CardFormView? = nil
10
- var metadata: [String: String]? = nil
5
+ var billingDetailsParams: STPPaymentMethodBillingDetails?
6
+ var paymentMethodData: NSDictionary?
7
+ var paymentMethodOptions: NSDictionary?
8
+ var cardFieldView: CardFieldView?
9
+ var cardFormView: CardFormView?
10
+ var metadata: [String: String]?
11
11
 
12
12
  init(paymentMethodData: NSDictionary?, options: NSDictionary, cardFieldView: CardFieldView?, cardFormView: CardFormView?) {
13
13
  self.paymentMethodData = paymentMethodData
@@ -61,8 +61,8 @@ class PaymentMethodFactory {
61
61
  return try createCashAppPaymentMethodParams()
62
62
  case STPPaymentMethodType.revolutPay:
63
63
  return try createRevolutPayPaymentMethodParams()
64
- // case STPPaymentMethodType.weChatPay:
65
- // return try createWeChatPayPaymentMethodParams()
64
+ // case STPPaymentMethodType.weChatPay:
65
+ // return try createWeChatPayPaymentMethodParams()
66
66
  default:
67
67
  throw PaymentMethodError.paymentNotSupported
68
68
  }
@@ -124,11 +124,11 @@ class PaymentMethodFactory {
124
124
  }
125
125
  }
126
126
 
127
- // private func createWeChatPayPaymentMethodParams() throws -> STPPaymentMethodParams {
128
- // let params = STPPaymentMethodWeChatPayParams()
129
- // return STPPaymentMethodParams(weChatPay: params, billingDetails: billingDetailsParams, metadata: metadata)
130
- // }
131
- //
127
+ // private func createWeChatPayPaymentMethodParams() throws -> STPPaymentMethodParams {
128
+ // let params = STPPaymentMethodWeChatPayParams()
129
+ // return STPPaymentMethodParams(weChatPay: params, billingDetails: billingDetailsParams, metadata: metadata)
130
+ // }
131
+ //
132
132
 
133
133
  private func createUSBankAccountPaymentMethodOptions() throws -> STPConfirmPaymentMethodOptions {
134
134
  let paymentOptions = STPConfirmPaymentMethodOptions()
@@ -155,26 +155,25 @@ class PaymentMethodFactory {
155
155
  params.bankName = bankName
156
156
  }
157
157
 
158
-
159
- return STPPaymentMethodParams(iDEAL: params, billingDetails: billingDetailsParams, metadata: metadata)
158
+ return STPPaymentMethodParams(iDEAL: params, billingDetails: billingDetailsParams, metadata: metadata)
160
159
  }
161
160
 
162
161
  private func createGrabpayPaymentMethodParams() -> STPPaymentMethodParams {
163
162
  let params = STPPaymentMethodGrabPayParams()
164
163
 
165
- return STPPaymentMethodParams(grabPay: params, billingDetails: billingDetailsParams, metadata: metadata)
164
+ return STPPaymentMethodParams(grabPay: params, billingDetails: billingDetailsParams, metadata: metadata)
166
165
  }
167
166
 
168
167
  private func createCardPaymentMethodParams() throws -> STPPaymentMethodParams {
169
168
  if let token = paymentMethodData?["token"] as? String {
170
169
  let methodParams = STPPaymentMethodCardParams()
171
170
  methodParams.token = token
172
- return STPPaymentMethodParams(card: methodParams, billingDetails: billingDetailsParams, metadata: metadata)
171
+ return STPPaymentMethodParams(card: methodParams, billingDetails: billingDetailsParams, metadata: metadata)
173
172
  }
174
173
 
175
174
  if let params = cardFieldView?.cardParams as? STPPaymentMethodParams {
176
175
  if let postalCode = cardFieldView?.cardPostalCode{
177
- if (billingDetailsParams == nil) {
176
+ if billingDetailsParams == nil {
178
177
  let bd = STPPaymentMethodBillingDetails()
179
178
  bd.address = STPPaymentMethodAddress()
180
179
  bd.address?.postalCode = postalCode
@@ -188,7 +187,7 @@ class PaymentMethodFactory {
188
187
  }
189
188
  if let params = cardFormView?.cardParams as? STPPaymentMethodCardParams {
190
189
  if let address = cardFormView?.cardForm?.cardParams?.billingDetails?.address {
191
- if (billingDetailsParams == nil) {
190
+ if billingDetailsParams == nil {
192
191
  let bd = STPPaymentMethodBillingDetails()
193
192
  bd.address = STPPaymentMethodAddress()
194
193
  bd.address?.postalCode = address.postalCode
@@ -205,7 +204,6 @@ class PaymentMethodFactory {
205
204
  throw PaymentMethodError.cardPaymentMissingParams
206
205
  }
207
206
 
208
-
209
207
  private func createCardPaymentMethodOptions() -> STPConfirmPaymentMethodOptions? {
210
208
  let cvc = paymentMethodData?["cvc"] as? String
211
209
  guard cvc != nil else {
@@ -213,7 +211,7 @@ class PaymentMethodFactory {
213
211
  }
214
212
 
215
213
  let cardOptions = STPConfirmCardOptions()
216
- cardOptions.cvc = cvc;
214
+ cardOptions.cvc = cvc
217
215
  let paymentMethodOptions = STPConfirmPaymentMethodOptions()
218
216
  paymentMethodOptions.cardOptions = cardOptions
219
217
 
@@ -227,7 +225,7 @@ class PaymentMethodFactory {
227
225
  params.rawBankString = "test_offline_bank"
228
226
  }
229
227
 
230
- return STPPaymentMethodParams(fpx: params, billingDetails: billingDetailsParams, metadata: metadata)
228
+ return STPPaymentMethodParams(fpx: params, billingDetails: billingDetailsParams, metadata: metadata)
231
229
  }
232
230
 
233
231
  private func createAlipayPaymentMethodParams() throws -> STPPaymentMethodParams {
@@ -366,8 +364,10 @@ class PaymentMethodFactory {
366
364
  }
367
365
 
368
366
  private func createAffirmPaymentMethodParams() throws -> STPPaymentMethodParams {
369
- let params = STPPaymentMethodAffirmParams()
370
- return STPPaymentMethodParams(affirm: params, metadata: metadata)
367
+ let affirmParams = STPPaymentMethodAffirmParams()
368
+ let params = STPPaymentMethodParams(affirm: affirmParams, metadata: metadata)
369
+ params.billingDetails = billingDetailsParams
370
+ return params
371
371
  }
372
372
 
373
373
  private func createCashAppPaymentMethodParams() throws -> STPPaymentMethodParams {
@@ -32,7 +32,7 @@ extension EmbeddedPaymentElement.PaymentOptionDisplayData {
32
32
  "line1": addr.line1 ?? "",
33
33
  "line2": addr.line2 ?? "",
34
34
  "postalCode": addr.postalCode ?? "",
35
- "state": addr.state ?? ""
35
+ "state": addr.state ?? "",
36
36
  ]
37
37
  }()
38
38
 
@@ -40,7 +40,7 @@ extension EmbeddedPaymentElement.PaymentOptionDisplayData {
40
40
  "name": billing.name ?? "",
41
41
  "email": billing.email ?? "",
42
42
  "phone": billing.phone ?? "",
43
- "address": addressDict
43
+ "address": addressDict,
44
44
  ]
45
45
  }()
46
46
 
@@ -53,7 +53,7 @@ extension EmbeddedPaymentElement.PaymentOptionDisplayData {
53
53
  from: NSRange(location: 0, length: mandateText.length),
54
54
  documentAttributes: [
55
55
  .documentType: NSAttributedString.DocumentType.html,
56
- .characterEncoding: String.Encoding.utf8.rawValue
56
+ .characterEncoding: String.Encoding.utf8.rawValue,
57
57
  ]
58
58
  )
59
59
  return String(data: htmlData, encoding: .utf8)
@@ -69,7 +69,7 @@ extension EmbeddedPaymentElement.PaymentOptionDisplayData {
69
69
  "label": label,
70
70
  "billingDetails": billingDetailsDict,
71
71
  "paymentMethodType": paymentMethodType,
72
- "mandateHTML": mandateTextHTML
72
+ "mandateHTML": mandateTextHTML,
73
73
  ]
74
74
  }
75
75
  }
@@ -12,7 +12,7 @@ internal class PaymentPassFinder: NSObject {
12
12
  case CURRENT_DEVICE
13
13
  case PAIRED_DEVICE
14
14
  }
15
-
15
+
16
16
  class func findPassWith(
17
17
  primaryAccountIdentifier: String,
18
18
  hasPairedAppleWatch: Bool,
@@ -27,21 +27,21 @@ internal class PaymentPassFinder: NSObject {
27
27
  .first(where: { $0.paymentPass?.primaryAccountIdentifier == primaryAccountIdentifier && $0.paymentPass?.passActivationState != .deactivated && !$0.isRemotePass })
28
28
  }
29
29
  }()
30
-
30
+
31
31
  var passLocations: [PassLocation] = []
32
- if (existingPassOnDevice != nil) {
32
+ if existingPassOnDevice != nil {
33
33
  passLocations.append(.CURRENT_DEVICE)
34
34
  }
35
-
35
+
36
36
  // We're done here if the user does not have a paired Apple Watch
37
- if (!hasPairedAppleWatch) {
37
+ if !hasPairedAppleWatch {
38
38
  completion(
39
39
  passLocations.count < 1,
40
40
  passLocations
41
41
  )
42
42
  return
43
43
  }
44
-
44
+
45
45
  let existingPassOnPairedDevices: PKPass? = {
46
46
  if #available(iOS 13.4, *) {
47
47
  return PKPassLibrary().remoteSecureElementPasses
@@ -51,12 +51,11 @@ internal class PaymentPassFinder: NSObject {
51
51
  .first(where: { $0.paymentPass?.primaryAccountIdentifier == primaryAccountIdentifier && $0.paymentPass?.passActivationState != .deactivated })
52
52
  }
53
53
  }()
54
-
55
-
56
- if (existingPassOnPairedDevices != nil) {
54
+
55
+ if existingPassOnPairedDevices != nil {
57
56
  passLocations.append(.PAIRED_DEVICE)
58
57
  }
59
-
58
+
60
59
  completion(
61
60
  passLocations.count < 2,
62
61
  passLocations