@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
@@ -25,6 +25,7 @@ import com.facebook.react.bridge.UiThreadUtil
25
25
  import com.facebook.react.bridge.WritableMap
26
26
  import com.facebook.react.bridge.WritableNativeMap
27
27
  import com.facebook.react.module.annotations.ReactModule
28
+ import com.facebook.react.modules.systeminfo.ReactNativeVersion
28
29
  import com.reactnativestripesdk.addresssheet.AddressLauncherManager
29
30
  import com.reactnativestripesdk.customersheet.CustomerSheetManager
30
31
  import com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy
@@ -32,7 +33,10 @@ import com.reactnativestripesdk.utils.ConfirmPaymentErrorType
32
33
  import com.reactnativestripesdk.utils.CreateTokenErrorType
33
34
  import com.reactnativestripesdk.utils.ErrorType
34
35
  import com.reactnativestripesdk.utils.GooglePayErrorType
36
+ import com.reactnativestripesdk.utils.RetrievePaymentIntentErrorType
37
+ import com.reactnativestripesdk.utils.RetrieveSetupIntentErrorType
35
38
  import com.reactnativestripesdk.utils.StripeUIManager
39
+ import com.reactnativestripesdk.utils.buildCheckoutAddressUpdate
36
40
  import com.reactnativestripesdk.utils.createCanAddCardResult
37
41
  import com.reactnativestripesdk.utils.createError
38
42
  import com.reactnativestripesdk.utils.createMissingActivityError
@@ -42,6 +46,7 @@ import com.reactnativestripesdk.utils.getBooleanOr
42
46
  import com.reactnativestripesdk.utils.getIntOrNull
43
47
  import com.reactnativestripesdk.utils.getLongOrNull
44
48
  import com.reactnativestripesdk.utils.getValOr
49
+ import com.reactnativestripesdk.utils.mapFromCheckoutState
45
50
  import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
46
51
  import com.reactnativestripesdk.utils.mapFromPaymentMethod
47
52
  import com.reactnativestripesdk.utils.mapFromSetupIntentResult
@@ -52,13 +57,16 @@ import com.reactnativestripesdk.utils.mapToPaymentMethodType
52
57
  import com.reactnativestripesdk.utils.mapToReturnURL
53
58
  import com.reactnativestripesdk.utils.mapToShippingDetails
54
59
  import com.reactnativestripesdk.utils.mapToUICustomization
60
+ import com.reactnativestripesdk.utils.toCheckoutAddress
55
61
  import com.stripe.android.ApiResultCallback
56
62
  import com.stripe.android.GooglePayJsonFactory
57
63
  import com.stripe.android.PaymentAuthConfig
58
64
  import com.stripe.android.PaymentConfiguration
59
65
  import com.stripe.android.Stripe
66
+ import com.stripe.android.checkout.Checkout
60
67
  import com.stripe.android.core.ApiVersion
61
68
  import com.stripe.android.core.AppInfo
69
+ import com.stripe.android.core.reactnative.ReactNativeAnalytics
62
70
  import com.stripe.android.core.reactnative.ReactNativeSdkInternal
63
71
  import com.stripe.android.customersheet.CustomerSheet
64
72
  import com.stripe.android.googlepaylauncher.GooglePayLauncher
@@ -71,6 +79,7 @@ import com.stripe.android.model.PaymentMethod
71
79
  import com.stripe.android.model.RadarSession
72
80
  import com.stripe.android.model.SetupIntent
73
81
  import com.stripe.android.model.Token
82
+ import com.stripe.android.paymentelement.CheckoutSessionPreview
74
83
  import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
75
84
  import com.stripe.android.paymentsheet.PaymentSheet
76
85
  import kotlinx.coroutines.CompletableDeferred
@@ -78,9 +87,10 @@ import kotlinx.coroutines.CoroutineScope
78
87
  import kotlinx.coroutines.Dispatchers
79
88
  import kotlinx.coroutines.launch
80
89
  import org.json.JSONObject
90
+ import java.util.UUID
81
91
 
82
92
  @ReactModule(name = StripeSdkModule.NAME)
