@stripe/stripe-react-native 0.30.0 → 0.31.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 (58) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/android/gradle.properties +1 -1
  3. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +41 -10
  4. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +10 -3
  5. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +129 -82
  6. package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +329 -0
  7. package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +138 -0
  8. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +8 -2
  9. package/ios/CustomerSheet/CustomerSheetUtils.swift +181 -0
  10. package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +173 -0
  11. package/ios/Mappers.swift +1 -1
  12. package/ios/StripeSdk+CustomerSheet.swift +166 -0
  13. package/ios/StripeSdk+PaymentSheet.swift +2 -2
  14. package/ios/StripeSdk.m +53 -0
  15. package/ios/StripeSdk.swift +14 -1
  16. package/jest/mock.js +0 -37
  17. package/lib/commonjs/NativeStripeSdk.js.map +1 -1
  18. package/lib/commonjs/components/CustomerSheet.js +2 -0
  19. package/lib/commonjs/components/CustomerSheet.js.map +1 -0
  20. package/lib/commonjs/functions.js +1 -1
  21. package/lib/commonjs/functions.js.map +1 -1
  22. package/lib/commonjs/index.js +1 -1
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/types/CustomerSheet.js +2 -0
  25. package/lib/commonjs/types/CustomerSheet.js.map +1 -0
  26. package/lib/commonjs/types/Errors.js +1 -1
  27. package/lib/commonjs/types/Errors.js.map +1 -1
  28. package/lib/commonjs/types/index.js +1 -1
  29. package/lib/commonjs/types/index.js.map +1 -1
  30. package/lib/module/NativeStripeSdk.js.map +1 -1
  31. package/lib/module/components/CustomerSheet.js +2 -0
  32. package/lib/module/components/CustomerSheet.js.map +1 -0
  33. package/lib/module/functions.js +1 -1
  34. package/lib/module/functions.js.map +1 -1
  35. package/lib/module/index.js +1 -1
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/module/types/CustomerSheet.js +2 -0
  38. package/lib/module/types/CustomerSheet.js.map +1 -0
  39. package/lib/module/types/Errors.js +1 -1
  40. package/lib/module/types/Errors.js.map +1 -1
  41. package/lib/module/types/index.js +1 -1
  42. package/lib/module/types/index.js.map +1 -1
  43. package/lib/typescript/src/NativeStripeSdk.d.ts +14 -1
  44. package/lib/typescript/src/components/CustomerSheet.d.ts +59 -0
  45. package/lib/typescript/src/index.d.ts +2 -0
  46. package/lib/typescript/src/types/CustomerSheet.d.ts +94 -0
  47. package/lib/typescript/src/types/Errors.d.ts +4 -0
  48. package/lib/typescript/src/types/index.d.ts +1 -0
  49. package/package.json +1 -1
  50. package/src/NativeStripeSdk.tsx +31 -0
  51. package/src/components/CustomerSheet.tsx +327 -0
  52. package/src/functions.ts +5 -0
  53. package/src/index.tsx +3 -0
  54. package/src/types/CustomerSheet.ts +111 -0
  55. package/src/types/Errors.ts +5 -0
  56. package/src/types/index.ts +1 -0
  57. package/stripe-react-native.podspec +1 -1
  58. package/android/src/main/java/com/reactnativestripesdk/GooglePayFragment.kt +0 -211
@@ -0,0 +1,173 @@
1
+ //
2
+ // ReactNativeCustomerAdapter.swift
3
+ // stripe-react-native
4
+ //
5
+ // Created by Charlie Cruzan on 9/5/23.
6
+ //
7
+
8
+ import Foundation
9
+ @_spi(PrivateBetaCustomerSheet) @_spi(STP) import StripePaymentSheet
10
+
11
+ class ReactNativeCustomerAdapter: StripeCustomerAdapter {
12
+ var overridesFetchPaymentMethods: Bool
13
+ var overridesAttachPaymentMethod: Bool
14
+ var overridesDetachPaymentMethod: Bool
15
+ var overridesSetSelectedPaymentOption: Bool
16
+ var overridesFetchSelectedPaymentOption: Bool
17
+ var overridesSetupIntentClientSecretForCustomerAttach: Bool
18
+ var stripeSdk: StripeSdk
19
+
20
+ init(
21
+ fetchPaymentMethods: Bool,
22
+ attachPaymentMethod: Bool,
23
+ detachPaymentMethod: Bool,
24
+ setSelectedPaymentOption: Bool,
25
+ fetchSelectedPaymentOption: Bool,
26
+ setupIntentClientSecretForCustomerAttach: Bool,
27
+ customerId: String,
28
+ ephemeralKeySecret: String,
29
+ setupIntentClientSecret: String?,
30
+ stripeSdk: StripeSdk
31
+ ) {
32
+ self.overridesFetchPaymentMethods = fetchPaymentMethods
33
+ self.overridesAttachPaymentMethod = attachPaymentMethod
34
+ self.overridesDetachPaymentMethod = detachPaymentMethod
35
+ self.overridesSetSelectedPaymentOption = setSelectedPaymentOption
36
+ self.overridesFetchSelectedPaymentOption = fetchSelectedPaymentOption
37
+ self.overridesSetupIntentClientSecretForCustomerAttach = setupIntentClientSecretForCustomerAttach
38
+ self.stripeSdk = stripeSdk
39
+
40
+ if let setupIntentClientSecret = setupIntentClientSecret {
41
+ super.init(
42
+ customerEphemeralKeyProvider: {
43
+ return CustomerEphemeralKey(customerId: customerId, ephemeralKeySecret: ephemeralKeySecret)
44
+ },
45
+ setupIntentClientSecretProvider: {
46
+ return setupIntentClientSecret
47
+ }
48
+ )
49
+ } else {
50
+ super.init(
51
+ customerEphemeralKeyProvider: {
52
+ return CustomerEphemeralKey(customerId: customerId, ephemeralKeySecret: ephemeralKeySecret)
53
+ }
54
+ )
55
+ }
56
+ }
57
+
58
+ override func fetchPaymentMethods() async throws -> [STPPaymentMethod] {
59
+ if (self.overridesFetchPaymentMethods) {
60
+ return await withCheckedContinuation({ continuation in
61
+ fetchPaymentMethods { paymentMethods in
62
+ continuation.resume(returning: paymentMethods)
63
+ }
64
+ })
65
+ } else {
66
+ return try await super.fetchPaymentMethods()
67
+ }
68
+ }
69
+
70
+ override func attachPaymentMethod(_ paymentMethodId: String) async throws {
71
+ if (self.overridesAttachPaymentMethod) {
72
+ return await withCheckedContinuation({ continuation in
73
+ attachPaymentMethod(paymentMethodId) {
74
+ continuation.resume(returning: ())
75
+ }
76
+ })
77
+ } else {
78
+ return try await super.attachPaymentMethod(paymentMethodId)
79
+ }
80
+ }
81
+
82
+ override func detachPaymentMethod(paymentMethodId: String) async throws {
83
+ if (self.overridesDetachPaymentMethod) {
84
+ return await withCheckedContinuation({ continuation in
85
+ detachPaymentMethod(paymentMethodId) {
86
+ continuation.resume(returning: ())
87
+ }
88
+ })
89
+ } else {
90
+ return try await super.detachPaymentMethod(paymentMethodId: paymentMethodId)
91
+ }
92
+ }
93
+
94
+ override func setSelectedPaymentOption(paymentOption: CustomerPaymentOption?) async throws {
95
+ if (self.overridesSetSelectedPaymentOption) {
96
+ return await withCheckedContinuation({ continuation in
97
+ setSelectedPaymentOption(paymentOption) {
98
+ continuation.resume(returning: ())
99
+ }
100
+ })
101
+ } else {
102
+ return try await super.setSelectedPaymentOption(paymentOption: paymentOption)
103
+ }
104
+ }
105
+
106
+ override func fetchSelectedPaymentOption() async throws -> CustomerPaymentOption? {
107
+ if (self.overridesFetchSelectedPaymentOption) {
108
+ return await withCheckedContinuation({ continuation in
109
+ fetchSelectedPaymentOption { paymentOption in
110
+ continuation.resume(returning: paymentOption)
111
+ }
112
+ })
113
+ } else {
114
+ return try await super.fetchSelectedPaymentOption()
115
+ }
116
+ }
117
+
118
+ override func setupIntentClientSecretForCustomerAttach() async throws -> String {
119
+ if (self.overridesSetupIntentClientSecretForCustomerAttach) {
120
+ return await withCheckedContinuation({ continuation in
121
+ setupIntentClientSecretForCustomerAttach { clientSecret in
122
+ continuation.resume(returning: clientSecret)
123
+ }
124
+ })
125
+ } else {
126
+ return try await super.setupIntentClientSecretForCustomerAttach()
127
+ }
128
+ }
129
+ }
130
+
131
+ extension ReactNativeCustomerAdapter {
132
+ func fetchPaymentMethods(completion: @escaping ([STPPaymentMethod]) -> Void) {
133
+ DispatchQueue.main.async {
134
+ self.stripeSdk.fetchPaymentMethodsCallback = completion
135
+ self.stripeSdk.sendEvent(withName: "onCustomerAdapterFetchPaymentMethodsCallback", body: [:])
136
+ }
137
+ }
138
+
139
+ func attachPaymentMethod(_ paymentMethodId: String, completion: @escaping () -> Void) {
140
+ DispatchQueue.main.async {
141
+ self.stripeSdk.attachPaymentMethodCallback = completion
142
+ self.stripeSdk.sendEvent(withName: "onCustomerAdapterAttachPaymentMethodCallback", body: ["paymentMethodId": paymentMethodId])
143
+ }
144
+ }
145
+
146
+ func detachPaymentMethod(_ paymentMethodId: String, completion: @escaping () -> Void) {
147
+ DispatchQueue.main.async {
148
+ self.stripeSdk.detachPaymentMethodCallback = completion
149
+ self.stripeSdk.sendEvent(withName: "onCustomerAdapterDetachPaymentMethodCallback", body: ["paymentMethodId": paymentMethodId])
150
+ }
151
+ }
152
+
153
+ func setSelectedPaymentOption(_ paymentOption: CustomerPaymentOption?, completion: @escaping () -> Void) {
154
+ DispatchQueue.main.async {
155
+ self.stripeSdk.setSelectedPaymentOptionCallback = completion
156
+ self.stripeSdk.sendEvent(withName: "onCustomerAdapterSetSelectedPaymentOptionCallback", body: ["paymentOption": paymentOption?.value])
157
+ }
158
+ }
159
+
160
+ func fetchSelectedPaymentOption(completion: @escaping (CustomerPaymentOption?) -> Void) {
161
+ DispatchQueue.main.async {
162
+ self.stripeSdk.fetchSelectedPaymentOptionCallback = completion
163
+ self.stripeSdk.sendEvent(withName: "onCustomerAdapterFetchSelectedPaymentOptionCallback", body: [:])
164
+ }
165
+ }
166
+
167
+ func setupIntentClientSecretForCustomerAttach(completion: @escaping (String) -> Void) {
168
+ DispatchQueue.main.async {
169
+ self.stripeSdk.setupIntentClientSecretForCustomerAttachCallback = completion
170
+ self.stripeSdk.sendEvent(withName: "onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback", body: [:])
171
+ }
172
+ }
173
+ }
package/ios/Mappers.swift CHANGED
@@ -754,7 +754,7 @@ class Mappers {
754
754
  }
