@stripe/stripe-react-native 0.28.0 → 0.29.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.
- package/CHANGELOG.md +14 -0
- package/README.md +2 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +0 -5
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +11 -27
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +131 -6
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +29 -6
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +14 -1
- package/ios/ApplePayButtonView.swift +4 -18
- package/ios/ApplePayViewController.swift +1 -28
- package/ios/StripeSdk+PaymentSheet.swift +100 -10
- package/ios/StripeSdk.m +15 -29
- package/ios/StripeSdk.swift +27 -85
- package/jest/mock.js +0 -6
- package/lib/commonjs/NativeStripeSdk.js.map +1 -1
- package/lib/commonjs/components/ApplePayButtonNative.js.map +1 -1
- package/lib/commonjs/components/GooglePayButtonNative.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/hooks/useStripe.js +1 -1
- package/lib/commonjs/hooks/useStripe.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/ApplePay.js.map +1 -1
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/commonjs/types/PaymentSheet.js +1 -1
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/PlatformPay.js.map +1 -1
- package/lib/commonjs/types/components/GooglePayButtonComponent.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/NativeStripeSdk.js.map +1 -1
- package/lib/module/components/ApplePayButtonNative.js.map +1 -1
- package/lib/module/components/GooglePayButtonNative.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/hooks/useStripe.js +1 -1
- package/lib/module/hooks/useStripe.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/ApplePay.js.map +1 -1
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/module/types/PaymentSheet.js +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/PlatformPay.js.map +1 -1
- package/lib/module/types/components/GooglePayButtonComponent.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/NativeStripeSdk.d.ts +4 -15
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts +1 -1
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts +1 -1
- package/lib/typescript/src/functions.d.ts +8 -27
- package/lib/typescript/src/hooks/usePlatformPay.d.ts +1 -1
- package/lib/typescript/src/hooks/useStripe.d.ts +2 -18
- package/lib/typescript/src/index.d.ts +0 -7
- package/lib/typescript/src/types/ApplePay.d.ts +0 -52
- package/lib/typescript/src/types/PaymentIntent.d.ts +3 -2
- package/lib/typescript/src/types/PaymentSheet.d.ts +48 -2
- package/lib/typescript/src/types/PlatformPay.d.ts +34 -4
- package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts +0 -1
- package/lib/typescript/src/types/index.d.ts +1 -4
- package/package.json +1 -1
- package/src/NativeStripeSdk.tsx +6 -31
- package/src/components/ApplePayButtonNative.tsx +1 -1
- package/src/components/GooglePayButtonNative.tsx +1 -1
- package/src/functions.ts +54 -200
- package/src/hooks/useStripe.tsx +2 -109
- package/src/index.tsx +0 -7
- package/src/types/ApplePay.ts +0 -71
- package/src/types/PaymentIntent.ts +4 -2
- package/src/types/PaymentSheet.ts +86 -2
- package/src/types/PlatformPay.ts +35 -4
- package/src/types/components/GooglePayButtonComponent.ts +0 -1
- package/src/types/index.ts +0 -6
- package/stripe-react-native.podspec +1 -1
- package/lib/commonjs/components/ApplePayButton.js +0 -2
- package/lib/commonjs/components/ApplePayButton.js.map +0 -1
- package/lib/commonjs/components/GooglePayButton.js +0 -2
- package/lib/commonjs/components/GooglePayButton.js.map +0 -1
- package/lib/commonjs/hooks/useApplePay.js +0 -2
- package/lib/commonjs/hooks/useApplePay.js.map +0 -1
- package/lib/commonjs/hooks/useGooglePay.js +0 -2
- package/lib/commonjs/hooks/useGooglePay.js.map +0 -1
- package/lib/commonjs/types/GooglePay.js +0 -2
- package/lib/commonjs/types/GooglePay.js.map +0 -1
- package/lib/module/components/ApplePayButton.js +0 -2
- package/lib/module/components/ApplePayButton.js.map +0 -1
- package/lib/module/components/GooglePayButton.js +0 -2
- package/lib/module/components/GooglePayButton.js.map +0 -1
- package/lib/module/hooks/useApplePay.js +0 -2
- package/lib/module/hooks/useApplePay.js.map +0 -1
- package/lib/module/hooks/useGooglePay.js +0 -2
- package/lib/module/hooks/useGooglePay.js.map +0 -1
- package/lib/module/types/GooglePay.js +0 -2
- package/lib/module/types/GooglePay.js.map +0 -1
- package/lib/typescript/src/components/ApplePayButton.d.ts +0 -31
- package/lib/typescript/src/components/GooglePayButton.d.ts +0 -26
- package/lib/typescript/src/hooks/useApplePay.d.ts +0 -54
- package/lib/typescript/src/hooks/useGooglePay.d.ts +0 -11
- package/lib/typescript/src/types/GooglePay.d.ts +0 -47
- package/src/components/ApplePayButton.tsx +0 -108
- package/src/components/GooglePayButton.tsx +0 -58
- package/src/hooks/useApplePay.tsx +0 -161
- package/src/hooks/useGooglePay.tsx +0 -72
- package/src/types/GooglePay.ts +0 -74
|
@@ -9,7 +9,9 @@ import Foundation
|
|
|
9
9
|
import StripePaymentSheet
|
|
10
10
|
|
|
11
11
|
extension StripeSdk {
|
|
12
|
-
internal func buildPaymentSheetConfiguration(
|
|
12
|
+
internal func buildPaymentSheetConfiguration(
|
|
13
|
+
params: NSDictionary
|
|
14
|
+
) -> (error: NSDictionary?, configuration: PaymentSheet.Configuration?) {
|
|
13
15
|
var configuration = PaymentSheet.Configuration()
|
|
14
16
|
|
|
15
17
|
configuration.primaryButtonLabel = params["primaryButtonLabel"] as? String
|
|
@@ -29,7 +31,7 @@ extension StripeSdk {
|
|
|
29
31
|
merchantCountryCode: applePayParams["merchantCountryCode"] as? String,
|
|
30
32
|
paymentSummaryItems: applePayParams["cartItems"] as? [[String : Any]],
|
|
31
33
|
buttonType: applePayParams["buttonType"] as? NSNumber,
|
|
32
|
-
customHandlers: buildCustomerHandlersForPaymentSheet(applePayParams: applePayParams
|
|
34
|
+
customHandlers: buildCustomerHandlersForPaymentSheet(applePayParams: applePayParams)
|
|
33
35
|
)
|
|
34
36
|
} catch {
|
|
35
37
|
return(error: Errors.createError(ErrorType.Failed, error.localizedDescription), configuration: nil)
|
|
@@ -96,8 +98,13 @@ extension StripeSdk {
|
|
|
96
98
|
return (nil, configuration)
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
internal func preparePaymentSheetInstance(
|
|
100
|
-
|
|
101
|
+
internal func preparePaymentSheetInstance(
|
|
102
|
+
params: NSDictionary,
|
|
103
|
+
configuration: PaymentSheet.Configuration,
|
|
104
|
+
resolve: @escaping RCTPromiseResolveBlock
|
|
105
|
+
) {
|
|
106
|
+
self.paymentSheetFlowController = nil
|
|
107
|
+
|
|
101
108
|
func handlePaymentSheetFlowControllerResult(result: Result<PaymentSheet.FlowController, Error>, stripeSdk: StripeSdk?) {
|
|
102
109
|
switch result {
|
|
103
110
|
case .failure(let error):
|
|
@@ -146,12 +153,91 @@ extension StripeSdk {
|
|
|
146
153
|
resolve([])
|
|
147
154
|
}
|
|
148
155
|
} else {
|
|
149
|
-
|
|
156
|
+
guard let intentConfiguration = params["intentConfiguration"] as? NSDictionary else {
|
|
157
|
+
resolve(Errors.createError(ErrorType.Failed, "One of `paymentIntentClientSecret`, `setupIntentClientSecret`, or `intentConfiguration` is required"))
|
|
158
|
+
return
|
|
159
|
+
}
|
|
160
|
+
guard let modeParams = intentConfiguration["mode"] as? NSDictionary else {
|
|
161
|
+
resolve(Errors.createError(ErrorType.Failed, "One of `paymentIntentClientSecret`, `setupIntentClientSecret`, or `intentConfiguration.mode` is required"))
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
if (intentConfiguration.object(forKey: "confirmHandler") == nil) {
|
|
165
|
+
resolve(Errors.createError(ErrorType.Failed, "You must provide `intentConfiguration.confirmHandler` if you are not passing an intent client secret"))
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
let captureMethodString = intentConfiguration["captureMethod"] as? String
|
|
169
|
+
let intentConfig = buildIntentConfiguration(
|
|
170
|
+
modeParams: modeParams,
|
|
171
|
+
paymentMethodTypes: intentConfiguration["paymentMethodTypes"] as? [String],
|
|
172
|
+
captureMethod: mapCaptureMethod(captureMethodString)
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
if params["customFlow"] as? Bool == true {
|
|
176
|
+
PaymentSheet.FlowController.create(intentConfiguration: intentConfig, configuration: configuration) { [weak self] result in
|
|
177
|
+
handlePaymentSheetFlowControllerResult(result: result, stripeSdk: self)
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
self.paymentSheet = PaymentSheet(
|
|
181
|
+
intentConfiguration: intentConfig,
|
|
182
|
+
configuration: configuration
|
|
183
|
+
)
|
|
184
|
+
resolve([])
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
private func mapCaptureMethod(_ captureMethod: String?) -> PaymentSheet.IntentConfiguration.CaptureMethod {
|
|
190
|
+
if let captureMethod = captureMethod {
|
|
191
|
+
switch captureMethod {
|
|
192
|
+
case "Automatic": return PaymentSheet.IntentConfiguration.CaptureMethod.automatic
|
|
193
|
+
case "Manual": return PaymentSheet.IntentConfiguration.CaptureMethod.manual
|
|
194
|
+
case "AutomaticAsync": return PaymentSheet.IntentConfiguration.CaptureMethod.automaticAsync
|
|
195
|
+
default: return PaymentSheet.IntentConfiguration.CaptureMethod.automatic
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return PaymentSheet.IntentConfiguration.CaptureMethod.automatic
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private func buildIntentConfiguration(
|
|
202
|
+
modeParams: NSDictionary,
|
|
203
|
+
paymentMethodTypes: [String]?,
|
|
204
|
+
captureMethod: PaymentSheet.IntentConfiguration.CaptureMethod
|
|
205
|
+
) -> PaymentSheet.IntentConfiguration {
|
|
206
|
+
var mode: PaymentSheet.IntentConfiguration.Mode
|
|
207
|
+
if let amount = modeParams["amount"] as? Int {
|
|
208
|
+
mode = PaymentSheet.IntentConfiguration.Mode.payment(
|
|
209
|
+
amount: amount,
|
|
210
|
+
currency: modeParams["currencyCode"] as? String ?? "",
|
|
211
|
+
setupFutureUsage: modeParams["setupFutureUsage"] != nil
|
|
212
|
+
? (modeParams["setupFutureUsage"] as? String == "OffSession" ? .offSession : .onSession)
|
|
213
|
+
: nil,
|
|
214
|
+
captureMethod: captureMethod
|
|
215
|
+
)
|
|
216
|
+
} else {
|
|
217
|
+
mode = PaymentSheet.IntentConfiguration.Mode.setup(
|
|
218
|
+
currency: modeParams["currencyCode"] as? String,
|
|
219
|
+
setupFutureUsage: modeParams["setupFutureUsage"] as? String == "OffSession" ? .offSession : .onSession
|
|
220
|
+
)
|
|
150
221
|
}
|
|
222
|
+
|
|
223
|
+
return PaymentSheet.IntentConfiguration.init(
|
|
224
|
+
mode: mode,
|
|
225
|
+
paymentMethodTypes: paymentMethodTypes,
|
|
226
|
+
confirmHandler: { paymentMethod, shouldSavePaymentMethod, intentCreationCallback in
|
|
227
|
+
if (self.hasEventListeners) {
|
|
228
|
+
self.paymentSheetIntentCreationCallback = intentCreationCallback
|
|
229
|
+
self.sendEvent(withName: "onConfirmHandlerCallback", body: [
|
|
230
|
+
"paymentMethod": Mappers.mapFromPaymentMethod(paymentMethod) ?? NSNull(),
|
|
231
|
+
"shouldSavePaymentMethod": shouldSavePaymentMethod
|
|
232
|
+
])
|
|
233
|
+
} else {
|
|
234
|
+
RCTMakeAndLogError("Tried to call confirmHandler, but no callback was found. Please file an issue: https://github.com/stripe/stripe-react-native/issues", nil, nil)
|
|
235
|
+
}
|
|
236
|
+
})
|
|
151
237
|
}
|
|
152
238
|
|
|
153
|
-
private func buildCustomerHandlersForPaymentSheet(applePayParams: NSDictionary
|
|
154
|
-
if (applePayParams["request"] == nil
|
|
239
|
+
private func buildCustomerHandlersForPaymentSheet(applePayParams: NSDictionary) -> PaymentSheet.ApplePayConfiguration.Handlers? {
|
|
240
|
+
if (applePayParams["request"] == nil) {
|
|
155
241
|
return nil
|
|
156
242
|
}
|
|
157
243
|
return PaymentSheet.ApplePayConfiguration.Handlers(paymentRequestHandler: { request in
|
|
@@ -163,9 +249,13 @@ extension StripeSdk {
|
|
|
163
249
|
}
|
|
164
250
|
return request
|
|
165
251
|
}, authorizationResultHandler: { result, completion in
|
|
166
|
-
if
|
|
167
|
-
self.
|
|
168
|
-
|
|
252
|
+
if applePayParams.object(forKey: "setOrderTracking") != nil {
|
|
253
|
+
if (self.hasEventListeners) {
|
|
254
|
+
self.orderTrackingHandler = (result, completion)
|
|
255
|
+
self.sendEvent(withName: "onOrderTrackingCallback", body: [:])
|
|
256
|
+
} else {
|
|
257
|
+
RCTMakeAndLogError("Order tracking is enabled, but no callback was found. Please file an issue: https://github.com/stripe/stripe-react-native/issues", nil, nil)
|
|
258
|
+
}
|
|
169
259
|
} else {
|
|
170
260
|
completion(result)
|
|
171
261
|
}
|
package/ios/StripeSdk.m
CHANGED
|
@@ -10,25 +10,24 @@ RCT_EXTERN_METHOD(
|
|
|
10
10
|
rejecter: (RCTPromiseRejectBlock)reject
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
-
RCT_EXTERN_METHOD(
|
|
14
|
-
isApplePaySupported: (RCTPromiseResolveBlock)resolve
|
|
15
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
16
|
-
|
|
17
13
|
RCT_EXTERN_METHOD(
|
|
18
14
|
createToken: (NSDictionary *)params
|
|
19
15
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
20
|
-
rejecter: (RCTPromiseRejectBlock)reject
|
|
16
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
17
|
+
)
|
|
21
18
|
|
|
22
19
|
RCT_EXTERN_METHOD(
|
|
23
20
|
isPlatformPaySupported:(NSDictionary *)params
|
|
24
21
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
25
|
-
rejecter: (RCTPromiseRejectBlock)reject
|
|
22
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
23
|
+
)
|
|
26
24
|
|
|
27
25
|
RCT_EXTERN_METHOD(
|
|
28
26
|
createPlatformPayPaymentMethod:(NSDictionary *)params
|
|
29
27
|
usesDeprecatedTokenFlow:(BOOL)usesDeprecatedTokenFlow
|
|
30
28
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
31
|
-
rejecter: (RCTPromiseRejectBlock)reject
|
|
29
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
30
|
+
)
|
|
32
31
|
|
|
33
32
|
RCT_EXTERN_METHOD(
|
|
34
33
|
confirmPlatformPay:(NSString *)clientSecret
|
|
@@ -40,43 +39,31 @@ RCT_EXTERN_METHOD(
|
|
|
40
39
|
|
|
41
40
|
RCT_EXTERN_METHOD(
|
|
42
41
|
dismissPlatformPay: (RCTPromiseResolveBlock)resolve
|
|
43
|
-
rejecter: (RCTPromiseRejectBlock)reject
|
|
42
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
43
|
+
)
|
|
44
44
|
|
|
45
45
|
RCT_EXTERN_METHOD(
|
|
46
46
|
updatePlatformPaySheet:(NSArray *)summaryItems
|
|
47
47
|
shippingMethods:(NSArray *)summaryItems
|
|
48
48
|
errors: (NSArray *)errors
|
|
49
49
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
50
|
-
rejecter: (RCTPromiseRejectBlock)reject
|
|
51
|
-
|
|
52
|
-
RCT_EXTERN_METHOD(
|
|
53
|
-
presentApplePay:(NSDictionary *)params
|
|
54
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
55
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
50
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
51
|
+
)
|
|
56
52
|
|
|
57
53
|
RCT_EXTERN_METHOD(
|
|
58
54
|
openApplePaySetup: (RCTPromiseResolveBlock)resolve
|
|
59
|
-
rejecter: (RCTPromiseRejectBlock)reject
|
|
60
|
-
|
|
61
|
-
RCT_EXTERN_METHOD(
|
|
62
|
-
updateApplePaySummaryItems:(NSArray *)summaryItems
|
|
63
|
-
errorAddressFields: (NSArray *)errorAddressFields
|
|
64
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
65
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
55
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
56
|
+
)
|
|
66
57
|
|
|
67
58
|
RCT_EXTERN_METHOD(
|
|
68
59
|
createTokenForCVCUpdate:(NSString *)cvc
|
|
69
60
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
70
|
-
rejecter: (RCTPromiseRejectBlock)reject
|
|
61
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
62
|
+
)
|
|
71
63
|
|
|
72
64
|
RCT_EXTERN_METHOD(
|
|
73
65
|
handleURLCallback:(NSString *)url
|
|
74
66
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
75
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
76
|
-
|
|
77
|
-
RCT_EXTERN_METHOD(
|
|
78
|
-
confirmApplePayPayment:(NSString *)clientSecret
|
|
79
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
80
67
|
rejecter: (RCTPromiseRejectBlock)reject
|
|
81
68
|
)
|
|
82
69
|
|
|
@@ -113,8 +100,7 @@ RCT_EXTERN_METHOD(
|
|
|
113
100
|
)
|
|
114
101
|
|
|
115
102
|
RCT_EXTERN_METHOD(
|
|
116
|
-
|
|
117
|
-
callback:(RCTResponseSenderBlock)orderTrackingCallback
|
|
103
|
+
intentCreationCallback:(NSDictionary *)result
|
|
118
104
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
119
105
|
rejecter: (RCTPromiseRejectBlock)reject
|
|
120
106
|
)
|
package/ios/StripeSdk.swift
CHANGED
|
@@ -2,6 +2,7 @@ import PassKit
|
|
|
2
2
|
import Stripe
|
|
3
3
|
import StripePaymentSheet
|
|
4
4
|
import StripeFinancialConnections
|
|
5
|
+
import Foundation
|
|
5
6
|
|
|
6
7
|
@objc(StripeSdk)
|
|
7
8
|
class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdaptivePresentationControllerDelegate {
|
|
@@ -12,16 +13,11 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
12
13
|
|
|
13
14
|
internal var paymentSheet: PaymentSheet?
|
|
14
15
|
internal var paymentSheetFlowController: PaymentSheet.FlowController?
|
|
15
|
-
|
|
16
|
+
var paymentSheetIntentCreationCallback: ((Result<String, Error>) -> Void)?
|
|
17
|
+
|
|
16
18
|
var urlScheme: String? = nil
|
|
17
19
|
|
|
18
20
|
var confirmPaymentResolver: RCTPromiseResolveBlock? = nil
|
|
19
|
-
|
|
20
|
-
var applePayCompletionCallback: STPIntentClientSecretCompletionBlock? = nil
|
|
21
|
-
var deprecatedApplePayRequestResolver: RCTPromiseResolveBlock? = nil
|
|
22
|
-
var deprecatedApplePayRequestRejecter: RCTPromiseRejectBlock? = nil
|
|
23
|
-
var deprecatedApplePayCompletionRejecter: RCTPromiseRejectBlock? = nil
|
|
24
|
-
var deprecatedConfirmApplePayPaymentResolver: RCTPromiseResolveBlock? = nil
|
|
25
21
|
|
|
26
22
|
var confirmApplePayResolver: RCTPromiseResolveBlock? = nil
|
|
27
23
|
var confirmApplePayPaymentClientSecret: String? = nil
|
|
@@ -52,16 +48,16 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
52
48
|
var applePayShippingAddressErrors: [Error]? = nil
|
|
53
49
|
var applePayCouponCodeErrors: [Error]? = nil
|
|
54
50
|
|
|
55
|
-
var
|
|
51
|
+
var hasEventListeners = false
|
|
56
52
|
override func startObserving() {
|
|
57
|
-
|
|
53
|
+
hasEventListeners = true
|
|
58
54
|
}
|
|
59
55
|
override func stopObserving() {
|
|
60
|
-
|
|
56
|
+
hasEventListeners = false
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
override func supportedEvents() -> [String]! {
|
|
64
|
-
return ["
|
|
60
|
+
return ["onOrderTrackingCallback", "onConfirmHandlerCallback"]
|
|
65
61
|
}
|
|
66
62
|
|
|
67
63
|
@objc override static func requiresMainQueueSetup() -> Bool {
|
|
@@ -109,8 +105,6 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
109
105
|
@objc(initPaymentSheet:resolver:rejecter:)
|
|
110
106
|
func initPaymentSheet(params: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
111
107
|
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
112
|
-
self.paymentSheetFlowController = nil
|
|
113
|
-
|
|
114
108
|
let (error, configuration) = buildPaymentSheetConfiguration(params: params)
|
|
115
109
|
guard let configuration = configuration else {
|
|
116
110
|
resolve(error)
|
|
@@ -120,16 +114,29 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
120
114
|
preparePaymentSheetInstance(params: params, configuration: configuration, resolve: resolve)
|
|
121
115
|
}
|
|
122
116
|
|
|
123
|
-
@objc(
|
|
124
|
-
func
|
|
117
|
+
@objc(intentCreationCallback:resolver:rejecter:)
|
|
118
|
+
func intentCreationCallback(result: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
125
119
|
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
126
|
-
let
|
|
127
|
-
|
|
128
|
-
resolve(error)
|
|
120
|
+
guard let paymentSheetIntentCreationCallback = self.paymentSheetIntentCreationCallback else {
|
|
121
|
+
resolve(Errors.createError(ErrorType.Failed, "No intent creation callback was set"))
|
|
129
122
|
return
|
|
130
123
|
}
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
if let clientSecret = result["clientSecret"] as? String {
|
|
125
|
+
paymentSheetIntentCreationCallback(.success(clientSecret))
|
|
126
|
+
} else {
|
|
127
|
+
class ConfirmationError: Error, LocalizedError {
|
|
128
|
+
private var errorMessage: String
|
|
129
|
+
init(errorMessage: String) {
|
|
130
|
+
self.errorMessage = errorMessage
|
|
131
|
+
}
|
|
132
|
+
public var errorDescription: String? {
|
|
133
|
+
return errorMessage
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
let errorParams = result["error"] as? NSDictionary
|
|
137
|
+
let error = ConfirmationError.init(errorMessage: errorParams?["localizedMessage"] as? String ?? "An unknown error occurred.")
|
|
138
|
+
paymentSheetIntentCreationCallback(.failure(error))
|
|
139
|
+
}
|
|
133
140
|
}
|
|
134
141
|
|
|
135
142
|
@objc(confirmPaymentSheetPayment:rejecter:)
|
|
@@ -342,35 +349,6 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
342
349
|
self.shippingContactUpdateCompletion = nil
|
|
343
350
|
resolve([])
|
|
344
351
|
}
|
|
345
|
-
|
|
346
|
-
@objc(updateApplePaySummaryItems:errorAddressFields:resolver:rejecter:)
|
|
347
|
-
func updateApplePaySummaryItems(summaryItems: NSArray, errorAddressFields: [NSDictionary], resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
348
|
-
if (shippingMethodUpdateCompletion == nil && shippingContactUpdateCompletion == nil) {
|
|
349
|
-
resolve(Errors.createError(ErrorType.Failed, "You can use this method only after either onDidSetShippingMethod or onDidSetShippingContact events emitted"))
|
|
350
|
-
return
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
var paymentSummaryItems : [PKPaymentSummaryItem] = []
|
|
354
|
-
do {
|
|
355
|
-
paymentSummaryItems = try ApplePayUtils.buildPaymentSummaryItems(items: summaryItems as? [[String : Any]])
|
|
356
|
-
} catch {
|
|
357
|
-
resolve(Errors.createError(ErrorType.Failed, error.localizedDescription))
|
|
358
|
-
return
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
var shippingAddressErrors: [Error] = []
|
|
362
|
-
for item in errorAddressFields {
|
|
363
|
-
let field = item["field"] as! String
|
|
364
|
-
let message = item["message"] as? String ?? field + " error"
|
|
365
|
-
shippingAddressErrors.append(PKPaymentRequest.paymentShippingAddressInvalidError(withKey: field, localizedDescription: message))
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
shippingMethodUpdateCompletion?(PKPaymentRequestShippingMethodUpdate.init(paymentSummaryItems: paymentSummaryItems))
|
|
369
|
-
shippingContactUpdateCompletion?(PKPaymentRequestShippingContactUpdate.init(errors: shippingAddressErrors, paymentSummaryItems: paymentSummaryItems, shippingMethods: []))
|
|
370
|
-
self.shippingMethodUpdateCompletion = nil
|
|
371
|
-
self.shippingContactUpdateCompletion = nil
|
|
372
|
-
resolve([])
|
|
373
|
-
}
|
|
374
352
|
|
|
375
353
|
@objc(openApplePaySetup:rejecter:)
|
|
376
354
|
func openApplePaySetup(resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
@@ -378,20 +356,6 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
378
356
|
resolve([])
|
|
379
357
|
}
|
|
380
358
|
|
|
381
|
-
@objc(confirmApplePayPayment:resolver:rejecter:)
|
|
382
|
-
func confirmApplePayPayment(clientSecret: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
383
|
-
self.deprecatedApplePayCompletionRejecter = reject
|
|
384
|
-
self.deprecatedConfirmApplePayPaymentResolver = resolve
|
|
385
|
-
self.applePayCompletionCallback?(clientSecret, nil)
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
@objc(isApplePaySupported:rejecter:)
|
|
389
|
-
func isApplePaySupported(resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
390
|
-
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
391
|
-
let isSupported = StripeAPI.deviceSupportsApplePay()
|
|
392
|
-
resolve(isSupported)
|
|
393
|
-
}
|
|
394
|
-
|
|
395
359
|
@objc(handleURLCallback:resolver:rejecter:)
|
|
396
360
|
func handleURLCallback(url: String?, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
397
361
|
guard let url = url else {
|
|
@@ -408,28 +372,6 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
408
372
|
}
|
|
409
373
|
}
|
|
410
374
|
}
|
|
411
|
-
|
|
412
|
-
@objc(presentApplePay:resolver:rejecter:)
|
|
413
|
-
func presentApplePay(params: NSDictionary,
|
|
414
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
415
|
-
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
416
|
-
self.deprecatedApplePayRequestResolver = resolve
|
|
417
|
-
self.deprecatedApplePayRequestRejecter = reject
|
|
418
|
-
|
|
419
|
-
let (error, paymentRequest) = ApplePayUtils.createPaymentRequest(merchantIdentifier: merchantIdentifier, params: params)
|
|
420
|
-
guard let paymentRequest = paymentRequest else {
|
|
421
|
-
resolve(error)
|
|
422
|
-
return
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
if let applePayContext = STPApplePayContext(paymentRequest: paymentRequest, delegate: self) {
|
|
426
|
-
DispatchQueue.main.async {
|
|
427
|
-
applePayContext.presentApplePay(completion: nil)
|
|
428
|
-
}
|
|
429
|
-
} else {
|
|
430
|
-
resolve(Errors.createError(ErrorType.Failed, "Payment not completed"))
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
375
|
|
|
434
376
|
@objc(isPlatformPaySupported:resolver:rejecter:)
|
|
435
377
|
func isPlatformPaySupported(params: NSDictionary,
|
package/jest/mock.js
CHANGED
|
@@ -46,12 +46,6 @@ const mockFunctions = {
|
|
|
46
46
|
openPlatformPaySetup: jest.fn(async () => {
|
|
47
47
|
return;
|
|
48
48
|
}),
|
|
49
|
-
isApplePaySupported: jest.fn(async () => true),
|
|
50
|
-
presentApplePay: jest.fn(async () => ({
|
|
51
|
-
error: null,
|
|
52
|
-
})),
|
|
53
|
-
updateApplePaySummaryItems: jest.fn(async () => ({})),
|
|
54
|
-
confirmApplePayPayment: jest.fn(async () => ({})),
|
|
55
49
|
handleNextAction: jest.fn(async () => ({
|
|
56
50
|
paymentIntent: {},
|
|
57
51
|
error: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StripeSdk","NativeModules"],"sources":["NativeStripeSdk.tsx"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport type {\n PaymentMethod,\n PaymentIntent,\n
|
|
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 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 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,yCAsHA,GAAQA,UAAS,CAAKC,0BAAa,CAA3BD,SAAS,CAAmB,aAErBA,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ApplePayButtonNative","requireNativeComponent"],"sources":["ApplePayButtonNative.tsx"],"sourcesContent":["import { requireNativeComponent } from 'react-native';\nimport type
|
|
1
|
+
{"version":3,"names":["ApplePayButtonNative","requireNativeComponent"],"sources":["ApplePayButtonNative.tsx"],"sourcesContent":["import { requireNativeComponent } from 'react-native';\nimport type * as ApplePayButtonComponent from '../types/components/ApplePayButtonComponent';\nconst ApplePayButtonNative =\n requireNativeComponent<ApplePayButtonComponent.NativeProps>('ApplePayButton');\nexport default ApplePayButtonNative;\n"],"mappings":"gFAAA,yCAEA,GAAMA,qBAAoB,CACxB,GAAAC,mCAAsB,EAAsC,gBAAgB,CAAC,CAAC,aACjED,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GooglePayButtonNative","requireNativeComponent"],"sources":["GooglePayButtonNative.tsx"],"sourcesContent":["import { requireNativeComponent } from 'react-native';\nimport type
|
|
1
|
+
{"version":3,"names":["GooglePayButtonNative","requireNativeComponent"],"sources":["GooglePayButtonNative.tsx"],"sourcesContent":["import { requireNativeComponent } from 'react-native';\nimport type * as GooglePayButtonComponent from '../types/components/GooglePayButtonComponent';\nconst GooglePayButtonNative =\n requireNativeComponent<GooglePayButtonComponent.NativeProps>(\n 'GooglePayButton'\n );\nexport default GooglePayButtonNative;\n"],"mappings":"gFAAA,yCAEA,GAAMA,sBAAqB,CACzB,GAAAC,mCAAsB,EACpB,iBAAiB,CAClB,CAAC,aACWD,qBAAqB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.verifyMicrodepositsForSetup=exports.verifyMicrodepositsForPayment=exports.updatePlatformPaySheet=exports.updateApplePaySummaryItems=exports.retrieveSetupIntent=exports.retrievePaymentIntent=exports.resetPaymentSheetCustomer=exports.presentPaymentSheet=exports.presentGooglePay=exports.presentApplePay=exports.openPlatformPaySetup=exports.openApplePaySetup=exports.isPlatformPaySupported=exports.isGooglePaySupported=exports.isCardInWallet=exports.isApplePaySupported=exports.initPaymentSheet=exports.initGooglePay=exports.handleURLCallback=exports.handleNextAction=exports.dismissPlatformPay=exports.createTokenForCVCUpdate=exports.createToken=exports.createPlatformPayToken=exports.createPlatformPayPaymentMethod=exports.createPaymentMethod=exports.createGooglePayPaymentMethod=exports.confirmSetupIntent=exports.confirmPlatformPaySetupIntent=exports.confirmPlatformPayPayment=exports.confirmPaymentSheetPayment=exports.confirmPayment=exports.confirmApplePayPayment=exports.collectFinancialConnectionsAccounts=exports.collectBankAccountToken=exports.collectBankAccountForSetup=exports.collectBankAccountForPayment=exports.canAddCardToWallet=exports.Constants=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _helpers=require("./helpers");var _Errors=require("./types/Errors");var _NativeStripeSdk=_interopRequireDefault(require("./NativeStripeSdk"));var _types=require("./types");var _reactNative=require("react-native");var APPLE_PAY_NOT_SUPPORTED_MESSAGE='Apple pay is not supported on this device';var createPaymentMethod=function(){var _ref=(0,_asyncToGenerator2.default)(function*(params){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};try{var _yield$NativeStripeSd=yield _NativeStripeSdk.default.createPaymentMethod(params,options),paymentMethod=_yield$NativeStripeSd.paymentMethod,error=_yield$NativeStripeSd.error;if(error){return{error:error};}return{paymentMethod:paymentMethod};}catch(error){return{error:error};}});return function createPaymentMethod(_x){return _ref.apply(this,arguments);};}();exports.createPaymentMethod=createPaymentMethod;var createToken=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(params){var _params$country;if(params.type==='BankAccount'&&((_params$country=params.country)==null?void 0:_params$country.toLowerCase())==='us'&&!params.routingNumber){return{error:_Errors.MissingRoutingNumber};}try{var _yield$NativeStripeSd2=yield _NativeStripeSdk.default.createToken(params),token=_yield$NativeStripeSd2.token,error=_yield$NativeStripeSd2.error;if(error){return{error:error};}return{token:token};}catch(error){return{error:error};}});return function createToken(_x2){return _ref2.apply(this,arguments);};}();exports.createToken=createToken;var retrievePaymentIntent=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd3=yield _NativeStripeSdk.default.retrievePaymentIntent(clientSecret),paymentIntent=_yield$NativeStripeSd3.paymentIntent,error=_yield$NativeStripeSd3.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function retrievePaymentIntent(_x3){return _ref3.apply(this,arguments);};}();exports.retrievePaymentIntent=retrievePaymentIntent;var retrieveSetupIntent=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd4=yield _NativeStripeSdk.default.retrieveSetupIntent(clientSecret),setupIntent=_yield$NativeStripeSd4.setupIntent,error=_yield$NativeStripeSd4.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function retrieveSetupIntent(_x4){return _ref4.apply(this,arguments);};}();exports.retrieveSetupIntent=retrieveSetupIntent;var confirmPayment=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,params){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{var _yield$NativeStripeSd5=yield _NativeStripeSdk.default.confirmPayment(paymentIntentClientSecret,params,options),paymentIntent=_yield$NativeStripeSd5.paymentIntent,error=_yield$NativeStripeSd5.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function confirmPayment(_x5,_x6){return _ref5.apply(this,arguments);};}();exports.confirmPayment=confirmPayment;var isApplePaySupported=function(){var _ref6=(0,_asyncToGenerator2.default)(function*(){return _helpers.isiOS&&(yield _NativeStripeSdk.default.isApplePaySupported());});return function isApplePaySupported(){return _ref6.apply(this,arguments);};}();exports.isApplePaySupported=isApplePaySupported;var presentApplePay=function(){var _ref7=(0,_asyncToGenerator2.default)(function*(params){if(!(yield _NativeStripeSdk.default.isApplePaySupported())){return{error:{code:_types.ApplePayError.Canceled,message:APPLE_PAY_NOT_SUPPORTED_MESSAGE}};}try{var _yield$NativeStripeSd6=yield _NativeStripeSdk.default.presentApplePay(params),paymentMethod=_yield$NativeStripeSd6.paymentMethod,error=_yield$NativeStripeSd6.error;if(error){return{error:error};}return{paymentMethod:paymentMethod};}catch(error){return{error:error};}});return function presentApplePay(_x7){return _ref7.apply(this,arguments);};}();exports.presentApplePay=presentApplePay;var updateApplePaySummaryItems=function(){var _ref8=(0,_asyncToGenerator2.default)(function*(summaryItems){var errorAddressFields=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];if(!(yield _NativeStripeSdk.default.isApplePaySupported())){return{error:{code:_types.ApplePayError.Canceled,message:APPLE_PAY_NOT_SUPPORTED_MESSAGE}};}try{yield _NativeStripeSdk.default.updateApplePaySummaryItems(summaryItems,errorAddressFields);return{};}catch(error){return{error:error};}});return function updateApplePaySummaryItems(_x8){return _ref8.apply(this,arguments);};}();exports.updateApplePaySummaryItems=updateApplePaySummaryItems;var confirmApplePayPayment=function(){var _ref9=(0,_asyncToGenerator2.default)(function*(clientSecret){if(!(yield _NativeStripeSdk.default.isApplePaySupported())){return{error:{code:_types.ApplePayError.Canceled,message:APPLE_PAY_NOT_SUPPORTED_MESSAGE}};}try{yield _NativeStripeSdk.default.confirmApplePayPayment(clientSecret);return{};}catch(error){return{error:error};}});return function confirmApplePayPayment(_x9){return _ref9.apply(this,arguments);};}();exports.confirmApplePayPayment=confirmApplePayPayment;var handleNextAction=function(){var _ref10=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,returnURL){try{var _ref11=_reactNative.Platform.OS==='ios'?yield _NativeStripeSdk.default.handleNextAction(paymentIntentClientSecret,returnURL!=null?returnURL:null):yield _NativeStripeSdk.default.handleNextAction(paymentIntentClientSecret),paymentIntent=_ref11.paymentIntent,error=_ref11.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function handleNextAction(_x10,_x11){return _ref10.apply(this,arguments);};}();exports.handleNextAction=handleNextAction;var confirmSetupIntent=function(){var _ref12=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,params){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{var _yield$NativeStripeSd7=yield _NativeStripeSdk.default.confirmSetupIntent(paymentIntentClientSecret,params,options),setupIntent=_yield$NativeStripeSd7.setupIntent,error=_yield$NativeStripeSd7.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function confirmSetupIntent(_x12,_x13){return _ref12.apply(this,arguments);};}();exports.confirmSetupIntent=confirmSetupIntent;var createTokenForCVCUpdate=function(){var _ref13=(0,_asyncToGenerator2.default)(function*(cvc){try{var _yield$NativeStripeSd8=yield _NativeStripeSdk.default.createTokenForCVCUpdate(cvc),tokenId=_yield$NativeStripeSd8.tokenId,error=_yield$NativeStripeSd8.error;if(error){return{error:error};}return{tokenId:tokenId};}catch(error){return{error:error};}});return function createTokenForCVCUpdate(_x14){return _ref13.apply(this,arguments);};}();exports.createTokenForCVCUpdate=createTokenForCVCUpdate;var handleURLCallback=function(){var _ref14=(0,_asyncToGenerator2.default)(function*(url){var stripeHandled=yield _NativeStripeSdk.default.handleURLCallback(url);return stripeHandled;});return function handleURLCallback(_x15){return _ref14.apply(this,arguments);};}();exports.handleURLCallback=handleURLCallback;var verifyMicrodepositsForPayment=function(){var _ref15=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref16=yield _NativeStripeSdk.default.verifyMicrodeposits(true,clientSecret,params),paymentIntent=_ref16.paymentIntent,error=_ref16.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function verifyMicrodepositsForPayment(_x16,_x17){return _ref15.apply(this,arguments);};}();exports.verifyMicrodepositsForPayment=verifyMicrodepositsForPayment;var verifyMicrodepositsForSetup=function(){var _ref17=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref18=yield _NativeStripeSdk.default.verifyMicrodeposits(false,clientSecret,params),setupIntent=_ref18.setupIntent,error=_ref18.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function verifyMicrodepositsForSetup(_x18,_x19){return _ref17.apply(this,arguments);};}();exports.verifyMicrodepositsForSetup=verifyMicrodepositsForSetup;var initPaymentSheet=function(){var _ref19=(0,_asyncToGenerator2.default)(function*(params){var _params$applePay;var result;var setOrderTracking=params==null?void 0:(_params$applePay=params.applePay)==null?void 0:_params$applePay.setOrderTracking;try{if(setOrderTracking&&_reactNative.Platform.OS==='ios'){result=yield _NativeStripeSdk.default.initPaymentSheetWithOrderTracking(params,function(){setOrderTracking(_NativeStripeSdk.default.configureOrderTracking);});}else{result=yield _NativeStripeSdk.default.initPaymentSheet(params);}if(result.error){return{error:result.error};}return{paymentOption:result.paymentOption};}catch(error){return{error:error};}});return function initPaymentSheet(_x20){return _ref19.apply(this,arguments);};}();exports.initPaymentSheet=initPaymentSheet;var presentPaymentSheet=function(){var _ref20=(0,_asyncToGenerator2.default)(function*(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};try{var _yield$NativeStripeSd9=yield _NativeStripeSdk.default.presentPaymentSheet(options),paymentOption=_yield$NativeStripeSd9.paymentOption,error=_yield$NativeStripeSd9.error;if(error){return{error:error};}return{paymentOption:paymentOption};}catch(error){return{error:error};}});return function presentPaymentSheet(){return _ref20.apply(this,arguments);};}();exports.presentPaymentSheet=presentPaymentSheet;var confirmPaymentSheetPayment=function(){var _ref21=(0,_asyncToGenerator2.default)(function*(){try{var _yield$NativeStripeSd10=yield _NativeStripeSdk.default.confirmPaymentSheetPayment(),error=_yield$NativeStripeSd10.error;if(error){return{error:error};}return{};}catch(error){return{error:error};}});return function confirmPaymentSheetPayment(){return _ref21.apply(this,arguments);};}();exports.confirmPaymentSheetPayment=confirmPaymentSheetPayment;var resetPaymentSheetCustomer=function(){var _ref22=(0,_asyncToGenerator2.default)(function*(){return yield _NativeStripeSdk.default.resetPaymentSheetCustomer();});return function resetPaymentSheetCustomer(){return _ref22.apply(this,arguments);};}();exports.resetPaymentSheetCustomer=resetPaymentSheetCustomer;var isGooglePaySupported=function(){var _ref23=(0,_asyncToGenerator2.default)(function*(params){return _helpers.isAndroid&&(yield _NativeStripeSdk.default.isGooglePaySupported(params!=null?params:{}));});return function isGooglePaySupported(_x21){return _ref23.apply(this,arguments);};}();exports.isGooglePaySupported=isGooglePaySupported;var initGooglePay=function(){var _ref24=(0,_asyncToGenerator2.default)(function*(params){try{var _yield$NativeStripeSd11=yield _NativeStripeSdk.default.initGooglePay(params),error=_yield$NativeStripeSd11.error;if(error){return{error:error};}return{};}catch(error){return{error:error};}});return function initGooglePay(_x22){return _ref24.apply(this,arguments);};}();exports.initGooglePay=initGooglePay;var presentGooglePay=function(){var _ref25=(0,_asyncToGenerator2.default)(function*(params){try{var _yield$NativeStripeSd12=yield _NativeStripeSdk.default.presentGooglePay(params),error=_yield$NativeStripeSd12.error;if(error){return{error:error};}return{};}catch(error){return{error:error};}});return function presentGooglePay(_x23){return _ref25.apply(this,arguments);};}();exports.presentGooglePay=presentGooglePay;var createGooglePayPaymentMethod=function(){var _ref26=(0,_asyncToGenerator2.default)(function*(params){try{var _yield$NativeStripeSd13=yield _NativeStripeSdk.default.createGooglePayPaymentMethod(params),error=_yield$NativeStripeSd13.error,paymentMethod=_yield$NativeStripeSd13.paymentMethod;if(error){return{error:error};}return{paymentMethod:paymentMethod};}catch(error){return{error:error};}});return function createGooglePayPaymentMethod(_x24){return _ref26.apply(this,arguments);};}();exports.createGooglePayPaymentMethod=createGooglePayPaymentMethod;var openApplePaySetup=function(){var _ref27=(0,_asyncToGenerator2.default)(function*(){try{var _yield$NativeStripeSd14=yield _NativeStripeSdk.default.openApplePaySetup(),error=_yield$NativeStripeSd14.error;if(error){return{error:error};}return{};}catch(error){return{error:error};}});return function openApplePaySetup(){return _ref27.apply(this,arguments);};}();exports.openApplePaySetup=openApplePaySetup;var collectBankAccountForPayment=function(){var _ref28=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref29=yield _NativeStripeSdk.default.collectBankAccount(true,clientSecret,params),paymentIntent=_ref29.paymentIntent,error=_ref29.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountForPayment(_x25,_x26){return _ref28.apply(this,arguments);};}();exports.collectBankAccountForPayment=collectBankAccountForPayment;var collectBankAccountForSetup=function(){var _ref30=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref31=yield _NativeStripeSdk.default.collectBankAccount(false,clientSecret,params),setupIntent=_ref31.setupIntent,error=_ref31.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountForSetup(_x27,_x28){return _ref30.apply(this,arguments);};}();exports.collectBankAccountForSetup=collectBankAccountForSetup;var collectBankAccountToken=function(){var _ref32=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd15=yield _NativeStripeSdk.default.collectBankAccountToken(clientSecret),session=_yield$NativeStripeSd15.session,token=_yield$NativeStripeSd15.token,error=_yield$NativeStripeSd15.error;if(error){return{error:error};}return{session:session,token:token};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountToken(_x29){return _ref32.apply(this,arguments);};}();exports.collectBankAccountToken=collectBankAccountToken;var collectFinancialConnectionsAccounts=function(){var _ref33=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd16=yield _NativeStripeSdk.default.collectFinancialConnectionsAccounts(clientSecret),session=_yield$NativeStripeSd16.session,error=_yield$NativeStripeSd16.error;if(error){return{error:error};}return{session:session};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectFinancialConnectionsAccounts(_x30){return _ref33.apply(this,arguments);};}();exports.collectFinancialConnectionsAccounts=collectFinancialConnectionsAccounts;var canAddCardToWallet=function(){var _ref34=(0,_asyncToGenerator2.default)(function*(params){try{var _yield$NativeStripeSd17=yield _NativeStripeSdk.default.canAddCardToWallet(params),canAddCard=_yield$NativeStripeSd17.canAddCard,details=_yield$NativeStripeSd17.details,error=_yield$NativeStripeSd17.error;if(error){return{error:error};}return{canAddCard:canAddCard,details:details};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function canAddCardToWallet(_x31){return _ref34.apply(this,arguments);};}();exports.canAddCardToWallet=canAddCardToWallet;var isCardInWallet=function(){var _ref35=(0,_asyncToGenerator2.default)(function*(params){try{var _yield$NativeStripeSd18=yield _NativeStripeSdk.default.isCardInWallet(params),isInWallet=_yield$NativeStripeSd18.isInWallet,token=_yield$NativeStripeSd18.token,error=_yield$NativeStripeSd18.error;if(error){return{error:error};}return{isInWallet:isInWallet,token:token};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function isCardInWallet(_x32){return _ref35.apply(this,arguments);};}();exports.isCardInWallet=isCardInWallet;var Constants=_NativeStripeSdk.default.getConstants();exports.Constants=Constants;var isPlatformPaySupported=function(){var _ref36=(0,_asyncToGenerator2.default)(function*(params){return yield _NativeStripeSdk.default.isPlatformPaySupported(params!=null?params:{});});return function isPlatformPaySupported(_x33){return _ref36.apply(this,arguments);};}();exports.isPlatformPaySupported=isPlatformPaySupported;var confirmPlatformPaySetupIntent=function(){var _ref37=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref38=yield _NativeStripeSdk.default.confirmPlatformPay(clientSecret,params,false),error=_ref38.error,setupIntent=_ref38.setupIntent;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function confirmPlatformPaySetupIntent(_x34,_x35){return _ref37.apply(this,arguments);};}();exports.confirmPlatformPaySetupIntent=confirmPlatformPaySetupIntent;var confirmPlatformPayPayment=function(){var _ref39=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref40=yield _NativeStripeSdk.default.confirmPlatformPay(clientSecret,params,true),error=_ref40.error,paymentIntent=_ref40.paymentIntent;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function confirmPlatformPayPayment(_x36,_x37){return _ref39.apply(this,arguments);};}();exports.confirmPlatformPayPayment=confirmPlatformPayPayment;var dismissPlatformPay=function(){var _ref41=(0,_asyncToGenerator2.default)(function*(){if(_reactNative.Platform.OS!=='ios'){return false;}try{var didDismiss=yield _NativeStripeSdk.default.dismissPlatformPay();return didDismiss;}catch(error){return false;}});return function dismissPlatformPay(){return _ref41.apply(this,arguments);};}();exports.dismissPlatformPay=dismissPlatformPay;var createPlatformPayPaymentMethod=function(){var _ref42=(0,_asyncToGenerator2.default)(function*(params){try{var _ref43=yield _NativeStripeSdk.default.createPlatformPayPaymentMethod(params,false),error=_ref43.error,paymentMethod=_ref43.paymentMethod;if(error){return{error:error};}return{paymentMethod:paymentMethod};}catch(error){return{error:error};}});return function createPlatformPayPaymentMethod(_x38){return _ref42.apply(this,arguments);};}();exports.createPlatformPayPaymentMethod=createPlatformPayPaymentMethod;var createPlatformPayToken=function(){var _ref44=(0,_asyncToGenerator2.default)(function*(params){try{var _ref45=yield _NativeStripeSdk.default.createPlatformPayPaymentMethod(params,true),error=_ref45.error,token=_ref45.token;if(error){return{error:error};}return{token:token};}catch(error){return{error:error};}});return function createPlatformPayToken(_x39){return _ref44.apply(this,arguments);};}();exports.createPlatformPayToken=createPlatformPayToken;var updatePlatformPaySheet=function(){var _ref46=(0,_asyncToGenerator2.default)(function*(params){if(_reactNative.Platform.OS!=='ios'){return{};}try{yield _NativeStripeSdk.default.updatePlatformPaySheet(params.applePay.cartItems,params.applePay.shippingMethods,params.applePay.errors);return{};}catch(error){return{error:error};}});return function updatePlatformPaySheet(_x40){return _ref46.apply(this,arguments);};}();exports.updatePlatformPaySheet=updatePlatformPaySheet;var openPlatformPaySetup=function(){var _ref47=(0,_asyncToGenerator2.default)(function*(){if(_reactNative.Platform.OS==='ios'){yield _NativeStripeSdk.default.openApplePaySetup();}});return function openPlatformPaySetup(){return _ref47.apply(this,arguments);};}();exports.openPlatformPaySetup=openPlatformPaySetup;
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.verifyMicrodepositsForSetup=exports.verifyMicrodepositsForPayment=exports.updatePlatformPaySheet=exports.retrieveSetupIntent=exports.retrievePaymentIntent=exports.resetPaymentSheetCustomer=exports.presentPaymentSheet=exports.openPlatformPaySetup=exports.isPlatformPaySupported=exports.isCardInWallet=exports.initPaymentSheet=exports.handleURLCallback=exports.handleNextAction=exports.dismissPlatformPay=exports.createTokenForCVCUpdate=exports.createToken=exports.createPlatformPayToken=exports.createPlatformPayPaymentMethod=exports.createPaymentMethod=exports.confirmSetupIntent=exports.confirmPlatformPaySetupIntent=exports.confirmPlatformPayPayment=exports.confirmPaymentSheetPayment=exports.confirmPayment=exports.collectFinancialConnectionsAccounts=exports.collectBankAccountToken=exports.collectBankAccountForSetup=exports.collectBankAccountForPayment=exports.canAddCardToWallet=exports.Constants=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _helpers=require("./helpers");var _Errors=require("./types/Errors");var _NativeStripeSdk=_interopRequireDefault(require("./NativeStripeSdk"));var _reactNative=require("react-native");var createPaymentMethod=function(){var _ref=(0,_asyncToGenerator2.default)(function*(params){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};try{var _yield$NativeStripeSd=yield _NativeStripeSdk.default.createPaymentMethod(params,options),paymentMethod=_yield$NativeStripeSd.paymentMethod,error=_yield$NativeStripeSd.error;if(error){return{error:error};}return{paymentMethod:paymentMethod};}catch(error){return{error:error};}});return function createPaymentMethod(_x){return _ref.apply(this,arguments);};}();exports.createPaymentMethod=createPaymentMethod;var createToken=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(params){var _params$country;if(params.type==='BankAccount'&&((_params$country=params.country)==null?void 0:_params$country.toLowerCase())==='us'&&!params.routingNumber){return{error:_Errors.MissingRoutingNumber};}try{var _yield$NativeStripeSd2=yield _NativeStripeSdk.default.createToken(params),token=_yield$NativeStripeSd2.token,error=_yield$NativeStripeSd2.error;if(error){return{error:error};}return{token:token};}catch(error){return{error:error};}});return function createToken(_x2){return _ref2.apply(this,arguments);};}();exports.createToken=createToken;var retrievePaymentIntent=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd3=yield _NativeStripeSdk.default.retrievePaymentIntent(clientSecret),paymentIntent=_yield$NativeStripeSd3.paymentIntent,error=_yield$NativeStripeSd3.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function retrievePaymentIntent(_x3){return _ref3.apply(this,arguments);};}();exports.retrievePaymentIntent=retrievePaymentIntent;var retrieveSetupIntent=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd4=yield _NativeStripeSdk.default.retrieveSetupIntent(clientSecret),setupIntent=_yield$NativeStripeSd4.setupIntent,error=_yield$NativeStripeSd4.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function retrieveSetupIntent(_x4){return _ref4.apply(this,arguments);};}();exports.retrieveSetupIntent=retrieveSetupIntent;var confirmPayment=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,params){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{var _yield$NativeStripeSd5=yield _NativeStripeSdk.default.confirmPayment(paymentIntentClientSecret,params,options),paymentIntent=_yield$NativeStripeSd5.paymentIntent,error=_yield$NativeStripeSd5.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function confirmPayment(_x5,_x6){return _ref5.apply(this,arguments);};}();exports.confirmPayment=confirmPayment;var handleNextAction=function(){var _ref6=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,returnURL){try{var _ref7=_reactNative.Platform.OS==='ios'?yield _NativeStripeSdk.default.handleNextAction(paymentIntentClientSecret,returnURL!=null?returnURL:null):yield _NativeStripeSdk.default.handleNextAction(paymentIntentClientSecret),paymentIntent=_ref7.paymentIntent,error=_ref7.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function handleNextAction(_x7,_x8){return _ref6.apply(this,arguments);};}();exports.handleNextAction=handleNextAction;var confirmSetupIntent=function(){var _ref8=(0,_asyncToGenerator2.default)(function*(paymentIntentClientSecret,params){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{var _yield$NativeStripeSd6=yield _NativeStripeSdk.default.confirmSetupIntent(paymentIntentClientSecret,params,options),setupIntent=_yield$NativeStripeSd6.setupIntent,error=_yield$NativeStripeSd6.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function confirmSetupIntent(_x9,_x10){return _ref8.apply(this,arguments);};}();exports.confirmSetupIntent=confirmSetupIntent;var createTokenForCVCUpdate=function(){var _ref9=(0,_asyncToGenerator2.default)(function*(cvc){try{var _yield$NativeStripeSd7=yield _NativeStripeSdk.default.createTokenForCVCUpdate(cvc),tokenId=_yield$NativeStripeSd7.tokenId,error=_yield$NativeStripeSd7.error;if(error){return{error:error};}return{tokenId:tokenId};}catch(error){return{error:error};}});return function createTokenForCVCUpdate(_x11){return _ref9.apply(this,arguments);};}();exports.createTokenForCVCUpdate=createTokenForCVCUpdate;var handleURLCallback=function(){var _ref10=(0,_asyncToGenerator2.default)(function*(url){var stripeHandled=_reactNative.Platform.OS==='ios'?yield _NativeStripeSdk.default.handleURLCallback(url):false;return stripeHandled;});return function handleURLCallback(_x12){return _ref10.apply(this,arguments);};}();exports.handleURLCallback=handleURLCallback;var verifyMicrodepositsForPayment=function(){var _ref11=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref12=yield _NativeStripeSdk.default.verifyMicrodeposits(true,clientSecret,params),paymentIntent=_ref12.paymentIntent,error=_ref12.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function verifyMicrodepositsForPayment(_x13,_x14){return _ref11.apply(this,arguments);};}();exports.verifyMicrodepositsForPayment=verifyMicrodepositsForPayment;var verifyMicrodepositsForSetup=function(){var _ref13=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref14=yield _NativeStripeSdk.default.verifyMicrodeposits(false,clientSecret,params),setupIntent=_ref14.setupIntent,error=_ref14.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function verifyMicrodepositsForSetup(_x15,_x16){return _ref13.apply(this,arguments);};}();exports.verifyMicrodepositsForSetup=verifyMicrodepositsForSetup;var eventEmitter=new _reactNative.NativeEventEmitter(_reactNative.NativeModules.StripeSdk);var confirmHandlerCallback=null;var orderTrackingCallbackListener=null;var initPaymentSheet=function(){var _ref15=(0,_asyncToGenerator2.default)(function*(params){var _params$intentConfigu,_params$applePay;var result;var confirmHandler=params==null?void 0:(_params$intentConfigu=params.intentConfiguration)==null?void 0:_params$intentConfigu.confirmHandler;if(confirmHandler){var _confirmHandlerCallba;(_confirmHandlerCallba=confirmHandlerCallback)==null?void 0:_confirmHandlerCallba.remove();confirmHandlerCallback=eventEmitter.addListener('onConfirmHandlerCallback',function(_ref16){var paymentMethod=_ref16.paymentMethod,shouldSavePaymentMethod=_ref16.shouldSavePaymentMethod;confirmHandler(paymentMethod,shouldSavePaymentMethod,_NativeStripeSdk.default.intentCreationCallback);});}var orderTrackingCallback=params==null?void 0:(_params$applePay=params.applePay)==null?void 0:_params$applePay.setOrderTracking;if(orderTrackingCallback){var _orderTrackingCallbac;(_orderTrackingCallbac=orderTrackingCallbackListener)==null?void 0:_orderTrackingCallbac.remove();orderTrackingCallbackListener=eventEmitter.addListener('onOrderTrackingCallback',function(){orderTrackingCallback(_NativeStripeSdk.default.configureOrderTracking);});}try{result=yield _NativeStripeSdk.default.initPaymentSheet(params);if(result.error){return{error:result.error};}return{paymentOption:result.paymentOption};}catch(error){return{error:error};}});return function initPaymentSheet(_x17){return _ref15.apply(this,arguments);};}();exports.initPaymentSheet=initPaymentSheet;var presentPaymentSheet=function(){var _ref17=(0,_asyncToGenerator2.default)(function*(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};try{var _yield$NativeStripeSd8=yield _NativeStripeSdk.default.presentPaymentSheet(options),paymentOption=_yield$NativeStripeSd8.paymentOption,error=_yield$NativeStripeSd8.error;if(error){return{error:error};}return{paymentOption:paymentOption};}catch(error){return{error:error};}});return function presentPaymentSheet(){return _ref17.apply(this,arguments);};}();exports.presentPaymentSheet=presentPaymentSheet;var confirmPaymentSheetPayment=function(){var _ref18=(0,_asyncToGenerator2.default)(function*(){try{var _yield$NativeStripeSd9=yield _NativeStripeSdk.default.confirmPaymentSheetPayment(),error=_yield$NativeStripeSd9.error;if(error){return{error:error};}return{};}catch(error){return{error:error};}});return function confirmPaymentSheetPayment(){return _ref18.apply(this,arguments);};}();exports.confirmPaymentSheetPayment=confirmPaymentSheetPayment;var resetPaymentSheetCustomer=function(){var _ref19=(0,_asyncToGenerator2.default)(function*(){return yield _NativeStripeSdk.default.resetPaymentSheetCustomer();});return function resetPaymentSheetCustomer(){return _ref19.apply(this,arguments);};}();exports.resetPaymentSheetCustomer=resetPaymentSheetCustomer;var collectBankAccountForPayment=function(){var _ref20=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref21=yield _NativeStripeSdk.default.collectBankAccount(true,clientSecret,params),paymentIntent=_ref21.paymentIntent,error=_ref21.error;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountForPayment(_x18,_x19){return _ref20.apply(this,arguments);};}();exports.collectBankAccountForPayment=collectBankAccountForPayment;var collectBankAccountForSetup=function(){var _ref22=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref23=yield _NativeStripeSdk.default.collectBankAccount(false,clientSecret,params),setupIntent=_ref23.setupIntent,error=_ref23.error;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountForSetup(_x20,_x21){return _ref22.apply(this,arguments);};}();exports.collectBankAccountForSetup=collectBankAccountForSetup;var collectBankAccountToken=function(){var _ref24=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd10=yield _NativeStripeSdk.default.collectBankAccountToken(clientSecret),session=_yield$NativeStripeSd10.session,token=_yield$NativeStripeSd10.token,error=_yield$NativeStripeSd10.error;if(error){return{error:error};}return{session:session,token:token};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectBankAccountToken(_x22){return _ref24.apply(this,arguments);};}();exports.collectBankAccountToken=collectBankAccountToken;var collectFinancialConnectionsAccounts=function(){var _ref25=(0,_asyncToGenerator2.default)(function*(clientSecret){try{var _yield$NativeStripeSd11=yield _NativeStripeSdk.default.collectFinancialConnectionsAccounts(clientSecret),session=_yield$NativeStripeSd11.session,error=_yield$NativeStripeSd11.error;if(error){return{error:error};}return{session:session};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function collectFinancialConnectionsAccounts(_x23){return _ref25.apply(this,arguments);};}();exports.collectFinancialConnectionsAccounts=collectFinancialConnectionsAccounts;var canAddCardToWallet=function(){var _ref26=(0,_asyncToGenerator2.default)(function*(params){try{var _yield$NativeStripeSd12=yield _NativeStripeSdk.default.canAddCardToWallet(params),canAddCard=_yield$NativeStripeSd12.canAddCard,details=_yield$NativeStripeSd12.details,error=_yield$NativeStripeSd12.error;if(error){return{error:error};}return{canAddCard:canAddCard,details:details};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function canAddCardToWallet(_x24){return _ref26.apply(this,arguments);};}();exports.canAddCardToWallet=canAddCardToWallet;var isCardInWallet=function(){var _ref27=(0,_asyncToGenerator2.default)(function*(params){try{var _yield$NativeStripeSd13=yield _NativeStripeSdk.default.isCardInWallet(params),isInWallet=_yield$NativeStripeSd13.isInWallet,token=_yield$NativeStripeSd13.token,error=_yield$NativeStripeSd13.error;if(error){return{error:error};}return{isInWallet:isInWallet,token:token};}catch(error){return{error:(0,_helpers.createError)(error)};}});return function isCardInWallet(_x25){return _ref27.apply(this,arguments);};}();exports.isCardInWallet=isCardInWallet;var Constants=_NativeStripeSdk.default.getConstants();exports.Constants=Constants;var isPlatformPaySupported=function(){var _ref28=(0,_asyncToGenerator2.default)(function*(params){return yield _NativeStripeSdk.default.isPlatformPaySupported(params!=null?params:{});});return function isPlatformPaySupported(_x26){return _ref28.apply(this,arguments);};}();exports.isPlatformPaySupported=isPlatformPaySupported;var confirmPlatformPaySetupIntent=function(){var _ref29=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref30=yield _NativeStripeSdk.default.confirmPlatformPay(clientSecret,params,false),error=_ref30.error,setupIntent=_ref30.setupIntent;if(error){return{error:error};}return{setupIntent:setupIntent};}catch(error){return{error:error};}});return function confirmPlatformPaySetupIntent(_x27,_x28){return _ref29.apply(this,arguments);};}();exports.confirmPlatformPaySetupIntent=confirmPlatformPaySetupIntent;var confirmPlatformPayPayment=function(){var _ref31=(0,_asyncToGenerator2.default)(function*(clientSecret,params){try{var _ref32=yield _NativeStripeSdk.default.confirmPlatformPay(clientSecret,params,true),error=_ref32.error,paymentIntent=_ref32.paymentIntent;if(error){return{error:error};}return{paymentIntent:paymentIntent};}catch(error){return{error:error};}});return function confirmPlatformPayPayment(_x29,_x30){return _ref31.apply(this,arguments);};}();exports.confirmPlatformPayPayment=confirmPlatformPayPayment;var dismissPlatformPay=function(){var _ref33=(0,_asyncToGenerator2.default)(function*(){if(_reactNative.Platform.OS!=='ios'){return false;}try{var didDismiss=yield _NativeStripeSdk.default.dismissPlatformPay();return didDismiss;}catch(error){return false;}});return function dismissPlatformPay(){return _ref33.apply(this,arguments);};}();exports.dismissPlatformPay=dismissPlatformPay;var createPlatformPayPaymentMethod=function(){var _ref34=(0,_asyncToGenerator2.default)(function*(params){try{var _ref35=yield _NativeStripeSdk.default.createPlatformPayPaymentMethod(params,false),error=_ref35.error,paymentMethod=_ref35.paymentMethod;if(error){return{error:error};}return{paymentMethod:paymentMethod};}catch(error){return{error:error};}});return function createPlatformPayPaymentMethod(_x31){return _ref34.apply(this,arguments);};}();exports.createPlatformPayPaymentMethod=createPlatformPayPaymentMethod;var createPlatformPayToken=function(){var _ref36=(0,_asyncToGenerator2.default)(function*(params){try{var _ref37=yield _NativeStripeSdk.default.createPlatformPayPaymentMethod(params,true),error=_ref37.error,token=_ref37.token;if(error){return{error:error};}return{token:token};}catch(error){return{error:error};}});return function createPlatformPayToken(_x32){return _ref36.apply(this,arguments);};}();exports.createPlatformPayToken=createPlatformPayToken;var updatePlatformPaySheet=function(){var _ref38=(0,_asyncToGenerator2.default)(function*(params){if(_reactNative.Platform.OS!=='ios'){return{};}try{yield _NativeStripeSdk.default.updatePlatformPaySheet(params.applePay.cartItems,params.applePay.shippingMethods,params.applePay.errors);return{};}catch(error){return{error:error};}});return function updatePlatformPaySheet(_x33){return _ref38.apply(this,arguments);};}();exports.updatePlatformPaySheet=updatePlatformPaySheet;var openPlatformPaySetup=function(){var _ref39=(0,_asyncToGenerator2.default)(function*(){if(_reactNative.Platform.OS==='ios'){yield _NativeStripeSdk.default.openApplePaySetup();}});return function openPlatformPaySetup(){return _ref39.apply(this,arguments);};}();exports.openPlatformPaySetup=openPlatformPaySetup;
|
|
2
2
|
//# sourceMappingURL=functions.js.map
|