@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
@@ -6,12 +6,23 @@ import android.annotation.SuppressLint
6
6
  import androidx.compose.ui.graphics.toArgb
7
7
  import com.reactnativestripesdk.mapAppearance
8
8
  import com.reactnativestripesdk.mapConfig
9
+ import com.reactnativestripesdk.mapFromKycInfo
10
+ import com.reactnativestripesdk.mapGooglePayConfig
11
+ import com.reactnativestripesdk.mapPaymentDetailsType
9
12
  import com.reactnativestripesdk.utils.readableMapOf
10
13
  import com.stripe.android.crypto.onramp.ExperimentalCryptoOnramp
14
+ import com.stripe.android.crypto.onramp.model.KycInfo
15
+ import com.stripe.android.crypto.onramp.model.PaymentMethodDisplayData
16
+ import com.stripe.android.googlepaylauncher.GooglePayEnvironment
17
+ import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher
11
18
  import com.stripe.android.link.LinkAppearance.Style
19
+ import com.stripe.android.model.DateOfBirth
20
+ import com.stripe.android.paymentsheet.PaymentSheet
12
21
  import org.junit.Assert.assertEquals
22
+ import org.junit.Assert.assertFalse
13
23
  import org.junit.Assert.assertNotNull
14
24
  import org.junit.Assert.assertNull
25
+ import org.junit.Assert.assertTrue
15
26
  import org.junit.Test
16
27
  import org.junit.runner.RunWith
17
28
  import org.robolectric.RobolectricTestRunner
@@ -19,6 +30,182 @@ import org.robolectric.RobolectricTestRunner
19
30
  @SuppressLint("RestrictedApi")
20
31
  @RunWith(RobolectricTestRunner::class)
