@stripe/stripe-react-native 0.57.3 → 0.59.0

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 (233) hide show
  1. package/android/build.gradle +2 -0
  2. package/android/gradle.properties +1 -1
  3. package/android/src/main/AndroidManifest.xml +27 -1
  4. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +0 -3
  5. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +7 -3
  6. package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +8 -0
  7. package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +12 -1
  8. package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +26 -0
  9. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfig.kt +147 -0
  10. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementView.kt +164 -0
  11. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementViewManager.kt +65 -0
  12. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +1 -1
  13. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +60 -31
  14. package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +17 -5
  15. package/android/src/main/java/com/reactnativestripesdk/StripeConnectDeepLinkInterceptorActivity.kt +77 -0
  16. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +334 -24
  17. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +1 -0
  18. package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +3 -0
  19. package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +8 -0
  20. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +0 -2
  21. package/android/src/main/res/xml/file_paths.xml +4 -0
  22. package/android/src/oldarch/java/com/facebook/react/viewmanagers/PaymentMethodMessagingElementViewManagerDelegate.java +36 -0
  23. package/android/src/oldarch/java/com/facebook/react/viewmanagers/PaymentMethodMessagingElementViewManagerInterface.java +18 -0
  24. package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +20 -0
  25. package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +175 -1
  26. package/android/src/test/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfigTest.kt +543 -0
  27. package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +70 -0
  28. package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +13 -19
  29. package/ios/CustomerSheet/CustomerSheetUtils.swift +4 -0
  30. package/ios/OldArch/StripeSdkEventEmitterCompat.h +2 -0
  31. package/ios/OldArch/StripeSdkEventEmitterCompat.m +13 -1
  32. package/ios/PaymentMethodMessagingElementConfig.swift +116 -0
  33. package/ios/PaymentMethodMessagingElementHandler.m +9 -0
  34. package/ios/PaymentMethodMessagingElementView.swift +139 -0
  35. package/ios/StripeSdk.mm +40 -0
  36. package/ios/StripeSdkEmitter.swift +2 -0
  37. package/ios/StripeSdkImpl+CustomerSheet.swift +1 -0
  38. package/ios/StripeSdkImpl+Embedded.swift +8 -1
  39. package/ios/StripeSdkImpl+PaymentSheet.swift +44 -1
  40. package/ios/StripeSdkImpl.swift +158 -2
  41. package/jest/mock.js +26 -0
  42. package/jest/setup.js +30 -0
  43. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  44. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  45. package/lib/commonjs/components/AddressSheet.js +1 -1
  46. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  47. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  48. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  49. package/lib/commonjs/components/CardField.js +1 -1
  50. package/lib/commonjs/components/CardField.js.map +1 -1
  51. package/lib/commonjs/components/CardForm.js +1 -1
  52. package/lib/commonjs/components/CardForm.js.map +1 -1
  53. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  54. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  55. package/lib/commonjs/components/StripeContainer.js +1 -1
  56. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  57. package/lib/commonjs/connect/Components.js +1 -1
  58. package/lib/commonjs/connect/Components.js.map +1 -1
  59. package/lib/commonjs/connect/ConnectComponentsProvider.js +1 -1
  60. package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -1
  61. package/lib/commonjs/connect/EmbeddedComponent.js +10 -5
  62. package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
  63. package/lib/commonjs/connect/ModalCloseButton.js +1 -1
  64. package/lib/commonjs/connect/ModalCloseButton.js.map +1 -1
  65. package/lib/commonjs/connect/NavigationBar.js +1 -1
  66. package/lib/commonjs/connect/NavigationBar.js.map +1 -1
  67. package/lib/commonjs/connect/analytics/AnalyticsClient.js +2 -0
  68. package/lib/commonjs/connect/analytics/AnalyticsClient.js.map +1 -0
  69. package/lib/commonjs/connect/analytics/ComponentAnalyticsClient.js +2 -0
  70. package/lib/commonjs/connect/analytics/ComponentAnalyticsClient.js.map +1 -0
  71. package/lib/commonjs/connect/analytics/events.js +2 -0
  72. package/lib/commonjs/connect/analytics/events.js.map +1 -0
  73. package/lib/commonjs/connect/testUtils.js +2 -0
  74. package/lib/commonjs/connect/testUtils.js.map +1 -0
  75. package/lib/commonjs/events.js.map +1 -1
  76. package/lib/commonjs/functions.js +1 -1
  77. package/lib/commonjs/functions.js.map +1 -1
  78. package/lib/commonjs/helpers.js +1 -1
  79. package/lib/commonjs/hooks/useStripe.js +1 -1
  80. package/lib/commonjs/hooks/useStripe.js.map +1 -1
  81. package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
  82. package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
  83. package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
  84. package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
  85. package/lib/commonjs/specs/NativeCardField.js +1 -1
  86. package/lib/commonjs/specs/NativeCardField.js.map +1 -1
  87. package/lib/commonjs/specs/NativeCardForm.js +1 -1
  88. package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
  89. package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +1 -1
  90. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
  91. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  92. package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
  93. package/lib/commonjs/specs/NativeNavigationBar.js +1 -1
  94. package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +2 -0
  95. package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js.map +1 -0
  96. package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
  97. package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
  98. package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
  99. package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
  100. package/lib/commonjs/types/Errors.js +1 -1
  101. package/lib/commonjs/types/Errors.js.map +1 -1
  102. package/lib/commonjs/types/FinancialConnections.js.map +1 -1
  103. package/lib/commonjs/types/PaymentSheet.js +1 -1
  104. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  105. package/lib/commonjs/types/components/PaymentMethodMessagingElementComponent.js +2 -0
  106. package/lib/commonjs/types/components/PaymentMethodMessagingElementComponent.js.map +1 -0
  107. package/lib/commonjs/types/index.js.map +1 -1
  108. package/lib/module/components/AddToWalletButton.js +1 -1
  109. package/lib/module/components/AddToWalletButton.js.map +1 -1
  110. package/lib/module/components/AddressSheet.js +1 -1
  111. package/lib/module/components/AddressSheet.js.map +1 -1
  112. package/lib/module/components/AuBECSDebitForm.js +1 -1
  113. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  114. package/lib/module/components/CardField.js +1 -1
  115. package/lib/module/components/CardField.js.map +1 -1
  116. package/lib/module/components/CardForm.js +1 -1
  117. package/lib/module/components/CardForm.js.map +1 -1
  118. package/lib/module/components/PlatformPayButton.js +1 -1
  119. package/lib/module/components/PlatformPayButton.js.map +1 -1
  120. package/lib/module/components/StripeContainer.js +1 -1
  121. package/lib/module/components/StripeContainer.js.map +1 -1
  122. package/lib/module/connect/Components.js +1 -1
  123. package/lib/module/connect/Components.js.map +1 -1
  124. package/lib/module/connect/ConnectComponentsProvider.js +1 -1
  125. package/lib/module/connect/ConnectComponentsProvider.js.map +1 -1
  126. package/lib/module/connect/EmbeddedComponent.js +10 -5
  127. package/lib/module/connect/EmbeddedComponent.js.map +1 -1
  128. package/lib/module/connect/ModalCloseButton.js +1 -1
  129. package/lib/module/connect/ModalCloseButton.js.map +1 -1
  130. package/lib/module/connect/NavigationBar.js +1 -1
  131. package/lib/module/connect/NavigationBar.js.map +1 -1
  132. package/lib/module/connect/analytics/AnalyticsClient.js +2 -0
  133. package/lib/module/connect/analytics/AnalyticsClient.js.map +1 -0
  134. package/lib/module/connect/analytics/ComponentAnalyticsClient.js +2 -0
  135. package/lib/module/connect/analytics/ComponentAnalyticsClient.js.map +1 -0
  136. package/lib/module/connect/analytics/events.js +2 -0
  137. package/lib/module/connect/analytics/events.js.map +1 -0
  138. package/lib/module/connect/testUtils.js +2 -0
  139. package/lib/module/connect/testUtils.js.map +1 -0
  140. package/lib/module/events.js.map +1 -1
  141. package/lib/module/functions.js +1 -1
  142. package/lib/module/functions.js.map +1 -1
  143. package/lib/module/helpers.js +1 -1
  144. package/lib/module/hooks/useStripe.js +1 -1
  145. package/lib/module/hooks/useStripe.js.map +1 -1
  146. package/lib/module/specs/NativeAddToWalletButton.js +1 -1
  147. package/lib/module/specs/NativeAddressSheet.js +1 -1
  148. package/lib/module/specs/NativeApplePayButton.js +1 -1
  149. package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
  150. package/lib/module/specs/NativeCardField.js +1 -1
  151. package/lib/module/specs/NativeCardField.js.map +1 -1
  152. package/lib/module/specs/NativeCardForm.js +1 -1
  153. package/lib/module/specs/NativeCardForm.js.map +1 -1
  154. package/lib/module/specs/NativeConnectAccountOnboardingView.js +1 -1
  155. package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
  156. package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  157. package/lib/module/specs/NativeGooglePayButton.js +1 -1
  158. package/lib/module/specs/NativeNavigationBar.js +1 -1
  159. package/lib/module/specs/NativePaymentMethodMessagingElement.js +2 -0
  160. package/lib/module/specs/NativePaymentMethodMessagingElement.js.map +1 -0
  161. package/lib/module/specs/NativeStripeContainer.js +1 -1
  162. package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
  163. package/lib/module/types/EmbeddedPaymentElement.js +1 -1
  164. package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
  165. package/lib/module/types/Errors.js +1 -1
  166. package/lib/module/types/Errors.js.map +1 -1
  167. package/lib/module/types/FinancialConnections.js.map +1 -1
  168. package/lib/module/types/PaymentSheet.js +1 -1
  169. package/lib/module/types/PaymentSheet.js.map +1 -1
  170. package/lib/module/types/components/PaymentMethodMessagingElementComponent.js +2 -0
  171. package/lib/module/types/components/PaymentMethodMessagingElementComponent.js.map +1 -0
  172. package/lib/module/types/index.js.map +1 -1
  173. package/lib/typescript/src/connect/Components.d.ts +91 -0
  174. package/lib/typescript/src/connect/Components.d.ts.map +1 -1
  175. package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +61 -0
  176. package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -1
  177. package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -1
  178. package/lib/typescript/src/connect/analytics/AnalyticsClient.d.ts +32 -0
  179. package/lib/typescript/src/connect/analytics/AnalyticsClient.d.ts.map +1 -0
  180. package/lib/typescript/src/connect/analytics/ComponentAnalyticsClient.d.ts +94 -0
  181. package/lib/typescript/src/connect/analytics/ComponentAnalyticsClient.d.ts.map +1 -0
  182. package/lib/typescript/src/connect/analytics/events.d.ts +215 -0
  183. package/lib/typescript/src/connect/analytics/events.d.ts.map +1 -0
  184. package/lib/typescript/src/connect/connectTypes.d.ts +5 -1
  185. package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -1
  186. package/lib/typescript/src/connect/testUtils.d.ts +45 -0
  187. package/lib/typescript/src/connect/testUtils.d.ts.map +1 -0
  188. package/lib/typescript/src/events.d.ts +2 -0
  189. package/lib/typescript/src/events.d.ts.map +1 -1
  190. package/lib/typescript/src/functions.d.ts +13 -1
  191. package/lib/typescript/src/functions.d.ts.map +1 -1
  192. package/lib/typescript/src/hooks/useStripe.d.ts +2 -1
  193. package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -1
  194. package/lib/typescript/src/specs/NativePaymentMethodMessagingElement.d.ts +16 -0
  195. package/lib/typescript/src/specs/NativePaymentMethodMessagingElement.d.ts.map +1 -0
  196. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +16 -1
  197. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
  198. package/lib/typescript/src/types/CustomerSheet.d.ts +5 -0
  199. package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -1
  200. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +11 -1
  201. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
  202. package/lib/typescript/src/types/Errors.d.ts +4 -0
  203. package/lib/typescript/src/types/Errors.d.ts.map +1 -1
  204. package/lib/typescript/src/types/FinancialConnections.d.ts +2 -0
  205. package/lib/typescript/src/types/FinancialConnections.d.ts.map +1 -1
  206. package/lib/typescript/src/types/PaymentSheet.d.ts +35 -0
  207. package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
  208. package/lib/typescript/src/types/components/PaymentMethodMessagingElementComponent.d.ts +69 -0
  209. package/lib/typescript/src/types/components/PaymentMethodMessagingElementComponent.d.ts.map +1 -0
  210. package/lib/typescript/src/types/index.d.ts +8 -1
  211. package/lib/typescript/src/types/index.d.ts.map +1 -1
  212. package/package.json +4 -1
  213. package/src/connect/Components.tsx +109 -11
  214. package/src/connect/ConnectComponentsProvider.tsx +69 -2
  215. package/src/connect/EmbeddedComponent.tsx +458 -23
  216. package/src/connect/analytics/AnalyticsClient.ts +75 -0
  217. package/src/connect/analytics/ComponentAnalyticsClient.ts +315 -0
  218. package/src/connect/analytics/events.ts +253 -0
  219. package/src/connect/connectTypes.ts +5 -1
  220. package/src/connect/testUtils.ts +37 -0
  221. package/src/events.ts +2 -0
  222. package/src/functions.ts +10 -0
  223. package/src/hooks/useStripe.tsx +8 -0
  224. package/src/specs/NativePaymentMethodMessagingElement.ts +25 -0
  225. package/src/specs/NativeStripeSdkModule.ts +21 -1
  226. package/src/types/CustomerSheet.ts +5 -0
  227. package/src/types/EmbeddedPaymentElement.tsx +11 -1
  228. package/src/types/Errors.ts +5 -0
  229. package/src/types/FinancialConnections.ts +2 -0
  230. package/src/types/PaymentSheet.ts +38 -1
  231. package/src/types/components/PaymentMethodMessagingElementComponent.tsx +74 -0
  232. package/src/types/index.ts +11 -0
  233. package/stripe-react-native.podspec +1 -1
