@stripe/stripe-react-native 0.63.0 → 0.64.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 (285) hide show
  1. package/README.md +2 -2
  2. package/android/build.gradle +2 -2
  3. package/android/detekt/detekt-baseline.xml +81 -0
  4. package/android/detekt/detekt.gradle +45 -0
  5. package/android/detekt/detekt.yml +722 -0
  6. package/android/gradle.properties +4 -4
  7. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +3 -1
  8. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +2 -1
  9. package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +5 -1
  10. package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementView.kt +26 -0
  11. package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementViewManager.kt +42 -0
  12. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +105 -49
  13. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +72 -12
  14. package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetManager.kt +8 -4
  15. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +2 -1
  16. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +26 -11
  17. package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +2 -1
  18. package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +14 -5
  19. package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +6 -2
  20. package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherManager.kt +2 -2
  21. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +24 -1
  22. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfig.kt +7 -4
  23. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementViewManager.kt +2 -1
  24. package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +8 -4
  25. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +9 -3
  26. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +110 -29
  27. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +256 -12
  28. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +6 -5
  29. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt +2 -1
  30. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +3 -1
  31. package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +6 -2
  32. package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +3 -1
  33. package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -1
  34. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +2 -1
  35. package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutAddressUpdate.kt +45 -0
  36. package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutMappers.kt +101 -0
  37. package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +4 -2
  38. package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +5 -1
  39. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +31 -17
  40. package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -1
  41. package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +6 -0
  42. package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +2 -0
  43. package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeCurrencySelectorElementManagerDelegate.java +35 -0
  44. package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeCurrencySelectorElementManagerInterface.java +18 -0
  45. package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +44 -0
  46. package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +43 -0
  47. package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +5 -1
  48. package/android/src/test/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfigTest.kt +3 -3
  49. package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +93 -0
  50. package/android/src/test/java/com/reactnativestripesdk/mappers/OnrampMappersTest.kt +336 -0
  51. package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +9 -4
  52. package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutMappersTest.kt +89 -0
  53. package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutTestFixtures.java +49 -0
  54. package/ios/AddressSheet/AddressSheetUtils.swift +23 -0
  55. package/ios/AddressSheet/AddressSheetView.swift +9 -14
  56. package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +6 -8
  57. package/ios/CurrencySelectorElementManager.m +9 -0
  58. package/ios/CurrencySelectorElementManager.swift +12 -0
  59. package/ios/CurrencySelectorElementView.swift +24 -0
  60. package/ios/Mappers+Checkout.swift +193 -0
  61. package/ios/Mappers.swift +74 -5
  62. package/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm +16 -2
  63. package/ios/NewArch/StripeCurrencySelectorElementComponentView.h +10 -0
  64. package/ios/NewArch/StripeCurrencySelectorElementComponentView.mm +75 -0
  65. package/ios/PaymentMethodFactory.swift +19 -0
  66. package/ios/PaymentMethodMessagingElementConfig.swift +6 -3
  67. package/ios/PaymentMethodMessagingElementView.swift +19 -0
  68. package/ios/StripeSdk-Bridging-Header.h +1 -0
  69. package/ios/StripeSdk.mm +124 -1
  70. package/ios/StripeSdkImpl+Checkout.swift +308 -0
  71. package/ios/StripeSdkImpl+Embedded.swift +108 -27
  72. package/ios/StripeSdkImpl+PaymentSheet.swift +18 -2
  73. package/ios/StripeSdkImpl.swift +41 -103
  74. package/ios/StripeSwiftInterop.h +1 -0
  75. package/jest/mock.js +16 -1
  76. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  77. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  78. package/lib/commonjs/components/AddressSheet.js +1 -1
  79. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  80. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  81. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  82. package/lib/commonjs/components/CardField.js +1 -1
  83. package/lib/commonjs/components/CardField.js.map +1 -1
  84. package/lib/commonjs/components/CardForm.js +1 -1
  85. package/lib/commonjs/components/CardForm.js.map +1 -1
  86. package/lib/commonjs/components/CurrencySelectorElement.js +2 -0
  87. package/lib/commonjs/components/CurrencySelectorElement.js.map +1 -0
  88. package/lib/commonjs/components/PaymentMethodMessagingElement.js +2 -0
  89. package/lib/commonjs/components/PaymentMethodMessagingElement.js.map +1 -0
  90. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  91. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  92. package/lib/commonjs/components/StripeContainer.js +1 -1
  93. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  94. package/lib/commonjs/components/StripeProvider.js +1 -1
  95. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  96. package/lib/commonjs/connect/Components.js +1 -1
  97. package/lib/commonjs/connect/Components.js.map +1 -1
  98. package/lib/commonjs/connect/ConnectComponentsProvider.js +1 -1
  99. package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -1
  100. package/lib/commonjs/connect/EmbeddedComponent.js +1 -1
  101. package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
  102. package/lib/commonjs/connect/ModalCloseButton.js +1 -1
  103. package/lib/commonjs/connect/ModalCloseButton.js.map +1 -1
  104. package/lib/commonjs/connect/NavigationBar.js +1 -1
  105. package/lib/commonjs/connect/NavigationBar.js.map +1 -1
  106. package/lib/commonjs/connect/testUtils.js +1 -1
  107. package/lib/commonjs/connect/testUtils.js.map +1 -1
  108. package/lib/commonjs/events.js +1 -1
  109. package/lib/commonjs/events.js.map +1 -1
  110. package/lib/commonjs/functions.js +1 -1
  111. package/lib/commonjs/functions.js.map +1 -1
  112. package/lib/commonjs/helpers.js +1 -1
  113. package/lib/commonjs/hooks/useCheckout.js +2 -0
  114. package/lib/commonjs/hooks/useCheckout.js.map +1 -0
  115. package/lib/commonjs/hooks/useOnramp.js +1 -1
  116. package/lib/commonjs/hooks/useOnramp.js.map +1 -1
  117. package/lib/commonjs/index.js +1 -1
  118. package/lib/commonjs/index.js.map +1 -1
  119. package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
  120. package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
  121. package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
  122. package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
  123. package/lib/commonjs/specs/NativeCardField.js +1 -1
  124. package/lib/commonjs/specs/NativeCardField.js.map +1 -1
  125. package/lib/commonjs/specs/NativeCardForm.js +1 -1
  126. package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
  127. package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +1 -1
  128. package/lib/commonjs/specs/NativeCurrencySelectorElement.js +2 -0
  129. package/lib/commonjs/specs/NativeCurrencySelectorElement.js.map +1 -0
  130. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
  131. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  132. package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
  133. package/lib/commonjs/specs/NativeNavigationBar.js +1 -1
  134. package/lib/commonjs/specs/NativeOnrampSdkModule.js +1 -1
  135. package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -1
  136. package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +1 -1
  137. package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js.map +1 -1
  138. package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
  139. package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
  140. package/lib/commonjs/types/Checkout.js +2 -0
  141. package/lib/commonjs/types/Checkout.js.map +1 -0
  142. package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
  143. package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
  144. package/lib/commonjs/types/Onramp.js.map +1 -1
  145. package/lib/commonjs/types/PaymentIntent.js.map +1 -1
  146. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  147. package/lib/module/components/AddToWalletButton.js +1 -1
  148. package/lib/module/components/AddToWalletButton.js.map +1 -1
  149. package/lib/module/components/AddressSheet.js +1 -1
  150. package/lib/module/components/AddressSheet.js.map +1 -1
  151. package/lib/module/components/AuBECSDebitForm.js +1 -1
  152. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  153. package/lib/module/components/CardField.js +1 -1
  154. package/lib/module/components/CardField.js.map +1 -1
  155. package/lib/module/components/CardForm.js +1 -1
  156. package/lib/module/components/CardForm.js.map +1 -1
  157. package/lib/module/components/CurrencySelectorElement.js +2 -0
  158. package/lib/module/components/CurrencySelectorElement.js.map +1 -0
  159. package/lib/module/components/PaymentMethodMessagingElement.js +2 -0
  160. package/lib/module/components/PaymentMethodMessagingElement.js.map +1 -0
  161. package/lib/module/components/PlatformPayButton.js +1 -1
  162. package/lib/module/components/PlatformPayButton.js.map +1 -1
  163. package/lib/module/components/StripeContainer.js +1 -1
  164. package/lib/module/components/StripeContainer.js.map +1 -1
  165. package/lib/module/components/StripeProvider.js +1 -1
  166. package/lib/module/components/StripeProvider.js.map +1 -1
  167. package/lib/module/connect/Components.js +1 -1
  168. package/lib/module/connect/Components.js.map +1 -1
  169. package/lib/module/connect/ConnectComponentsProvider.js +1 -1
  170. package/lib/module/connect/ConnectComponentsProvider.js.map +1 -1
  171. package/lib/module/connect/EmbeddedComponent.js +1 -1
  172. package/lib/module/connect/EmbeddedComponent.js.map +1 -1
  173. package/lib/module/connect/ModalCloseButton.js +1 -1
  174. package/lib/module/connect/ModalCloseButton.js.map +1 -1
  175. package/lib/module/connect/NavigationBar.js +1 -1
  176. package/lib/module/connect/NavigationBar.js.map +1 -1
  177. package/lib/module/connect/testUtils.js +1 -1
  178. package/lib/module/connect/testUtils.js.map +1 -1
  179. package/lib/module/events.js +1 -1
  180. package/lib/module/events.js.map +1 -1
  181. package/lib/module/functions.js +1 -1
  182. package/lib/module/functions.js.map +1 -1
  183. package/lib/module/helpers.js +1 -1
  184. package/lib/module/hooks/useCheckout.js +2 -0
  185. package/lib/module/hooks/useCheckout.js.map +1 -0
  186. package/lib/module/hooks/useOnramp.js +1 -1
  187. package/lib/module/hooks/useOnramp.js.map +1 -1
  188. package/lib/module/index.js +1 -1
  189. package/lib/module/index.js.map +1 -1
  190. package/lib/module/specs/NativeAddToWalletButton.js +1 -1
  191. package/lib/module/specs/NativeAddressSheet.js +1 -1
  192. package/lib/module/specs/NativeApplePayButton.js +1 -1
  193. package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
  194. package/lib/module/specs/NativeCardField.js +1 -1
  195. package/lib/module/specs/NativeCardField.js.map +1 -1
  196. package/lib/module/specs/NativeCardForm.js +1 -1
  197. package/lib/module/specs/NativeCardForm.js.map +1 -1
  198. package/lib/module/specs/NativeConnectAccountOnboardingView.js +1 -1
  199. package/lib/module/specs/NativeCurrencySelectorElement.js +2 -0
  200. package/lib/module/specs/NativeCurrencySelectorElement.js.map +1 -0
  201. package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
  202. package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  203. package/lib/module/specs/NativeGooglePayButton.js +1 -1
  204. package/lib/module/specs/NativeNavigationBar.js +1 -1
  205. package/lib/module/specs/NativeOnrampSdkModule.js +1 -1
  206. package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -1
  207. package/lib/module/specs/NativePaymentMethodMessagingElement.js +1 -1
  208. package/lib/module/specs/NativePaymentMethodMessagingElement.js.map +1 -1
  209. package/lib/module/specs/NativeStripeContainer.js +1 -1
  210. package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
  211. package/lib/module/types/Checkout.js +2 -0
  212. package/lib/module/types/Checkout.js.map +1 -0
  213. package/lib/module/types/EmbeddedPaymentElement.js +1 -1
  214. package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
  215. package/lib/module/types/Onramp.js.map +1 -1
  216. package/lib/module/types/PaymentIntent.js.map +1 -1
  217. package/lib/module/types/PaymentSheet.js.map +1 -1
  218. package/lib/typescript/src/components/CurrencySelectorElement.d.ts +62 -0
  219. package/lib/typescript/src/components/CurrencySelectorElement.d.ts.map +1 -0
  220. package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts +41 -0
  221. package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts.map +1 -0
  222. package/lib/typescript/src/connect/testUtils.d.ts +4 -0
  223. package/lib/typescript/src/connect/testUtils.d.ts.map +1 -1
  224. package/lib/typescript/src/events.d.ts +11 -0
  225. package/lib/typescript/src/events.d.ts.map +1 -1
  226. package/lib/typescript/src/functions.d.ts +2 -0
  227. package/lib/typescript/src/functions.d.ts.map +1 -1
  228. package/lib/typescript/src/hooks/useCheckout.d.ts +21 -0
  229. package/lib/typescript/src/hooks/useCheckout.d.ts.map +1 -0
  230. package/lib/typescript/src/hooks/useOnramp.d.ts +9 -3
  231. package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -1
  232. package/lib/typescript/src/index.d.ts +3 -0
  233. package/lib/typescript/src/index.d.ts.map +1 -1
  234. package/lib/typescript/src/specs/NativeCurrencySelectorElement.d.ts +25 -0
  235. package/lib/typescript/src/specs/NativeCurrencySelectorElement.d.ts.map +1 -0
  236. package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +5 -1
  237. package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -1
  238. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +1 -1
  239. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -1
  240. package/lib/typescript/src/specs/NativePaymentMethodMessagingElement.d.ts +1 -6
  241. package/lib/typescript/src/specs/NativePaymentMethodMessagingElement.d.ts.map +1 -1
  242. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +19 -2
  243. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
  244. package/lib/typescript/src/types/Checkout.d.ts +336 -0
  245. package/lib/typescript/src/types/Checkout.d.ts.map +1 -0
  246. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +36 -1
  247. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
  248. package/lib/typescript/src/types/NextAction.d.ts +8 -1
  249. package/lib/typescript/src/types/NextAction.d.ts.map +1 -1
  250. package/lib/typescript/src/types/Onramp.d.ts +40 -1
  251. package/lib/typescript/src/types/Onramp.d.ts.map +1 -1
  252. package/lib/typescript/src/types/PaymentIntent.d.ts +11 -1
  253. package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
  254. package/lib/typescript/src/types/PaymentMethod.d.ts +10 -6
  255. package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -1
  256. package/lib/typescript/src/types/PaymentSheet.d.ts +22 -6
  257. package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
  258. package/lib/typescript/src/types/components/PaymentMethodMessagingElementComponent.d.ts +16 -1
  259. package/lib/typescript/src/types/components/PaymentMethodMessagingElementComponent.d.ts.map +1 -1
  260. package/package.json +21 -7
  261. package/src/components/CurrencySelectorElement.tsx +95 -0
  262. package/src/components/PaymentMethodMessagingElement.tsx +109 -0
  263. package/src/components/StripeProvider.tsx +1 -1
  264. package/src/connect/testUtils.ts +2 -0
  265. package/src/events.ts +20 -3
  266. package/src/functions.ts +31 -2
  267. package/src/hooks/useCheckout.tsx +207 -0
  268. package/src/hooks/useOnramp.tsx +45 -24
  269. package/src/index.tsx +4 -0
  270. package/src/specs/NativeCurrencySelectorElement.ts +35 -0
  271. package/src/specs/NativeEmbeddedPaymentElement.ts +12 -2
  272. package/src/specs/NativeOnrampSdkModule.ts +1 -1
  273. package/src/specs/NativePaymentMethodMessagingElement.ts +0 -7
  274. package/src/specs/NativeStripeSdkModule.ts +61 -2
  275. package/src/types/Checkout.ts +377 -0
  276. package/src/types/EmbeddedPaymentElement.tsx +117 -26
  277. package/src/types/NextAction.ts +9 -0
  278. package/src/types/Onramp.ts +45 -1
  279. package/src/types/PaymentIntent.ts +10 -0
  280. package/src/types/PaymentMethod.ts +9 -6
  281. package/src/types/PaymentSheet.ts +29 -6
  282. package/src/types/components/PaymentMethodMessagingElementComponent.tsx +17 -1
  283. package/stripe-react-native.podspec +8 -8
  284. package/android/spotless.gradle +0 -19
  285. package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +0 -155