21
32
  class OnrampMappersTest {
33
+ @Test
34
+ fun mapGooglePayConfig_NullMap_ReturnsNull() {
35
+ val result = mapGooglePayConfig(null)
36
+ assertNull(result)
37
+ }
38
+
39
+ @Test
40
+ fun mapGooglePayConfig_MissingMerchantCountryCode_ReturnsNull() {
41
+ val params =
42
+ readableMapOf(
43
+ "merchantName" to "Test Merchant",
44
+ )
45
+ val result = mapGooglePayConfig(params)
46
+ assertNull(result)
47
+ }
48
+
49
+ @Test
50
+ fun mapGooglePayConfig_Defaults() {
51
+ val params =
52
+ readableMapOf(
53
+ "merchantCountryCode" to "US",
54
+ "merchantName" to "Test Merchant",
55
+ )
56
+ val result = mapGooglePayConfig(params)
57
+
58
+ assertNotNull(result)
59
+ assertEquals(GooglePayEnvironment.Production, result!!.environment)
60
+ assertFalse(result.isEmailRequired)
61
+ assertTrue(result.allowCreditCards)
62
+ assertFalse(result.existingPaymentMethodRequired)
63
+ }
64
+
65
+ @Test
66
+ fun mapGooglePayConfig_TestEnv() {
67
+ val params =
68
+ readableMapOf(
69
+ "merchantCountryCode" to "US",
70
+ "merchantName" to "Test Merchant",
71
+ "testEnv" to true,
72
+ )
73
+ val result = mapGooglePayConfig(params)
74
+
75
+ assertNotNull(result)
76
+ assertEquals(GooglePayEnvironment.Test, result!!.environment)
77
+ }
78
+
79
+ @Test
80
+ fun mapGooglePayConfig_IsEmailRequired_True() {
81
+ val params =
82
+ readableMapOf(
83
+ "merchantCountryCode" to "US",
84
+ "merchantName" to "Test Merchant",
85
+ "isEmailRequired" to true,
86
+ )
87
+ val result = mapGooglePayConfig(params)
88
+
89
+ assertNotNull(result)
90
+ assertTrue(result!!.isEmailRequired)
91
+ }
92
+
93
+ @Test
94
+ fun mapGooglePayConfig_AllowCreditCards_False() {
95
+ val params =
96
+ readableMapOf(
97
+ "merchantCountryCode" to "US",
98
+ "merchantName" to "Test Merchant",
99
+ "allowCreditCards" to false,
100
+ )
101
+ val result = mapGooglePayConfig(params)
102
+
103
+ assertNotNull(result)
104
+ assertFalse(result!!.allowCreditCards)
105
+ }
106
+
107
+ @Test
108
+ fun mapGooglePayConfig_MissingMerchantName_ReturnsNull() {
109
+ val params =
110
+ readableMapOf(
111
+ "merchantCountryCode" to "US",
112
+ )
113
+ val result = mapGooglePayConfig(params)
114
+ assertNull(result)
115
+ }
116
+
117
+ @Test
118
+ fun mapGooglePayConfig_ExistingPaymentMethodRequired_False() {
119
+ val params =
120
+ readableMapOf(
121
+ "merchantCountryCode" to "US",
122
+ "merchantName" to "Test Merchant",
123
+ "existingPaymentMethodRequired" to false,
124
+ )
125
+ val result = mapGooglePayConfig(params)
126
+
127
+ assertNotNull(result)
128
+ assertFalse(result!!.existingPaymentMethodRequired)
129
+ }
130
+
131
+ @Test
132
+ fun mapGooglePayConfig_WithBillingAddressConfig_IsRequired() {
133
+ val billingAddressConfig =
134
+ readableMapOf(
135
+ "isRequired" to true,
136
+ )
137
+ val params =
138
+ readableMapOf(
139
+ "merchantCountryCode" to "US",
140
+ "merchantName" to "Test Merchant",
141
+ "billingAddressConfig" to billingAddressConfig,
142
+ )
143
+ val result = mapGooglePayConfig(params)
144
+
145
+ assertNotNull(result)
146
+ assertTrue(result!!.billingAddressConfig.isRequired)
147
+ }
148
+
149
+ @Test
150
+ fun mapGooglePayConfig_WithBillingAddressConfig_FullFormat() {
151
+ val billingAddressConfig =
152
+ readableMapOf(
153
+ "format" to "Full",
154
+ )
155
+ val params =
156
+ readableMapOf(
157
+ "merchantCountryCode" to "US",
158
+ "merchantName" to "Test Merchant",
159
+ "billingAddressConfig" to billingAddressConfig,
160
+ )
161
+ val result = mapGooglePayConfig(params)
162
+
163
+ assertNotNull(result)
164
+ assertEquals(
165
+ GooglePayPaymentMethodLauncher.BillingAddressConfig.Format.Full,
166
+ result!!.billingAddressConfig.format,
167
+ )
168
+ }
169
+
170
+ @Test
171
+ fun mapGooglePayConfig_WithBillingAddressConfig_UnknownFormat_DefaultsToMin() {
172
+ val billingAddressConfig =
173
+ readableMapOf(
174
+ "format" to "Unknown",
175
+ )
176
+ val params =
177
+ readableMapOf(
178
+ "merchantCountryCode" to "US",
179
+ "merchantName" to "Test Merchant",
180
+ "billingAddressConfig" to billingAddressConfig,
181
+ )
182
+ val result = mapGooglePayConfig(params)
183
+
184
+ assertNotNull(result)
185
+ assertEquals(
186
+ GooglePayPaymentMethodLauncher.BillingAddressConfig.Format.Min,
187
+ result!!.billingAddressConfig.format,
188
+ )
189
+ }
190
+
191
+ @Test
192
+ fun mapGooglePayConfig_WithBillingAddressConfig_IsPhoneNumberRequired() {
193
+ val billingAddressConfig =
194
+ readableMapOf(
195
+ "isPhoneNumberRequired" to true,
196
+ )
197
+ val params =
198
+ readableMapOf(
199
+ "merchantCountryCode" to "US",
200
+ "merchantName" to "Test Merchant",
201
+ "billingAddressConfig" to billingAddressConfig,
202
+ )
203
+ val result = mapGooglePayConfig(params)
204
+
205
+ assertNotNull(result)
206
+ assertTrue(result!!.billingAddressConfig.isPhoneNumberRequired)
207
+ }
208
+
22
209
  @Test
23
210
  fun mapConfig_WithAppearance() {
24
211
  val appearance =
@@ -178,6 +365,35 @@ class OnrampMappersTest {
178
365
  assertNull(state.primaryButton.heightDp)
179
366
  }
180
367
 
368
+ @Test
369
+ fun mapAppearance_WithPrimaryButton_HeightOnly() {
370
+ val primaryButton =
371
+ readableMapOf(
372
+ "height" to 48.0,
373
+ )
374
+ val appearanceMap =
375
+ readableMapOf(
376
+ "primaryButton" to primaryButton,
377
+ )
378
+ val state = mapAppearance(appearanceMap).build()
379
+
380
+ assertNull(state.primaryButton.cornerRadiusDp)
381
+ assertEquals(48f, state.primaryButton.heightDp)
382
+ }
383
+
384
+ @Test
385
+ fun mapAppearance_WithPrimaryButton_EmptyMap() {
386
+ val primaryButton = readableMapOf()
387
+ val appearanceMap =
388
+ readableMapOf(
389
+ "primaryButton" to primaryButton,
390
+ )
391
+ val state = mapAppearance(appearanceMap).build()
392
+
393
+ assertNull(state.primaryButton.cornerRadiusDp)
394
+ assertNull(state.primaryButton.heightDp)
395
+ }
396
+
181
397
  @Test
182
398
  fun mapAppearance_FullConfig() {
183
399
  val lightColors =
@@ -219,4 +435,124 @@ class OnrampMappersTest {
219
435
  assertEquals(8f, state.primaryButton.cornerRadiusDp)
220
436
  assertEquals(48f, state.primaryButton.heightDp)
221
437
  }
438
+
439
+ @Test
440
+ fun mapPaymentDetailsType_MapsAllSupportedTypes() {
441
+ assertEquals("Card", mapPaymentDetailsType(PaymentMethodDisplayData.Type.Card))
442
+ assertEquals("BankAccount", mapPaymentDetailsType(PaymentMethodDisplayData.Type.BankAccount))
443
+ assertEquals("GooglePay", mapPaymentDetailsType(PaymentMethodDisplayData.Type.GooglePay))
444
+ }
445
+
446
+ @Test
447
+ fun mapFromKycInfo_AllFields() {
448
+ val kycInfo =
449
+ KycInfo(
450
+ firstName = "Jane",
451
+ lastName = "Doe",
452
+ idNumber = "123456789",
453
+ address =
454
+ PaymentSheet.Address(
455
+ city = "San Francisco",
456
+ country = "US",
457
+ line1 = "123 Main St",
458
+ line2 = "Apt 4",
459
+ postalCode = "94105",
460
+ state = "CA",
461
+ ),
462
+ dateOfBirth = DateOfBirth(day = 15, month = 6, year = 1990),
463
+ )
464
+ val result = mapFromKycInfo(kycInfo)
465
+
466
+ assertEquals("Jane", result.getString("firstName"))
467
+ assertEquals("Doe", result.getString("lastName"))
468
+ assertEquals("123456789", result.getString("idNumber"))
469
+
470
+ val address = result.getMap("address")
471
+ assertNotNull(address)
472
+ assertEquals("San Francisco", address!!.getString("city"))
473
+ assertEquals("US", address.getString("country"))
474
+ assertEquals("123 Main St", address.getString("line1"))
475
+ assertEquals("Apt 4", address.getString("line2"))
476
+ assertEquals("94105", address.getString("postalCode"))
477
+ assertEquals("CA", address.getString("state"))
478
+
479
+ val dob = result.getMap("dateOfBirth")
480
+ assertNotNull(dob)
481
+ assertEquals(15, dob!!.getInt("day"))
482
+ assertEquals(6, dob.getInt("month"))
483
+ assertEquals(1990, dob.getInt("year"))
484
+ }
485
+
486
+ @Test
487
+ fun mapFromKycInfo_AllNullFields() {
488
+ val kycInfo =
489
+ KycInfo(
490
+ firstName = null,
491
+ lastName = null,
492
+ idNumber = null,
493
+ address = null,
494
+ dateOfBirth = null,
495
+ )
496
+ val result = mapFromKycInfo(kycInfo)
497
+
498
+ assertFalse(result.hasKey("firstName"))
499
+ assertFalse(result.hasKey("lastName"))
500
+ assertFalse(result.hasKey("idNumber"))
501
+ assertFalse(result.hasKey("address"))
502
+ assertFalse(result.hasKey("dateOfBirth"))
503
+ }
504
+
505
+ @Test
506
+ fun mapFromKycInfo_PartialFields() {
507
+ val kycInfo =
508
+ KycInfo(
509
+ firstName = "Jane",
510
+ lastName = null,
511
+ idNumber = null,
512
+ address = null,
513
+ dateOfBirth = DateOfBirth(day = 1, month = 1, year = 2000),
514
+ )
515
+ val result = mapFromKycInfo(kycInfo)
516
+
517
+ assertEquals("Jane", result.getString("firstName"))
518
+ assertFalse(result.hasKey("lastName"))
519
+ assertFalse(result.hasKey("idNumber"))
520
+ assertFalse(result.hasKey("address"))
521
+
522
+ val dob = result.getMap("dateOfBirth")
523
+ assertNotNull(dob)
524
+ assertEquals(1, dob!!.getInt("day"))
525
+ assertEquals(1, dob.getInt("month"))
526
+ assertEquals(2000, dob.getInt("year"))
527
+ }
528
+
529
+ @Test
530
+ fun mapFromKycInfo_AddressWithPartialFields() {
531
+ val kycInfo =
532
+ KycInfo(
533
+ firstName = null,
534
+ lastName = null,
535
+ idNumber = null,
536
+ address =
537
+ PaymentSheet.Address(
538
+ city = "New York",
539
+ country = "US",
540
+ line1 = null,
541
+ line2 = null,
542
+ postalCode = null,
543
+ state = null,
544
+ ),
545
+ dateOfBirth = null,
546
+ )
547
+ val result = mapFromKycInfo(kycInfo)
548
+
549
+ val address = result.getMap("address")
550
+ assertNotNull(address)
551
+ assertEquals("New York", address!!.getString("city"))
552
+ assertEquals("US", address.getString("country"))
553
+ assertFalse(address.hasKey("line1"))
554
+ assertFalse(address.hasKey("line2"))
555
+ assertFalse(address.hasKey("postalCode"))
556
+ assertFalse(address.hasKey("state"))
557
+ }
222
558
  }
@@ -52,7 +52,8 @@ class PaymentOptionDisplayDataMapperTest {
52
52
  val result = annotatedString.toHtmlString()
53
53
 
54
54
  Assert.assertEquals(
55
- "By continuing, you agree to our <a href=\"https://stripe.com/privacy\">Privacy Policy</a> and <a href=\"https://stripe.com/terms\">Terms of Service</a>.",
55
+ "By continuing, you agree to our <a href=\"https://stripe.com/privacy\">Privacy Policy</a>" +
56
+ " and <a href=\"https://stripe.com/terms\">Terms of Service</a>.",
56
57
  result,
57
58
  )
58
59
  }
@@ -193,7 +194,8 @@ class PaymentOptionDisplayDataMapperTest {
193
194
  val result = annotatedString.toHtmlString()
194
195
 
195
196
  Assert.assertEquals(
196
- "Visit our <b><font color=\"#0000FF\"><a href=\"https://stripe.com/privacy\">Privacy Policy</a></font></b> for details",
197
+ "Visit our <b><font color=\"#0000FF\"><a href=\"https://stripe.com/privacy\">" +
198
+ "Privacy Policy</a></font></b> for details",
197
199
  result,
198
200
  )
199
201
  }
@@ -293,7 +295,8 @@ class PaymentOptionDisplayDataMapperTest {
293
295
  val result = annotatedString.toHtmlString()
294
296
 
295
297
  Assert.assertEquals(
296
- "Check <b><a href=\"https://stripe.com\">Stripe</a></b> and <i><font color=\"#00FF00\"><a href=\"https://github.com\">GitHub</a></font></i>",
298
+ "Check <b><a href=\"https://stripe.com\">Stripe</a></b> and <i><font color=\"#00FF00\">" +
299
+ "<a href=\"https://github.com\">GitHub</a></font></i>",
297
300
  result,
298
301
  )
299
302
  }
@@ -449,7 +452,9 @@ class PaymentOptionDisplayDataMapperTest {
449
452
  val result = annotatedString.toHtmlString()
450
453
 
451
454
  Assert.assertEquals(
452
- "By continuing, you agree to <b><font color=\"#0000FF\"><u><a href=\"https://stripe.com/terms\">Terms</a></u></font></b> and <i><font color=\"#FF0000\"><a href=\"https://stripe.com/privacy\">Privacy</a></font></i>. Important details are <span style=\"background-color: #FFFF00;\">highlighted</span>.",
455
+ "By continuing, you agree to <b><font color=\"#0000FF\"><u><a href=\"https://stripe.com/terms\">" +
456
+ "Terms</a></u></font></b> and <i><font color=\"#FF0000\"><a href=\"https://stripe.com/privacy\">" +
457
+ "Privacy</a></font></i>. Important details are <span style=\"background-color: #FFFF00;\">highlighted</span>.",
453
458
  result,
454
459
  )
455
460
  }
@@ -0,0 +1,89 @@
1
+ package com.reactnativestripesdk.utils
2
+
3
+ import com.stripe.android.paymentelement.CheckoutSessionPreview
4
+ import org.junit.Assert.assertEquals
5
+ import org.junit.Assert.assertFalse
6
+ import org.junit.Assert.assertNotNull
7
+ import org.junit.Test
8
+ import org.junit.runner.RunWith
9
+ import org.robolectric.RobolectricTestRunner
10
+
11
+ @RunWith(RobolectricTestRunner::class)
12
+ @OptIn(CheckoutSessionPreview::class)
13
+ class CheckoutMappersTest {
14
+ @Test
15
+ fun mapFromCheckoutState_mapsLoadedSessionAndCurrentAndroidPlaceholders() {
16
+ val mapped =
17
+ mapFromCheckoutState(
18
+ isLoading = false,
19
+ session = CheckoutTestFixtures.fullSession(),
20
+ )
21
+
22
+ assertEquals("loaded", mapped.getString("status"))
23
+
24
+ val session = mapped.getMap("session")
25
+ assertNotNull(session)
26
+ assertEquals("cs_test_123", session!!.getString("id"))
27
+ assertEquals("unknown", session.getString("status"))
28
+ assertEquals("unknown", session.getString("paymentStatus"))
29
+ assertFalse(session.getBoolean("livemode"))
30
+ assertEquals("usd", session.getString("currency"))
31
+ assertFalse(session.hasKey("customerId"))
32
+ assertFalse(session.hasKey("customerEmail"))
33
+ assertFalse(session.hasKey("billingAddress"))
34
+ assertFalse(session.hasKey("shippingAddress"))
35
+
36
+ val totals = session.getMap("totals")
37
+ assertNotNull(totals)
38
+ assertEquals(5000.0, totals!!.getDouble("subtotal"), 0.0)
39
+ assertEquals(4044.0, totals.getDouble("total"), 0.0)
40
+ assertEquals(4044.0, totals.getDouble("due"), 0.0)
41
+ assertEquals(0.0, totals.getDouble("discount"), 0.0)
42
+ assertEquals(500.0, totals.getDouble("shipping"), 0.0)
43
+ assertEquals(294.0, totals.getDouble("tax"), 0.0)
44
+
45
+ val discounts = session.getArray("discounts")
46
+ assertNotNull(discounts)
47
+ assertEquals(0, discounts!!.size())
48
+
49
+ val lineItems = session.getArray("lineItems")
50
+ assertNotNull(lineItems)
51
+ assertEquals(2, lineItems!!.size())
52
+ assertEquals("li_item1", lineItems.getMap(0)?.getString("id"))
53
+ assertEquals("Llama Figure", lineItems.getMap(0)?.getString("name"))
54
+ assertEquals(2, lineItems.getMap(0)?.getInt("quantity"))
55
+ assertEquals(0.0, lineItems.getMap(0)?.getDouble("unitAmount") ?: -1.0, 0.0)
56
+ assertEquals("usd", lineItems.getMap(0)?.getString("currency"))
57
+ assertEquals(2499.0, lineItems.getMap(1)?.getDouble("unitAmount") ?: -1.0, 0.0)
58
+
59
+ val shippingOptions = session.getArray("shippingOptions")
60
+ assertNotNull(shippingOptions)
61
+ assertEquals(2, shippingOptions!!.size())
62
+ assertEquals("shr_standard", shippingOptions.getMap(0)?.getString("id"))
63
+ assertEquals("Standard Shipping", shippingOptions.getMap(0)?.getString("displayName"))
64
+ assertEquals(500.0, shippingOptions.getMap(0)?.getDouble("amount") ?: -1.0, 0.0)
65
+ assertEquals("usd", shippingOptions.getMap(0)?.getString("currency"))
66
+ assertFalse(shippingOptions.getMap(0)?.hasKey("deliveryEstimate") ?: true)
67
+ assertEquals("1-2 business days", shippingOptions.getMap(1)?.getString("deliveryEstimate"))
68
+ }
69
+
70
+ @Test
71
+ fun mapFromCheckoutState_mapsLoadingStateAndOmitsBlankCurrency() {
72
+ val mapped =
73
+ mapFromCheckoutState(
74
+ isLoading = true,
75
+ session = CheckoutTestFixtures.blankCurrencySession(),
76
+ )
77
+
78
+ assertEquals("loading", mapped.getString("status"))
79
+
80
+ val session = mapped.getMap("session")
81
+ assertNotNull(session)
82
+ assertEquals("cs_test_blank_currency", session!!.getString("id"))
83
+ assertFalse(session.hasKey("currency"))
84
+ assertFalse(session.hasKey("totals"))
85
+ assertEquals(0, session.getArray("lineItems")!!.size())
86
+ assertEquals(0, session.getArray("shippingOptions")!!.size())
87
+ assertEquals(0, session.getArray("discounts")!!.size())
88
+ }
89
+ }
@@ -0,0 +1,49 @@
1
+ package com.reactnativestripesdk.utils;
2
+
3
+ import com.stripe.android.checkout.CheckoutSession;
4
+ import com.stripe.android.paymentsheet.verticalmode.CurrencySelectorOptions;
5
+ import java.util.Arrays;
6
+ import java.util.Collections;
7
+
8
+ public final class CheckoutTestFixtures {
9
+ private CheckoutTestFixtures() {}
10
+
11
+ public static CheckoutSession fullSession() {
12
+ CheckoutSession.TotalSummary totals =
13
+ new CheckoutSession.TotalSummary(
14
+ 5000L,
15
+ 4044L,
16
+ 4044L,
17
+ Arrays.asList(
18
+ new CheckoutSession.DiscountAmount(500L, "SUMMER10"),
19
+ new CheckoutSession.DiscountAmount(250L, "LOYALTY5")),
20
+ Collections.singletonList(
21
+ new CheckoutSession.TaxAmount(294L, false, "Sales Tax", 6.875d)),
22
+ new CheckoutSession.ShippingRate(
23
+ "shr_standard", 500L, "Standard Shipping", "5-7 business days"),
24
+ null);
25
+
26
+ return new CheckoutSession(
27
+ "cs_test_123",
28
+ "usd",
29
+ totals,
30
+ Arrays.asList(
31
+ new CheckoutSession.LineItem("li_item1", "Llama Figure", 2, null, 1998L, 1998L),
32
+ new CheckoutSession.LineItem("li_item2", "Alpaca Plushie", 1, 2499L, 2499L, 2499L)),
33
+ Arrays.asList(
34
+ new CheckoutSession.ShippingRate("shr_standard", 500L, "Standard Shipping", null),
35
+ new CheckoutSession.ShippingRate(
36
+ "shr_express", 1500L, "Express Shipping", "1-2 business days")),
37
+ (CurrencySelectorOptions) null);
38
+ }
39
+
40
+ public static CheckoutSession blankCurrencySession() {
41
+ return new CheckoutSession(
42
+ "cs_test_blank_currency",
43
+ "",
44
+ null,
45
+ Collections.<CheckoutSession.LineItem>emptyList(),
46
+ Collections.<CheckoutSession.ShippingRate>emptyList(),
47
+ (CurrencySelectorOptions) null);
48
+ }
49
+ }
@@ -79,6 +79,29 @@ class AddressSheetUtils {
79
79
  }
80
80
  }
81
81
 
82
+ internal class func buildConfiguration(
83
+ appearance: NSDictionary?,
84
+ defaultValues: NSDictionary?,
85
+ additionalFields: NSDictionary?,
86
+ allowedCountries: [String],
87
+ autocompleteCountries: [String],
88
+ buttonTitle: String?,
89
+ sheetTitle: String?
90
+ ) throws -> AddressViewController.Configuration {
91
+ let appearanceConfiguration = try PaymentSheetAppearance.buildAppearanceFromParams(userParams: appearance)
92
+
93
+ var config = AddressViewController.Configuration(
94
+ defaultValues: buildDefaultValues(params: defaultValues),
95
+ additionalFields: buildAdditionalFieldsConfiguration(params: additionalFields),
96
+ allowedCountries: allowedCountries,
97
+ appearance: appearanceConfiguration,
98
+ buttonTitle: buttonTitle,
99
+ title: sheetTitle
100
+ )
101
+ config.autocompleteCountries = autocompleteCountries
102
+ return config
103
+ }
104
+
82
105
  internal class func buildResult(address: AddressViewController.AddressDetails) -> [AnyHashable: Any] {
83
106
  return [
84
107
  "result": [
@@ -60,7 +60,15 @@ public class AddressSheetView: UIView {
60
60
  }
61
61
  var config: AddressViewController.Configuration
62
62
  do {
63
- config = try buildAddressSheetConfiguration()
63
+ config = try AddressSheetUtils.buildConfiguration(
64
+ appearance: appearance,
65
+ defaultValues: defaultValues,
66
+ additionalFields: additionalFields,
67
+ allowedCountries: allowedCountries,
68
+ autocompleteCountries: autocompleteCountries,
69
+ buttonTitle: primaryButtonTitle,
70
+ sheetTitle: sheetTitle
71
+ )
64
72
  } catch {
65
73
  onErrorAction!(
66
74
  Errors.createError(ErrorType.Failed, error.localizedDescription) as? [AnyHashable: Any]
@@ -80,19 +88,6 @@ public class AddressSheetView: UIView {
80
88
  vc.present(navigationController, animated: true)
81
89
  }
82
90
 
83
- private func buildAddressSheetConfiguration() throws -> AddressViewController.Configuration {
84
- let appearanceConfiguration = try PaymentSheetAppearance.buildAppearanceFromParams(userParams: appearance)
85
-
86
- return AddressViewController.Configuration(
87
- defaultValues: AddressSheetUtils.buildDefaultValues(params: defaultValues),
88
- additionalFields: AddressSheetUtils.buildAdditionalFieldsConfiguration(params: additionalFields),
89
- allowedCountries: allowedCountries,
90
- appearance: appearanceConfiguration,
91
- buttonTitle: primaryButtonTitle,
92
- title: sheetTitle
93
- )
94
- }
95
-
96
91
  private func getModalPresentationStyle() -> UIModalPresentationStyle {
97
92
  switch presentationStyle {
98
93
  case "fullscreen":
@@ -122,12 +122,10 @@ class ConnectAccountOnboardingViewController: UIViewController {
122
122
  reactContentView?.layoutIfNeeded()
123
123
  }
124
124
 
125
- override func viewWillDisappear(_ animated: Bool) {
126
- super.viewWillDisappear(animated)
127
-
128
- // If being dismissed (not just going to background), notify
129
- if isBeingDismissed {
130
- onClose?()
131
- }
132
- }
125
+ // No viewWillDisappear/isBeingDismissed handler here. The modal uses .fullScreen
126
+ // presentation which prevents swipe-to-dismiss, so the only user-initiated exit path
127
+ // is the close button (handleCloseButtonPressed). Adding isBeingDismissed here would
128
+ // cause spurious onExit events when iOS presents a child VC (e.g. ASWebAuthenticationSession
129
+ // for identity verification) over this modal — UIKit calls viewWillDisappear and reports
130
+ // isBeingDismissed = true even though the user didn't close the modal.
133
131
  }
@@ -0,0 +1,9 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <React/RCTBridgeModule.h>
3
+ #import <React/RCTViewManager.h>
4
+
5
+ @interface RCT_EXTERN_MODULE(StripeCurrencySelectorElementManager, RCTViewManager)
6
+ RCT_EXPORT_VIEW_PROPERTY(sessionKey, NSString)
7
+ RCT_EXPORT_VIEW_PROPERTY(disabled, BOOL)
8
+ RCT_EXPORT_VIEW_PROPERTY(onHeightChange, RCTDirectEventBlock)
9
+ @end
@@ -0,0 +1,12 @@
1
+ import Foundation
2
+
3
+ @objc(StripeCurrencySelectorElementManager)
4
+ class StripeCurrencySelectorElementManager: RCTViewManager {
5
+ override static func requiresMainQueueSetup() -> Bool {
6
+ return true
7
+ }
8
+
9
+ override func view() -> UIView! {
10
+ return StripeCurrencySelectorElementContainerView(frame: .zero)
11
+ }
12
+ }
@@ -0,0 +1,24 @@
1
+ import Foundation
2
+ import UIKit
3
+
4
+ /// Minimal stub so the JS-side `CurrencySelectorElement` codegen mapping
5
+ /// resolves at app launch. The real implementation (hosting
6
+ /// `Checkout.CurrencySelectorView`, height reporting, session observation)
7
+ /// lives on the full-feature branch and will replace this once that lands.
8
+ @objc(StripeCurrencySelectorElementContainerView)
9
+ public class StripeCurrencySelectorElementContainerView: UIView {
10
+ @objc public var sessionKey: String?
11
+
12
+ @objc public var disabled: Bool = false
13
+
14
+ @objc public var onHeightChange: RCTDirectEventBlock?
15
+
16
+ public override init(frame: CGRect) {
17
+ super.init(frame: frame)
18
+ }
19
+
20
+ @available(*, unavailable)
21
+ required init?(coder _: NSCoder) {
22
+ fatalError("init(coder:) has not been implemented")
23
+ }
24
+ }