@@ -21,6 +21,7 @@ class CustomerSheetUtils {
21
21
  defaultBillingDetails: NSDictionary?,
22
22
  preferredNetworks: [Int]?,
23
23
  allowsRemovalOfLastSavedPaymentMethod: Bool?,
24
+ opensCardScannerAutomatically: Bool?,
24
25
  cardBrandAcceptance: PaymentSheet.CardBrandAcceptance
25
26
  ) -> CustomerSheet.Configuration {
26
27
  var config = CustomerSheet.Configuration()
@@ -59,6 +60,9 @@ class CustomerSheetUtils {
59
60
  if let allowsRemovalOfLastSavedPaymentMethod = allowsRemovalOfLastSavedPaymentMethod {
60
61
  config.allowsRemovalOfLastSavedPaymentMethod = allowsRemovalOfLastSavedPaymentMethod
61
62
  }
63
+ if let opensCardScannerAutomatically = opensCardScannerAutomatically {
64
+ config.opensCardScannerAutomatically = opensCardScannerAutomatically
65
+ }
62
66
  config.cardBrandAcceptance = cardBrandAcceptance
63
67
  return config
64
68
  }
@@ -24,5 +24,7 @@
24
24
  - (void)emitEmbeddedPaymentElementLoadingFailed:(NSDictionary *)value;
25
25
  - (void)emitOnCustomPaymentMethodConfirmHandlerCallback:(NSDictionary *)value;
26
26
  - (void)emitOnCheckoutClientSecretRequested:(NSDictionary *)value;
27
+ - (void)emitPaymentMethodMessagingElementDidUpdateHeight:(NSDictionary *)value;
28
+ - (void)emitPaymentMethodMessagingElementConfigureResult:(NSDictionary *)value;
27
29
  @end
28
30
 
@@ -24,7 +24,9 @@
24
24
  @"embeddedPaymentElementRowSelectionImmediateAction",
25
25
  @"embeddedPaymentElementLoadingFailed",
26
26
  @"onCustomPaymentMethodConfirmHandlerCallback",
27
- @"onCheckoutClientSecretRequested"
27
+ @"onCheckoutClientSecretRequested",
28
+ @"paymentMethodMessagingElementDidUpdateHeight",
29
+ @"paymentMethodMessagingElementConfigureResult",
28
30
  ];