83
- @OptIn(ReactNativeSdkInternal::class)
93
+ @OptIn(ReactNativeSdkInternal::class, CheckoutSessionPreview::class)
84
94
  class StripeSdkModule(
85
95
  reactContext: ReactApplicationContext,
86
96
  ) : NativeStripeSdkModuleSpec(reactContext) {
@@ -102,6 +112,7 @@ class StripeSdkModule(
102
112
  private var financialConnectionsSheetManager: FinancialConnectionsSheetManager? = null
103
113
  private var googlePayLauncherManager: GooglePayLauncherManager? = null
104
114
  private var googlePayPaymentMethodLauncherManager: GooglePayPaymentMethodLauncherManager? = null
115
+ internal val checkoutInstances = mutableMapOf<String, Checkout>()
105
116
 
106
117
  private var customerSheetManager: CustomerSheetManager? = null
107
118
 
@@ -154,6 +165,7 @@ class StripeSdkModule(
154
165
 
155
166
  stripeUIManagers.forEach { it.destroy() }
156
167
  stripeUIManagers.clear()
168
+ checkoutInstances.clear()
157
169
  }
158
170
 
159
171
  private fun registerStripeUIManager(uiManager: StripeUIManager) {
@@ -213,10 +225,16 @@ class StripeSdkModule(
213
225
  ).toString()
214
226
  ),
215
227
  "appVersion" to (packageInfo?.versionName ?: ""),
228
+ "isNewArchitecture" to BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
229
+ "reactNativeVersion" to
230
+ with(ReactNativeVersion.VERSION) {
231
+ "${get("major")}.${get("minor")}.${get("patch")}"
232
+ },
216
233
  ),
217
234
  )
218
235
  }
219
236
 
237
+ @SuppressLint("RestrictedApi")
220
238
  @ReactMethod