@@ -0,0 +1,193 @@
1
+ //
2
+ // Mappers+Checkout.swift
3
+ // stripe-react-native
4
+ //
5
+ // Created by Nick Porter on 4/29/26.
6
+ //
7
+
8
+ import Foundation
9
+ @_spi(CheckoutSessionsPreview) import StripePaymentSheet
10
+
11
+ extension Mappers {
12
+ class func mapFromCheckoutState(_ state: Checkout.State) -> NSDictionary {
13
+ return [
14
+ "status": state.isLoading ? "loading" : "loaded",
15
+ "session": mapFromCheckoutSession(state.session),
16
+ ]
17
+ }
18
+
19
+ class func mapFromCheckoutSession(_ session: any Checkout.Session) -> NSDictionary {
20
+ let result = NSMutableDictionary()
21
+ result["id"] = session.id
22
+ result["paymentStatus"] = mapFromCheckoutPaymentStatus(session.paymentStatus)
23
+ result["livemode"] = session.livemode
24
+ result["lineItems"] = session.lineItems.map(mapFromCheckoutLineItem)
25
+ result["shippingOptions"] = session.shippingOptions.map(mapFromCheckoutShippingOption)
26
+ result["discounts"] = session.discounts.map(mapFromCheckoutDiscount)
27
+
28
+ if let status = mapFromCheckoutStatus(session.status) {
29
+ result["status"] = status
30
+ }
31
+
32
+ if let currency = session.currency {
33
+ result["currency"] = currency
34
+ }
35
+
36
+ if let totals = session.totals {
37
+ result["totals"] = mapFromCheckoutTotals(totals)
38
+ }
39
+
40
+ if let customerId = session.customerId {
41
+ result["customerId"] = customerId
42
+ }
43
+
44
+ if let customerEmail = session.customerEmail {
45
+ result["customerEmail"] = customerEmail
46
+ }
47
+
48
+ if let billingAddress = session.billingAddress {
49
+ result["billingAddress"] = mapFromCheckoutAddressUpdate(billingAddress)
50
+ }
51
+
52
+ if let shippingAddress = session.shippingAddress {
53
+ result["shippingAddress"] = mapFromCheckoutAddressUpdate(shippingAddress)
54
+ }
55
+
56
+ return result
57
+ }
58
+
59
+ class func mapFromCheckoutAddressUpdate(_ addressUpdate: Checkout.AddressUpdate) -> NSDictionary {
60
+ let result = NSMutableDictionary()
61
+ result["address"] = mapFromCheckoutAddress(addressUpdate.address)
62
+
63
+ if let name = addressUpdate.name {
64
+ result["name"] = name
65
+ }
66
+
67
+ if let phone = addressUpdate.phone {
68
+ result["phone"] = phone
69
+ }
70
+
71
+ return result
72
+ }
73
+
74
+ private class func mapFromCheckoutAddress(_ address: Checkout.Address) -> NSDictionary {
75
+ let result = NSMutableDictionary()
76
+ result["country"] = address.country
77
+
78
+ if let line1 = address.line1 {
79
+ result["line1"] = line1
80
+ }
81
+
82
+ if let line2 = address.line2 {
83
+ result["line2"] = line2
84
+ }
85
+
86
+ if let city = address.city {
87
+ result["city"] = city
88
+ }
89
+
90
+ if let state = address.state {
91
+ result["state"] = state
92
+ }
93
+
94
+ if let postalCode = address.postalCode {
95
+ result["postalCode"] = postalCode
96
+ }
97
+
98
+ return result
99
+ }
100
+
101
+ private class func mapFromCheckoutTotals(_ totals: Checkout.Totals) -> NSDictionary {
102
+ return [
103
+ "subtotal": totals.subtotal,
104
+ "total": totals.total,
105
+ "due": totals.due,
106
+ "discount": totals.discount,
107
+ "shipping": totals.shipping,
108
+ "tax": totals.tax,
109
+ ]
110
+ }
111
+
112
+ private class func mapFromCheckoutLineItem(_ lineItem: Checkout.LineItem) -> NSDictionary {
113
+ return [
114
+ "id": lineItem.id,
115
+ "name": lineItem.name,
116
+ "quantity": lineItem.quantity,
117
+ "unitAmount": lineItem.unitAmount,
118
+ "currency": lineItem.currency,
119
+ ]
120
+ }
121
+
122
+ private class func mapFromCheckoutShippingOption(_ shippingOption: Checkout.ShippingOption) -> NSDictionary {
123
+ return [
124
+ "id": shippingOption.id,
125
+ "displayName": shippingOption.displayName,
126
+ "amount": shippingOption.amount,
127
+ "currency": shippingOption.currency,
128
+ ]
129
+ }
130
+
131
+ private class func mapFromCheckoutDiscount(_ discount: Checkout.Discount) -> NSDictionary {
132
+ let result = NSMutableDictionary()
133
+ result["coupon"] = mapFromCheckoutCoupon(discount.coupon)
134
+ result["amount"] = discount.amount
135
+
136
+ if let promotionCode = discount.promotionCode {
137
+ result["promotionCode"] = promotionCode
138
+ }
139
+
140
+ return result
141
+ }
142
+
143
+ private class func mapFromCheckoutCoupon(_ coupon: Checkout.Coupon) -> NSDictionary {
144
+ let result = NSMutableDictionary()
145
+ result["id"] = coupon.id
146
+
147
+ if let name = coupon.name {
148
+ result["name"] = name
149
+ }
150
+
151
+ if let percentOff = coupon.percentOff {
152
+ result["percentOff"] = percentOff
153
+ }
154
+
155
+ if let amountOff = coupon.amountOff {
156
+ result["amountOff"] = amountOff
157
+ }
158
+
159
+ return result
160
+ }
161
+
162
+ private class func mapFromCheckoutStatus(_ status: Checkout.Status?) -> String? {
163
+ switch status {
164
+ case .open:
165
+ return "open"
166
+ case .complete:
167
+ return "complete"
168
+ case .expired:
169
+ return "expired"
170
+ case .unknown:
171
+ return "unknown"
172
+ case nil:
173
+ return nil
174
+ @unknown default:
175
+ return "unknown"
176
+ }
177
+ }
178
+
179
+ private class func mapFromCheckoutPaymentStatus(_ paymentStatus: Checkout.PaymentStatus) -> String {
180
+ switch paymentStatus {
181
+ case .paid:
182
+ return "paid"
183
+ case .unpaid:
184
+ return "unpaid"
185
+ case .noPaymentRequired:
186
+ return "noPaymentRequired"
187
+ case .unknown:
188
+ return "unknown"
189
+ @unknown default:
190
+ return "unknown"
191
+ }
192
+ }
193
+ }
package/ios/Mappers.swift CHANGED
@@ -295,8 +295,8 @@ class Mappers {
295
295
  case STPPaymentMethodType.EPS: return "Eps"
296
296
  case STPPaymentMethodType.bancontact: return "Bancontact"
297
297
  case STPPaymentMethodType.billie: return "Billie"
298
+ case STPPaymentMethodType.multibanco: return "Multibanco"
298
299
  case STPPaymentMethodType.OXXO: return "Oxxo"
299
- case STPPaymentMethodType.UPI: return "Upi"
300
300
  case STPPaymentMethodType.afterpayClearpay: return "AfterpayClearpay"
301
301
  case STPPaymentMethodType.klarna: return "Klarna"
302
302
  case STPPaymentMethodType.USBankAccount: return "USBankAccount"
@@ -327,8 +327,8 @@ class Mappers {
327
327
  case "Eps": return STPPaymentMethodType.EPS
328
328
  case "Bancontact": return STPPaymentMethodType.bancontact
329
329
  case "Billie": return STPPaymentMethodType.billie
330
+ case "Multibanco": return STPPaymentMethodType.multibanco
330
331
  case "Oxxo": return STPPaymentMethodType.OXXO
331
- case "Upi": return STPPaymentMethodType.UPI
332
332
  case "AfterpayClearpay": return STPPaymentMethodType.afterpayClearpay
333
333
  case "Klarna": return STPPaymentMethodType.klarna
334
334
  case "WeChatPay": return STPPaymentMethodType.weChatPay
@@ -475,6 +475,14 @@ class Mappers {
475
475
  "type": "konbiniVoucher",
476
476
  "voucherURL": it.konbiniDisplayDetails?.hostedVoucherURL.absoluteString ?? NSNull(),
477
477
  ]
478
+ case .multibancoDisplayDetails:
479
+ return [
480
+ "type": "multibanco",
481
+ "entity": it.multibancoDisplayDetails?.entity ?? NSNull(),
482
+ "reference": it.multibancoDisplayDetails?.reference ?? NSNull(),
483
+ "expiresAt": it.multibancoDisplayDetails?.expiresAt.timeIntervalSince1970 ?? NSNull(),
484
+ "voucherURL": it.multibancoDisplayDetails?.hostedVoucherURL.absoluteString ?? NSNull(),
485
+ ]
478
486
  default: // .useStripeSDK, .BLIKAuthorize, .unknown
479
487
  return nil
480
488
  }
@@ -691,9 +699,6 @@ class Mappers {
691
699
  "SepaDebit": sepaDebit,
692
700
  "BacsDebit": bacsDebit,
693
701
  "AuBecsDebit": auBECSDebit,
694
- "Upi": [
695
- "vpa": paymentMethod.upi?.vpa
696
- ],
697
702
  "USBankAccount": USBankAccount,
698
703
  ]
699
704
  return method
@@ -1267,6 +1272,70 @@ class Mappers {
1267
1272
  )
1268
1273
  }