29
31
  }
30
32
 
@@ -128,4 +130,14 @@
128
130
  [self sendEventWithName:@"onCheckoutClientSecretRequested" body:value];
129
131
  }
130
132
 
133
+ - (void)emitPaymentMethodMessagingElementDidUpdateHeight:(NSDictionary *)value
134
+ {
135
+ [self sendEventWithName:@"paymentMethodMessagingElementDidUpdateHeight" body:value];
136
+ }
137
+
138
+ - (void)emitPaymentMethodMessagingElementConfigureResult:(NSDictionary *)value
139
+ {
140
+ [self sendEventWithName:@"paymentMethodMessagingElementConfigureResult" body:value];
141
+ }
142
+
131
143
  @end
@@ -0,0 +1,116 @@
1
+ //
2
+ // PaymentMethodMessagingElementConfig.swift
3
+ // stripe-react-native
4
+ //
5
+ // Created by Tyler Clawson on 2/18/26.
6
+ //
7
+
8
+ @_spi(PaymentMethodMessagingElementPreview) @_spi(STP) import StripePaymentSheet
9
+
10
+ internal class PaymentMethodMessagingElementConfig {
11
+ class func buildAppearanceFromParams(params: NSDictionary?) -> PaymentMethodMessagingElement.Appearance {
12
+ var appearance = PaymentMethodMessagingElement.Appearance()
13
+
14
+ guard let params = params else { return appearance }
15
+
16
+ // Parse theme/style
17
+ if let styleString = params["style"] as? String {
18
+ switch styleString {
19
+ case "dark":
20
+ appearance.style = .alwaysDark
21
+ case "flat":
22
+ appearance.style = .flat
23
+ case "light":
24
+ appearance.style = .alwaysLight
25
+ default:
26
+ appearance.style = .automatic
27
+ }
28
+ }
29
+
30
+ // Parse font
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) {
35
+ appearance.font = customFont
36
+ }
37
+ }
38
+
39
+ // Parse colors
40
+ if let textColorHex = parseThemedColor(params: params, key: "textColor") {
41
+ appearance.textColor = textColorHex
42
+ }
43
+
44
+ if let linkTextColorHex = parseThemedColor(params: params, key: "linkTextColor") {
45
+ appearance.infoIconColor = linkTextColorHex
46
+ }
47
+
48
+ return appearance
49
+ }
50
+
51
+ private class func parseThemedColor(params: NSDictionary, key: String) -> UIColor? {
52
+ // Check if it's a dictionary with light/dark keys
53
+ if let colorDict = params[key] as? [String: String] {
54
+ let lightHex = colorDict["light"]
55
+ let darkHex = colorDict["dark"]
56
+
57
+ if let light = lightHex, let dark = darkHex {
58
+ return UIColor { traitCollection in
59
+ return traitCollection.userInterfaceStyle == .dark
60
+ ? UIColor(hexString: dark)
61
+ : UIColor(hexString: light)
62
+ }
63
+ }
64
+ }
65
+
66
+ // Check if it's a plain string
67
+ if let colorString = params[key] as? String {
68
+ return UIColor(hexString: colorString)
69
+ }
70
+
71
+ return nil
72
+ }
73
+
74
+ class func buildPaymentMethodMessagingElementConfiguration(
75
+ params: NSDictionary
76
+ ) -> (error: NSDictionary?, configuration: PaymentMethodMessagingElement.Configuration?) {
77
+
78
+ // Parse required parameters
79
+ guard let amount = params["amount"] as? Int else {
80
+ let error: NSDictionary = [
81
+ "code": "InvalidConfiguration",
82
+ "message": "amount is required",
83
+ ]
84
+ return (error, nil)
85
+ }
86
+
87
+ guard let currency = params["currency"] as? String else {
88
+ let error: NSDictionary = [
89
+ "code": "InvalidConfiguration",
90
+ "message": "currency is required",
91
+ ]
92
+ return (error, nil)
93
+ }
94
+
95
+ // Parse optional parameters
96
+ let locale = params["locale"] as? String
97
+ let country = params["country"] as? String
98
+
99
+ var paymentMethodTypes: [STPPaymentMethodType]?
100
+ if let paymentMethodTypesArray = params["paymentMethodTypes"] as? [String] {
101
+ paymentMethodTypes = paymentMethodTypesArray.map {
102
+ STPPaymentMethodType.fromIdentifier($0)
103
+ }
104
+ }
105
+
106
+ var configuration = PaymentMethodMessagingElement.Configuration(
107
+ amount: amount,
108
+ currency: currency,
109
+ locale: locale,
110
+ countryCode: country,
111
+ paymentMethodTypes: paymentMethodTypes,
112
+ )
113
+
114
+ return (nil, configuration)
115
+ }
116
+ }
@@ -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(PaymentMethodMessagingElementView, RCTViewManager)
6
+ RCT_EXPORT_VIEW_PROPERTY(appearance, NSDictionary)
7
+ RCT_EXPORT_VIEW_PROPERTY(configuration, NSDictionary)
8
+ RCT_EXPORT_VIEW_PROPERTY(onLoadComplete, RCTDirectEventBlock)
9
+ @end
@@ -0,0 +1,139 @@
1
+ import Foundation
2
+ @_spi(PaymentMethodMessagingElementPreview) @_spi(STP) import StripePaymentSheet
3
+ import UIKit
4
+
5
+ @objc(PaymentMethodMessagingElementView)
6
+ class PaymentMethodMessagingElementView: RCTViewManager {
7
+
8
+ override static func requiresMainQueueSetup() -> Bool {
9
+ return true
10
+ }
11
+
12
+ override func view() -> UIView! {
13
+ return PaymentMethodMessagingElementContainerView(frame: .zero)
14
+ }
15
+ }
16
+
17
+ @objc(PaymentMethodMessagingElementContainerView)
18
+ public class PaymentMethodMessagingElementContainerView: UIView, UIGestureRecognizerDelegate {
19
+ private var paymentMethodMessagingElementView: UIView?
20
+ private var messagingInstance: PaymentMethodMessagingElement?
21
+ private var appearanceConfig: PaymentMethodMessagingElement.Appearance?
22
+ private var lastConfig: NSDictionary?
23
+
24
+ @objc var appearance: NSDictionary? {
25
+ didSet {
26
+ if let appearance = appearance {
27
+ appearanceConfig = PaymentMethodMessagingElementConfig.buildAppearanceFromParams(params: appearance)
28
+ // Re-initialize if configuration already exists
29
+ if let config = lastConfig {
30
+ initMessagingElement(config: config)
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ @objc var configuration: NSDictionary? {
37
+ didSet {
38
+ if let configuration = configuration {
39
+ lastConfig = configuration
40
+ initMessagingElement(config: configuration)
41
+ }
42
+ }
43
+ }
44
+
45
+ override init(frame: CGRect) {
46
+ super.init(frame: frame)
47
+ backgroundColor = .clear
48
+ }
49
+
50
+ required init?(coder: NSCoder) {
51
+ fatalError()
52
+ }
53
+
54
+ public override func didMoveToWindow() {
55
+ super.didMoveToWindow()
56
+ if window != nil {
57
+ // Only attach when we have a valid window
58
+ attachPaymentElementIfAvailable()
59
+ }
60
+ }
61
+
62
+ public override func willMove(toWindow newWindow: UIWindow?) {
63
+ super.willMove(toWindow: newWindow)
64
+ if newWindow == nil {
65
+ // Remove the view when moving away from window
66
+ removePaymentMethodMessagingElement()
67
+ }
68
+ }
69
+
70
+ private func attachPaymentElementIfAvailable() {
71
+ removePaymentMethodMessagingElement()
72
+ guard let messagingElement = messagingInstance else {
73
+ return
74
+ }
75
+
76
+ let messagingElementView = messagingElement.view
77
+ addSubview(messagingElementView)
78
+ messagingElementView.translatesAutoresizingMaskIntoConstraints = false
79
+
80
+ NSLayoutConstraint.activate([
81
+ messagingElementView.topAnchor.constraint(equalTo: topAnchor),
82
+ messagingElementView.leadingAnchor.constraint(equalTo: leadingAnchor),
83
+ messagingElementView.trailingAnchor.constraint(equalTo: trailingAnchor),
84
+ messagingElementView.bottomAnchor.constraint(equalTo: bottomAnchor),
85
+ ])
86
+
87
+ self.paymentMethodMessagingElementView = messagingElementView
88
+ }
89
+
90
+ private func removePaymentMethodMessagingElement() {
91
+ paymentMethodMessagingElementView?.removeFromSuperview()
92
+ paymentMethodMessagingElementView = nil
93
+ }
94
+
95
+ private func initMessagingElement(config: NSDictionary) {
96
+ let configResult = PaymentMethodMessagingElementConfig.buildPaymentMethodMessagingElementConfiguration(params: config)
97
+
98
+ if let error = configResult.error {
99
+ StripeSdkImpl.shared.emitter?.emitPaymentMethodMessagingElementConfigureResult([
100
+ "status": "failed",
101
+ "error": error,
102
+ ])
103
+ return
104
+ }
105
+
106
+ guard var configuration = configResult.configuration else {
107
+ return
108
+ }
109
+
110
+ // Add appearance if available
111
+ if let appearance = appearanceConfig {
112
+ configuration.appearance = appearance
113
+ }
114
+
115
+ var resultMap: [String: String] = [:]
116
+ var height: CGFloat? = 0
117
+
118
+ Task { @MainActor in
119
+ StripeSdkImpl.shared.emitter?.emitPaymentMethodMessagingElementConfigureResult(["status": "loading"])
120
+ switch await PaymentMethodMessagingElement.create(configuration: configuration) {
121
+ case .success(let paymentMethodMessagingElement):
122
+ self.messagingInstance = paymentMethodMessagingElement
123
+ height = self.messagingInstance?.view.systemLayoutSizeFitting(CGSize(width: paymentMethodMessagingElement.view.bounds.width, height: UIView.layoutFittingCompressedSize.height)).height
124
+ resultMap["status"] = "loaded"
125
+ case .noContent:
126
+ resultMap["status"] = "no_content"
127
+ self.messagingInstance = nil
128
+ case .failed(let error):
129
+ self.messagingInstance = nil
130
+ resultMap["status"] = "failed"
131
+ resultMap["message"] = error.localizedDescription
132
+ }
133
+
134
+ StripeSdkImpl.shared.emitter?.emitPaymentMethodMessagingElementDidUpdateHeight(["height": height ?? 0])
135
+ StripeSdkImpl.shared.emitter?.emitPaymentMethodMessagingElementConfigureResult(resultMap)
136
+ attachPaymentElementIfAvailable()
137
+ }
138
+ }
139
+ }
package/ios/StripeSdk.mm CHANGED
@@ -390,6 +390,40 @@ RCT_EXPORT_METHOD(openAuthenticatedWebView:(nonnull NSString *)id
390
390
  [StripeSdkImpl.shared openAuthenticatedWebView:id url:url resolver:resolve rejecter:reject];
391
391
  }
392
392
 
393
+ RCT_EXPORT_METHOD(downloadAndShareFile:(nonnull NSString *)url
394
+ filename:(nullable NSString *)filename
395
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
396
+ reject:(nonnull RCTPromiseRejectBlock)reject)
397
+ {
398
+ [StripeSdkImpl.shared downloadAndShareFile:url
399
+ filename:filename
400
+ resolver:resolve
401
+ rejecter:reject];
402
+ }
403
+
404
+ RCT_EXPORT_METHOD(authWebViewDeepLinkHandled:(nonnull NSString *)id
405
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
406
+ reject:(nonnull RCTPromiseRejectBlock)reject)
407
+ {
408
+ // No-op for iOS since it doesn't have this issue
409
+ resolve(@[]);
410
+ }
411
+
412
+ RCT_EXPORT_METHOD(storeStripeConnectDeepLink:(nonnull NSString *)url
413
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
414
+ reject:(nonnull RCTPromiseRejectBlock)reject)
415
+ {
416
+ // No-op for iOS - iOS doesn't need this mechanism
417
+ resolve([NSNull null]);
418
+ }
419
+
420
+ RCT_EXPORT_METHOD(pollAndClearPendingStripeConnectUrls:(nonnull RCTPromiseResolveBlock)resolve
421
+ reject:(nonnull RCTPromiseRejectBlock)reject)
422
+ {
423
+ // No-op for iOS - iOS doesn't need this mechanism
424
+ resolve(@[]);
425
+ }
426
+
393
427
  RCT_EXPORT_METHOD(verifyMicrodeposits:(BOOL)isPaymentIntent
394
428
  clientSecret:(nonnull NSString *)clientSecret
395
429
  params:(nonnull NSDictionary *)params
@@ -443,6 +477,12 @@ RCT_EXPORT_METHOD(customPaymentMethodResultCallback:(nonnull NSDictionary *)resu
443
477
  [StripeSdkImpl.shared customPaymentMethodResultCallback:result resolver:resolve rejecter:reject];
444
478
  }
445
479
 
480
+ RCT_EXPORT_METHOD(createRadarSession:(nonnull RCTPromiseResolveBlock)resolve
481
+ reject:(nonnull RCTPromiseRejectBlock)reject)
482
+ {
483
+ [StripeSdkImpl.shared createRadarSession:resolve rejecter:reject];
484
+ }
485
+
446
486
  /* clang-format on */
447
487
 
448
488
  #ifdef RCT_NEW_ARCH_ENABLED
@@ -20,6 +20,8 @@ import Foundation
20
20
  func emitEmbeddedPaymentElementRowSelectionImmediateAction()
21
21
  func emitEmbeddedPaymentElementLoadingFailed(_ value: [String: Any])
22
22
  func emitOnCustomPaymentMethodConfirmHandlerCallback(_ value: [String: Any])
23
+ func emitPaymentMethodMessagingElementDidUpdateHeight(_ value: [String: Any])
24
+ func emitPaymentMethodMessagingElementConfigureResult(_ value: [String: Any])
23
25
  }
24
26
 
25
27
  @objc public protocol StripeOnrampSdkEmitter {
@@ -26,6 +26,7 @@ extension StripeSdkImpl {
26
26
  defaultBillingDetails: params["defaultBillingDetails"] as? NSDictionary,
27
27
  preferredNetworks: params["preferredNetworks"] as? [Int],
28
28
  allowsRemovalOfLastSavedPaymentMethod: params["allowsRemovalOfLastSavedPaymentMethod"] as? Bool,
29
+ opensCardScannerAutomatically: params["opensCardScannerAutomatically"] as? Bool,
29
30
  cardBrandAcceptance: StripeSdkImpl.computeCardBrandAcceptance(params: params)
30
31
  )
31
32
  } catch {
@@ -6,7 +6,7 @@
6
6
  //
7
7
 
8
8
  import Foundation
9
- @_spi(EmbeddedPaymentElementPrivateBeta) @_spi(ExperimentalAllowsRemovalOfLastSavedPaymentMethodAPI) @_spi(CustomerSessionBetaAccess) @_spi(STP) @_spi(CustomPaymentMethodsBeta) import StripePaymentSheet
9
+ @_spi(EmbeddedPaymentElementPrivateBeta) @_spi(ExperimentalAllowsRemovalOfLastSavedPaymentMethodAPI) @_spi(CustomerSessionBetaAccess) @_spi(STP) @_spi(CustomPaymentMethodsBeta) @_spi(CardFundingFilteringPrivatePreview) import StripePaymentSheet
10
10
 
11
11
  @objc(StripeSdkImpl)
12
12
  extension StripeSdkImpl {
@@ -310,7 +310,14 @@ extension StripeSdkImpl {
310
310
  configuration.paymentMethodOrder = paymentMethodOrder
311
311
  }
312
312
 
313
+ if let opensCardScannerAutomatically = params["opensCardScannerAutomatically"] as? Bool {
314
+ configuration.opensCardScannerAutomatically = opensCardScannerAutomatically
315
+ }
316
+
313
317
  configuration.cardBrandAcceptance = StripeSdkImpl.computeCardBrandAcceptance(params: params)
318
+ if let allowedCardFundingTypes = StripeSdkImpl.computeAllowedCardFundingTypes(params: params) {
319
+ configuration.allowedCardFundingTypes = allowedCardFundingTypes
320
+ }
314
321
 
315
322
  if let formSheetActionParams = params["formSheetAction"] as? NSDictionary,
316
323
  let actionType = formSheetActionParams["type"] as? String {
@@ -6,7 +6,7 @@
6
6
  //
7
7
 
8
8
  import Foundation
9
- @_spi(ExperimentalAllowsRemovalOfLastSavedPaymentMethodAPI) @_spi(CustomerSessionBetaAccess) @_spi(EmbeddedPaymentElementPrivateBeta) @_spi(STP) @_spi(PaymentMethodOptionsSetupFutureUsagePreview) @_spi(CustomPaymentMethodsBeta) @_spi(ConfirmationTokensPublicPreview) import StripePaymentSheet
9
+ @_spi(ExperimentalAllowsRemovalOfLastSavedPaymentMethodAPI) @_spi(CustomerSessionBetaAccess) @_spi(EmbeddedPaymentElementPrivateBeta) @_spi(STP) @_spi(PaymentMethodOptionsSetupFutureUsagePreview) @_spi(CustomPaymentMethodsBeta) @_spi(ConfirmationTokensPublicPreview) @_spi(CardFundingFilteringPrivatePreview) import StripePaymentSheet
10
10
 
11
11
  extension StripeSdkImpl {
12
12
  internal func buildPaymentSheetConfiguration(
@@ -122,6 +122,10 @@ extension StripeSdkImpl {
122
122
  configuration.allowsRemovalOfLastSavedPaymentMethod = allowsRemovalOfLastSavedPaymentMethod
123
123
  }
124
124
 
125
+ if let opensCardScannerAutomatically = params["opensCardScannerAutomatically"] as? Bool {
126
+ configuration.opensCardScannerAutomatically = opensCardScannerAutomatically
127
+ }
128
+
125
129
  if let paymentMethodOrder = params["paymentMethodOrder"] as? [String] {
126
130
  configuration.paymentMethodOrder = paymentMethodOrder
127
131
  }
@@ -136,6 +140,9 @@ extension StripeSdkImpl {
136
140
  }
137
141
 
138
142
  configuration.cardBrandAcceptance = StripeSdkImpl.computeCardBrandAcceptance(params: params)
143
+ if let allowedCardFundingTypes = StripeSdkImpl.computeAllowedCardFundingTypes(params: params) {
144
+ configuration.allowedCardFundingTypes = allowedCardFundingTypes
145
+ }
139
146
 
140
147
  // Parse custom payment method configuration
141
148
  if let customPaymentMethodConfig = params["customPaymentMethodConfiguration"] as? [String: Any] {
@@ -145,6 +152,11 @@ extension StripeSdkImpl {
145
152
  )
146
153
  }
147
154
 
155
+ let userKeyTermsDisplay = StripeSdkImpl.computeTermsDisplayForUserKey()
156
+ if !userKeyTermsDisplay.isEmpty {
157
+ configuration.termsDisplay = userKeyTermsDisplay
158
+ }
159
+
148
160
  return (nil, configuration)
149
161
  }
150
162
 
@@ -286,6 +298,30 @@ extension StripeSdkImpl {
286
298
  }
287
299
  }
288
300
 
301
+ internal static func computeAllowedCardFundingTypes(params: NSDictionary) -> PaymentSheet.CardFundingType? {
302
+ guard let cardFundingFiltering = params["cardFundingFiltering"] as? NSDictionary,
303
+ let allowedTypes = cardFundingFiltering["allowedCardFundingTypes"] as? [String] else {
304
+ return nil
305
+ }
306
+
307
+ var result: PaymentSheet.CardFundingType = []
308
+ for type in allowedTypes {
309
+ switch type {
310
+ case "debit":
311
+ result.insert(.debit)
312
+ case "credit":
313
+ result.insert(.credit)
314
+ case "prepaid":
315
+ result.insert(.prepaid)
316
+ case "unknown":
317
+ result.insert(.unknown)
318
+ default:
319
+ break
320
+ }
321
+ }
322
+ return result.isEmpty ? nil : result
323
+ }
324
+
289
325
  static func mapCaptureMethod(_ captureMethod: String?) -> PaymentSheet.IntentConfiguration.CaptureMethod {
290
326
  if let captureMethod = captureMethod {
291
327
  switch captureMethod {
@@ -450,6 +486,13 @@ extension StripeSdkImpl {
450
486
  }
451
487
  }
452
488
 
489
+ internal static func computeTermsDisplayForUserKey() -> [STPPaymentMethodType: PaymentSheet.TermsDisplay] {
490
+ if STPAPIClient.shared.publishableKeyIsUserKey {
491
+ return [.card: .never]
492
+ }
493
+ return [:]
494
+ }
495
+
453
496
  internal static func mapToLinkDisplay(value: String?) -> PaymentSheet.LinkConfiguration.Display {
454
497
  switch value {
455
498
  case "automatic":