755
755
 
756
756
  @available(iOS 13.0, *)
757
- class func mapToUserInterfaceStyle(_ style: String) -> PaymentSheet.UserInterfaceStyle {
757
+ class func mapToUserInterfaceStyle(_ style: String?) -> PaymentSheet.UserInterfaceStyle {
758
758
  switch style {
759
759
  case "alwaysDark": return PaymentSheet.UserInterfaceStyle.alwaysDark
760
760
  case "alwaysLight": return PaymentSheet.UserInterfaceStyle.alwaysLight
@@ -0,0 +1,166 @@
1
+ //
2
+ // CustomerSheetView.swift
3
+ // stripe-react-native
4
+ //
5
+ // Created by Charles Cruzan on 08/28/23.
6
+ //
7
+
8
+ import Foundation
9
+ @_spi(PrivateBetaCustomerSheet) @_spi(STP) import StripePaymentSheet
10
+
11
+ extension StripeSdk {
12
+ @objc(initCustomerSheet:customerAdapterOverrides:resolver:rejecter:)
13
+ func initCustomerSheet(params: NSDictionary, customerAdapterOverrides: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock,
14
+ rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
15
+ do {
16
+ customerSheetConfiguration = CustomerSheetUtils.buildCustomerSheetConfiguration(
17
+ appearance: try PaymentSheetAppearance.buildAppearanceFromParams(userParams: params["appearance"] as? NSDictionary),
18
+ style: Mappers.mapToUserInterfaceStyle(params["style"] as? String),
19
+ removeSavedPaymentMethodMessage: params["removeSavedPaymentMethodMessage"] as? String,
20
+ returnURL: params["returnURL"] as? String,
21
+ headerTextForSelectionScreen: params["headerTextForSelectionScreen"] as? String,
22
+ applePayEnabled: params["applePayEnabled"] as? Bool,
23
+ merchantDisplayName: params["merchantDisplayName"] as? String,
24
+ billingDetailsCollectionConfiguration: params["billingDetailsCollectionConfiguration"] as? NSDictionary,
25
+ defaultBillingDetails: params["defaultBillingDetails"] as? NSDictionary)
26
+ } catch {
27
+ resolve(
28
+ Errors.createError(ErrorType.Failed, error.localizedDescription)
29
+ )
30
+ return
31
+ }
32
+
33
+ guard let customerId = params["customerId"] as? String else {
34
+ resolve(Errors.createError(ErrorType.Failed, "You must provide `customerId`"))
35
+ return
36
+ }
37
+ guard let customerEphemeralKeySecret = params["customerEphemeralKeySecret"] as? String else {
38
+ resolve(Errors.createError(ErrorType.Failed, "You must provide `customerEphemeralKeySecret`"))
39
+ return
40
+ }
41
+
42
+ customerAdapter = CustomerSheetUtils.buildStripeCustomerAdapter(
43
+ customerId: customerId,
44
+ ephemeralKeySecret: customerEphemeralKeySecret,
45
+ setupIntentClientSecret: params["setupIntentClientSecret"] as? String,
46
+ customerAdapter: customerAdapterOverrides,
47
+ stripeSdk: self
48
+ )
49
+
50
+ customerSheet = CustomerSheet(configuration: customerSheetConfiguration, customer: customerAdapter!)
51
+
52
+ resolve([])
53
+ }
54
+
55
+ @objc(presentCustomerSheet:resolver:rejecter:)
56
+ func presentCustomerSheet(params: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock,
57
+ rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
58
+ if (STPAPIClient.shared.publishableKey == nil) {
59
+ resolve(
60
+ Errors.createError(ErrorType.Failed, "No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.")
61
+ )
62
+ return
63
+ }
64
+
65
+ if let timeout = params["timeout"] as? Double {
66
+ DispatchQueue.main.asyncAfter(deadline: .now() + timeout/1000) {
67
+ if let customerSheetViewController = self.customerSheetViewController {
68
+ customerSheetViewController.dismiss(animated: true)
69
+ resolve(Errors.createError(ErrorType.Timeout, "The payment has timed out."))
70
+ }
71
+ }
72
+ }
73
+
74
+ DispatchQueue.main.async {
75
+ self.customerSheetViewController = findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController())
76
+ if let customerSheetViewController = self.customerSheetViewController {
77
+ customerSheetViewController.modalPresentationStyle = CustomerSheetUtils.getModalPresentationStyle(params["presentationStyle"] as? String)
78
+ customerSheetViewController.modalTransitionStyle = CustomerSheetUtils.getModalTransitionStyle(params["animationStyle"] as? String)
79
+ if let customerSheet = self.customerSheet {
80
+ customerSheet.present(
81
+ from: customerSheetViewController, completion: { result in
82
+ resolve(CustomerSheetUtils.interpretResult(result: result))
83
+ })
84
+ } else {
85
+ resolve(Errors.createError(ErrorType.Failed, "CustomerSheet has not been properly initialized."))
86
+ return
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ @objc(retrieveCustomerSheetPaymentOptionSelection:rejecter:)
93
+ func retrieveCustomerSheetPaymentOptionSelection(resolver resolve: @escaping RCTPromiseResolveBlock,
94
+ rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
95
+ guard let customerAdapter = customerAdapter else {
96
+ resolve(Errors.createError(ErrorType.Failed, "CustomerSheet has not been properly initialized."))
97
+ return
98
+ }
99
+
100
+ Task {
101
+ var payload: NSDictionary = [:]
102
+ var paymentMethodOption: CustomerSheet.PaymentOptionSelection? = nil
103
+ do {
104
+ paymentMethodOption = try await customerAdapter.retrievePaymentOptionSelection()
105
+ } catch {
106
+ resolve(Errors.createError(ErrorType.Failed, error as NSError))
107
+ return
108
+ }
109
+
110
+ switch paymentMethodOption {
111
+ case .applePay(let paymentOptionDisplayData):
112
+ payload = CustomerSheetUtils.buildPaymentOptionResult(label: paymentOptionDisplayData.label, imageData: paymentOptionDisplayData.image.pngData()?.base64EncodedString(), paymentMethod: nil)
113
+ case .paymentMethod(let paymentMethod, let paymentOptionDisplayData):
114
+ payload = CustomerSheetUtils.buildPaymentOptionResult(label: paymentOptionDisplayData.label, imageData: paymentOptionDisplayData.image.pngData()?.base64EncodedString(), paymentMethod: paymentMethod)
115
+ case .none:
116
+ break
117
+ }
118
+ resolve(payload)
119
+ }
120
+ }
121
+
122
+ @objc(customerAdapterFetchPaymentMethodsCallback:resolver:rejecter:)
123
+ func customerAdapterFetchPaymentMethodsCallback(paymentMethods: [NSDictionary], resolver resolve: @escaping RCTPromiseResolveBlock,
124
+ rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
125
+ let decodedPaymentMethods = paymentMethods.compactMap { STPPaymentMethod.decodedObject(fromAPIResponse: $0 as? [AnyHashable : Any]) }
126
+ self.fetchPaymentMethodsCallback?(decodedPaymentMethods)
127
+ resolve([])
128
+ }
129
+
130
+ @objc(customerAdapterAttachPaymentMethodCallback:resolver:rejecter:)
131
+ func customerAdapterAttachPaymentMethodCallback(unusedPaymentMethod: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock,
132
+ rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
133
+ self.attachPaymentMethodCallback?()
134
+ resolve([])
135
+ }
136
+
137
+ @objc(customerAdapterDetachPaymentMethodCallback:resolver:rejecter:)
138
+ func customerAdapterDetachPaymentMethodCallback(unusedPaymentMethod: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock,
139
+ rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
140
+ self.detachPaymentMethodCallback?()
141
+ resolve([])
142
+ }
143
+
144
+ @objc(customerAdapterSetSelectedPaymentOptionCallback:rejecter:)
145
+ func customerAdapterSetSelectedPaymentOptionCallback(resolver resolve: @escaping RCTPromiseResolveBlock,
146
+ rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
147
+ self.setSelectedPaymentOptionCallback?()
148
+ resolve([])
149
+ }
150
+
151
+ @objc(customerAdapterFetchSelectedPaymentOptionCallback:resolver:rejecter:)
152
+ func customerAdapterFetchSelectedPaymentOptionCallback(paymentOption: String?, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
153
+ if let paymentOption = paymentOption {
154
+ self.fetchSelectedPaymentOptionCallback?(CustomerPaymentOption.init(value: paymentOption))
155
+ } else {
156
+ self.fetchSelectedPaymentOptionCallback?(nil)
157
+ }
158
+ resolve([])
159
+ }
160
+
161
+ @objc(customerAdapterSetupIntentClientSecretForCustomerAttachCallback:resolver:rejecter:)
162
+ func customerAdapterSetupIntentClientSecretForCustomerAttachCallback(clientSecret: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
163
+ self.setupIntentClientSecretForCustomerAttachCallback?(clientSecret)
164
+ resolve([])
165
+ }
166
+ }
@@ -262,7 +262,7 @@ extension StripeSdk {
262
262
  })
263
263
  }
264
264
 
265
- private static func mapToCollectionMode(str: String?) -> PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode {
265
+ internal static func mapToCollectionMode(str: String?) -> PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode {
266
266
  switch str {
267
267
  case "automatic":
268
268
  return .automatic
@@ -275,7 +275,7 @@ extension StripeSdk {
275
275
  }
276
276
  }
277
277
 
278
- private static func mapToAddressCollectionMode(str: String?) -> PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode {
278
+ internal static func mapToAddressCollectionMode(str: String?) -> PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode {
279
279
  switch str {
280
280
  case "automatic":
281
281
  return .automatic
package/ios/StripeSdk.m CHANGED
@@ -186,4 +186,57 @@ RCT_EXTERN_METHOD(
186
186
  resolver: (RCTPromiseResolveBlock)resolve
187
187
  rejecter: (RCTPromiseRejectBlock)reject
188
188
  )
189
+
190
+ RCT_EXTERN_METHOD(
191
+ initCustomerSheet:(NSDictionary *)params
192
+ customerAdapterOverrides: (NSDictionary *)customerAdapterOverrides
193
+ resolver: (RCTPromiseResolveBlock)resolve
194
+ rejecter: (RCTPromiseRejectBlock)reject
195
+ )
196
+
197
+ RCT_EXTERN_METHOD(
198
+ presentCustomerSheet:(NSDictionary *)params
199
+ resolver: (RCTPromiseResolveBlock)resolve
200
+ rejecter: (RCTPromiseRejectBlock)reject
201
+ )
202
+
203
+ RCT_EXTERN_METHOD(
204
+ retrieveCustomerSheetPaymentOptionSelection:(RCTPromiseResolveBlock)resolve
205
+ rejecter: (RCTPromiseRejectBlock)reject
206
+ )
207
+
208
+ RCT_EXTERN_METHOD(
209
+ customerAdapterFetchPaymentMethodsCallback:(NSArray *)paymentMethods
210
+ resolver: (RCTPromiseResolveBlock)resolve
211
+ rejecter: (RCTPromiseRejectBlock)reject
212
+ )
213
+
214
+ RCT_EXTERN_METHOD(
215
+ customerAdapterAttachPaymentMethodCallback:(NSDictionary *)unusedPaymentMethod
216
+ resolver: (RCTPromiseResolveBlock)resolve
217
+ rejecter: (RCTPromiseRejectBlock)reject
218
+ )
219
+
220
+ RCT_EXTERN_METHOD(
221
+ customerAdapterDetachPaymentMethodCallback:(NSDictionary *)unusedPaymentMethod
222
+ resolver: (RCTPromiseResolveBlock)resolve
223
+ rejecter: (RCTPromiseRejectBlock)reject
224
+ )
225
+
226
+ RCT_EXTERN_METHOD(
227
+ customerAdapterSetSelectedPaymentOptionCallback:(RCTPromiseResolveBlock)resolve
228
+ rejecter: (RCTPromiseRejectBlock)reject
229
+ )
230
+
231
+ RCT_EXTERN_METHOD(
232
+ customerAdapterFetchSelectedPaymentOptionCallback:(NSString *)paymentOption
233
+ resolver: (RCTPromiseResolveBlock)resolve
234
+ rejecter: (RCTPromiseRejectBlock)reject
235
+ )
236
+
237
+ RCT_EXTERN_METHOD(
238
+ customerAdapterSetupIntentClientSecretForCustomerAttachCallback:(NSString *)clientSecret
239
+ resolver: (RCTPromiseResolveBlock)resolve
240
+ rejecter: (RCTPromiseRejectBlock)reject
241
+ )
189
242
  @end
@@ -48,6 +48,17 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
48
48
  var applePayShippingAddressErrors: [Error]? = nil
49
49
  var applePayCouponCodeErrors: [Error]? = nil
50
50
 
51
+ var customerSheetConfiguration = CustomerSheet.Configuration()
52
+ var customerSheet: CustomerSheet? = nil
53
+ var customerAdapter: StripeCustomerAdapter? = nil
54
+ var customerSheetViewController: UIViewController?
55
+ var fetchPaymentMethodsCallback: (([STPPaymentMethod]) -> Void)? = nil
56
+ var attachPaymentMethodCallback: (() -> Void)? = nil
57
+ var detachPaymentMethodCallback: (() -> Void)? = nil
58
+ var setSelectedPaymentOptionCallback: (() -> Void)? = nil
59
+ var fetchSelectedPaymentOptionCallback: ((CustomerPaymentOption?) -> Void)? = nil
60
+ var setupIntentClientSecretForCustomerAttachCallback: ((String) -> Void)? = nil
61
+
51
62
  var hasEventListeners = false
52
63
  override func startObserving() {
53
64
  hasEventListeners = true
@@ -57,7 +68,9 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
57
68
  }
58
69
 
59
70
  override func supportedEvents() -> [String]! {
60
- return ["onOrderTrackingCallback", "onConfirmHandlerCallback"]
71
+ return ["onOrderTrackingCallback", "onConfirmHandlerCallback", "onCustomerAdapterFetchPaymentMethodsCallback", "onCustomerAdapterAttachPaymentMethodCallback",
72
+ "onCustomerAdapterDetachPaymentMethodCallback", "onCustomerAdapterSetSelectedPaymentOptionCallback", "onCustomerAdapterFetchSelectedPaymentOptionCallback",
73
+ "onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback"]
61
74
  }
62
75
 
63
76
  @objc override static func requiresMainQueueSetup() -> Bool {
package/jest/mock.js CHANGED
@@ -83,17 +83,6 @@ const mockFunctions = {
83
83
  error: null,
84
84
  })),
85
85
  resetPaymentSheetCustomer: jest.fn(async () => null),
86
- initGooglePay: jest.fn(async () => ({
87
- error: null,
88
- })),
89
- isGooglePaySupported: jest.fn(async () => true),
90
- presentGooglePay: jest.fn(async () => ({
91
- error: null,
92
- })),
93
- createGooglePayPaymentMethod: jest.fn(async () => ({
94
- paymentMethod: {},
95
- error: null,
96
- })),
97
86
  openApplePaySetup: jest.fn(async () => ({
98
87
  error: null,
99
88
  })),
@@ -137,32 +126,6 @@ const mockHooks = {
137
126
  ...mockFunctions.confirmSetupIntent(),
138
127
  })),
139
128
  })),
140
- useGooglePay: jest.fn(() => ({
141
- loading: false,
142
- initGooglePay: jest.fn(async () => ({
143
- ...mockFunctions.initGooglePay(),
144
- })),
145
- isGooglePaySupported: jest.fn(async () => true),
146
- presentGooglePay: jest.fn(async () => ({
147
- ...mockFunctions.presentGooglePay(),
148
- })),
149
- createGooglePayPaymentMethod: jest.fn(async () => ({
150
- ...mockFunctions.createGooglePayPayment(),
151
- })),
152
- })),
153
- useApplePay: jest.fn(() => ({
154
- loading: false,
155
- isApplePaySupported: true,
156
- presentApplePay: jest.fn(async () => ({
157
- ...mockFunctions.presentApplePay(),
158
- })),
159
- confirmApplePayPayment: jest.fn(async () => ({
160
- ...mockFunctions.confirmApplePayPayment(),
161
- })),
162
- openApplePaySetup: jest.fn(async () => ({
163
- ...mockFunctions.openApplePaySetup(),
164
- })),
165
- })),
166
129
  usePlatformPay: jest.fn(() => ({
167
130
  loading: false,
168
131
  isPlatformPaySupported: true,
@@ -1 +1 @@
1
- {"version":3,"names":["StripeSdk","NativeModules"],"sources":["NativeStripeSdk.tsx"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport type {\n PaymentMethod,\n PaymentIntent,\n PlatformPay,\n PaymentSheet,\n SetupIntent,\n InitialiseParams,\n CreatePaymentMethodResult,\n RetrievePaymentIntentResult,\n RetrieveSetupIntentResult,\n ConfirmPaymentResult,\n HandleNextActionResult,\n HandleNextActionForSetupResult,\n ConfirmSetupIntentResult,\n CreateTokenForCVCUpdateResult,\n InitPaymentSheetResult,\n PresentPaymentSheetResult,\n ConfirmPaymentSheetPaymentResult,\n CreateTokenResult,\n OpenApplePaySetupResult,\n Token,\n VerifyMicrodepositsParams,\n IsCardInWalletResult,\n CanAddCardToWalletParams,\n CanAddCardToWalletResult,\n FinancialConnections,\n} from './types';\n\ntype NativeStripeSdkType = {\n initialise(params: InitialiseParams): Promise<void>;\n createPaymentMethod(\n params: PaymentMethod.CreateParams,\n options: PaymentMethod.CreateOptions\n ): Promise<CreatePaymentMethodResult>;\n handleNextAction(\n paymentIntentClientSecret: string,\n returnURL?: string | null\n ): Promise<HandleNextActionResult>;\n handleNextActionForSetup(\n setupIntentClientSecret: string,\n returnURL?: string | null\n ): Promise<HandleNextActionForSetupResult>;\n confirmPayment(\n paymentIntentClientSecret: string,\n params?: PaymentIntent.ConfirmParams,\n options?: PaymentIntent.ConfirmOptions\n ): Promise<ConfirmPaymentResult>;\n confirmSetupIntent(\n paymentIntentClientSecret: string,\n params: SetupIntent.ConfirmParams,\n options: SetupIntent.ConfirmOptions\n ): Promise<ConfirmSetupIntentResult>;\n retrievePaymentIntent(\n clientSecret: string\n ): Promise<RetrievePaymentIntentResult>;\n retrieveSetupIntent(clientSecret: string): Promise<RetrieveSetupIntentResult>;\n initPaymentSheet(\n params: PaymentSheet.SetupParams\n ): Promise<InitPaymentSheetResult>;\n intentCreationCallback(\n result: PaymentSheet.IntentCreationCallbackParams\n ): void;\n presentPaymentSheet(\n options: PaymentSheet.PresentOptions\n ): Promise<PresentPaymentSheetResult>;\n confirmPaymentSheetPayment(): Promise<ConfirmPaymentSheetPaymentResult>;\n createTokenForCVCUpdate(cvc: string): Promise<CreateTokenForCVCUpdateResult>;\n handleURLCallback(url: string): Promise<boolean>;\n createToken(params: Token.CreateParams): Promise<CreateTokenResult>;\n openApplePaySetup(): Promise<OpenApplePaySetupResult>;\n verifyMicrodeposits(\n isPaymentIntent: boolean,\n clientSecret: string,\n params: VerifyMicrodepositsParams\n ): Promise<ConfirmSetupIntentResult | ConfirmPaymentResult>;\n collectBankAccount(\n isPaymentIntent: boolean,\n clientSecret: string,\n params: PaymentMethod.CollectBankAccountParams\n ): Promise<ConfirmSetupIntentResult | ConfirmPaymentResult>;\n getConstants(): { API_VERSIONS: { CORE: string; ISSUING: string } };\n canAddCardToWallet(\n params: CanAddCardToWalletParams\n ): Promise<CanAddCardToWalletResult>;\n isCardInWallet(params: {\n cardLastFour: string;\n }): Promise<IsCardInWalletResult>;\n collectBankAccountToken(\n clientSecret: string\n ): Promise<FinancialConnections.TokenResult>;\n collectFinancialConnectionsAccounts(\n clientSecret: string\n ): Promise<FinancialConnections.SessionResult>;\n resetPaymentSheetCustomer(): Promise<null>;\n isPlatformPaySupported(params: {\n googlePay?: PlatformPay.IsGooglePaySupportedParams;\n }): Promise<boolean>;\n createPlatformPayPaymentMethod(\n params: PlatformPay.PaymentMethodParams,\n usesDeprecatedTokenFlow: boolean\n ): Promise<PlatformPay.PaymentMethodResult | PlatformPay.TokenResult>;\n dismissPlatformPay(): Promise<boolean>;\n updatePlatformPaySheet(\n summaryItems: Array<PlatformPay.CartSummaryItem>,\n shippingMethods: Array<PlatformPay.ShippingMethod>,\n errors: Array<PlatformPay.ApplePaySheetError>\n ): Promise<void>;\n confirmPlatformPay(\n clientSecret: string,\n params: PlatformPay.ConfirmParams,\n isPaymentIntent: boolean\n ): Promise<\n PlatformPay.ConfirmPaymentResult | PlatformPay.ConfirmSetupIntentResult\n >;\n configureOrderTracking(\n orderTypeIdentifier: string,\n orderIdentifier: string,\n webServiceUrl: string,\n authenticationToken: string\n ): Promise<void>;\n};\n\nconst { StripeSdk } = NativeModules;\n\nexport default StripeSdk as NativeStripeSdkType;\n"],"mappings":"gFAAA,yCA2HA,GAAQA,UAAS,CAAKC,0BAAa,CAA3BD,SAAS,CAAmB,aAErBA,SAAS"}
1
+ {"version":3,"names":["StripeSdk","NativeModules"],"sources":["NativeStripeSdk.tsx"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport type {\n PaymentMethod,\n PaymentIntent,\n PlatformPay,\n PaymentSheet,\n SetupIntent,\n InitialiseParams,\n CreatePaymentMethodResult,\n RetrievePaymentIntentResult,\n RetrieveSetupIntentResult,\n ConfirmPaymentResult,\n HandleNextActionResult,\n HandleNextActionForSetupResult,\n ConfirmSetupIntentResult,\n CreateTokenForCVCUpdateResult,\n InitPaymentSheetResult,\n PresentPaymentSheetResult,\n ConfirmPaymentSheetPaymentResult,\n CreateTokenResult,\n OpenApplePaySetupResult,\n Token,\n VerifyMicrodepositsParams,\n IsCardInWalletResult,\n CanAddCardToWalletParams,\n CanAddCardToWalletResult,\n FinancialConnections,\n CustomerSheetInitParams,\n CustomerSheetPresentParams,\n CustomerSheetResult,\n CustomerSheetError,\n StripeError,\n CustomerPaymentOption,\n CustomerAdapter,\n} from './types';\n\ntype NativeStripeSdkType = {\n initialise(params: InitialiseParams): Promise<void>;\n createPaymentMethod(\n params: PaymentMethod.CreateParams,\n options: PaymentMethod.CreateOptions\n ): Promise<CreatePaymentMethodResult>;\n handleNextAction(\n paymentIntentClientSecret: string,\n returnURL?: string | null\n ): Promise<HandleNextActionResult>;\n handleNextActionForSetup(\n setupIntentClientSecret: string,\n returnURL?: string | null\n ): Promise<HandleNextActionForSetupResult>;\n confirmPayment(\n paymentIntentClientSecret: string,\n params?: PaymentIntent.ConfirmParams,\n options?: PaymentIntent.ConfirmOptions\n ): Promise<ConfirmPaymentResult>;\n confirmSetupIntent(\n paymentIntentClientSecret: string,\n params: SetupIntent.ConfirmParams,\n options: SetupIntent.ConfirmOptions\n ): Promise<ConfirmSetupIntentResult>;\n retrievePaymentIntent(\n clientSecret: string\n ): Promise<RetrievePaymentIntentResult>;\n retrieveSetupIntent(clientSecret: string): Promise<RetrieveSetupIntentResult>;\n initPaymentSheet(\n params: PaymentSheet.SetupParams\n ): Promise<InitPaymentSheetResult>;\n intentCreationCallback(\n result: PaymentSheet.IntentCreationCallbackParams\n ): void;\n presentPaymentSheet(\n options: PaymentSheet.PresentOptions\n ): Promise<PresentPaymentSheetResult>;\n confirmPaymentSheetPayment(): Promise<ConfirmPaymentSheetPaymentResult>;\n createTokenForCVCUpdate(cvc: string): Promise<CreateTokenForCVCUpdateResult>;\n handleURLCallback(url: string): Promise<boolean>;\n createToken(params: Token.CreateParams): Promise<CreateTokenResult>;\n openApplePaySetup(): Promise<OpenApplePaySetupResult>;\n verifyMicrodeposits(\n isPaymentIntent: boolean,\n clientSecret: string,\n params: VerifyMicrodepositsParams\n ): Promise<ConfirmSetupIntentResult | ConfirmPaymentResult>;\n collectBankAccount(\n isPaymentIntent: boolean,\n clientSecret: string,\n params: PaymentMethod.CollectBankAccountParams\n ): Promise<ConfirmSetupIntentResult | ConfirmPaymentResult>;\n getConstants(): { API_VERSIONS: { CORE: string; ISSUING: string } };\n canAddCardToWallet(\n params: CanAddCardToWalletParams\n ): Promise<CanAddCardToWalletResult>;\n isCardInWallet(params: {\n cardLastFour: string;\n }): Promise<IsCardInWalletResult>;\n collectBankAccountToken(\n clientSecret: string\n ): Promise<FinancialConnections.TokenResult>;\n collectFinancialConnectionsAccounts(\n clientSecret: string\n ): Promise<FinancialConnections.SessionResult>;\n resetPaymentSheetCustomer(): Promise<null>;\n isPlatformPaySupported(params: {\n googlePay?: PlatformPay.IsGooglePaySupportedParams;\n }): Promise<boolean>;\n createPlatformPayPaymentMethod(\n params: PlatformPay.PaymentMethodParams,\n usesDeprecatedTokenFlow: boolean\n ): Promise<PlatformPay.PaymentMethodResult | PlatformPay.TokenResult>;\n dismissPlatformPay(): Promise<boolean>;\n updatePlatformPaySheet(\n summaryItems: Array<PlatformPay.CartSummaryItem>,\n shippingMethods: Array<PlatformPay.ShippingMethod>,\n errors: Array<PlatformPay.ApplePaySheetError>\n ): Promise<void>;\n confirmPlatformPay(\n clientSecret: string,\n params: PlatformPay.ConfirmParams,\n isPaymentIntent: boolean\n ): Promise<\n PlatformPay.ConfirmPaymentResult | PlatformPay.ConfirmSetupIntentResult\n >;\n configureOrderTracking(\n orderTypeIdentifier: string,\n orderIdentifier: string,\n webServiceUrl: string,\n authenticationToken: string\n ): Promise<void>;\n initCustomerSheet(\n params: CustomerSheetInitParams,\n customerAdapterOverrides: { [Property in keyof CustomerAdapter]: boolean }\n ): Promise<{ error?: StripeError<CustomerSheetError> }>;\n presentCustomerSheet(\n params: CustomerSheetPresentParams\n ): Promise<CustomerSheetResult>;\n retrieveCustomerSheetPaymentOptionSelection(): Promise<CustomerSheetResult>;\n customerAdapterFetchPaymentMethodsCallback(\n paymentMethods: Array<object>\n ): Promise<void>;\n customerAdapterAttachPaymentMethodCallback(\n paymentMethod: object\n ): Promise<void>;\n customerAdapterDetachPaymentMethodCallback(\n paymentMethod: object\n ): Promise<void>;\n customerAdapterSetSelectedPaymentOptionCallback(): Promise<void>;\n customerAdapterFetchSelectedPaymentOptionCallback(\n paymentOption: CustomerPaymentOption | null\n ): Promise<void>;\n customerAdapterSetupIntentClientSecretForCustomerAttachCallback(\n clientSecret: String\n ): Promise<void>;\n};\n\nconst { StripeSdk } = NativeModules;\n\nexport default StripeSdk as NativeStripeSdkType;\n"],"mappings":"gFAAA,yCA0JA,GAAQA,UAAS,CAAKC,0BAAa,CAA3BD,SAAS,CAAmB,aAErBA,SAAS"}
@@ -0,0 +1,2 @@
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.CustomerSheetBeta=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _NativeStripeSdk=_interopRequireDefault(require("../NativeStripeSdk"));var eventEmitter=new _reactNative.NativeEventEmitter(_reactNative.NativeModules.StripeSdk);var fetchPaymentMethodsCallback=null;var attachPaymentMethodCallback=null;var detachPaymentMethodCallback=null;var setSelectedPaymentOptionCallback=null;var fetchSelectedPaymentOptionCallback=null;var setupIntentClientSecretForCustomerAttachCallback=null;var initialize=function(){var _ref=(0,_asyncToGenerator2.default)(function*(params){var customerAdapterOverrides={};if(params.customerAdapter){customerAdapterOverrides=configureCustomerAdapterEventListeners(params.customerAdapter);}try{var _yield$NativeStripeSd=yield _NativeStripeSdk.default.initCustomerSheet(params,customerAdapterOverrides),error=_yield$NativeStripeSd.error;if(error){return{error:error};}return{};}catch(error){return{error:error};}});return function initialize(_x){return _ref.apply(this,arguments);};}();var configureCustomerAdapterEventListeners=function configureCustomerAdapterEventListeners(customerAdapter){if(customerAdapter.fetchPaymentMethods){var _fetchPaymentMethodsC;(_fetchPaymentMethodsC=fetchPaymentMethodsCallback)==null?void 0:_fetchPaymentMethodsC.remove();fetchPaymentMethodsCallback=eventEmitter.addListener('onCustomerAdapterFetchPaymentMethodsCallback',(0,_asyncToGenerator2.default)(function*(){if(customerAdapter.fetchPaymentMethods){var paymentMethods=yield customerAdapter.fetchPaymentMethods();yield _NativeStripeSdk.default.customerAdapterFetchPaymentMethodsCallback(paymentMethods);}else{throw new Error('[@stripe/stripe-react-native] Tried to call `fetchPaymentMethods` on your CustomerAdapter, but no matching method was found.');}}));}if(customerAdapter.attachPaymentMethod){var _attachPaymentMethodC;(_attachPaymentMethodC=attachPaymentMethodCallback)==null?void 0:_attachPaymentMethodC.remove();attachPaymentMethodCallback=eventEmitter.addListener('onCustomerAdapterAttachPaymentMethodCallback',function(){var _ref4=(0,_asyncToGenerator2.default)(function*(_ref3){var paymentMethodId=_ref3.paymentMethodId;if(customerAdapter.attachPaymentMethod){var paymentMethod=yield customerAdapter.attachPaymentMethod(paymentMethodId);yield _NativeStripeSdk.default.customerAdapterAttachPaymentMethodCallback(paymentMethod);}else{throw new Error('[@stripe/stripe-react-native] Tried to call `attachPaymentMethod` on your CustomerAdapter, but no matching method was found.');}});return function(_x2){return _ref4.apply(this,arguments);};}());}if(customerAdapter.detachPaymentMethod){var _detachPaymentMethodC;(_detachPaymentMethodC=detachPaymentMethodCallback)==null?void 0:_detachPaymentMethodC.remove();detachPaymentMethodCallback=eventEmitter.addListener('onCustomerAdapterDetachPaymentMethodCallback',function(){var _ref6=(0,_asyncToGenerator2.default)(function*(_ref5){var paymentMethodId=_ref5.paymentMethodId;if(customerAdapter.detachPaymentMethod){var paymentMethod=yield customerAdapter.detachPaymentMethod(paymentMethodId);yield _NativeStripeSdk.default.customerAdapterDetachPaymentMethodCallback(paymentMethod);}else{throw new Error('[@stripe/stripe-react-native] Tried to call `detachPaymentMethod` on your CustomerAdapter, but no matching method was found.');}});return function(_x3){return _ref6.apply(this,arguments);};}());}if(customerAdapter.setSelectedPaymentOption){var _setSelectedPaymentOp;(_setSelectedPaymentOp=setSelectedPaymentOptionCallback)==null?void 0:_setSelectedPaymentOp.remove();setSelectedPaymentOptionCallback=eventEmitter.addListener('onCustomerAdapterSetSelectedPaymentOptionCallback',function(){var _ref8=(0,_asyncToGenerator2.default)(function*(_ref7){var paymentOption=_ref7.paymentOption;if(customerAdapter.setSelectedPaymentOption){yield customerAdapter.setSelectedPaymentOption(paymentOption);yield _NativeStripeSdk.default.customerAdapterSetSelectedPaymentOptionCallback();}else{throw new Error('[@stripe/stripe-react-native] Tried to call `setSelectedPaymentOption` on your CustomerAdapter, but no matching method was found.');}});return function(_x4){return _ref8.apply(this,arguments);};}());}if(customerAdapter.fetchSelectedPaymentOption){var _fetchSelectedPayment;(_fetchSelectedPayment=fetchSelectedPaymentOptionCallback)==null?void 0:_fetchSelectedPayment.remove();fetchSelectedPaymentOptionCallback=eventEmitter.addListener('onCustomerAdapterFetchSelectedPaymentOptionCallback',(0,_asyncToGenerator2.default)(function*(){if(customerAdapter.fetchSelectedPaymentOption){var paymentOption=yield customerAdapter.fetchSelectedPaymentOption();yield _NativeStripeSdk.default.customerAdapterFetchSelectedPaymentOptionCallback(paymentOption);}else{throw new Error('[@stripe/stripe-react-native] Tried to call `fetchSelectedPaymentOption` on your CustomerAdapter, but no matching method was found.');}}));}if(customerAdapter.setupIntentClientSecretForCustomerAttach){var _setupIntentClientSec;(_setupIntentClientSec=setupIntentClientSecretForCustomerAttachCallback)==null?void 0:_setupIntentClientSec.remove();setupIntentClientSecretForCustomerAttachCallback=eventEmitter.addListener('onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback',(0,_asyncToGenerator2.default)(function*(){if(customerAdapter.setupIntentClientSecretForCustomerAttach){var clientSecret=yield customerAdapter.setupIntentClientSecretForCustomerAttach();yield _NativeStripeSdk.default.customerAdapterSetupIntentClientSecretForCustomerAttachCallback(clientSecret);}else{throw new Error('[@stripe/stripe-react-native] Tried to call `setupIntentClientSecretForCustomerAttach` on your CustomerAdapter, but no matching method was found.');}}));}return{fetchPaymentMethods:!!customerAdapter.fetchPaymentMethods,attachPaymentMethod:!!customerAdapter.attachPaymentMethod,detachPaymentMethod:!!customerAdapter.detachPaymentMethod,setSelectedPaymentOption:!!customerAdapter.setSelectedPaymentOption,fetchSelectedPaymentOption:!!customerAdapter.fetchSelectedPaymentOption,setupIntentClientSecretForCustomerAttach:!!customerAdapter.setupIntentClientSecretForCustomerAttach};};var present=function(){var _ref11=(0,_asyncToGenerator2.default)(function*(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};try{return yield _NativeStripeSdk.default.presentCustomerSheet(params);}catch(error){return{error:error};}});return function present(){return _ref11.apply(this,arguments);};}();var retrievePaymentOptionSelection=function(){var _ref12=(0,_asyncToGenerator2.default)(function*(){try{return yield _NativeStripeSdk.default.retrieveCustomerSheetPaymentOptionSelection();}catch(error){return{error:error};}});return function retrievePaymentOptionSelection(){return _ref12.apply(this,arguments);};}();function CustomerSheet(_ref13){var visible=_ref13.visible,presentationStyle=_ref13.presentationStyle,animationStyle=_ref13.animationStyle,style=_ref13.style,appearance=_ref13.appearance,setupIntentClientSecret=_ref13.setupIntentClientSecret,customerId=_ref13.customerId,customerEphemeralKeySecret=_ref13.customerEphemeralKeySecret,merchantDisplayName=_ref13.merchantDisplayName,headerTextForSelectionScreen=_ref13.headerTextForSelectionScreen,defaultBillingDetails=_ref13.defaultBillingDetails,billingDetailsCollectionConfiguration=_ref13.billingDetailsCollectionConfiguration,returnURL=_ref13.returnURL,removeSavedPaymentMethodMessage=_ref13.removeSavedPaymentMethodMessage,applePayEnabled=_ref13.applePayEnabled,googlePayEnabled=_ref13.googlePayEnabled,timeout=_ref13.timeout,onResult=_ref13.onResult,customerAdapter=_ref13.customerAdapter;_react.default.useEffect(function(){if(visible){initialize({style:style,appearance:appearance,setupIntentClientSecret:setupIntentClientSecret,customerId:customerId,customerEphemeralKeySecret:customerEphemeralKeySecret,merchantDisplayName:merchantDisplayName,headerTextForSelectionScreen:headerTextForSelectionScreen,defaultBillingDetails:defaultBillingDetails,billingDetailsCollectionConfiguration:billingDetailsCollectionConfiguration,returnURL:returnURL,removeSavedPaymentMethodMessage:removeSavedPaymentMethodMessage,applePayEnabled:applePayEnabled,googlePayEnabled:googlePayEnabled,customerAdapter:customerAdapter}).then(function(initResult){if(initResult.error){onResult(initResult);}else{present({timeout:timeout,presentationStyle:presentationStyle,animationStyle:animationStyle}).then(function(presentResult){onResult(presentResult);});}});}},[visible]);return null;}var CustomerSheetBeta={CustomerSheet:CustomerSheet,initialize:initialize,present:present,retrievePaymentOptionSelection:retrievePaymentOptionSelection};exports.CustomerSheetBeta=CustomerSheetBeta;
2
+ //# sourceMappingURL=CustomerSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["eventEmitter","NativeEventEmitter","NativeModules","StripeSdk","fetchPaymentMethodsCallback","attachPaymentMethodCallback","detachPaymentMethodCallback","setSelectedPaymentOptionCallback","fetchSelectedPaymentOptionCallback","setupIntentClientSecretForCustomerAttachCallback","initialize","params","customerAdapterOverrides","customerAdapter","configureCustomerAdapterEventListeners","NativeStripeSdk","initCustomerSheet","error","fetchPaymentMethods","remove","addListener","paymentMethods","customerAdapterFetchPaymentMethodsCallback","Error","attachPaymentMethod","paymentMethodId","paymentMethod","customerAdapterAttachPaymentMethodCallback","detachPaymentMethod","customerAdapterDetachPaymentMethodCallback","setSelectedPaymentOption","paymentOption","customerAdapterSetSelectedPaymentOptionCallback","fetchSelectedPaymentOption","customerAdapterFetchSelectedPaymentOptionCallback","setupIntentClientSecretForCustomerAttach","clientSecret","customerAdapterSetupIntentClientSecretForCustomerAttachCallback","present","presentCustomerSheet","retrievePaymentOptionSelection","retrieveCustomerSheetPaymentOptionSelection","CustomerSheet","visible","presentationStyle","animationStyle","style","appearance","setupIntentClientSecret","customerId","customerEphemeralKeySecret","merchantDisplayName","headerTextForSelectionScreen","defaultBillingDetails","billingDetailsCollectionConfiguration","returnURL","removeSavedPaymentMethodMessage","applePayEnabled","googlePayEnabled","timeout","onResult","React","useEffect","then","initResult","presentResult","CustomerSheetBeta"],"sources":["CustomerSheet.tsx"],"sourcesContent":["import React from 'react';\nimport {\n NativeEventEmitter,\n NativeModules,\n EmitterSubscription,\n} from 'react-native';\nimport NativeStripeSdk from '../NativeStripeSdk';\nimport type {\n CustomerSheetInitParams,\n CustomerSheetPresentParams,\n CustomerSheetResult,\n CustomerSheetError,\n StripeError,\n CustomerAdapter,\n} from '../types';\n\nconst eventEmitter = new NativeEventEmitter(NativeModules.StripeSdk);\nlet fetchPaymentMethodsCallback: EmitterSubscription | null = null;\nlet attachPaymentMethodCallback: EmitterSubscription | null = null;\nlet detachPaymentMethodCallback: EmitterSubscription | null = null;\nlet setSelectedPaymentOptionCallback: EmitterSubscription | null = null;\nlet fetchSelectedPaymentOptionCallback: EmitterSubscription | null = null;\nlet setupIntentClientSecretForCustomerAttachCallback: EmitterSubscription | null =\n null;\n\n/** Initialize an instance of Customer Sheet with your desired configuration. */\nconst initialize = async (\n params: CustomerSheetInitParams\n): Promise<{ error?: StripeError<CustomerSheetError> }> => {\n let customerAdapterOverrides = {};\n if (params.customerAdapter) {\n customerAdapterOverrides = configureCustomerAdapterEventListeners(\n params.customerAdapter\n );\n }\n\n try {\n const { error } = await NativeStripeSdk.initCustomerSheet(\n params,\n customerAdapterOverrides\n );\n if (error) {\n return { error };\n }\n return {};\n } catch (error: any) {\n return {\n error,\n };\n }\n};\n\nconst configureCustomerAdapterEventListeners = (\n customerAdapter: CustomerAdapter\n): { [Property in keyof CustomerAdapter]: boolean } => {\n if (customerAdapter.fetchPaymentMethods) {\n fetchPaymentMethodsCallback?.remove();\n fetchPaymentMethodsCallback = eventEmitter.addListener(\n 'onCustomerAdapterFetchPaymentMethodsCallback',\n async () => {\n if (customerAdapter.fetchPaymentMethods) {\n const paymentMethods = await customerAdapter.fetchPaymentMethods();\n await NativeStripeSdk.customerAdapterFetchPaymentMethodsCallback(\n paymentMethods\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `fetchPaymentMethods` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.attachPaymentMethod) {\n attachPaymentMethodCallback?.remove();\n attachPaymentMethodCallback = eventEmitter.addListener(\n 'onCustomerAdapterAttachPaymentMethodCallback',\n async ({ paymentMethodId }: { paymentMethodId: string }) => {\n if (customerAdapter.attachPaymentMethod) {\n const paymentMethod = await customerAdapter.attachPaymentMethod(\n paymentMethodId\n );\n await NativeStripeSdk.customerAdapterAttachPaymentMethodCallback(\n paymentMethod\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `attachPaymentMethod` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.detachPaymentMethod) {\n detachPaymentMethodCallback?.remove();\n detachPaymentMethodCallback = eventEmitter.addListener(\n 'onCustomerAdapterDetachPaymentMethodCallback',\n async ({ paymentMethodId }: { paymentMethodId: string }) => {\n if (customerAdapter.detachPaymentMethod) {\n const paymentMethod = await customerAdapter.detachPaymentMethod(\n paymentMethodId\n );\n await NativeStripeSdk.customerAdapterDetachPaymentMethodCallback(\n paymentMethod\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `detachPaymentMethod` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.setSelectedPaymentOption) {\n setSelectedPaymentOptionCallback?.remove();\n setSelectedPaymentOptionCallback = eventEmitter.addListener(\n 'onCustomerAdapterSetSelectedPaymentOptionCallback',\n async ({ paymentOption }: { paymentOption: string }) => {\n if (customerAdapter.setSelectedPaymentOption) {\n await customerAdapter.setSelectedPaymentOption(paymentOption);\n await NativeStripeSdk.customerAdapterSetSelectedPaymentOptionCallback();\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `setSelectedPaymentOption` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.fetchSelectedPaymentOption) {\n fetchSelectedPaymentOptionCallback?.remove();\n fetchSelectedPaymentOptionCallback = eventEmitter.addListener(\n 'onCustomerAdapterFetchSelectedPaymentOptionCallback',\n async () => {\n if (customerAdapter.fetchSelectedPaymentOption) {\n const paymentOption =\n await customerAdapter.fetchSelectedPaymentOption();\n await NativeStripeSdk.customerAdapterFetchSelectedPaymentOptionCallback(\n paymentOption\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `fetchSelectedPaymentOption` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.setupIntentClientSecretForCustomerAttach) {\n setupIntentClientSecretForCustomerAttachCallback?.remove();\n setupIntentClientSecretForCustomerAttachCallback = eventEmitter.addListener(\n 'onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback',\n async () => {\n if (customerAdapter.setupIntentClientSecretForCustomerAttach) {\n const clientSecret =\n await customerAdapter.setupIntentClientSecretForCustomerAttach();\n await NativeStripeSdk.customerAdapterSetupIntentClientSecretForCustomerAttachCallback(\n clientSecret\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `setupIntentClientSecretForCustomerAttach` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n return {\n fetchPaymentMethods: !!customerAdapter.fetchPaymentMethods,\n attachPaymentMethod: !!customerAdapter.attachPaymentMethod,\n detachPaymentMethod: !!customerAdapter.detachPaymentMethod,\n setSelectedPaymentOption: !!customerAdapter.setSelectedPaymentOption,\n fetchSelectedPaymentOption: !!customerAdapter.fetchSelectedPaymentOption,\n setupIntentClientSecretForCustomerAttach:\n !!customerAdapter.setupIntentClientSecretForCustomerAttach,\n };\n};\n\n/** Launches the Customer Sheet UI. */\nconst present = async (\n params: CustomerSheetPresentParams = {}\n): Promise<CustomerSheetResult> => {\n try {\n return await NativeStripeSdk.presentCustomerSheet(params);\n } catch (error: any) {\n return {\n error,\n };\n }\n};\n\n/**\n * You can use this to obtain the selected payment method without presenting the CustomerSheet.\n * This will return an error if you have not called `.initialize`\n */\nconst retrievePaymentOptionSelection =\n async (): Promise<CustomerSheetResult> => {\n try {\n return await NativeStripeSdk.retrieveCustomerSheetPaymentOptionSelection();\n } catch (error: any) {\n return {\n error,\n };\n }\n };\n\n/**\n * Props\n */\nexport type Props = {\n /** Whether the sheet is visible. Defaults to false. */\n visible: boolean;\n /** Called when the user submits, dismisses, or cancels the sheet, or when an error occurs. */\n onResult: (result: CustomerSheetResult) => void;\n} & CustomerSheetInitParams &\n CustomerSheetPresentParams;\n\n/**\n * A component wrapper around the Customer Sheet functions. Upon passing `true` to the `visible` prop,\n * Customer Sheet will call `initialize` and `present`, and the result(s) will be passed through to the\n * onResult callback.\n *\n * @example\n * ```ts\n * const [selectedPaymentOption, setSelectedPaymentOption] = React.useState(null);\n * const [customerSheetVisible, setCustomerSheetVisible] = React.useState(false);\n *\n * return (\n * <CustomerSheet\n * visible={customerSheetVisible}\n * customerEphemeralKeySecret={ephemeralKeySecret}\n * customerId={customer}\n * returnURL={'stripe-example://stripe-redirect'}\n * onResult={({ error, paymentOption, paymentMethod }) => {\n * setCustomerSheetVisible(false);\n * if (error) {\n * Alert.alert(error.code, error.localizedMessage);\n * }\n * if (paymentOption) {\n * setSelectedPaymentOption(paymentOption);\n * console.log(JSON.stringify(paymentOption, null, 2));\n * }\n * if (paymentMethod) {\n * console.log(JSON.stringify(paymentMethod, null, 2));\n * }\n * }}\n * />\n * );\n * ```\n * @param __namedParameters Props\n * @returns JSX.Element\n * @category ReactComponents\n */\nfunction CustomerSheet({\n visible,\n presentationStyle,\n animationStyle,\n style,\n appearance,\n setupIntentClientSecret,\n customerId,\n customerEphemeralKeySecret,\n merchantDisplayName,\n headerTextForSelectionScreen,\n defaultBillingDetails,\n billingDetailsCollectionConfiguration,\n returnURL,\n removeSavedPaymentMethodMessage,\n applePayEnabled,\n googlePayEnabled,\n timeout,\n onResult,\n customerAdapter,\n}: Props) {\n React.useEffect(() => {\n if (visible) {\n initialize({\n style,\n appearance,\n setupIntentClientSecret,\n customerId,\n customerEphemeralKeySecret,\n merchantDisplayName,\n headerTextForSelectionScreen,\n defaultBillingDetails,\n billingDetailsCollectionConfiguration,\n returnURL,\n removeSavedPaymentMethodMessage,\n applePayEnabled,\n googlePayEnabled,\n customerAdapter,\n }).then((initResult) => {\n if (initResult.error) {\n onResult(initResult);\n } else {\n present({\n timeout,\n presentationStyle,\n animationStyle,\n }).then((presentResult) => {\n onResult(presentResult);\n });\n }\n });\n }\n // Only run this hook when visible prop changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [visible]);\n\n return null;\n}\n\n/**\n * The Customer Sheet is a prebuilt UI component that lets your customers manage their saved payment methods.\n */\nexport const CustomerSheetBeta = {\n CustomerSheet,\n initialize,\n present,\n retrievePaymentOptionSelection,\n};\n"],"mappings":"+QAAA,oDACA,yCAKA,2EAUA,GAAMA,aAAY,CAAG,GAAIC,gCAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC,CACpE,GAAIC,4BAAuD,CAAG,IAAI,CAClE,GAAIC,4BAAuD,CAAG,IAAI,CAClE,GAAIC,4BAAuD,CAAG,IAAI,CAClE,GAAIC,iCAA4D,CAAG,IAAI,CACvE,GAAIC,mCAA8D,CAAG,IAAI,CACzE,GAAIC,iDAA4E,CAC9E,IAAI,CAGN,GAAMC,WAAU,oDAAG,UACjBC,MAA+B,CAC0B,CACzD,GAAIC,yBAAwB,CAAG,CAAC,CAAC,CACjC,GAAID,MAAM,CAACE,eAAe,CAAE,CAC1BD,wBAAwB,CAAGE,sCAAsC,CAC/DH,MAAM,CAACE,eAAe,CACvB,CACH,CAEA,GAAI,CACF,+BAAwBE,yBAAe,CAACC,iBAAiB,CACvDL,MAAM,CACNC,wBAAwB,CACzB,CAHOK,KAAK,uBAALA,KAAK,CAIb,GAAIA,KAAK,CAAE,CACT,MAAO,CAAEA,KAAK,CAALA,KAAM,CAAC,CAClB,CACA,MAAO,CAAC,CAAC,CACX,CAAE,MAAOA,KAAU,CAAE,CACnB,MAAO,CACLA,KAAK,CAALA,KACF,CAAC,CACH,CACF,CAAC,iBAxBKP,WAAU,4CAwBf,CAED,GAAMI,uCAAsC,CAAG,QAAzCA,uCAAsC,CAC1CD,eAAgC,CACqB,CACrD,GAAIA,eAAe,CAACK,mBAAmB,CAAE,2BACvC,uBAAAd,2BAA2B,eAA3B,sBAA6Be,MAAM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