@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
@@ -9,18 +9,18 @@ public class ApplePayButtonView: UIView {
9
9
  @objc public var onShippingContactSelectedAction: RCTDirectEventBlock?
10
10
  @objc public var onCouponCodeEnteredAction: RCTDirectEventBlock?
11
11
  @objc public var onOrderTrackingAction: RCTDirectEventBlock?
12
-
12
+
13
13
  // Boolean flags to track which callbacks were provided as props
14
14
  @objc public var hasShippingMethodCallback = false
15
15
  @objc public var hasShippingContactCallback = false
16
16
  @objc public var hasCouponCodeCallback = false
17
17
  @objc public var hasOrderTrackingCallback = false
18
-
18
+
19
19
  @objc public var type: NSNumber?
20
20
  @objc public var buttonStyle: NSNumber?
21
21
  @objc public var buttonBorderRadius: NSNumber?
22
22
  @objc public var disabled = false
23
-
23
+
24
24
  @objc func handleApplePayButtonTapped() {
25
25
  // Only set callbacks that were actually provided as props
26
26
  StripeSdkImpl.shared.shippingMethodUpdateJSCallback = hasShippingMethodCallback ? onShippingMethodSelectedAction : nil
@@ -28,7 +28,7 @@ public class ApplePayButtonView: UIView {
28
28
  StripeSdkImpl.shared.couponCodeEnteredJSCallback = hasCouponCodeCallback ? onCouponCodeEnteredAction : nil
29
29
  StripeSdkImpl.shared.platformPayOrderTrackingJSCallback = hasOrderTrackingCallback ? onOrderTrackingAction : nil
30
30
  }
31
-
31
+
32
32
  @objc public func didSetProps() {
33
33
  if let applePayButton = self.applePayButton {
34
34
  applePayButton.removeFromSuperview()
@@ -39,31 +39,30 @@ public class ApplePayButtonView: UIView {
39
39
  if #available(iOS 12.0, *) {
40
40
  self.applePayButton?.cornerRadius = self.buttonBorderRadius as? CGFloat ?? 4.0
41
41
  }
42
-
42
+
43
43
  if let applePayButton = self.applePayButton {
44
44
  applePayButton.isEnabled = !disabled
45
45
  applePayButton.addTarget(self, action: #selector(handleApplePayButtonTapped), for: .touchUpInside)
46
46
  self.addSubview(applePayButton)
47
47
  }
48
48
  }
49
-
49
+
50
50
  override public func didSetProps(_ changedProps: [String]!) {
51
51
  // This is only called on old arch, for new arch didSetProps() will be called
52
52
  // by the view component.
53
53
  self.didSetProps()
54
54
  }
55
-
56
-
55
+
57
56
  override public init(frame: CGRect) {
58
57
  super.init(frame: frame)
59
58
  }
60
-
59
+
61
60
  override public func layoutSubviews() {
62
61
  if let applePayButton = self.applePayButton {
63
62
  applePayButton.frame = self.bounds
64
63
  }
65
64
  }
66
-
65
+
67
66
  required init?(coder: NSCoder) {
68
67
  fatalError("init(coder:) has not been implemented")
69
68
  }
@@ -9,7 +9,7 @@ import Foundation
9
9
  import StripePaymentSheet
10
10
 
11
11
  class ApplePayUtils {
12
-
12
+
13
13
  internal class func createPaymentRequest(
14
14
  merchantIdentifier: String?,
15
15
  params: NSDictionary
@@ -20,17 +20,17 @@ class ApplePayUtils {
20
20
 
21
21
  if let additionalEnabledNetworks = params["additionalEnabledNetworks"] as? [String] {
22
22
  StripeAPI.additionalEnabledApplePayNetworks = ApplePayUtils.mapToArrayOfPaymentNetworks(arrayOfStrings: additionalEnabledNetworks)
23
- } else if (params["jcbEnabled"] as? Bool == true) {
23
+ } else if params["jcbEnabled"] as? Bool == true {
24
24
  StripeAPI.additionalEnabledApplePayNetworks = [.JCB]
25
25
  }
26
26
 
27
27
  guard let summaryItems = params["cartItems"] as? NSArray else {
28
28
  return (Errors.createError(ErrorType.Failed, "`cartItems` cannot be null."), nil)
29
29
  }
30
- if (summaryItems.count == 0) {
30
+ if summaryItems.count == 0 {
31
31
  return (Errors.createError(ErrorType.Failed, "`cartItems` cannot be empty."), nil)
32
32
  }
33
-
33
+
34
34
  guard let countryCode = ((params.object(forKey: "merchantCountryCode") != nil) ? params["merchantCountryCode"] : params["country"]) as? String else {
35
35
  return (Errors.createError(ErrorType.Failed, "You must provide the country"), nil)
36
36
  }
@@ -52,27 +52,27 @@ class ApplePayUtils {
52
52
  Mappers.mapToPKContactField(field: $0 as! String)
53
53
  })
54
54
 
55
- paymentRequest.shippingMethods = ApplePayUtils.buildShippingMethods(items: shippingMethods as? [[String : Any]])
55
+ paymentRequest.shippingMethods = ApplePayUtils.buildShippingMethods(items: shippingMethods as? [[String: Any]])
56
56
 
57
57
  do {
58
58
  paymentRequest.paymentSummaryItems = try ApplePayUtils
59
- .buildPaymentSummaryItems(items: summaryItems as? [[String : Any]])
59
+ .buildPaymentSummaryItems(items: summaryItems as? [[String: Any]])
60
60
  } catch {
61
61
  return (Errors.createError(ErrorType.Failed, error.localizedDescription), nil)
62
62
  }
63
-
63
+
64
64
  if let capabilities = params["merchantCapabilities"] as? [String] {
65
65
  for capability in capabilities {
66
66
  paymentRequest.merchantCapabilities.update(with: ApplePayUtils.getMerchantCapabilityFrom(string: capability))
67
67
  }
68
68
  }
69
-
69
+
70
70
  paymentRequest.shippingType = ApplePayUtils.getShippingTypeFrom(string: params["shippingType"] as? String)
71
71
  if let supportedCountries = params["supportedCountries"] as? Set<String> {
72
72
  paymentRequest.supportedCountries = supportedCountries
73
73
  }
74
74
  if #available(iOS 15.0, *) {
75
- if (params["supportsCouponCode"] as? Bool == true) {
75
+ if params["supportsCouponCode"] as? Bool == true {
76
76
  paymentRequest.supportsCouponCode = true
77
77
  }
78
78
  if let couponCode = params["couponCode"] as? String {
@@ -89,8 +89,8 @@ class ApplePayUtils {
89
89
 
90
90
  return (nil, paymentRequest)
91
91
  }
92
-
93
- #if compiler(>=5.7)
92
+
93
+ #if compiler(>=5.7)
94
94
  @available(iOS 16.0, *)
95
95
  internal class func buildRecurringPaymentRequest(params: NSDictionary) throws -> PKRecurringPaymentRequest {
96
96
  guard let description = params["description"] as? String else {
@@ -102,9 +102,9 @@ class ApplePayUtils {
102
102
  guard let url = URL(string: urlString) else {
103
103
  throw ApplePayUtilsError.invalidUrl(urlString)
104
104
  }
105
- let regularBilling = try ApplePayUtils.createRecurringPaymentSummaryItem(item: params["billing"] as? [String : Any] ?? [:])
105
+ let regularBilling = try ApplePayUtils.createRecurringPaymentSummaryItem(item: params["billing"] as? [String: Any] ?? [:])
106
106
  let request = PKRecurringPaymentRequest(paymentDescription: description, regularBilling: regularBilling, managementURL: url)
107
- if let trialParams = params["trialBilling"] as? [String : Any] {
107
+ if let trialParams = params["trialBilling"] as? [String: Any] {
108
108
  request.trialBilling = try ApplePayUtils.createRecurringPaymentSummaryItem(item: trialParams)
109
109
  }
110
110
  if let tokenNotificationURL = params["tokenNotificationURL"] as? String {
@@ -113,7 +113,7 @@ class ApplePayUtils {
113
113
  request.billingAgreement = params["billingAgreement"] as? String
114
114
  return request
115
115
  }
116
-
116
+
117
117
  @available(iOS 16.0, *)
118
118
  internal class func buildAutomaticReloadPaymentRequest(params: NSDictionary) throws -> PKAutomaticReloadPaymentRequest {
119
119
  guard let description = params["description"] as? String else {
@@ -137,9 +137,9 @@ class ApplePayUtils {
137
137
  request.billingAgreement = params["billingAgreement"] as? String
138
138
  return request
139
139
  }
140
-
140
+
141
141
  @available(iOS 16.0, *)
142
- internal class func buildPaymentTokenContexts(items: [[String : Any]]) -> [PKPaymentTokenContext] {
142
+ internal class func buildPaymentTokenContexts(items: [[String: Any]]) -> [PKPaymentTokenContext] {
143
143
  var result: [PKPaymentTokenContext] = []
144
144
  for item in items {
145
145
  let context = PKPaymentTokenContext.init(merchantIdentifier: item["merchantIdentifier"] as? String ?? "",
@@ -151,8 +151,8 @@ class ApplePayUtils {
151
151
  }
152
152
  return result
153
153
  }
154
- #endif
155
-
154
+ #endif
155
+
156
156
  internal class func getMerchantCapabilityFrom(string: String?) -> PKMerchantCapability {
157
157
  switch string {
158
158
  case "supportsDebit":
@@ -167,7 +167,7 @@ class ApplePayUtils {
167
167
  return .capability3DS
168
168
  }
169
169
  }
170
-
170
+
171
171
  internal class func getShippingTypeFrom(string: String?) -> PKShippingType {
172
172
  switch string {
173
173
  case "delivery":
@@ -182,12 +182,12 @@ class ApplePayUtils {
182
182
  return .shipping
183
183
  }
184
184
  }
185
-
185
+
186
186
  @available(iOS 15.0, *)
187
- internal class func createDeferredPaymentSummaryItem(item: [String : Any]) throws -> PKDeferredPaymentSummaryItem {
187
+ internal class func createDeferredPaymentSummaryItem(item: [String: Any]) throws -> PKDeferredPaymentSummaryItem {
188
188
  let label = item["label"] as? String ?? ""
189
189
  let amount = NSDecimalNumber(string: item["amount"] as? String ?? "")
190
-
190
+
191
191
  let deferredItem = PKDeferredPaymentSummaryItem(
192
192
  label: label,
193
193
  amount: amount
@@ -198,12 +198,12 @@ class ApplePayUtils {
198
198
  deferredItem.deferredDate = Date(timeIntervalSince1970: date)
199
199
  return deferredItem
200
200
  }
201
-
201
+
202
202
  @available(iOS 15.0, *)
203
- internal class func createRecurringPaymentSummaryItem(item: [String : Any]) throws -> PKRecurringPaymentSummaryItem {
203
+ internal class func createRecurringPaymentSummaryItem(item: [String: Any]) throws -> PKRecurringPaymentSummaryItem {
204
204
  let label = item["label"] as? String ?? ""
205
205
  let amount = NSDecimalNumber(string: item["amount"] as? String ?? "")
206
-
206
+
207
207
  let recurringItem = PKRecurringPaymentSummaryItem(
208
208
  label: label,
209
209
  amount: amount
@@ -221,7 +221,7 @@ class ApplePayUtils {
221
221
  }
222
222
  return recurringItem
223
223
  }
224
-
224
+
225
225
  internal class func mapToIntervalUnit(intervalString: String?) throws -> NSCalendar.Unit {
226
226
  switch intervalString {
227
227
  case "minute":
@@ -238,11 +238,11 @@ class ApplePayUtils {
238
238
  throw ApplePayUtilsError.invalidTimeInterval(intervalString ?? "null")
239
239
  }
240
240
  }
241
-
242
- internal class func createImmediatePaymentSummaryItem(item: [String : Any]) -> PKPaymentSummaryItem {
241
+
242
+ internal class func createImmediatePaymentSummaryItem(item: [String: Any]) -> PKPaymentSummaryItem {
243
243
  let label = item["label"] as? String ?? ""
244
244
  let amount = NSDecimalNumber(string: item["amount"] as? String ?? "")
245
-
245
+
246
246
  return PKPaymentSummaryItem(
247
247
  label: label,
248
248
  amount: amount,
@@ -250,8 +250,8 @@ class ApplePayUtils {
250
250
  PKPaymentSummaryItemType.pending : PKPaymentSummaryItemType.final
251
251
  )
252
252
  }
253
-
254
- public class func buildPaymentSummaryItems(items: [[String : Any]]?) throws -> [PKPaymentSummaryItem] {
253
+
254
+ public class func buildPaymentSummaryItems(items: [[String: Any]]?) throws -> [PKPaymentSummaryItem] {
255
255
  var paymentSummaryItems: [PKPaymentSummaryItem] = []
256
256
  if let items = items {
257
257
  for item in items {
@@ -259,11 +259,11 @@ class ApplePayUtils {
259
259
  paymentSummaryItems.append(paymentSummaryItem)
260
260
  }
261
261
  }
262
-
262
+
263
263
  return paymentSummaryItems
264
264
  }
265
-
266
- internal class func buildPaymentSummaryItem(item: [String : Any]) throws -> PKPaymentSummaryItem {
265
+
266
+ internal class func buildPaymentSummaryItem(item: [String: Any]) throws -> PKPaymentSummaryItem {
267
267
  switch item["paymentType"] as? String {
268
268
  case "Deferred":
269
269
  if #available(iOS 15.0, *) {
@@ -283,8 +283,8 @@ class ApplePayUtils {
283
283
  throw ApplePayUtilsError.invalidCartSummaryItemType(item["paymentType"] as? String ?? "null")
284
284
  }
285
285
  }
286
-
287
- public class func buildShippingMethods(items: [[String : Any]]?) -> [PKShippingMethod] {
286
+
287
+ public class func buildShippingMethods(items: [[String: Any]]?) -> [PKShippingMethod] {
288
288
  var shippingMethods: [PKShippingMethod] = []
289
289
  if let items = items {
290
290
  for item in items {
@@ -292,11 +292,11 @@ class ApplePayUtils {
292
292
  shippingMethods.append(shippingMethod)
293
293
  }
294
294
  }
295
-
295
+
296
296
  return shippingMethods
297
297
  }
298
-
299
- internal class func buildShippingMethod(item: [String : Any]) -> PKShippingMethod {
298
+
299
+ internal class func buildShippingMethod(item: [String: Any]) -> PKShippingMethod {
300
300
  let label = item["label"] as? String ?? ""
301
301
  let amount = NSDecimalNumber(string: item["amount"] as? String ?? "")
302
302
  let shippingMethod = PKShippingMethod(
@@ -321,11 +321,11 @@ class ApplePayUtils {
321
321
  }
322
322
  return shippingMethod
323
323
  }
324
-
324
+
325
325
  public class func buildApplePayErrors(errorItems: [NSDictionary]) throws -> (shippingAddressErrors: [Error], couponCodeErrors: [Error]) {
326
326
  var shippingAddressErrors: [Error] = []
327
327
  var couponCodeErrors: [Error] = []
328
-
328
+
329
329
  for item in errorItems {
330
330
  let type = item["errorType"] as? String
331
331
  let message = item["message"] as? String
@@ -349,18 +349,18 @@ class ApplePayUtils {
349
349
  }
350
350
  return (shippingAddressErrors, couponCodeErrors)
351
351
  }
352
-
352
+
353
353
  internal class func mapToArrayOfPaymentNetworks(arrayOfStrings: [String]) -> [PKPaymentNetwork] {
354
354
  let validNetworks: [PKPaymentNetwork?] = arrayOfStrings.map { networkString in
355
355
  return PKPaymentNetwork.init(rawValue: networkString)
356
356
  }
357
357
  return validNetworks.compactMap { $0 }
358
358
  }
359
-
359
+
360
360
  public class func buildPaymentSheetApplePayConfig(
361
361
  merchantIdentifier: String?,
362
362
  merchantCountryCode: String?,
363
- paymentSummaryItems: [[String : Any]]?,
363
+ paymentSummaryItems: [[String: Any]]?,
364
364
  buttonType: NSNumber?,
365
365
  customHandlers: PaymentSheet.ApplePayConfiguration.Handlers?
366
366
  ) throws -> PaymentSheet.ApplePayConfiguration {
@@ -373,7 +373,7 @@ class ApplePayUtils {
373
373
  let paymentSummaryItems = try ApplePayUtils.buildPaymentSummaryItems(
374
374
  items: paymentSummaryItems
375
375
  )
376
-
376
+
377
377
  return PaymentSheet.ApplePayConfiguration.init(
378
378
  merchantId: merchantId,
379
379
  merchantCountryCode: countryCode,
@@ -384,7 +384,7 @@ class ApplePayUtils {
384
384
  }
385
385
  }
386
386
 
387
- enum ApplePayUtilsError : Error, Equatable {
387
+ enum ApplePayUtilsError: Error, Equatable {
388
388
  case invalidCartSummaryItemType(String)
389
389
  case missingParameter(String?, String)
390
390
  case invalidTimeInterval(String)
@@ -395,7 +395,7 @@ enum ApplePayUtilsError : Error, Equatable {
395
395
  case missingMerchantId
396
396
  case missingCountryCode
397
397
  }
398
-
398
+
399
399
  extension ApplePayUtilsError: LocalizedError {
400
400
  public var errorDescription: String? {
401
401
  switch self {
@@ -426,8 +426,8 @@ extension ApplePayUtilsError: LocalizedError {
426
426
  }
427
427
 
428
428
  extension PKPaymentRequest {
429
- func configureRequestType(requestParams: NSDictionary?) throws -> Void {
430
- #if compiler(>=5.7)
429
+ func configureRequestType(requestParams: NSDictionary?) throws {
430
+ #if compiler(>=5.7)
431
431
  if #available(iOS 16.0, *) {
432
432
  if let requestParams = requestParams {
433
433
  switch requestParams["type"] as? String {
@@ -436,12 +436,12 @@ extension PKPaymentRequest {
436
436
  case "AutomaticReload":
437
437
  self.automaticReloadPaymentRequest = try ApplePayUtils.buildAutomaticReloadPaymentRequest(params: requestParams)
438
438
  case "MultiMerchant":
439
- self.multiTokenContexts = ApplePayUtils.buildPaymentTokenContexts(items: requestParams["merchants"] as? [[String : Any]] ?? [])
439
+ self.multiTokenContexts = ApplePayUtils.buildPaymentTokenContexts(items: requestParams["merchants"] as? [[String: Any]] ?? [])
440
440
  default:
441
441
  throw ApplePayUtilsError.invalidRequestType(String(describing: requestParams["type"]))
442
442
  }
443
443
  }
444
444
  }
445
- #endif
445
+ #endif
446
446
  }
447
447
  }
@@ -8,15 +8,15 @@
8
8
  import Foundation
9
9
  import Stripe
10
10
 
11
- extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApplePayContextDelegate {
11
+ extension StripeSdkImpl: PKPaymentAuthorizationViewControllerDelegate, STPApplePayContextDelegate {
12
12
  public func paymentAuthorizationViewController(
13
13
  _ controller: PKPaymentAuthorizationViewController,
14
14
  didAuthorizePayment payment: PKPayment,
15
15
  handler completion: @escaping (PKPaymentAuthorizationResult) -> Void
16
16
  ) {
17
17
  applePaymentMethodFlowCanBeCanceled = false
18
-
19
- if (platformPayUsesDeprecatedTokenFlow) {
18
+
19
+ if platformPayUsesDeprecatedTokenFlow {
20
20
  STPAPIClient.shared.createToken(with: payment) { token, error in
21
21
  if let error = error {
22
22
  self.createPlatformPayPaymentMethodResolver?(Errors.createError(ErrorType.Failed, error))
@@ -43,24 +43,24 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
43
43
  if let shippingContact = payment.shippingContact {
44
44
  promiseResult["shippingContact"] = Mappers.mapFromShippingContact(shippingContact: shippingContact)
45
45
  }
46
-
46
+
47
47
  self.createPlatformPayPaymentMethodResolver?(promiseResult)
48
48
  }
49
49
  completion(PKPaymentAuthorizationResult.init(status: .success, errors: nil))
50
50
  }
51
51
  }
52
52
  }
53
-
53
+
54
54
  public func paymentAuthorizationViewControllerDidFinish(
55
55
  _ controller: PKPaymentAuthorizationViewController
56
56
  ) {
57
- if (applePaymentMethodFlowCanBeCanceled) {
57
+ if applePaymentMethodFlowCanBeCanceled {
58
58
  self.createPlatformPayPaymentMethodResolver?(Errors.createError(ErrorType.Canceled, "The payment has been canceled"))
59
59
  applePaymentMethodFlowCanBeCanceled = false
60
60
  }
61
61
  _ = maybeDismissApplePay()
62
62
  }
63
-
63
+
64
64
  func maybeDismissApplePay() -> Bool {
65
65
  if let applePaymentAuthorizationController = applePaymentAuthorizationController {
66
66
  DispatchQueue.main.async {
@@ -70,7 +70,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
70
70
  }
71
71
  return false
72
72
  }
73
-
73
+
74
74
  @available(iOS 15.0, *)
75
75
  public func paymentAuthorizationViewController(
76
76
  _ controller: PKPaymentAuthorizationViewController,
@@ -83,14 +83,14 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
83
83
  } else {
84
84
  completion(
85
85
  PKPaymentRequestCouponCodeUpdate.init(
86
- errors: self.applePayCouponCodeErrors,
87
- paymentSummaryItems: self.applePaySummaryItems,
88
- shippingMethods: self.applePayShippingMethods
86
+ errors: self.applePayCouponCodeErrors,
87
+ paymentSummaryItems: self.applePaySummaryItems,
88
+ shippingMethods: self.applePayShippingMethods
89
89
  )
90
90
  )
91
91
  }
92
92
  }
93
-
93
+
94
94
  public func paymentAuthorizationViewController(
95
95
  _ controller: PKPaymentAuthorizationViewController,
96
96
  didSelect shippingMethod: PKShippingMethod,
@@ -105,7 +105,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
105
105
  )
106
106
  }
107
107
  }
108
-
108
+
109
109
  public func paymentAuthorizationViewController(
110
110
  _ controller: PKPaymentAuthorizationViewController,
111
111
  didSelectShippingContact contact: PKContact,
@@ -124,7 +124,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
124
124
  )
125
125
  }
126
126
  }
127
-
127
+
128
128
  public func applePayContext(
129
129
  _ context: STPApplePayContext,
130
130
  didSelect shippingMethod: PKShippingMethod,
@@ -139,7 +139,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
139
139
  )
140
140
  }
141
141
  }
142
-
142
+
143
143
  public func applePayContext(
144
144
  _ context: STPApplePayContext,
145
145
  didSelectShippingContact contact: PKContact,
@@ -158,7 +158,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
158
158
  )
159
159
  }
160
160
  }
161
-
161
+
162
162
  public func applePayContext(
163
163
  _ context: STPApplePayContext,
164
164
  didCreatePaymentMethod paymentMethod: STPPaymentMethod,
@@ -174,7 +174,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
174
174
  RCTMakeAndLogError("Tried to complete Apple Pay payment, but no client secret was found.", nil, nil)
175
175
  }
176
176
  }
177
-
177
+
178
178
  public func applePayContext(
179
179
  _ context: STPApplePayContext,
180
180
  willCompleteWithResult authorizationResult: PKPaymentAuthorizationResult,
@@ -187,7 +187,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
187
187
  handler(authorizationResult)
188
188
  }
189
189
  }
190
-
190
+
191
191
  public func applePayContext(
192
192
  _ context: STPApplePayContext,
193
193
  didCompleteWith status: STPPaymentStatus,
@@ -209,7 +209,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
209
209
 
210
210
  if let paymentIntent = paymentIntent {
211
211
  let result = Mappers.mapFromPaymentIntent(paymentIntent: paymentIntent)
212
- if (paymentIntent.paymentMethod == nil) {
212
+ if paymentIntent.paymentMethod == nil {
213
213
  result.setValue(Mappers.mapFromPaymentMethod(self.confirmApplePayPaymentMethod), forKey: "paymentMethod")
214
214
  }
215
215
  resolve(Mappers.createResult("paymentIntent", result))
@@ -231,7 +231,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
231
231
 
232
232
  if let setupIntent = setupIntent {
233
233
  let result = Mappers.mapFromSetupIntent(setupIntent: setupIntent)
234
- if (setupIntent.paymentMethod == nil) {
234
+ if setupIntent.paymentMethod == nil {
235
235
  result.setValue(Mappers.mapFromPaymentMethod(self.confirmApplePayPaymentMethod), forKey: "paymentMethod")
236
236
  }
237
237
  resolve(Mappers.createResult("setupIntent", result))
@@ -242,38 +242,34 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
242
242
  }
243
243
  }
244
244
  }
245
- break
246
245
  case .error:
247
246
  if let resolve = self.confirmApplePayResolver {
248
247
  resolve(Errors.createError(ErrorType.Failed, error as NSError?))
249
248
  }
250
- break
251
249
  case .userCancellation:
252
250
  let message = "The payment has been canceled"
253
251
  if let resolve = self.confirmApplePayResolver {
254
252
  resolve(Errors.createError(ErrorType.Canceled, message))
255
253
  }
256
- break
257
254
  @unknown default:
258
255
  if let resolve = self.confirmApplePayResolver {
259
256
  resolve(Errors.createError(ErrorType.Unknown, error as NSError?))
260
257
  }
261
- break
262
258
  }
263
259
  confirmApplePayResolver = nil
264
260
  confirmApplePayPaymentClientSecret = nil
265
261
  confirmApplePaySetupClientSecret = nil
266
262
  }
267
-
263
+
268
264
  }
269
265
 
270
266
  extension STPPaymentMethod {
271
267
  func splitApplePayAddressByNewline() -> STPPaymentMethod {
272
268
  let address = self.billingDetails?.address?.line1?.split(whereSeparator: \.isNewline)
273
- if (address?.indices.contains(0) == true) {
269
+ if address?.indices.contains(0) == true {
274
270
  self.billingDetails?.address?.line1 = String(address?[0] ?? "")
275
271
  }
276
- if (address?.indices.contains(1) == true) {
272
+ if address?.indices.contains(1) == true {
277
273
  self.billingDetails?.address?.line2 = String(address?[1] ?? "")
278
274
  }
279
275
  return self
@@ -283,10 +279,10 @@ extension STPPaymentMethod {
283
279
  extension STPToken {
284
280
  func splitApplePayAddressByNewline() -> STPToken {
285
281
  let address = self.card?.address?.line1?.split(whereSeparator: \.isNewline)
286
- if (address?.indices.contains(0) == true) {
282
+ if address?.indices.contains(0) == true {
287
283
  self.card?.address?.line1 = String(address?[0] ?? "")
288
284
  }
289
- if (address?.indices.contains(1) == true) {
285
+ if address?.indices.contains(1) == true {
290
286
  self.card?.address?.line2 = String(address?[1] ?? "")
291
287
  }
292
288
  return self
@@ -5,7 +5,7 @@ class AuBECSDebitFormManager: RCTViewManager {
5
5
  override func view() -> UIView! {
6
6
  return AuBECSDebitFormView(frame: CGRect.init())
7
7
  }
8
-
8
+
9
9
  override class func requiresMainQueueSetup() -> Bool {
10
10
  return true
11
11
  }
@@ -1,6 +1,6 @@
1
1
  import Foundation
2
- import UIKit
3
2
  import Stripe
3
+ import UIKit
4
4
 
5
5
  @objc(AuBECSDebitFormView)
6
6
  public class AuBECSDebitFormView: UIView, STPAUBECSDebitFormViewDelegate {
@@ -8,35 +8,33 @@ public class AuBECSDebitFormView: UIView, STPAUBECSDebitFormViewDelegate {
8
8
  var auBecsFormView: STPAUBECSDebitFormView?
9
9
  @objc public var onCompleteAction: RCTDirectEventBlock?
10
10
  @objc public var companyName: NSString?
11
-
11
+
12
12
  @objc public func didSetProps() {
13
13
  if let auBecsFormView = self.auBecsFormView {
14
14
  auBecsFormView.removeFromSuperview()
15
15
  }
16
-
17
16
 
18
17
  self.auBecsFormView = STPAUBECSDebitFormView(companyName: (companyName ?? "") as String)
19
18
  self.auBecsFormView?.becsDebitFormDelegate = self
20
-
21
-
19
+
22
20
  if let auBecsFormView = self.auBecsFormView {
23
21
  self.addSubview(auBecsFormView)
24
22
  setStyles()
25
23
  }
26
24
  }
27
-
25
+
28
26
  override public func didSetProps(_ changedProps: [String]!) {
29
27
  // This is only called on old arch, for new arch didSetProps() will be called
30
28
  // by the view component.
31
- self.didSetProps();
29
+ self.didSetProps()
32
30
  }
33
-
31
+
34
32
  @objc public var formStyle: NSDictionary = NSDictionary() {
35
33
  didSet {
36
- setStyles()
34
+ setStyles()
37
35
  }
38
36
  }
39
-
37
+
40
38
  private func setStyles() {
41
39
  auBecsFormView?.formFont = UIFont.systemFont(ofSize: CGFloat(30))
42
40
 
@@ -65,26 +63,26 @@ public class AuBECSDebitFormView: UIView, STPAUBECSDebitFormViewDelegate {
65
63
  auBecsFormView?.layer.borderWidth = borderWidth
66
64
  }
67
65
  }
68
-
66
+
69
67
  public func auBECSDebitForm(_ form: STPAUBECSDebitFormView, didChangeToStateComplete complete: Bool) {
70
68
  onCompleteAction!([
71
69
  "accountNumber": form.paymentMethodParams?.auBECSDebit?.accountNumber ?? "",
72
70
  "bsbNumber": form.paymentMethodParams?.auBECSDebit?.bsbNumber ?? "",
73
71
  "name": form.paymentMethodParams?.billingDetails?.name ?? "",
74
- "email": form.paymentMethodParams?.billingDetails?.email ?? ""
72
+ "email": form.paymentMethodParams?.billingDetails?.email ?? "",
75
73
  ])
76
74
  }
77
-
75
+
78
76
  override public init(frame: CGRect) {
79
77
  super.init(frame: frame)
80
78
  }
81
-
79
+
82
80
  override public func layoutSubviews() {
83
81
  if let auBecsFormView = self.auBecsFormView {
84
82
  auBecsFormView.frame = self.bounds
85
83
  }
86
84
  }
87
-
85
+
88
86
  required init?(coder: NSCoder) {
89
87
  fatalError("init(coder:) has not been implemented")
90
88
  }