1269
1274
 
1275
+ class func mapFromKycInfo(_ kycInfo: KycInfo) -> [String: Any] {
1276
+ var result: [String: Any] = [:]
1277
+
1278
+ if let firstName = kycInfo.firstName {
1279
+ result["firstName"] = firstName
1280
+ }
1281
+
1282
+ if let lastName = kycInfo.lastName {
1283
+ result["lastName"] = lastName
1284
+ }
1285
+
1286
+ if let idNumber = kycInfo.idNumber {
1287
+ result["idNumber"] = idNumber
1288
+ }
1289
+
1290
+ if let address = kycInfo.address {
1291
+ result["address"] = mapFromKycAddress(address)
1292
+ }
1293
+
1294
+ if let dateOfBirth = kycInfo.dateOfBirth {
1295
+ result["dateOfBirth"] = mapFromDateOfBirth(dateOfBirth)
1296
+ }
1297
+
1298
+ return result
1299
+ }
1300
+
1301
+ class func mapFromKycAddress(_ address: Address) -> [String: Any] {
1302
+ var result: [String: Any] = [:]
1303
+
1304
+ if let city = address.city {
1305
+ result["city"] = city
1306
+ }
1307
+
1308
+ if let country = address.country {
1309
+ result["country"] = country
1310
+ }
1311
+
1312
+ if let line1 = address.line1 {
1313
+ result["line1"] = line1
1314
+ }
1315
+
1316
+ if let line2 = address.line2 {
1317
+ result["line2"] = line2
1318
+ }
1319
+
1320
+ if let postalCode = address.postalCode {
1321
+ result["postalCode"] = postalCode
1322
+ }
1323
+
1324
+ if let state = address.state {
1325
+ result["state"] = state
1326
+ }
1327
+
1328
+ return result
1329
+ }
1330
+
1331
+ class func mapFromDateOfBirth(_ dateOfBirth: KycInfo.DateOfBirth) -> [String: Int] {
1332
+ [
1333
+ "day": dateOfBirth.day,
1334
+ "month": dateOfBirth.month,
1335
+ "year": dateOfBirth.year,
1336
+ ]
1337
+ }
1338
+
1270
1339
  private class func mapOptionalKycAddress(_ value: Any?) throws -> Address? {
1271
1340
  guard let value else {
1272
1341
  return nil
@@ -48,14 +48,28 @@ using namespace facebook::react;
48
48
  RCTEmbeddedPaymentElementViewHandleCommand(self, commandName, args);
49
49
  }
50
50
 
51
+ #pragma mark - Shared Codegen Commands
52
+
53
+ // These commands are declared on the shared `NativeEmbeddedPaymentElement`
54
+ // component spec because Android targets its mounted Compose view directly.
55
+ // iOS does not handle EPE actions through this view: the view only hosts
56
+ // `StripeSdkImpl.shared.embeddedInstance.view`, while create/update/confirm/
57
+ // clear are routed through `StripeSdkImpl` module methods. The no-op methods
58
+ // keep the generated Fabric command protocol satisfied on iOS.
51
59
  - (void)clearPaymentOption
52
60
  {
53
- // Android only.
54
61
  }
55
62
 
56
63
  - (void)confirm
57
64
  {
58
- // Android only.
65
+ }
66
+
67
+ - (void)update:(NSString *)intentConfigurationJson
68
+ {
69
+ }
70
+
71
+ - (void)updateWithCheckout:(NSString *)sessionKey
72
+ {
59
73
  }
60
74
 
61
75
  #pragma mark - RCTComponentViewProtocol
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+ #import <React/RCTViewComponentView.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ @interface StripeCurrencySelectorElementComponentView : RCTViewComponentView
7
+
8
+ @end
9
+
10
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,75 @@
1
+ #import "StripeCurrencySelectorElementComponentView.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
+
11
+ #import "StripeNewArchConversions.h"
12
+ #import "StripeSwiftInterop.h"
13
+
14
+ using namespace facebook::react;
15
+
16
+ @interface StripeCurrencySelectorElementComponentView () <RCTStripeCurrencySelectorElementViewProtocol>
17
+ @end
18
+
19
+ @implementation StripeCurrencySelectorElementComponentView {
20
+ StripeCurrencySelectorElementContainerView *_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 StripeCurrencySelectorElementProps>();
33
+ _props = defaultProps;
34
+ [self prepareView];
35
+ }
36
+
37
+ return self;
38
+ }
39
+
40
+ - (void)prepareView
41
+ {
42
+ _view = [[StripeCurrencySelectorElementContainerView alloc] initWithFrame:self.frame];
43
+ self.contentView = _view;
44
+ }
45
+
46
+ - (void)updateProps:(const facebook::react::Props::Shared &)props
47
+ oldProps:(const facebook::react::Props::Shared &)oldProps
48
+ {
49
+ const auto &newViewProps = *std::static_pointer_cast<const StripeCurrencySelectorElementProps>(props);
50
+
51
+ _view.sessionKey = RCTNSStringFromStringNilIfEmpty(newViewProps.sessionKey);
52
+ _view.disabled = newViewProps.disabled;
53
+
54
+ [super updateProps:props oldProps:oldProps];
55
+ }
56
+
57
+ #pragma mark - RCTComponentViewProtocol
58
+
59
+ + (ComponentDescriptorProvider)componentDescriptorProvider
60
+ {
61
+ return concreteComponentDescriptorProvider<StripeCurrencySelectorElementComponentDescriptor>();
62
+ }
63
+
64
+ - (void)prepareForRecycle
65
+ {
66
+ [super prepareForRecycle];
67
+ [self prepareView];
68
+ }
69
+
70
+ @end
71
+
72
+ Class<RCTComponentViewProtocol> StripeCurrencySelectorElementCls(void)
73
+ {
74
+ return StripeCurrencySelectorElementComponentView.class;
75
+ }
@@ -37,6 +37,8 @@ class PaymentMethodFactory {
37
37
  return try createBancontactPaymentMethodParams()
38
38
  case STPPaymentMethodType.billie:
39
39
  return try createBilliePaymentMethodParams()
40
+ case STPPaymentMethodType.multibanco:
41
+ return try createMultibancoPaymentMethodParams()
40
42
  case STPPaymentMethodType.SEPADebit:
41
43
  return try createSepaPaymentMethodParams()
42
44
  case STPPaymentMethodType.EPS:
@@ -90,6 +92,8 @@ class PaymentMethodFactory {
90
92
  return nil
91
93
  case STPPaymentMethodType.billie:
92
94
  return nil
95
+ case STPPaymentMethodType.multibanco:
96
+ return nil
93
97
  case STPPaymentMethodType.SEPADebit:
94
98
  return nil
95
99
  case STPPaymentMethodType.OXXO:
@@ -297,6 +301,18 @@ class PaymentMethodFactory {
297
301
  return STPPaymentMethodParams(oxxo: params, billingDetails: billingDetails, metadata: metadata)
298
302
  }
299
303
 
304
+ private func createMultibancoPaymentMethodParams() throws -> STPPaymentMethodParams {
305
+ let params = STPPaymentMethodMultibancoParams()
306
+
307
+ guard let billingDetails = billingDetailsParams,
308
+ let email = billingDetails.email,
309
+ !email.isEmpty else {
310
+ throw PaymentMethodError.multibancoPaymentMissingParams
311
+ }
312
+
313
+ return STPPaymentMethodParams(multibanco: params, billingDetails: billingDetails, metadata: metadata)
314
+ }
315
+
300
316
  private func createEPSPaymentMethodParams() throws -> STPPaymentMethodParams {
301
317
  let params = STPPaymentMethodEPSParams()
302
318
 
@@ -406,6 +422,7 @@ enum PaymentMethodError: Error {
406
422
  case billiePaymentMissingParams
407
423
  case sepaPaymentMissingParams
408
424
  case p24PaymentMissingParams
425
+ case multibancoPaymentMissingParams
409
426
  case afterpayClearpayPaymentMissingParams
410
427
  // Klarna no longer requires email and country in billing details
411
428
  case weChatPayPaymentMissingParams
@@ -429,6 +446,8 @@ extension PaymentMethodError: LocalizedError {
429
446
  return NSLocalizedString("Billie requires that you provide the following billing details: email, country", comment: "Create payment error")
430
447
  case .sepaPaymentMissingParams:
431
448
  return NSLocalizedString("You must provide billing details and IBAN", comment: "Create payment error")
449
+ case .multibancoPaymentMissingParams:
450
+ return NSLocalizedString("Multibanco requires that you provide the following billing details: email", comment: "Create payment error")
432
451
  case .epsPaymentMissingParams:
433
452
  return NSLocalizedString("You must provide billing details", comment: "Create payment error")
434
453
  case .afterpayClearpayPaymentMissingParams:
@@ -29,10 +29,13 @@ internal class PaymentMethodMessagingElementConfig {
29
29
 
30
30
  // Parse font
31
31
  if let fontParams = params["font"] as? NSDictionary {
32
- let scale = fontParams["scale"] as? CGFloat ?? 1
33
- if let fontFamily = fontParams["family"] as? String,
34
- let customFont = UIFont(name: fontFamily, size: UIFont.systemFontSize * scale) {
32
+ let size = fontParams["size"] as? CGFloat
33
+ let family = fontParams["family"] as? String
34
+
35
+ if let family = family, let customFont = UIFont(name: family, size: size ?? UIFont.systemFontSize) {
35
36
  appearance.font = customFont
37
+ } else if let size = size {
38
+ appearance.font = UIFont.systemFont(ofSize: size)
36
39
  }
37
40
  }
38
41
 
@@ -21,6 +21,9 @@ public class PaymentMethodMessagingElementContainerView: UIView, UIGestureRecogn
21
21
  private var appearanceConfig: PaymentMethodMessagingElement.Appearance?
22
22
  private var lastConfig: NSDictionary?
23
23
 
24
+ // Used to track height updates
25
+ private var previousHeight: CGFloat?
26
+
24
27
  @objc var appearance: NSDictionary? {
25
28
  didSet {
26
29
  if let appearance = appearance {
@@ -67,6 +70,19 @@ public class PaymentMethodMessagingElementContainerView: UIView, UIGestureRecogn
67
70
  }
68
71
  }
69
72
 
73
+ public override func layoutSubviews() {
74
+ super.layoutSubviews()
75
+
76
+ // Calculate our natural height
77
+ let desiredHeight = systemLayoutSizeFitting(CGSize(width: frame.width, height: UIView.layoutFittingCompressedSize.height)).height
78
+
79
+ // Notify if changed
80
+ if desiredHeight != previousHeight {
81
+ StripeSdkImpl.shared.emitter?.emitPaymentMethodMessagingElementDidUpdateHeight(["height": desiredHeight])
82
+ self.previousHeight = desiredHeight
83
+ }
84
+ }
85
+
70
86
  private func attachPaymentElementIfAvailable() {
71
87
  removePaymentMethodMessagingElement()
72
88
  guard let messagingElement = messagingInstance else {
@@ -76,7 +92,10 @@ public class PaymentMethodMessagingElementContainerView: UIView, UIGestureRecogn
76
92
  let messagingElementView = messagingElement.view
77
93
  addSubview(messagingElementView)
78
94
  messagingElementView.translatesAutoresizingMaskIntoConstraints = false
95
+ let height = self.messagingInstance?.view.systemLayoutSizeFitting(CGSize(width: self.messagingInstance?.view.bounds.width ?? 0, height: UIView.layoutFittingCompressedSize.height)).height
96
+ self.previousHeight = height ?? 0
79
97
 
98
+ StripeSdkImpl.shared.emitter?.emitPaymentMethodMessagingElementDidUpdateHeight(["height": height ?? 0])
80
99
  NSLayoutConstraint.activate([
81
100
  messagingElementView.topAnchor.constraint(equalTo: topAnchor),
82
101
  messagingElementView.leadingAnchor.constraint(equalTo: leadingAnchor),
@@ -6,3 +6,4 @@
6
6
  #import <React/RCTUIManager.h>
7
7
  #import <PassKit/PassKit.h>
8
8
  #import <React/RCTEventEmitter.h>
9
+ #import <React/RCTVersion.h>