221
239
  override fun initialise(
222
240
  params: ReadableMap,
@@ -246,6 +264,11 @@ class StripeSdkModule(
246
264
 
247
265
  PaymentConfiguration.init(reactApplicationContext, publishableKey, stripeAccountId)
248
266
 
267
+ ReactNativeAnalytics.isNewArchitecture = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
268
+ ReactNativeAnalytics.reactNativeVersion =
269
+ with(ReactNativeVersion.VERSION) {
270
+ "${get("major")}.${get("minor")}.${get("patch")}"
271
+ }
249
272
  preventActivityRecreation()
250
273
  setupComposeCompatView()
251
274
 
@@ -263,7 +286,7 @@ class StripeSdkModule(
263
286
  }
264
287
  } else {
265
288
  paymentSheetManager =
266
- PaymentSheetManager(reactApplicationContext, params, promise).also {
289
+ PaymentSheetManager(reactApplicationContext, params, promise, checkoutInstances).also {
267
290
  registerStripeUIManager(it)
268
291
  }
269
292
  }
@@ -683,8 +706,12 @@ class StripeSdkModule(
683
706
  promise: Promise,
684
707
  ) {
685
708
  CoroutineScope(Dispatchers.IO).launch {
686
- val paymentIntent = stripe.retrievePaymentIntentSynchronous(clientSecret)
687
- promise.resolve(createResult("paymentIntent", mapFromPaymentIntentResult(paymentIntent)))
709
+ try {
710
+ val paymentIntent = stripe.retrievePaymentIntentSynchronous(clientSecret)
711
+ promise.resolve(createResult("paymentIntent", mapFromPaymentIntentResult(paymentIntent)))
712
+ } catch (e: Exception) {
713
+ promise.resolve(createError(RetrievePaymentIntentErrorType.Unknown.toString(), e))
714
+ }
688
715
  }
689
716
  }
690
717
 
@@ -694,8 +721,12 @@ class StripeSdkModule(
694
721
  promise: Promise,
695
722
  ) {
696
723
  CoroutineScope(Dispatchers.IO).launch {
697
- val setupIntent = stripe.retrieveSetupIntentSynchronous(clientSecret)
698
- promise.resolve(createResult("setupIntent", mapFromSetupIntentResult(setupIntent)))
724
+ try {
725
+ val setupIntent = stripe.retrieveSetupIntentSynchronous(clientSecret)
726
+ promise.resolve(createResult("setupIntent", mapFromSetupIntentResult(setupIntent)))
727
+ } catch (e: Exception) {
728
+ promise.resolve(createError(RetrieveSetupIntentErrorType.Unknown.toString(), e))
729
+ }
699
730
  }
700
731
  }
701
732
 
@@ -1359,13 +1390,28 @@ class StripeSdkModule(
1359
1390
  )
1360
1391
  }
1361
1392
 
1393
+ // Android owns EmbeddedPaymentElement through its native view. Configuration,
1394
+ // update, confirm, and clear commands are handled by EmbeddedPaymentElementViewManager
1395
+ // so they can target the mounted Compose view instance. iOS stores its
1396
+ // EmbeddedPaymentElement on StripeSdkImpl instead, so the shared TurboModule
1397
+ // spec includes these module methods for the iOS implementation.
1398
+
1362
1399
  @ReactMethod
1363
1400
  override fun createEmbeddedPaymentElement(
1364
1401
  intentConfig: ReadableMap,
1365
1402
  configuration: ReadableMap,
1366
1403
  promise: Promise,
1367
1404
  ) {
1368
- // TODO:
1405
+ promise.resolve(null)
1406
+ }
1407
+
1408
+ @ReactMethod
1409
+ override fun createEmbeddedPaymentElementWithCheckout(
1410
+ sessionKey: String,
1411
+ configuration: ReadableMap,
1412
+ promise: Promise,
1413
+ ) {
1414
+ promise.resolve(null)
1369
1415
  }
1370
1416
 
1371
1417
  @ReactMethod
@@ -1373,7 +1419,7 @@ class StripeSdkModule(
1373
1419
  viewTag: Double,
1374
1420
  promise: Promise,
1375
1421
  ) {
1376
- // noop, iOS only
1422
+ // No-op on Android. JS dispatches confirm through the view command instead.
1377
1423
  }
1378
1424
 
1379
1425
  @ReactMethod
@@ -1384,12 +1430,21 @@ class StripeSdkModule(
1384
1430
  // TODO:
1385
1431
  }
1386
1432
 
1433
+ @ReactMethod
1434
+ override fun updateEmbeddedPaymentElementWithCheckout(
1435
+ sessionKey: String,
1436
+ promise: Promise,
1437
+ ) {
1438
+ // No-op on Android. JS dispatches Checkout updates through the view command instead.
1439
+ promise.resolve(null)
1440
+ }
1441
+
1387
1442
  @ReactMethod
1388
1443
  override fun clearEmbeddedPaymentOption(
1389
1444
  viewTag: Double,
1390
1445
  promise: Promise,
1391
1446
  ) {
1392
- // noop, iOS only
1447
+ // No-op on Android. JS dispatches clear through the view command instead.
1393
1448
  }
1394
1449
 
1395
1450
  @ReactMethod
@@ -1540,7 +1595,7 @@ class StripeSdkModule(
1540
1595
  // Schedule cleanup
1541
1596
  android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
1542
1597
  file.delete()
1543
- }, 3000)
1598
+ }, FILE_CLEANUP_DELAY_MS)
1544
1599
 
