@stripe/stripe-react-native 0.27.2 → 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 +25 -0
- package/README.md +2 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +4 -0
- package/android/src/main/java/com/reactnativestripesdk/CardFieldViewManager.kt +5 -0
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +4 -0
- package/android/src/main/java/com/reactnativestripesdk/CardFormViewManager.kt +5 -0
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +33 -7
- 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/CardFieldManager.m +1 -0
- package/ios/CardFieldView.swift +6 -0
- package/ios/CardFormManager.m +2 -2
- package/ios/CardFormView.swift +9 -9
- package/ios/StripeSdk+PaymentSheet.swift +100 -10
- package/ios/StripeSdk.m +15 -29
- package/ios/StripeSdk.swift +32 -91
- 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/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/GooglePayButtonNative.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.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/CardFieldInput.js.map +1 -1
- package/lib/commonjs/types/components/CardFormView.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/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/GooglePayButtonNative.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.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/CardFieldInput.js.map +1 -1
- package/lib/module/types/components/CardFormView.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/CardField.d.ts +2 -0
- package/lib/typescript/src/components/CardForm.d.ts +2 -0
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts +1 -1
- package/lib/typescript/src/components/PlatformPayButton.d.ts +2 -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 +35 -5
- package/lib/typescript/src/types/components/CardFieldInput.d.ts +1 -0
- package/lib/typescript/src/types/components/CardFormView.d.ts +1 -0
- 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/CardField.tsx +2 -0
- package/src/components/CardForm.tsx +2 -4
- package/src/components/GooglePayButtonNative.tsx +1 -1
- package/src/components/PlatformPayButton.tsx +2 -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 +36 -5
- package/src/types/components/CardFieldInput.ts +1 -0
- package/src/types/components/CardFormView.ts +1 -1
- 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
package/ios/CardFormManager.m
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
RCT_EXPORT_VIEW_PROPERTY(onFormComplete, RCTDirectEventBlock)
|
|
7
7
|
RCT_EXPORT_VIEW_PROPERTY(dangerouslyGetFullCardDetails, BOOL)
|
|
8
8
|
RCT_EXPORT_VIEW_PROPERTY(autofocus, BOOL)
|
|
9
|
-
RCT_EXPORT_VIEW_PROPERTY(
|
|
9
|
+
RCT_EXPORT_VIEW_PROPERTY(cardStyle, NSDictionary)
|
|
10
|
+
RCT_EXPORT_VIEW_PROPERTY(disabled, BOOL)
|
|
10
11
|
RCT_EXTERN_METHOD(focus:(nonnull NSNumber*) reactTag)
|
|
11
12
|
RCT_EXTERN_METHOD(blur:(nonnull NSNumber*) reactTag)
|
|
12
|
-
RCT_EXPORT_VIEW_PROPERTY(cardStyle, NSDictionary)
|
|
13
13
|
@end
|
package/ios/CardFormView.swift
CHANGED
|
@@ -10,7 +10,7 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
10
10
|
@objc var dangerouslyGetFullCardDetails: Bool = false
|
|
11
11
|
@objc var onFormComplete: RCTDirectEventBlock?
|
|
12
12
|
@objc var autofocus: Bool = false
|
|
13
|
-
@objc var
|
|
13
|
+
@objc var disabled: Bool = false
|
|
14
14
|
|
|
15
15
|
override func didSetProps(_ changedProps: [String]!) {
|
|
16
16
|
if let cardForm = self.cardForm {
|
|
@@ -20,7 +20,7 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
20
20
|
let style = self.cardStyle["type"] as? String == "borderless" ? STPCardFormViewStyle.borderless : STPCardFormViewStyle.standard
|
|
21
21
|
let _cardForm = STPCardFormView(style: style)
|
|
22
22
|
_cardForm.delegate = self
|
|
23
|
-
|
|
23
|
+
_cardForm.isUserInteractionEnabled = !disabled
|
|
24
24
|
|
|
25
25
|
if autofocus == true {
|
|
26
26
|
let _ = _cardForm.becomeFirstResponder()
|
|
@@ -33,10 +33,10 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
33
33
|
|
|
34
34
|
@objc var cardStyle: NSDictionary = NSDictionary() {
|
|
35
35
|
didSet {
|
|
36
|
-
|
|
36
|
+
setStyles()
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
func cardFormView(_ form: STPCardFormView, didChangeToStateComplete complete: Bool) {
|
|
41
41
|
if onFormComplete != nil {
|
|
42
42
|
let brand = STPCardValidator.brand(forNumber: cardForm?.cardParams?.card?.number ?? "")
|
|
@@ -49,7 +49,7 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
49
49
|
"postalCode": cardForm?.cardParams?.billingDetails?.address?.postalCode ?? "",
|
|
50
50
|
"country": cardForm?.cardParams?.billingDetails?.address?.country
|
|
51
51
|
]
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
if (dangerouslyGetFullCardDetails) {
|
|
54
54
|
cardData["number"] = cardForm?.cardParams?.card?.number ?? ""
|
|
55
55
|
cardData["cvc"] = cardForm?.cardParams?.card?.cvc ?? ""
|
|
@@ -76,13 +76,13 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
76
76
|
cardForm?.backgroundColor = UIColor(hexString: backgroundColor)
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
The following reveals a bug in STPCardFormView where there's a extra space in the layer,
|
|
80
|
+
and thus must remain commented out for now.
|
|
81
81
|
|
|
82
82
|
if let borderWidth = cardStyle["borderWidth"] as? Int {
|
|
83
|
-
|
|
83
|
+
cardForm?.layer.borderWidth = CGFloat(borderWidth)
|
|
84
84
|
} else {
|
|
85
|
-
|
|
85
|
+
cardForm?.layer.borderWidth = CGFloat(0)
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
*/
|
|
@@ -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:)
|
|
@@ -145,9 +152,8 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
145
152
|
case .canceled:
|
|
146
153
|
resolve(Errors.createError(ErrorType.Canceled, "The payment flow has been canceled"))
|
|
147
154
|
case .failed(let error):
|
|
148
|
-
resolve(Errors.createError(ErrorType.Failed, error
|
|
155
|
+
resolve(Errors.createError(ErrorType.Failed, error))
|
|
149
156
|
}
|
|
150
|
-
|
|
151
157
|
}
|
|
152
158
|
} else {
|
|
153
159
|
resolve(Errors.createError(ErrorType.Failed, "No payment sheet has been initialized yet"))
|
|
@@ -221,7 +227,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
221
227
|
|
|
222
228
|
STPAPIClient.shared.createToken(forCVCUpdate: cvc) { (token, error) in
|
|
223
229
|
if error != nil || token == nil {
|
|
224
|
-
resolve(Errors.createError(ErrorType.Failed, error
|
|
230
|
+
resolve(Errors.createError(ErrorType.Failed, error as? NSError))
|
|
225
231
|
} else {
|
|
226
232
|
let tokenId = token?.tokenId
|
|
227
233
|
resolve(["tokenId": tokenId])
|
|
@@ -343,35 +349,6 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
343
349
|
self.shippingContactUpdateCompletion = nil
|
|
344
350
|
resolve([])
|
|
345
351
|
}
|
|
346
|
-
|
|
347
|
-
@objc(updateApplePaySummaryItems:errorAddressFields:resolver:rejecter:)
|
|
348
|
-
func updateApplePaySummaryItems(summaryItems: NSArray, errorAddressFields: [NSDictionary], resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
349
|
-
if (shippingMethodUpdateCompletion == nil && shippingContactUpdateCompletion == nil) {
|
|
350
|
-
resolve(Errors.createError(ErrorType.Failed, "You can use this method only after either onDidSetShippingMethod or onDidSetShippingContact events emitted"))
|
|
351
|
-
return
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
var paymentSummaryItems : [PKPaymentSummaryItem] = []
|
|
355
|
-
do {
|
|
356
|
-
paymentSummaryItems = try ApplePayUtils.buildPaymentSummaryItems(items: summaryItems as? [[String : Any]])
|
|
357
|
-
} catch {
|
|
358
|
-
resolve(Errors.createError(ErrorType.Failed, error.localizedDescription))
|
|
359
|
-
return
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
var shippingAddressErrors: [Error] = []
|
|
363
|
-
for item in errorAddressFields {
|
|
364
|
-
let field = item["field"] as! String
|
|
365
|
-
let message = item["message"] as? String ?? field + " error"
|
|
366
|
-
shippingAddressErrors.append(PKPaymentRequest.paymentShippingAddressInvalidError(withKey: field, localizedDescription: message))
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
shippingMethodUpdateCompletion?(PKPaymentRequestShippingMethodUpdate.init(paymentSummaryItems: paymentSummaryItems))
|
|
370
|
-
shippingContactUpdateCompletion?(PKPaymentRequestShippingContactUpdate.init(errors: shippingAddressErrors, paymentSummaryItems: paymentSummaryItems, shippingMethods: []))
|
|
371
|
-
self.shippingMethodUpdateCompletion = nil
|
|
372
|
-
self.shippingContactUpdateCompletion = nil
|
|
373
|
-
resolve([])
|
|
374
|
-
}
|
|
375
352
|
|
|
376
353
|
@objc(openApplePaySetup:rejecter:)
|
|
377
354
|
func openApplePaySetup(resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
@@ -379,20 +356,6 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
379
356
|
resolve([])
|
|
380
357
|
}
|
|
381
358
|
|
|
382
|
-
@objc(confirmApplePayPayment:resolver:rejecter:)
|
|
383
|
-
func confirmApplePayPayment(clientSecret: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
384
|
-
self.deprecatedApplePayCompletionRejecter = reject
|
|
385
|
-
self.deprecatedConfirmApplePayPaymentResolver = resolve
|
|
386
|
-
self.applePayCompletionCallback?(clientSecret, nil)
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
@objc(isApplePaySupported:rejecter:)
|
|
390
|
-
func isApplePaySupported(resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
391
|
-
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
392
|
-
let isSupported = StripeAPI.deviceSupportsApplePay()
|
|
393
|
-
resolve(isSupported)
|
|
394
|
-
}
|
|
395
|
-
|
|
396
359
|
@objc(handleURLCallback:resolver:rejecter:)
|
|
397
360
|
func handleURLCallback(url: String?, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
398
361
|
guard let url = url else {
|
|
@@ -409,28 +372,6 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
409
372
|
}
|
|
410
373
|
}
|
|
411
374
|
}
|
|
412
|
-
|
|
413
|
-
@objc(presentApplePay:resolver:rejecter:)
|
|
414
|
-
func presentApplePay(params: NSDictionary,
|
|
415
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
416
|
-
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
417
|
-
self.deprecatedApplePayRequestResolver = resolve
|
|
418
|
-
self.deprecatedApplePayRequestRejecter = reject
|
|
419
|
-
|
|
420
|
-
let (error, paymentRequest) = ApplePayUtils.createPaymentRequest(merchantIdentifier: merchantIdentifier, params: params)
|
|
421
|
-
guard let paymentRequest = paymentRequest else {
|
|
422
|
-
resolve(error)
|
|
423
|
-
return
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if let applePayContext = STPApplePayContext(paymentRequest: paymentRequest, delegate: self) {
|
|
427
|
-
DispatchQueue.main.async {
|
|
428
|
-
applePayContext.presentApplePay(completion: nil)
|
|
429
|
-
}
|
|
430
|
-
} else {
|
|
431
|
-
resolve(Errors.createError(ErrorType.Failed, "Payment not completed"))
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
375
|
|
|
435
376
|
@objc(isPlatformPaySupported:resolver:rejecter:)
|
|
436
377
|
func isPlatformPaySupported(params: NSDictionary,
|
|
@@ -558,7 +499,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
558
499
|
if let paymentMethodParams = paymentMethodParams {
|
|
559
500
|
STPAPIClient.shared.createPaymentMethod(with: paymentMethodParams) { paymentMethod, error in
|
|
560
501
|
if let createError = error {
|
|
561
|
-
resolve(Errors.createError(ErrorType.Failed, createError
|
|
502
|
+
resolve(Errors.createError(ErrorType.Failed, createError as NSError))
|
|
562
503
|
} else {
|
|
563
504
|
resolve(
|
|
564
505
|
Mappers.createResult("paymentMethod", Mappers.mapFromPaymentMethod(paymentMethod))
|
|
@@ -908,7 +849,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
908
849
|
if let lastPaymentError = paymentIntent?.lastPaymentError {
|
|
909
850
|
resolve(Errors.createError(ErrorType.Unknown, lastPaymentError))
|
|
910
851
|
} else {
|
|
911
|
-
resolve(Errors.createError(ErrorType.Unknown, error
|
|
852
|
+
resolve(Errors.createError(ErrorType.Unknown, error as? NSError))
|
|
912
853
|
}
|
|
913
854
|
return
|
|
914
855
|
}
|
|
@@ -932,7 +873,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
932
873
|
if let lastSetupError = setupIntent?.lastSetupError {
|
|
933
874
|
resolve(Errors.createError(ErrorType.Unknown, lastSetupError))
|
|
934
875
|
} else {
|
|
935
|
-
resolve(Errors.createError(ErrorType.Unknown, error
|
|
876
|
+
resolve(Errors.createError(ErrorType.Unknown, error as? NSError))
|
|
936
877
|
}
|
|
937
878
|
return
|
|
938
879
|
}
|
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,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.CardField=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _helpers=require("../helpers");var _excluded=["onCardChange","onFocus","onBlur","cardStyle","placeholders","postalCodeEnabled","countryCode"];var _this=this,_jsxFileName="/Users/charliecruzan/stripe/stripe-react-native/src/components/CardField.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var CardFieldNative=(0,_reactNative.requireNativeComponent)('CardField');var CardField=(0,_react.forwardRef)(function(_ref,ref){var onCardChange=_ref.onCardChange,onFocus=_ref.onFocus,onBlur=_ref.onBlur,cardStyle=_ref.cardStyle,placeholders=_ref.placeholders,postalCodeEnabled=_ref.postalCodeEnabled,countryCode=_ref.countryCode,props=(0,_objectWithoutProperties2.default)(_ref,_excluded);var inputRef=(0,_react.useRef)(null);var onCardChangeHandler=(0,_react.useCallback)(function(event){var card=event.nativeEvent;var data={last4:card.last4,expiryMonth:card.expiryMonth,expiryYear:card.expiryYear,complete:card.complete,brand:card.brand,validExpiryDate:card.validExpiryDate,validNumber:card.validNumber,validCVC:card.validCVC};if(card.hasOwnProperty('postalCode')){data.postalCode=card.postalCode||'';}if(card.hasOwnProperty('number')||card.hasOwnProperty('cvc')){data.number=card.number||'';data.cvc=card.cvc||'';if(__DEV__&&onCardChange&&card.complete){console.warn("[stripe-react-native] \u26A0\uFE0F WARNING: You've enabled `dangerouslyGetFullCardDetails`, meaning full card details are being returned. Only do this if you're certain that you fulfill the necessary PCI compliance requirements. Make sure that you're not mistakenly logging or storing full card details! See the docs for details: https://stripe.com/docs/security/guide#validating-pci-compliance");}}onCardChange==null?void 0:onCardChange(data);},[onCardChange]);var onFocusHandler=(0,_react.useCallback)(function(event){var focusedField=event.nativeEvent.focusedField;if(focusedField){(0,_helpers.focusInput)(inputRef.current);onFocus==null?void 0:onFocus(focusedField);}else{onBlur==null?void 0:onBlur();}},[onFocus,onBlur]);var focus=function focus(){_reactNative.UIManager.dispatchViewManagerCommand((0,_reactNative.findNodeHandle)(inputRef.current),'focus',[]);};var blur=function blur(){_reactNative.UIManager.dispatchViewManagerCommand((0,_reactNative.findNodeHandle)(inputRef.current),'blur',[]);};var clear=function clear(){_reactNative.UIManager.dispatchViewManagerCommand((0,_reactNative.findNodeHandle)(inputRef.current),'clear',[]);};(0,_react.useImperativeHandle)(ref,function(){return{focus:focus,blur:blur,clear:clear};});(0,_react.useLayoutEffect)(function(){var inputRefValue=inputRef.current;if(inputRefValue!==null){(0,_helpers.registerInput)(inputRefValue);return function(){(0,_helpers.unregisterInput)(inputRefValue);if((0,_helpers.currentlyFocusedInput)()===inputRefValue){inputRefValue.blur();}};}return function(){};},[inputRef]);return _react.default.createElement(CardFieldNative,(0,_extends2.default)({ref:inputRef,onCardChange:onCardChangeHandler,onFocusChange:onFocusHandler,postalCodeEnabled:postalCodeEnabled!=null?postalCodeEnabled:true,countryCode:countryCode!=null?countryCode:null,cardStyle:{backgroundColor:cardStyle==null?void 0:cardStyle.backgroundColor,borderColor:cardStyle==null?void 0:cardStyle.borderColor,borderWidth:cardStyle==null?void 0:cardStyle.borderWidth,borderRadius:cardStyle==null?void 0:cardStyle.borderRadius,cursorColor:cardStyle==null?void 0:cardStyle.cursorColor,fontSize:cardStyle==null?void 0:cardStyle.fontSize,placeholderColor:cardStyle==null?void 0:cardStyle.placeholderColor,textColor:cardStyle==null?void 0:cardStyle.textColor,textErrorColor:cardStyle==null?void 0:cardStyle.textErrorColor,fontFamily:cardStyle==null?void 0:cardStyle.fontFamily},placeholders:{number:placeholders==null?void 0:placeholders.number,expiration:placeholders==null?void 0:placeholders.expiration,cvc:placeholders==null?void 0:placeholders.cvc,postalCode:placeholders==null?void 0:placeholders.postalCode}},props,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.CardField=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _helpers=require("../helpers");var _excluded=["onCardChange","onFocus","onBlur","cardStyle","placeholders","postalCodeEnabled","countryCode"];var _this=this,_jsxFileName="/Users/charliecruzan/stripe/stripe-react-native/src/components/CardField.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var CardFieldNative=(0,_reactNative.requireNativeComponent)('CardField');var CardField=(0,_react.forwardRef)(function(_ref,ref){var onCardChange=_ref.onCardChange,onFocus=_ref.onFocus,onBlur=_ref.onBlur,cardStyle=_ref.cardStyle,placeholders=_ref.placeholders,postalCodeEnabled=_ref.postalCodeEnabled,countryCode=_ref.countryCode,props=(0,_objectWithoutProperties2.default)(_ref,_excluded);var inputRef=(0,_react.useRef)(null);var onCardChangeHandler=(0,_react.useCallback)(function(event){var card=event.nativeEvent;var data={last4:card.last4,expiryMonth:card.expiryMonth,expiryYear:card.expiryYear,complete:card.complete,brand:card.brand,validExpiryDate:card.validExpiryDate,validNumber:card.validNumber,validCVC:card.validCVC};if(card.hasOwnProperty('postalCode')){data.postalCode=card.postalCode||'';}if(card.hasOwnProperty('number')||card.hasOwnProperty('cvc')){data.number=card.number||'';data.cvc=card.cvc||'';if(__DEV__&&onCardChange&&card.complete){console.warn("[stripe-react-native] \u26A0\uFE0F WARNING: You've enabled `dangerouslyGetFullCardDetails`, meaning full card details are being returned. Only do this if you're certain that you fulfill the necessary PCI compliance requirements. Make sure that you're not mistakenly logging or storing full card details! See the docs for details: https://stripe.com/docs/security/guide#validating-pci-compliance");}}onCardChange==null?void 0:onCardChange(data);},[onCardChange]);var onFocusHandler=(0,_react.useCallback)(function(event){var focusedField=event.nativeEvent.focusedField;if(focusedField){(0,_helpers.focusInput)(inputRef.current);onFocus==null?void 0:onFocus(focusedField);}else{onBlur==null?void 0:onBlur();}},[onFocus,onBlur]);var focus=function focus(){_reactNative.UIManager.dispatchViewManagerCommand((0,_reactNative.findNodeHandle)(inputRef.current),'focus',[]);};var blur=function blur(){_reactNative.UIManager.dispatchViewManagerCommand((0,_reactNative.findNodeHandle)(inputRef.current),'blur',[]);};var clear=function clear(){_reactNative.UIManager.dispatchViewManagerCommand((0,_reactNative.findNodeHandle)(inputRef.current),'clear',[]);};(0,_react.useImperativeHandle)(ref,function(){return{focus:focus,blur:blur,clear:clear};});(0,_react.useLayoutEffect)(function(){var inputRefValue=inputRef.current;if(inputRefValue!==null){(0,_helpers.registerInput)(inputRefValue);return function(){(0,_helpers.unregisterInput)(inputRefValue);if((0,_helpers.currentlyFocusedInput)()===inputRefValue){inputRefValue.blur();}};}return function(){};},[inputRef]);return _react.default.createElement(CardFieldNative,(0,_extends2.default)({ref:inputRef,onCardChange:onCardChangeHandler,onFocusChange:onFocusHandler,postalCodeEnabled:postalCodeEnabled!=null?postalCodeEnabled:true,countryCode:countryCode!=null?countryCode:null,cardStyle:{backgroundColor:cardStyle==null?void 0:cardStyle.backgroundColor,borderColor:cardStyle==null?void 0:cardStyle.borderColor,borderWidth:cardStyle==null?void 0:cardStyle.borderWidth,borderRadius:cardStyle==null?void 0:cardStyle.borderRadius,cursorColor:cardStyle==null?void 0:cardStyle.cursorColor,fontSize:cardStyle==null?void 0:cardStyle.fontSize,placeholderColor:cardStyle==null?void 0:cardStyle.placeholderColor,textColor:cardStyle==null?void 0:cardStyle.textColor,textErrorColor:cardStyle==null?void 0:cardStyle.textErrorColor,fontFamily:cardStyle==null?void 0:cardStyle.fontFamily},placeholders:{number:placeholders==null?void 0:placeholders.number,expiration:placeholders==null?void 0:placeholders.expiration,cvc:placeholders==null?void 0:placeholders.cvc,postalCode:placeholders==null?void 0:placeholders.postalCode}},props,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:179,columnNumber:7}}));});exports.CardField=CardField;
|
|
2
2
|
//# sourceMappingURL=CardField.js.map
|