1545
1600
  promise.resolve(
1546
1601
  Arguments.createMap().apply {
@@ -1672,6 +1727,189 @@ class StripeSdkModule(
1672
1727
  // noop, iOS only.
1673
1728
  }
1674
1729
 
1730
+ override fun initCheckoutSession(
1731
+ clientSecret: String,
1732
+ configuration: ReadableMap,
1733
+ promise: Promise,
1734
+ ) {
1735
+ val checkoutConfiguration = buildCheckoutConfiguration(configuration)
1736
+
1737
+ CoroutineScope(Dispatchers.Main).launch {
1738
+ Checkout.configure(
1739
+ context = reactApplicationContext,
1740
+ checkoutSessionClientSecret = clientSecret,
1741
+ configuration = checkoutConfiguration,
1742
+ ).fold(
1743
+ onSuccess = { checkout ->
1744
+ val sessionKey = UUID.randomUUID().toString()
1745
+ checkoutInstances[sessionKey] = checkout
1746
+
1747
+ promise.resolve(
1748
+ Arguments.createMap().apply {
1749
+ putString("sessionKey", sessionKey)
1750
+ putMap("state", mapFromCheckoutState(checkout))
1751
+ },
1752
+ )
1753
+ },
1754
+ onFailure = { error ->
1755
+ promise.reject(
1756
+ ErrorType.Failed.toString(),
1757
+ error.message ?: "Failed to initialize checkout session.",
1758
+ error,
1759
+ )
1760
+ },
1761
+ )
1762
+ }
1763
+ }
1764
+
1765
+ override fun checkoutUpdateShippingAddress(
1766
+ sessionKey: String,
1767
+ address: ReadableMap,
1768
+ name: String?,
1769
+ phone: String?,
1770
+ promise: Promise,
1771
+ ) {
1772
+ val addressUpdate = buildCheckoutAddressUpdate(name, phone, address) ?: run {
1773
+ promise.reject(ErrorType.Failed.toString(), "A shipping address country is required.")
1774
+ return
1775
+ }
1776
+
1777
+ performCheckoutMutation(
1778
+ sessionKey = sessionKey,
1779
+ promise = promise,
1780
+ ) { checkout ->
1781
+ checkout.updateShippingAddress(
1782
+ name = addressUpdate.name,
1783
+ phoneNumber = addressUpdate.phone,
1784
+ address = addressUpdate.toCheckoutAddress(),
1785
+ )
1786
+ }
1787
+ }
1788
+
1789
+ override fun checkoutUpdateBillingAddress(
1790
+ sessionKey: String,
1791
+ address: ReadableMap,
1792
+ name: String?,
1793
+ phone: String?,
1794
+ promise: Promise,
1795
+ ) {
1796
+ val addressUpdate = buildCheckoutAddressUpdate(name, phone, address) ?: run {
1797
+ promise.reject(ErrorType.Failed.toString(), "A billing address country is required.")
1798
+ return
1799
+ }
1800
+
1801
+ performCheckoutMutation(
1802
+ sessionKey = sessionKey,
1803
+ promise = promise,
1804
+ ) { checkout ->
1805
+ checkout.updateBillingAddress(
1806
+ name = addressUpdate.name,
1807
+ phoneNumber = addressUpdate.phone,
1808
+ address = addressUpdate.toCheckoutAddress(),
1809
+ )
1810
+ }
1811
+ }
1812
+
1813
+ override fun checkoutApplyPromotionCode(
1814
+ sessionKey: String,
1815
+ code: String,
1816
+ promise: Promise,
1817
+ ) {
1818
+ performCheckoutMutation(sessionKey, promise) { checkout ->
1819
+ checkout.applyPromotionCode(code)
1820
+ }
1821
+ }
1822
+
1823
+ override fun checkoutRemovePromotionCode(
1824
+ sessionKey: String,
1825
+ promise: Promise,
1826
+ ) {
1827
+ performCheckoutMutation(sessionKey, promise) { checkout ->
1828
+ checkout.removePromotionCode()
1829
+ }
1830
+ }
1831
+
1832
+ override fun checkoutUpdateLineItemQuantity(
1833
+ sessionKey: String,
1834
+ lineItemId: String,
1835
+ quantity: Double,
1836
+ promise: Promise,
1837
+ ) {
1838
+ if (!quantity.isFinite() || quantity % 1.0 != 0.0) {
1839
+ promise.reject(ErrorType.Failed.toString(), "Line item quantity must be an integer.")
1840
+ return
1841
+ }
1842
+
1843
+ performCheckoutMutation(sessionKey, promise) { checkout ->
1844
+ checkout.updateLineItemQuantity(lineItemId = lineItemId, quantity = quantity.toInt())
1845
+ }
1846
+ }
1847
+
1848
+ override fun checkoutSelectShippingOption(
1849
+ sessionKey: String,
1850
+ id: String,
1851
+ promise: Promise,
1852
+ ) {
1853
+ performCheckoutMutation(sessionKey, promise) { checkout ->
1854
+ checkout.selectShippingOption(id)
1855
+ }
1856
+ }
1857
+
1858
+ override fun checkoutUpdateTaxId(
1859
+ sessionKey: String,
1860
+ type: String,
1861
+ value: String,
1862
+ promise: Promise,
1863
+ ) {
1864
+ performCheckoutMutation(sessionKey, promise) { checkout ->
1865
+ checkout.updateTaxId(type = type, value = value)
1866
+ }
1867
+ }
1868
+
1869
+ override fun checkoutRefresh(
1870
+ sessionKey: String,
1871
+ promise: Promise,
1872
+ ) {
1873
+ performCheckoutMutation(sessionKey, promise) { checkout ->
1874
+ checkout.refresh()
1875
+ }
1876
+ }
1877
+
1878
+ private fun buildCheckoutConfiguration(configuration: ReadableMap): Checkout.Configuration {
1879
+ val checkoutConfiguration = Checkout.Configuration()
1880
+ val adaptivePricing = configuration.getMap("adaptivePricing")
1881
+ if (adaptivePricing?.hasKey("allowed") == true) {
1882
+ checkoutConfiguration.adaptivePricingAllowed(adaptivePricing.getBooleanOr("allowed", false))
1883
+ }
1884
+ return checkoutConfiguration
1885
+ }
1886
+
1887
+ private fun performCheckoutMutation(
1888
+ sessionKey: String,
1889
+ promise: Promise,
1890
+ operation: suspend (Checkout) -> Result<Unit>,
1891
+ ) {
1892
+ val checkout = checkoutInstances[sessionKey] ?: run {
1893
+ promise.reject(ErrorType.Failed.toString(), "Checkout session not found.")
1894
+ return
1895
+ }
1896
+
1897
+ CoroutineScope(Dispatchers.Main).launch {
1898
+ operation(checkout).fold(
1899
+ onSuccess = {
1900
+ promise.resolve(mapFromCheckoutState(checkout))
1901
+ },
1902
+ onFailure = { error ->
1903
+ promise.reject(
1904
+ ErrorType.Failed.toString(),
1905
+ error.message ?: "Checkout operation failed.",
1906
+ error,
1907
+ )
1908
+ },
1909
+ )
1910
+ }
1911
+ }
1912
+
1675
1913
  /**
1676
1914
  * Safely get and cast the current activity as an AppCompatActivity. If that fails, the promise
1677
1915
  * provided will be resolved with an error message instructing the user to retry the method.
@@ -1740,13 +1978,17 @@ class StripeSdkModule(
1740
1978
  */
1741
1979
  private fun preventActivityRecreation() {
1742
1980
  isRecreatingReactActivity = false
1743
- reactApplicationContext.currentActivity?.application?.unregisterActivityLifecycleCallbacks(activityLifecycleCallbacks)
1981
+ reactApplicationContext.currentActivity?.application?.unregisterActivityLifecycleCallbacks(
1982
+ activityLifecycleCallbacks
1983
+ )
1744
1984
  reactApplicationContext.currentActivity?.application?.registerActivityLifecycleCallbacks(activityLifecycleCallbacks)
1745
1985
  }
1746
1986
 
1747
1987
  private fun setupComposeCompatView() {
1748
1988
  UiThreadUtil.runOnUiThread {
1749
- composeCompatView = composeCompatView ?: StripeAbstractComposeView.CompatView(context = reactApplicationContext).also {
1989
+ composeCompatView = composeCompatView ?: StripeAbstractComposeView.CompatView(
1990
+ context = reactApplicationContext
1991
+ ).also {
1750
1992
  reactApplicationContext.currentActivity?.findViewById<ViewGroup>(android.R.id.content)?.addView(
1751
1993
  it,
1752
1994
  )
@@ -1764,6 +2006,8 @@ class StripeSdkModule(
1764
2006
  // Timeout for auth webview fallback (if JavaScript doesn't call authWebViewDeepLinkHandled)
1765
2007
  private const val AUTH_WEBVIEW_FALLBACK_TIMEOUT_MS = 60_000L
1766
2008
 
2009
+ private const val FILE_CLEANUP_DELAY_MS = 3000L
2010
+
1767
2011
  // SDK-managed storage for pending stripe-connect:// URLs
1768
2012
  // This is static because deep links can arrive before ReactContext is available
1769
2013
  private val pendingConnectUrls = mutableListOf<String>()
@@ -20,7 +20,7 @@ class StripeSdkPackage : BaseReactPackage() {
20
20
  when (name) {
21
21
  StripeSdkModule.NAME -> StripeSdkModule(reactContext)
22
22
  NativeOnrampSdkModuleSpec.NAME -> {
23
- val onrampModuleClass = getOnrampModuleClass()
23
+ val onrampModuleClass = getOnrampModuleClass() ?: return null
24
24
  val constructor = onrampModuleClass.getConstructor(ReactApplicationContext::class.java)
25
25
  constructor.newInstance(reactContext) as NativeModule
26
26
  }
@@ -29,10 +29,10 @@ class StripeSdkPackage : BaseReactPackage() {
29
29
 
30
30
  override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
31
31
  val moduleList: Array<Class<out NativeModule?>> =
32
- arrayOf(
32
+ listOfNotNull(
33
33
  StripeSdkModule::class.java,
34
34
  getOnrampModuleClass(),
35
- )
35
+ ).toTypedArray()
36
36
  val reactModuleInfoMap: MutableMap<String, ReactModuleInfo> = HashMap()
37
37
  for (moduleClass in moduleList) {
38
38
  val reactModule = moduleClass.getAnnotation(ReactModule::class.java) ?: continue
@@ -54,6 +54,7 @@ class StripeSdkPackage : BaseReactPackage() {
54
54
  CardFieldViewManager(),
55
55
  AuBECSDebitFormViewManager(),
56
56
  StripeContainerManager(),
57
+ CurrencySelectorElementViewManager(),
57
58
  CardFormViewManager(),
58
59
  GooglePayButtonManager(),
59
60
  AddToWalletButtonManager(),
@@ -63,12 +64,12 @@ class StripeSdkPackage : BaseReactPackage() {
63
64
  PaymentMethodMessagingElementViewManager(),
64
65
  )
65
66
 
66
- private fun getOnrampModuleClass(): Class<out NativeModule?> {
67
+ private fun getOnrampModuleClass(): Class<out NativeModule?>? {
67
68
  if (BuildConfig.IS_ONRAMP_INCLUDED) {
68
69
  @Suppress("UNCHECKED_CAST")
69
70
  return Class.forName("com.reactnativestripesdk.OnrampSdkModule") as Class<out NativeModule?>
70
71
  } else {
71
- return FakeOnrampSdkModule::class.java
72
+ return null
72
73
  }
73
74
  }
74
75
  }
@@ -55,7 +55,8 @@ class AddressLauncherManager(
55
55
  callback.invoke(
56
56
  createError(
57
57
  ErrorType.Failed.toString(),
58
- "No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.",
58
+ "No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the " +
59
+ "StripeProvider component or the initStripe method.",
59
60
  ),
60
61
  null,
61
62
  )
@@ -162,7 +162,9 @@ class AddressSheetView(
162
162
  else -> AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.HIDDEN
163
163
  }
164
164
 
165
- internal fun buildAdditionalFieldsConfiguration(params: ReadableMap): AddressLauncher.AdditionalFieldsConfiguration {
165
+ internal fun buildAdditionalFieldsConfiguration(
166
+ params: ReadableMap
167
+ ): AddressLauncher.AdditionalFieldsConfiguration {
166
168
  val phoneConfiguration = getFieldConfiguration(params.getString("phoneNumber"))
167
169
 
168
170
  return AddressLauncher.AdditionalFieldsConfiguration(
@@ -326,7 +326,9 @@ class CustomerSheetManager(
326
326
  internal fun createDefaultBillingDetails(map: ReadableMap): PaymentSheet.BillingDetails =
327
327
  buildBillingDetails(map) ?: PaymentSheet.BillingDetails()
328
328
 
329
- internal fun createBillingDetailsCollectionConfiguration(map: ReadableMap): PaymentSheet.BillingDetailsCollectionConfiguration =
329
+ internal fun createBillingDetailsCollectionConfiguration(
330
+ map: ReadableMap
331
+ ): PaymentSheet.BillingDetailsCollectionConfiguration =
330
332
  buildBillingDetailsCollectionConfiguration(map)
331
333
 
332
334
  internal fun createCustomerAdapter(
@@ -405,7 +407,9 @@ class CustomerSheetManager(
405
407
  return paymentOptionResult
406
408
  }
407
409
 
408
- internal fun createIntentConfiguration(intentConfigurationBundle: ReadableMap?): CustomerSheet.IntentConfiguration? =
410
+ internal fun createIntentConfiguration(
411
+ intentConfigurationBundle: ReadableMap?
412
+ ): CustomerSheet.IntentConfiguration? =
409
413
  intentConfigurationBundle?.let { bundle ->
410
414
  val onBehalfOf = bundle.getString("onBehalfOf")
411
415
  CustomerSheet.IntentConfiguration
@@ -67,7 +67,9 @@ class ReactNativeCustomerAdapter(
67
67
  return adapter.detachPaymentMethod(paymentMethodId)
68
68
  }
69
69
 
70
- override suspend fun setSelectedPaymentOption(paymentOption: CustomerAdapter.PaymentOption?): CustomerAdapter.Result<Unit> {
70
+ override suspend fun setSelectedPaymentOption(
71
+ paymentOption: CustomerAdapter.PaymentOption?
72
+ ): CustomerAdapter.Result<Unit> {
71
73
  if (overridesSetSelectedPaymentOption) {
72
74
  CompletableDeferred<Unit>().also {
73
75
  setSelectedPaymentOptionCallback = it
@@ -14,7 +14,8 @@ class ReactNativeCustomerSessionProvider(
14
14
  internal var providesCustomerSessionClientSecretCallback:
15
15
  CompletableDeferred<CustomerSheet.CustomerSessionClientSecret>? = null
16
16
 
17
- override suspend fun intentConfiguration(): Result<CustomerSheet.IntentConfiguration> = Result.success(intentConfiguration)
17
+ override suspend fun intentConfiguration(): Result<CustomerSheet.IntentConfiguration> =
18
+ Result.success(intentConfiguration)
18
19
 
19
20
  override suspend fun provideSetupIntentClientSecret(customerId: String): Result<String> {
20
21
  CompletableDeferred<String>().also {
@@ -30,7 +30,8 @@ class AddToWalletButtonManager :
30
30
  view.onAfterUpdateTransaction()
31
31
  }
32
32
 
33
- override fun createViewInstance(reactContext: ThemedReactContext): AddToWalletButtonView = AddToWalletButtonView(reactContext)
33
+ override fun createViewInstance(reactContext: ThemedReactContext): AddToWalletButtonView =
34
+ AddToWalletButtonView(reactContext)
34
35
 
35
36
  override fun getExportedCustomDirectEventTypeConstants() =
36
37
  mutableMapOf(
@@ -0,0 +1,45 @@
1
+ package com.reactnativestripesdk.utils
2
+
3
+ import com.facebook.react.bridge.ReadableMap
4
+ import com.stripe.android.paymentelement.CheckoutSessionPreview
5
+ import com.stripe.android.checkout.Address as CheckoutAddress
6
+
7
+ @OptIn(CheckoutSessionPreview::class)
8
+ internal data class CheckoutAddressUpdate(
9
+ val name: String? = null,
10
+ val phone: String? = null,
11
+ val country: String,
12
+ val line1: String? = null,
13
+ val line2: String? = null,
14
+ val city: String? = null,
15
+ val state: String? = null,
16
+ val postalCode: String? = null,
17
+ )
18
+
19
+ internal fun buildCheckoutAddressUpdate(
20
+ name: String?,
21
+ phone: String?,
22
+ address: ReadableMap,
23
+ ): CheckoutAddressUpdate? {
24
+ val country = address.getString("country")?.trim()?.takeIf { it.isNotEmpty() } ?: return null
25
+ return CheckoutAddressUpdate(
26
+ name = name?.trim(),
27
+ phone = phone?.trim(),
28
+ country = country,
29
+ line1 = address.getString("line1")?.trim(),
30
+ line2 = address.getString("line2")?.trim(),
31
+ city = address.getString("city")?.trim(),
32
+ state = address.getString("state")?.trim(),
33
+ postalCode = address.getString("postalCode")?.trim(),
34
+ )
35
+ }
36
+
37
+ @OptIn(CheckoutSessionPreview::class)
38
+ internal fun CheckoutAddressUpdate.toCheckoutAddress(): CheckoutAddress =
39
+ CheckoutAddress()
40
+ .country(country)
41
+ .line1(line1)
42
+ .line2(line2)
43
+ .city(city)
44
+ .state(state)
45
+ .postalCode(postalCode)