@stripe/stripe-react-native 0.38.6 → 0.40.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/android/.project +0 -11
- package/android/.settings/org.eclipse.buildship.core.prefs +3 -3
- 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/PaymentSheetFragment.kt +43 -8
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +0 -60
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +3 -3
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +0 -2
- package/ios/CardFieldManager.m +1 -0
- package/ios/CardFieldView.swift +28 -39
- package/ios/CardFormManager.m +1 -0
- package/ios/StripeSdk+PaymentSheet.swift +17 -2
- package/ios/StripeSdk.swift +29 -66
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CustomerSheet.js +1 -1
- package/lib/commonjs/components/CustomerSheet.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/index.js +1 -1
- package/lib/commonjs/types/index.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/CustomerSheet.js +1 -1
- package/lib/module/components/CustomerSheet.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/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/components/CardField.d.ts +2 -0
- package/lib/typescript/src/components/CustomerSheet.d.ts +3 -3
- package/lib/typescript/src/types/PaymentSheet.d.ts +33 -3
- package/lib/typescript/src/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/CardField.tsx +2 -0
- package/src/components/CustomerSheet.tsx +3 -3
- package/src/types/PaymentSheet.ts +40 -3
- package/src/types/index.ts +1 -0
- package/stripe-react-native.podspec +1 -1
package/ios/StripeSdk.swift
CHANGED
|
@@ -5,7 +5,7 @@ import StripeFinancialConnections
|
|
|
5
5
|
import Foundation
|
|
6
6
|
|
|
7
7
|
@objc(StripeSdk)
|
|
8
|
-
class StripeSdk: RCTEventEmitter,
|
|
8
|
+
class StripeSdk: RCTEventEmitter, UIAdaptivePresentationControllerDelegate {
|
|
9
9
|
public var cardFieldView: CardFieldView? = nil
|
|
10
10
|
public var cardFormView: CardFormView? = nil
|
|
11
11
|
|
|
@@ -14,21 +14,21 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
14
14
|
internal var paymentSheet: PaymentSheet?
|
|
15
15
|
internal var paymentSheetFlowController: PaymentSheet.FlowController?
|
|
16
16
|
var paymentSheetIntentCreationCallback: ((Result<String, Error>) -> Void)?
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
var urlScheme: String? = nil
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
var confirmPaymentResolver: RCTPromiseResolveBlock? = nil
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
var confirmApplePayResolver: RCTPromiseResolveBlock? = nil
|
|
23
23
|
var confirmApplePayPaymentClientSecret: String? = nil
|
|
24
24
|
var confirmApplePaySetupClientSecret: String? = nil
|
|
25
25
|
var confirmApplePayPaymentMethod: STPPaymentMethod? = nil
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
var applePaymentAuthorizationController: PKPaymentAuthorizationViewController? = nil
|
|
28
28
|
var createPlatformPayPaymentMethodResolver: RCTPromiseResolveBlock? = nil
|
|
29
29
|
var platformPayUsesDeprecatedTokenFlow = false
|
|
30
30
|
var applePaymentMethodFlowCanBeCanceled = false
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
var confirmPaymentClientSecret: String? = nil
|
|
33
33
|
|
|
34
34
|
var shippingMethodUpdateCompletion: ((PKPaymentRequestShippingMethodUpdate) -> Void)? = nil
|
|
@@ -48,7 +48,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
48
48
|
var applePayShippingMethods: [PKShippingMethod] = []
|
|
49
49
|
var applePayShippingAddressErrors: [Error]? = nil
|
|
50
50
|
var applePayCouponCodeErrors: [Error]? = nil
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
var customerSheetConfiguration = CustomerSheet.Configuration()
|
|
53
53
|
var customerSheet: CustomerSheet? = nil
|
|
54
54
|
var customerAdapter: StripeCustomerAdapter? = nil
|
|
@@ -59,7 +59,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
59
59
|
var setSelectedPaymentOptionCallback: (() -> Void)? = nil
|
|
60
60
|
var fetchSelectedPaymentOptionCallback: ((CustomerPaymentOption?) -> Void)? = nil
|
|
61
61
|
var setupIntentClientSecretForCustomerAttachCallback: ((String) -> Void)? = nil
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
var hasEventListeners = false
|
|
64
64
|
override func startObserving() {
|
|
65
65
|
hasEventListeners = true
|
|
@@ -67,7 +67,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
67
67
|
override func stopObserving() {
|
|
68
68
|
hasEventListeners = false
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
override func supportedEvents() -> [String]! {
|
|
72
72
|
return ["onOrderTrackingCallback", "onConfirmHandlerCallback", "onCustomerAdapterFetchPaymentMethodsCallback", "onCustomerAdapterAttachPaymentMethodCallback",
|
|
73
73
|
"onCustomerAdapterDetachPaymentMethodCallback", "onCustomerAdapterSetSelectedPaymentOptionCallback", "onCustomerAdapterFetchSelectedPaymentOptionCallback",
|
|
@@ -124,10 +124,10 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
124
124
|
resolve(error)
|
|
125
125
|
return
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
preparePaymentSheetInstance(params: params, configuration: configuration, resolve: resolve)
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
@objc(intentCreationCallback:resolver:rejecter:)
|
|
132
132
|
func intentCreationCallback(result: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
133
133
|
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
@@ -174,7 +174,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
|
|
177
|
+
|
|
178
178
|
@objc(resetPaymentSheetCustomer:rejecter:)
|
|
179
179
|
func resetPaymentSheetCustomer(resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
180
180
|
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
@@ -187,7 +187,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
187
187
|
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
188
188
|
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
189
189
|
var paymentSheetViewController: UIViewController?
|
|
190
|
-
|
|
190
|
+
|
|
191
191
|
if let timeout = options["timeout"] as? Double {
|
|
192
192
|
DispatchQueue.main.asyncAfter(deadline: .now() + timeout/1000) {
|
|
193
193
|
if let paymentSheetViewController = paymentSheetViewController {
|
|
@@ -278,7 +278,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
278
278
|
err = Errors.createError(ErrorType.Failed, error as NSError?)
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
|
|
281
|
+
|
|
282
282
|
parameters.mandateData = factory.createMandateData()
|
|
283
283
|
|
|
284
284
|
return parameters
|
|
@@ -330,28 +330,28 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
330
330
|
}
|
|
331
331
|
return false
|
|
332
332
|
}()
|
|
333
|
-
|
|
333
|
+
|
|
334
334
|
if (shippingMethodUpdateCompletion == nil && shippingContactUpdateCompletion == nil && couponUpdateHandlerIsNil) {
|
|
335
335
|
resolve(Errors.createError(ErrorType.Failed, "You can use this method only after either onShippingContactSelected, onShippingMethodSelected, or onCouponCodeEntered callbacks are triggered"))
|
|
336
336
|
return
|
|
337
337
|
}
|
|
338
|
-
|
|
338
|
+
|
|
339
339
|
do {
|
|
340
340
|
applePaySummaryItems = try ApplePayUtils.buildPaymentSummaryItems(items: summaryItems as? [[String : Any]])
|
|
341
341
|
} catch {
|
|
342
342
|
resolve(Errors.createError(ErrorType.Failed, error.localizedDescription))
|
|
343
343
|
return
|
|
344
344
|
}
|
|
345
|
-
|
|
345
|
+
|
|
346
346
|
applePayShippingMethods = ApplePayUtils.buildShippingMethods(items: shippingMethods as? [[String : Any]])
|
|
347
|
-
|
|
347
|
+
|
|
348
348
|
do {
|
|
349
349
|
(applePayShippingAddressErrors, applePayCouponCodeErrors) = try ApplePayUtils.buildApplePayErrors(errorItems: errors)
|
|
350
350
|
} catch {
|
|
351
351
|
resolve(Errors.createError(ErrorType.Failed, error.localizedDescription))
|
|
352
352
|
return
|
|
353
353
|
}
|
|
354
|
-
|
|
354
|
+
|
|
355
355
|
|
|
356
356
|
shippingMethodUpdateCompletion?(PKPaymentRequestShippingMethodUpdate.init(paymentSummaryItems: applePaySummaryItems))
|
|
357
357
|
shippingContactUpdateCompletion?(PKPaymentRequestShippingContactUpdate.init(errors: applePayShippingAddressErrors, paymentSummaryItems: applePaySummaryItems, shippingMethods: applePayShippingMethods))
|
|
@@ -386,14 +386,14 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
|
|
389
|
+
|
|
390
390
|
@objc(isPlatformPaySupported:resolver:rejecter:)
|
|
391
391
|
func isPlatformPaySupported(params: NSDictionary,
|
|
392
392
|
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
393
393
|
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
394
394
|
resolve(StripeAPI.deviceSupportsApplePay())
|
|
395
395
|
}
|
|
396
|
-
|
|
396
|
+
|
|
397
397
|
@objc(createPlatformPayPaymentMethod:usesDeprecatedTokenFlow:resolver:rejecter:)
|
|
398
398
|
func createPlatformPayPaymentMethod(params: NSDictionary,
|
|
399
399
|
usesDeprecatedTokenFlow: Bool,
|
|
@@ -408,7 +408,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
408
408
|
resolve(error)
|
|
409
409
|
return
|
|
410
410
|
}
|
|
411
|
-
|
|
411
|
+
|
|
412
412
|
self.applePaySummaryItems = paymentRequest.paymentSummaryItems
|
|
413
413
|
self.applePayShippingMethods = paymentRequest.shippingMethods ?? []
|
|
414
414
|
self.applePayShippingAddressErrors = nil
|
|
@@ -431,13 +431,13 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
431
431
|
resolve(Errors.createError(ErrorType.Failed, "Invalid in-app payment request. Search the iOS logs for `NSUnderlyingError` to get more information."))
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
-
|
|
434
|
+
|
|
435
435
|
@objc(dismissPlatformPay:rejecter:)
|
|
436
436
|
func dismissPlatformPay(resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
437
437
|
let didDismiss = maybeDismissApplePay()
|
|
438
438
|
resolve(didDismiss)
|
|
439
439
|
}
|
|
440
|
-
|
|
440
|
+
|
|
441
441
|
@objc(confirmPlatformPay:params:isPaymentIntent:resolver:rejecter:)
|
|
442
442
|
func confirmPlatformPay(
|
|
443
443
|
clientSecret: String?,
|
|
@@ -475,7 +475,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
475
475
|
resolve(Errors.createError(ErrorType.Failed, "Payment not completed"))
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
|
-
|
|
478
|
+
|
|
479
479
|
func configure3dSecure(_ params: NSDictionary) {
|
|
480
480
|
let threeDSCustomizationSettings = STPPaymentHandler.shared().threeDSCustomizationSettings
|
|
481
481
|
let uiCustomization = Mappers.mapUICustomization(params)
|
|
@@ -695,7 +695,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
|
-
|
|
698
|
+
|
|
699
699
|
@objc(collectBankAccount:clientSecret:params:resolver:rejecter:)
|
|
700
700
|
func collectBankAccount(
|
|
701
701
|
isPaymentIntent: Bool,
|
|
@@ -806,14 +806,6 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
806
806
|
return
|
|
807
807
|
}
|
|
808
808
|
|
|
809
|
-
if (paymentMethodType == .FPX) {
|
|
810
|
-
let testOfflineBank = paymentMethodData?["testOfflineBank"] as? Bool
|
|
811
|
-
if (testOfflineBank == false || testOfflineBank == nil) {
|
|
812
|
-
payWithFPX(paymentIntentClientSecret)
|
|
813
|
-
return
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
|
|
817
809
|
let (error, paymentIntentParams) = createPaymentIntentParams(paymentIntentClientSecret: paymentIntentClientSecret, paymentMethodType: paymentMethodType, paymentMethodData: paymentMethodData, options: options)
|
|
818
810
|
|
|
819
811
|
if (error != nil) {
|
|
@@ -864,14 +856,14 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
864
856
|
err = Errors.createError(ErrorType.Failed, error as NSError?)
|
|
865
857
|
}
|
|
866
858
|
}
|
|
867
|
-
|
|
859
|
+
|
|
868
860
|
do {
|
|
869
861
|
parameters.paymentMethodOptions = try factory.createOptions(paymentMethodType: paymentMethodType)
|
|
870
862
|
parameters.mandateData = factory.createMandateData()
|
|
871
863
|
} catch {
|
|
872
864
|
err = Errors.createError(ErrorType.Failed, error as NSError?)
|
|
873
865
|
}
|
|
874
|
-
|
|
866
|
+
|
|
875
867
|
return parameters
|
|
876
868
|
}
|
|
877
869
|
}()
|
|
@@ -1071,7 +1063,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
1071
1063
|
}
|
|
1072
1064
|
FinancialConnections.present(withClientSecret: clientSecret, returnURL: returnURL, resolve: resolve)
|
|
1073
1065
|
}
|
|
1074
|
-
|
|
1066
|
+
|
|
1075
1067
|
@objc(configureOrderTracking:orderIdentifier:webServiceUrl:authenticationToken:resolver:rejecter:)
|
|
1076
1068
|
func configureOrderTracking(
|
|
1077
1069
|
orderTypeIdentifier: String,
|
|
@@ -1102,35 +1094,6 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
1102
1094
|
confirmPaymentResolver?(Errors.createError(ErrorType.Canceled, "FPX Payment has been canceled"))
|
|
1103
1095
|
}
|
|
1104
1096
|
|
|
1105
|
-
func payWithFPX(_ paymentIntentClientSecret: String) {
|
|
1106
|
-
let vc = STPBankSelectionViewController.init(bankMethod: .FPX)
|
|
1107
|
-
|
|
1108
|
-
vc.delegate = self
|
|
1109
|
-
|
|
1110
|
-
DispatchQueue.main.async {
|
|
1111
|
-
vc.presentationController?.delegate = self
|
|
1112
|
-
|
|
1113
|
-
let share = UIApplication.shared.delegate
|
|
1114
|
-
share?.window??.rootViewController?.present(vc, animated: true)
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
func bankSelectionViewController(_ bankViewController: STPBankSelectionViewController, didCreatePaymentMethodParams paymentMethodParams: STPPaymentMethodParams) {
|
|
1119
|
-
guard let clientSecret = confirmPaymentClientSecret else {
|
|
1120
|
-
confirmPaymentResolver?(Errors.createError(ErrorType.Failed, "Missing paymentIntentClientSecret"))
|
|
1121
|
-
return
|
|
1122
|
-
}
|
|
1123
|
-
let paymentIntentParams = STPPaymentIntentParams(clientSecret: clientSecret)
|
|
1124
|
-
paymentIntentParams.paymentMethodParams = paymentMethodParams
|
|
1125
|
-
|
|
1126
|
-
if let urlScheme = urlScheme {
|
|
1127
|
-
paymentIntentParams.returnURL = Mappers.mapToReturnURL(urlScheme: urlScheme)
|
|
1128
|
-
}
|
|
1129
|
-
let paymentHandler = STPPaymentHandler.shared()
|
|
1130
|
-
bankViewController.dismiss(animated: true)
|
|
1131
|
-
paymentHandler.confirmPayment(paymentIntentParams, with: self, completion: onCompleteConfirmPayment)
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
1097
|
func onCompleteConfirmPayment(status: STPPaymentHandlerActionStatus, paymentIntent: STPPaymentIntent?, error: NSError?) {
|
|
1135
1098
|
self.confirmPaymentClientSecret = nil
|
|
1136
1099
|
switch (status) {
|
|
@@ -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:184,columnNumber:7}}));});exports.CardField=CardField;
|
|
2
2
|
//# sourceMappingURL=CardField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CardFieldNative","requireNativeComponent","CardField","forwardRef","ref","onCardChange","onFocus","onBlur","cardStyle","placeholders","postalCodeEnabled","countryCode","props","inputRef","useRef","onCardChangeHandler","useCallback","event","card","nativeEvent","data","last4","expiryMonth","expiryYear","complete","brand","validExpiryDate","validNumber","validCVC","hasOwnProperty","postalCode","number","cvc","__DEV__","console","warn","onFocusHandler","focusedField","focusInput","current","focus","UIManager","dispatchViewManagerCommand","findNodeHandle","blur","clear","useImperativeHandle","useLayoutEffect","inputRefValue","registerInput","unregisterInput","currentlyFocusedInput","backgroundColor","borderColor","borderWidth","borderRadius","cursorColor","fontSize","placeholderColor","textColor","textErrorColor","fontFamily","expiration"],"sources":["CardField.tsx"],"sourcesContent":["import type { CardFieldInput, CardBrand } from '../types';\nimport React, {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n} from 'react';\nimport {\n AccessibilityProps,\n NativeSyntheticEvent,\n requireNativeComponent,\n UIManager,\n StyleProp,\n findNodeHandle,\n ViewStyle,\n} from 'react-native';\nimport {\n currentlyFocusedInput,\n focusInput,\n registerInput,\n unregisterInput,\n} from '../helpers';\n\nconst CardFieldNative =\n requireNativeComponent<CardFieldInput.NativeProps>('CardField');\n\n/**\n * Card Field Component Props\n */\nexport interface Props extends AccessibilityProps {\n style?: StyleProp<ViewStyle>;\n /** Controls if a postal code entry field can be displayed to the user. If true, the type of code entry shown is controlled by the set countryCode prop. Some country codes may result in no postal code entry being shown if those countries do not commonly use postal codes. If false, no postal code entry will ever be displayed. Defaults to true.*/\n postalCodeEnabled?: boolean;\n /** Controls the postal code entry shown (if the postalCodeEnabled prop is set to true). Defaults to the device's default locale. */\n countryCode?: string;\n /** Applies a disabled state such that user input is not accepted. Defaults to false. */\n disabled?: boolean;\n cardStyle?: CardFieldInput.Styles;\n placeholders?: CardFieldInput.Placeholders;\n autofocus?: boolean;\n onCardChange?(card: CardFieldInput.Details): void;\n onBlur?(): void;\n onFocus?(focusedField: CardFieldInput.FieldName | null): void;\n testID?: string;\n /** The list of preferred networks that should be used to process payments made with a co-branded card.\n * This value will only be used if your user hasn't selected a network themselves. */\n preferredNetworks?: Array<CardBrand>;\n /**\n * WARNING: If set to `true` the full card number will be returned in the `onCardChange` handler.\n * Only do this if you're certain that you fulfill the necessary PCI compliance requirements.\n * Make sure that you're not mistakenly logging or storing full card details!\n * See the docs for details: https://stripe.com/docs/security/guide#validating-pci-compliance\n */\n dangerouslyGetFullCardDetails?: boolean;\n}\n\n/**\n * Card Field Component\n *\n * @example\n * ```ts\n * <CardField\n * postalCodeEnabled={false}\n * onCardChange={(cardDetails) => {\n * console.log('card details', cardDetails);\n * setCard(cardDetails);\n * }}\n * style={{height: 50}}\n * />\n * ```\n * @param __namedParameters Props\n * @returns JSX.Element\n * @category ReactComponents\n */\nexport const CardField = forwardRef<CardFieldInput.Methods, Props>(\n (\n {\n onCardChange,\n onFocus,\n onBlur,\n cardStyle,\n placeholders,\n postalCodeEnabled,\n countryCode,\n ...props\n },\n ref\n ) => {\n const inputRef = useRef<any>(null);\n\n const onCardChangeHandler = useCallback(\n (event: NativeSyntheticEvent<CardFieldInput.Details>) => {\n const card = event.nativeEvent;\n\n const data: CardFieldInput.Details = {\n last4: card.last4,\n expiryMonth: card.expiryMonth,\n expiryYear: card.expiryYear,\n complete: card.complete,\n brand: card.brand,\n validExpiryDate: card.validExpiryDate,\n validNumber: card.validNumber,\n validCVC: card.validCVC,\n };\n\n if (card.hasOwnProperty('postalCode')) {\n data.postalCode = card.postalCode || '';\n }\n if (card.hasOwnProperty('number') || card.hasOwnProperty('cvc')) {\n data.number = card.number || '';\n data.cvc = card.cvc || '';\n if (__DEV__ && onCardChange && card.complete) {\n console.warn(\n `[stripe-react-native] ⚠️ 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`\n );\n }\n }\n onCardChange?.(data);\n },\n [onCardChange]\n );\n\n const onFocusHandler = useCallback(\n (event) => {\n const { focusedField } = event.nativeEvent;\n if (focusedField) {\n focusInput(inputRef.current);\n onFocus?.(focusedField);\n } else {\n onBlur?.();\n }\n },\n [onFocus, onBlur]\n );\n\n const focus = () => {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(inputRef.current),\n 'focus' as any,\n []\n );\n };\n\n const blur = () => {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(inputRef.current),\n 'blur' as any,\n []\n );\n };\n\n const clear = () => {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(inputRef.current),\n 'clear' as any,\n []\n );\n };\n\n useImperativeHandle(ref, () => ({\n focus,\n blur,\n clear,\n }));\n\n useLayoutEffect(() => {\n const inputRefValue = inputRef.current;\n if (inputRefValue !== null) {\n registerInput(inputRefValue);\n return () => {\n unregisterInput(inputRefValue);\n if (currentlyFocusedInput() === inputRefValue) {\n inputRefValue.blur();\n }\n };\n }\n return () => {};\n }, [inputRef]);\n\n return (\n <CardFieldNative\n ref={inputRef}\n onCardChange={onCardChangeHandler}\n onFocusChange={onFocusHandler}\n postalCodeEnabled={postalCodeEnabled ?? true}\n countryCode={countryCode ?? null}\n cardStyle={{\n backgroundColor: cardStyle?.backgroundColor,\n borderColor: cardStyle?.borderColor,\n borderWidth: cardStyle?.borderWidth,\n borderRadius: cardStyle?.borderRadius,\n cursorColor: cardStyle?.cursorColor,\n fontSize: cardStyle?.fontSize,\n placeholderColor: cardStyle?.placeholderColor,\n textColor: cardStyle?.textColor,\n textErrorColor: cardStyle?.textErrorColor,\n fontFamily: cardStyle?.fontFamily,\n }}\n placeholders={{\n number: placeholders?.number,\n expiration: placeholders?.expiration,\n cvc: placeholders?.cvc,\n postalCode: placeholders?.postalCode,\n }}\n {...props}\n />\n );\n }\n);\n"],"mappings":"qWACA,qDAOA,yCASA,mCAKoB,otCAEpB,GAAMA,gBAAe,CACnB,GAAAC,mCAAsB,EAA6B,WAAW,CAAC,CAkD1D,GAAMC,UAAS,CAAG,GAAAC,iBAAU,EACjC,cAWEC,GAAG,CACA,IAVDC,aAAY,MAAZA,YAAY,CACZC,OAAO,MAAPA,OAAO,CACPC,MAAM,MAANA,MAAM,CACNC,SAAS,MAATA,SAAS,CACTC,YAAY,MAAZA,YAAY,CACZC,iBAAiB,MAAjBA,iBAAiB,CACjBC,WAAW,MAAXA,WAAW,CACRC,KAAK,uDAIV,GAAMC,SAAQ,CAAG,GAAAC,aAAM,EAAM,IAAI,CAAC,CAElC,GAAMC,oBAAmB,CAAG,GAAAC,kBAAW,EACrC,SAACC,KAAmD,CAAK,CACvD,GAAMC,KAAI,CAAGD,KAAK,CAACE,WAAW,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,CAC7C,WAAW,CAAEC,WAAW,OAAXA,WAAW,CAAI,IAAK,CACjC,SAAS,CAAE,CACTyC,eAAe,CAAE5C,SAAS,cAATA,SAAS,CAAE4C,eAAe,CAC3CC,WAAW,CAAE7C,SAAS,cAATA,SAAS,CAAE6C,WAAW,CACnCC,WAAW,CAAE9C,SAAS,cAATA,SAAS,CAAE8C,WAAW,CACnCC,YAAY,CAAE/C,SAAS,cAATA,SAAS,CAAE+C,YAAY,CACrCC,WAAW,CAAEhD,SAAS,cAATA,SAAS,CAAEgD,WAAW,CACnCC,QAAQ,CAAEjD,SAAS,cAATA,SAAS,CAAEiD,QAAQ,CAC7BC,gBAAgB,CAAElD,SAAS,cAATA,SAAS,CAAEkD,gBAAgB,CAC7CC,SAAS,CAAEnD,SAAS,cAATA,SAAS,CAAEmD,SAAS,CAC/BC,cAAc,CAAEpD,SAAS,cAATA,SAAS,CAAEoD,cAAc,CACzCC,UAAU,CAAErD,SAAS,cAATA,SAAS,CAAEqD,UACzB,CAAE,CACF,YAAY,CAAE,CACZ9B,MAAM,CAAEtB,YAAY,cAAZA,YAAY,CAAEsB,MAAM,CAC5B+B,UAAU,CAAErD,YAAY,cAAZA,YAAY,CAAEqD,UAAU,CACpC9B,GAAG,CAAEvB,YAAY,cAAZA,YAAY,CAAEuB,GAAG,CACtBF,UAAU,CAAErB,YAAY,cAAZA,YAAY,CAAEqB,UAC5B,CAAE,EACElB,KAAK,gFACT,CAEN,CAAC,CACF,CAAC"}
|
|
1
|
+
{"version":3,"names":["CardFieldNative","requireNativeComponent","CardField","forwardRef","ref","onCardChange","onFocus","onBlur","cardStyle","placeholders","postalCodeEnabled","countryCode","props","inputRef","useRef","onCardChangeHandler","useCallback","event","card","nativeEvent","data","last4","expiryMonth","expiryYear","complete","brand","validExpiryDate","validNumber","validCVC","hasOwnProperty","postalCode","number","cvc","__DEV__","console","warn","onFocusHandler","focusedField","focusInput","current","focus","UIManager","dispatchViewManagerCommand","findNodeHandle","blur","clear","useImperativeHandle","useLayoutEffect","inputRefValue","registerInput","unregisterInput","currentlyFocusedInput","backgroundColor","borderColor","borderWidth","borderRadius","cursorColor","fontSize","placeholderColor","textColor","textErrorColor","fontFamily","expiration"],"sources":["CardField.tsx"],"sourcesContent":["import type { CardFieldInput, CardBrand } from '../types';\nimport React, {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n} from 'react';\nimport {\n AccessibilityProps,\n NativeSyntheticEvent,\n requireNativeComponent,\n UIManager,\n StyleProp,\n findNodeHandle,\n ViewStyle,\n} from 'react-native';\nimport {\n currentlyFocusedInput,\n focusInput,\n registerInput,\n unregisterInput,\n} from '../helpers';\n\nconst CardFieldNative =\n requireNativeComponent<CardFieldInput.NativeProps>('CardField');\n\n/**\n * Card Field Component Props\n */\nexport interface Props extends AccessibilityProps {\n style?: StyleProp<ViewStyle>;\n /** Controls if a postal code entry field can be displayed to the user. If true, the type of code entry shown is controlled by the set countryCode prop. Some country codes may result in no postal code entry being shown if those countries do not commonly use postal codes. If false, no postal code entry will ever be displayed. Defaults to true.*/\n postalCodeEnabled?: boolean;\n /** Controls the postal code entry shown (if the postalCodeEnabled prop is set to true). Defaults to the device's default locale. */\n countryCode?: string;\n /** Applies a disabled state such that user input is not accepted. Defaults to false. */\n disabled?: boolean;\n cardStyle?: CardFieldInput.Styles;\n placeholders?: CardFieldInput.Placeholders;\n autofocus?: boolean;\n onCardChange?(card: CardFieldInput.Details): void;\n onBlur?(): void;\n onFocus?(focusedField: CardFieldInput.FieldName | null): void;\n testID?: string;\n /** The list of preferred networks that should be used to process payments made with a co-branded card.\n * This value will only be used if your user hasn't selected a network themselves. */\n preferredNetworks?: Array<CardBrand>;\n /** The account (if any) for which the funds of the intent are intended. */\n onBehalfOf?: string;\n /**\n * WARNING: If set to `true` the full card number will be returned in the `onCardChange` handler.\n * Only do this if you're certain that you fulfill the necessary PCI compliance requirements.\n * Make sure that you're not mistakenly logging or storing full card details!\n * See the docs for details: https://stripe.com/docs/security/guide#validating-pci-compliance\n */\n dangerouslyGetFullCardDetails?: boolean;\n}\n\n/**\n * Card Field Component\n *\n * @example\n * ```ts\n * <CardField\n * postalCodeEnabled={false}\n * onCardChange={(cardDetails) => {\n * console.log('card details', cardDetails);\n * setCard(cardDetails);\n * }}\n * style={{height: 50}}\n * />\n * ```\n * @param __namedParameters Props\n * @returns JSX.Element\n * @category ReactComponents\n */\nexport const CardField = forwardRef<CardFieldInput.Methods, Props>(\n (\n {\n onCardChange,\n onFocus,\n onBlur,\n cardStyle,\n placeholders,\n postalCodeEnabled,\n countryCode,\n ...props\n },\n ref\n ) => {\n const inputRef = useRef<any>(null);\n\n const onCardChangeHandler = useCallback(\n (event: NativeSyntheticEvent<CardFieldInput.Details>) => {\n const card = event.nativeEvent;\n\n const data: CardFieldInput.Details = {\n last4: card.last4,\n expiryMonth: card.expiryMonth,\n expiryYear: card.expiryYear,\n complete: card.complete,\n brand: card.brand,\n validExpiryDate: card.validExpiryDate,\n validNumber: card.validNumber,\n validCVC: card.validCVC,\n };\n\n if (card.hasOwnProperty('postalCode')) {\n data.postalCode = card.postalCode || '';\n }\n if (card.hasOwnProperty('number') || card.hasOwnProperty('cvc')) {\n data.number = card.number || '';\n data.cvc = card.cvc || '';\n if (__DEV__ && onCardChange && card.complete) {\n console.warn(\n `[stripe-react-native] ⚠️ 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`\n );\n }\n }\n onCardChange?.(data);\n },\n [onCardChange]\n );\n\n const onFocusHandler = useCallback(\n (event) => {\n const { focusedField } = event.nativeEvent;\n if (focusedField) {\n focusInput(inputRef.current);\n onFocus?.(focusedField);\n } else {\n onBlur?.();\n }\n },\n [onFocus, onBlur]\n );\n\n const focus = () => {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(inputRef.current),\n 'focus' as any,\n []\n );\n };\n\n const blur = () => {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(inputRef.current),\n 'blur' as any,\n []\n );\n };\n\n const clear = () => {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(inputRef.current),\n 'clear' as any,\n []\n );\n };\n\n useImperativeHandle(ref, () => ({\n focus,\n blur,\n clear,\n }));\n\n useLayoutEffect(() => {\n const inputRefValue = inputRef.current;\n if (inputRefValue !== null) {\n registerInput(inputRefValue);\n return () => {\n unregisterInput(inputRefValue);\n if (currentlyFocusedInput() === inputRefValue) {\n inputRefValue.blur();\n }\n };\n }\n return () => {};\n }, [inputRef]);\n\n return (\n <CardFieldNative\n ref={inputRef}\n onCardChange={onCardChangeHandler}\n onFocusChange={onFocusHandler}\n postalCodeEnabled={postalCodeEnabled ?? true}\n countryCode={countryCode ?? null}\n cardStyle={{\n backgroundColor: cardStyle?.backgroundColor,\n borderColor: cardStyle?.borderColor,\n borderWidth: cardStyle?.borderWidth,\n borderRadius: cardStyle?.borderRadius,\n cursorColor: cardStyle?.cursorColor,\n fontSize: cardStyle?.fontSize,\n placeholderColor: cardStyle?.placeholderColor,\n textColor: cardStyle?.textColor,\n textErrorColor: cardStyle?.textErrorColor,\n fontFamily: cardStyle?.fontFamily,\n }}\n placeholders={{\n number: placeholders?.number,\n expiration: placeholders?.expiration,\n cvc: placeholders?.cvc,\n postalCode: placeholders?.postalCode,\n }}\n {...props}\n />\n );\n }\n);\n"],"mappings":"qWACA,qDAOA,yCASA,mCAKoB,otCAEpB,GAAMA,gBAAe,CACnB,GAAAC,mCAAsB,EAA6B,WAAW,CAAC,CAoD1D,GAAMC,UAAS,CAAG,GAAAC,iBAAU,EACjC,cAWEC,GAAG,CACA,IAVDC,aAAY,MAAZA,YAAY,CACZC,OAAO,MAAPA,OAAO,CACPC,MAAM,MAANA,MAAM,CACNC,SAAS,MAATA,SAAS,CACTC,YAAY,MAAZA,YAAY,CACZC,iBAAiB,MAAjBA,iBAAiB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C,CACjB,CAAC,CAAE,CAAC/B,QAAQ,CAAC,CAAC,CAEd,MACE,8BAAC,eAAe,wBACd,GAAG,CAAEA,QAAS,CACd,YAAY,CAAEE,mBAAoB,CAClC,aAAa,CAAEqB,cAAe,CAC9B,iBAAiB,CAAE1B,iBAAiB,OAAjBA,iBAAiB,CAAI,IAAK,CAC7C,WAAW,CAAEC,WAAW,OAAXA,WAAW,CAAI,IAAK,CACjC,SAAS,CAAE,CACTyC,eAAe,CAAE5C,SAAS,cAATA,SAAS,CAAE4C,eAAe,CAC3CC,WAAW,CAAE7C,SAAS,cAATA,SAAS,CAAE6C,WAAW,CACnCC,WAAW,CAAE9C,SAAS,cAATA,SAAS,CAAE8C,WAAW,CACnCC,YAAY,CAAE/C,SAAS,cAATA,SAAS,CAAE+C,YAAY,CACrCC,WAAW,CAAEhD,SAAS,cAATA,SAAS,CAAEgD,WAAW,CACnCC,QAAQ,CAAEjD,SAAS,cAATA,SAAS,CAAEiD,QAAQ,CAC7BC,gBAAgB,CAAElD,SAAS,cAATA,SAAS,CAAEkD,gBAAgB,CAC7CC,SAAS,CAAEnD,SAAS,cAATA,SAAS,CAAEmD,SAAS,CAC/BC,cAAc,CAAEpD,SAAS,cAATA,SAAS,CAAEoD,cAAc,CACzCC,UAAU,CAAErD,SAAS,cAATA,SAAS,CAAEqD,UACzB,CAAE,CACF,YAAY,CAAE,CACZ9B,MAAM,CAAEtB,YAAY,cAAZA,YAAY,CAAEsB,MAAM,CAC5B+B,UAAU,CAAErD,YAAY,cAAZA,YAAY,CAAEqD,UAAU,CACpC9B,GAAG,CAAEvB,YAAY,cAAZA,YAAY,CAAEuB,GAAG,CACtBF,UAAU,CAAErB,YAAY,cAAZA,YAAY,CAAEqB,UAC5B,CAAE,EACElB,KAAK,gFACT,CAEN,CAAC,CACF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.CustomerSheet=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _NativeStripeSdk=_interopRequireDefault(require("../NativeStripeSdk"));var eventEmitter=new _reactNative.NativeEventEmitter(_reactNative.NativeModules.StripeSdk);var fetchPaymentMethodsCallback=null;var attachPaymentMethodCallback=null;var detachPaymentMethodCallback=null;var setSelectedPaymentOptionCallback=null;var fetchSelectedPaymentOptionCallback=null;var setupIntentClientSecretForCustomerAttachCallback=null;var initialize=function(){var _ref=(0,_asyncToGenerator2.default)(function*(params){var customerAdapterOverrides={};if(params.customerAdapter){customerAdapterOverrides=configureCustomerAdapterEventListeners(params.customerAdapter);}try{var _yield$NativeStripeSd=yield _NativeStripeSdk.default.initCustomerSheet(params,customerAdapterOverrides),error=_yield$NativeStripeSd.error;if(error){return{error:error};}return{};}catch(error){return{error:error};}});return function initialize(_x){return _ref.apply(this,arguments);};}();var configureCustomerAdapterEventListeners=function configureCustomerAdapterEventListeners(customerAdapter){if(customerAdapter.fetchPaymentMethods){var _fetchPaymentMethodsC;(_fetchPaymentMethodsC=fetchPaymentMethodsCallback)==null?void 0:_fetchPaymentMethodsC.remove();fetchPaymentMethodsCallback=eventEmitter.addListener('onCustomerAdapterFetchPaymentMethodsCallback',(0,_asyncToGenerator2.default)(function*(){if(customerAdapter.fetchPaymentMethods){var paymentMethods=yield customerAdapter.fetchPaymentMethods();yield _NativeStripeSdk.default.customerAdapterFetchPaymentMethodsCallback(paymentMethods);}else{throw new Error('[@stripe/stripe-react-native] Tried to call `fetchPaymentMethods` on your CustomerAdapter, but no matching method was found.');}}));}if(customerAdapter.attachPaymentMethod){var _attachPaymentMethodC;(_attachPaymentMethodC=attachPaymentMethodCallback)==null?void 0:_attachPaymentMethodC.remove();attachPaymentMethodCallback=eventEmitter.addListener('onCustomerAdapterAttachPaymentMethodCallback',function(){var _ref4=(0,_asyncToGenerator2.default)(function*(_ref3){var paymentMethodId=_ref3.paymentMethodId;if(customerAdapter.attachPaymentMethod){var paymentMethod=yield customerAdapter.attachPaymentMethod(paymentMethodId);yield _NativeStripeSdk.default.customerAdapterAttachPaymentMethodCallback(paymentMethod);}else{throw new Error('[@stripe/stripe-react-native] Tried to call `attachPaymentMethod` on your CustomerAdapter, but no matching method was found.');}});return function(_x2){return _ref4.apply(this,arguments);};}());}if(customerAdapter.detachPaymentMethod){var _detachPaymentMethodC;(_detachPaymentMethodC=detachPaymentMethodCallback)==null?void 0:_detachPaymentMethodC.remove();detachPaymentMethodCallback=eventEmitter.addListener('onCustomerAdapterDetachPaymentMethodCallback',function(){var _ref6=(0,_asyncToGenerator2.default)(function*(_ref5){var paymentMethodId=_ref5.paymentMethodId;if(customerAdapter.detachPaymentMethod){var paymentMethod=yield customerAdapter.detachPaymentMethod(paymentMethodId);yield _NativeStripeSdk.default.customerAdapterDetachPaymentMethodCallback(paymentMethod);}else{throw new Error('[@stripe/stripe-react-native] Tried to call `detachPaymentMethod` on your CustomerAdapter, but no matching method was found.');}});return function(_x3){return _ref6.apply(this,arguments);};}());}if(customerAdapter.setSelectedPaymentOption){var _setSelectedPaymentOp;(_setSelectedPaymentOp=setSelectedPaymentOptionCallback)==null?void 0:_setSelectedPaymentOp.remove();setSelectedPaymentOptionCallback=eventEmitter.addListener('onCustomerAdapterSetSelectedPaymentOptionCallback',function(){var _ref8=(0,_asyncToGenerator2.default)(function*(_ref7){var paymentOption=_ref7.paymentOption;if(customerAdapter.setSelectedPaymentOption){yield customerAdapter.setSelectedPaymentOption(paymentOption);yield _NativeStripeSdk.default.customerAdapterSetSelectedPaymentOptionCallback();}else{throw new Error('[@stripe/stripe-react-native] Tried to call `setSelectedPaymentOption` on your CustomerAdapter, but no matching method was found.');}});return function(_x4){return _ref8.apply(this,arguments);};}());}if(customerAdapter.fetchSelectedPaymentOption){var _fetchSelectedPayment;(_fetchSelectedPayment=fetchSelectedPaymentOptionCallback)==null?void 0:_fetchSelectedPayment.remove();fetchSelectedPaymentOptionCallback=eventEmitter.addListener('onCustomerAdapterFetchSelectedPaymentOptionCallback',(0,_asyncToGenerator2.default)(function*(){if(customerAdapter.fetchSelectedPaymentOption){var paymentOption=yield customerAdapter.fetchSelectedPaymentOption();yield _NativeStripeSdk.default.customerAdapterFetchSelectedPaymentOptionCallback(paymentOption);}else{throw new Error('[@stripe/stripe-react-native] Tried to call `fetchSelectedPaymentOption` on your CustomerAdapter, but no matching method was found.');}}));}if(customerAdapter.setupIntentClientSecretForCustomerAttach){var _setupIntentClientSec;(_setupIntentClientSec=setupIntentClientSecretForCustomerAttachCallback)==null?void 0:_setupIntentClientSec.remove();setupIntentClientSecretForCustomerAttachCallback=eventEmitter.addListener('onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback',(0,_asyncToGenerator2.default)(function*(){if(customerAdapter.setupIntentClientSecretForCustomerAttach){var clientSecret=yield customerAdapter.setupIntentClientSecretForCustomerAttach();yield _NativeStripeSdk.default.customerAdapterSetupIntentClientSecretForCustomerAttachCallback(clientSecret);}else{throw new Error('[@stripe/stripe-react-native] Tried to call `setupIntentClientSecretForCustomerAttach` on your CustomerAdapter, but no matching method was found.');}}));}return{fetchPaymentMethods:!!customerAdapter.fetchPaymentMethods,attachPaymentMethod:!!customerAdapter.attachPaymentMethod,detachPaymentMethod:!!customerAdapter.detachPaymentMethod,setSelectedPaymentOption:!!customerAdapter.setSelectedPaymentOption,fetchSelectedPaymentOption:!!customerAdapter.fetchSelectedPaymentOption,setupIntentClientSecretForCustomerAttach:!!customerAdapter.setupIntentClientSecretForCustomerAttach};};var present=function(){var _ref11=(0,_asyncToGenerator2.default)(function*(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};try{return yield _NativeStripeSdk.default.presentCustomerSheet(params);}catch(error){return{error:error};}});return function present(){return _ref11.apply(this,arguments);};}();var retrievePaymentOptionSelection=function(){var _ref12=(0,_asyncToGenerator2.default)(function*(){try{return yield _NativeStripeSdk.default.retrieveCustomerSheetPaymentOptionSelection();}catch(error){return{error:error};}});return function retrievePaymentOptionSelection(){return _ref12.apply(this,arguments);};}();function Component(_ref13){var visible=_ref13.visible,presentationStyle=_ref13.presentationStyle,animationStyle=_ref13.animationStyle,style=_ref13.style,appearance=_ref13.appearance,setupIntentClientSecret=_ref13.setupIntentClientSecret,customerId=_ref13.customerId,customerEphemeralKeySecret=_ref13.customerEphemeralKeySecret,merchantDisplayName=_ref13.merchantDisplayName,headerTextForSelectionScreen=_ref13.headerTextForSelectionScreen,defaultBillingDetails=_ref13.defaultBillingDetails,billingDetailsCollectionConfiguration=_ref13.billingDetailsCollectionConfiguration,returnURL=_ref13.returnURL,removeSavedPaymentMethodMessage=_ref13.removeSavedPaymentMethodMessage,applePayEnabled=_ref13.applePayEnabled,googlePayEnabled=_ref13.googlePayEnabled,timeout=_ref13.timeout,onResult=_ref13.onResult,customerAdapter=_ref13.customerAdapter;_react.default.useEffect(function(){if(visible){initialize({style:style,appearance:appearance,setupIntentClientSecret:setupIntentClientSecret,customerId:customerId,customerEphemeralKeySecret:customerEphemeralKeySecret,merchantDisplayName:merchantDisplayName,headerTextForSelectionScreen:headerTextForSelectionScreen,defaultBillingDetails:defaultBillingDetails,billingDetailsCollectionConfiguration:billingDetailsCollectionConfiguration,returnURL:returnURL,removeSavedPaymentMethodMessage:removeSavedPaymentMethodMessage,applePayEnabled:applePayEnabled,googlePayEnabled:googlePayEnabled,customerAdapter:customerAdapter}).then(function(initResult){if(initResult.error){onResult(initResult);}else{present({timeout:timeout,presentationStyle:presentationStyle,animationStyle:animationStyle}).then(function(presentResult){onResult(presentResult);});}});}},[visible]);return null;}var CustomerSheet={Component:Component,initialize:initialize,present:present,retrievePaymentOptionSelection:retrievePaymentOptionSelection};exports.CustomerSheet=CustomerSheet;
|
|
2
2
|
//# sourceMappingURL=CustomerSheet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["eventEmitter","NativeEventEmitter","NativeModules","StripeSdk","fetchPaymentMethodsCallback","attachPaymentMethodCallback","detachPaymentMethodCallback","setSelectedPaymentOptionCallback","fetchSelectedPaymentOptionCallback","setupIntentClientSecretForCustomerAttachCallback","initialize","params","customerAdapterOverrides","customerAdapter","configureCustomerAdapterEventListeners","NativeStripeSdk","initCustomerSheet","error","fetchPaymentMethods","remove","addListener","paymentMethods","customerAdapterFetchPaymentMethodsCallback","Error","attachPaymentMethod","paymentMethodId","paymentMethod","customerAdapterAttachPaymentMethodCallback","detachPaymentMethod","customerAdapterDetachPaymentMethodCallback","setSelectedPaymentOption","paymentOption","customerAdapterSetSelectedPaymentOptionCallback","fetchSelectedPaymentOption","customerAdapterFetchSelectedPaymentOptionCallback","setupIntentClientSecretForCustomerAttach","clientSecret","customerAdapterSetupIntentClientSecretForCustomerAttachCallback","present","presentCustomerSheet","retrievePaymentOptionSelection","retrieveCustomerSheetPaymentOptionSelection","CustomerSheet","visible","presentationStyle","animationStyle","style","appearance","setupIntentClientSecret","customerId","customerEphemeralKeySecret","merchantDisplayName","headerTextForSelectionScreen","defaultBillingDetails","billingDetailsCollectionConfiguration","returnURL","removeSavedPaymentMethodMessage","applePayEnabled","googlePayEnabled","timeout","onResult","React","useEffect","then","initResult","presentResult","CustomerSheetBeta"],"sources":["CustomerSheet.tsx"],"sourcesContent":["import React from 'react';\nimport {\n NativeEventEmitter,\n NativeModules,\n EmitterSubscription,\n} from 'react-native';\nimport NativeStripeSdk from '../NativeStripeSdk';\nimport type {\n CustomerSheetInitParams,\n CustomerSheetPresentParams,\n CustomerSheetResult,\n CustomerSheetError,\n StripeError,\n CustomerAdapter,\n} from '../types';\n\nconst eventEmitter = new NativeEventEmitter(NativeModules.StripeSdk);\nlet fetchPaymentMethodsCallback: EmitterSubscription | null = null;\nlet attachPaymentMethodCallback: EmitterSubscription | null = null;\nlet detachPaymentMethodCallback: EmitterSubscription | null = null;\nlet setSelectedPaymentOptionCallback: EmitterSubscription | null = null;\nlet fetchSelectedPaymentOptionCallback: EmitterSubscription | null = null;\nlet setupIntentClientSecretForCustomerAttachCallback: EmitterSubscription | null =\n null;\n\n/** Initialize an instance of Customer Sheet with your desired configuration. */\nconst initialize = async (\n params: CustomerSheetInitParams\n): Promise<{ error?: StripeError<CustomerSheetError> }> => {\n let customerAdapterOverrides = {};\n if (params.customerAdapter) {\n customerAdapterOverrides = configureCustomerAdapterEventListeners(\n params.customerAdapter\n );\n }\n\n try {\n const { error } = await NativeStripeSdk.initCustomerSheet(\n params,\n customerAdapterOverrides\n );\n if (error) {\n return { error };\n }\n return {};\n } catch (error: any) {\n return {\n error,\n };\n }\n};\n\nconst configureCustomerAdapterEventListeners = (\n customerAdapter: CustomerAdapter\n): { [Property in keyof CustomerAdapter]: boolean } => {\n if (customerAdapter.fetchPaymentMethods) {\n fetchPaymentMethodsCallback?.remove();\n fetchPaymentMethodsCallback = eventEmitter.addListener(\n 'onCustomerAdapterFetchPaymentMethodsCallback',\n async () => {\n if (customerAdapter.fetchPaymentMethods) {\n const paymentMethods = await customerAdapter.fetchPaymentMethods();\n await NativeStripeSdk.customerAdapterFetchPaymentMethodsCallback(\n paymentMethods\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `fetchPaymentMethods` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.attachPaymentMethod) {\n attachPaymentMethodCallback?.remove();\n attachPaymentMethodCallback = eventEmitter.addListener(\n 'onCustomerAdapterAttachPaymentMethodCallback',\n async ({ paymentMethodId }: { paymentMethodId: string }) => {\n if (customerAdapter.attachPaymentMethod) {\n const paymentMethod = await customerAdapter.attachPaymentMethod(\n paymentMethodId\n );\n await NativeStripeSdk.customerAdapterAttachPaymentMethodCallback(\n paymentMethod\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `attachPaymentMethod` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.detachPaymentMethod) {\n detachPaymentMethodCallback?.remove();\n detachPaymentMethodCallback = eventEmitter.addListener(\n 'onCustomerAdapterDetachPaymentMethodCallback',\n async ({ paymentMethodId }: { paymentMethodId: string }) => {\n if (customerAdapter.detachPaymentMethod) {\n const paymentMethod = await customerAdapter.detachPaymentMethod(\n paymentMethodId\n );\n await NativeStripeSdk.customerAdapterDetachPaymentMethodCallback(\n paymentMethod\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `detachPaymentMethod` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.setSelectedPaymentOption) {\n setSelectedPaymentOptionCallback?.remove();\n setSelectedPaymentOptionCallback = eventEmitter.addListener(\n 'onCustomerAdapterSetSelectedPaymentOptionCallback',\n async ({ paymentOption }: { paymentOption: string }) => {\n if (customerAdapter.setSelectedPaymentOption) {\n await customerAdapter.setSelectedPaymentOption(paymentOption);\n await NativeStripeSdk.customerAdapterSetSelectedPaymentOptionCallback();\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `setSelectedPaymentOption` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.fetchSelectedPaymentOption) {\n fetchSelectedPaymentOptionCallback?.remove();\n fetchSelectedPaymentOptionCallback = eventEmitter.addListener(\n 'onCustomerAdapterFetchSelectedPaymentOptionCallback',\n async () => {\n if (customerAdapter.fetchSelectedPaymentOption) {\n const paymentOption =\n await customerAdapter.fetchSelectedPaymentOption();\n await NativeStripeSdk.customerAdapterFetchSelectedPaymentOptionCallback(\n paymentOption\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `fetchSelectedPaymentOption` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.setupIntentClientSecretForCustomerAttach) {\n setupIntentClientSecretForCustomerAttachCallback?.remove();\n setupIntentClientSecretForCustomerAttachCallback = eventEmitter.addListener(\n 'onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback',\n async () => {\n if (customerAdapter.setupIntentClientSecretForCustomerAttach) {\n const clientSecret =\n await customerAdapter.setupIntentClientSecretForCustomerAttach();\n await NativeStripeSdk.customerAdapterSetupIntentClientSecretForCustomerAttachCallback(\n clientSecret\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `setupIntentClientSecretForCustomerAttach` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n return {\n fetchPaymentMethods: !!customerAdapter.fetchPaymentMethods,\n attachPaymentMethod: !!customerAdapter.attachPaymentMethod,\n detachPaymentMethod: !!customerAdapter.detachPaymentMethod,\n setSelectedPaymentOption: !!customerAdapter.setSelectedPaymentOption,\n fetchSelectedPaymentOption: !!customerAdapter.fetchSelectedPaymentOption,\n setupIntentClientSecretForCustomerAttach:\n !!customerAdapter.setupIntentClientSecretForCustomerAttach,\n };\n};\n\n/** Launches the Customer Sheet UI. */\nconst present = async (\n params: CustomerSheetPresentParams = {}\n): Promise<CustomerSheetResult> => {\n try {\n return await NativeStripeSdk.presentCustomerSheet(params);\n } catch (error: any) {\n return {\n error,\n };\n }\n};\n\n/**\n * You can use this to obtain the selected payment method without presenting the CustomerSheet.\n * This will return an error if you have not called `.initialize`\n */\nconst retrievePaymentOptionSelection =\n async (): Promise<CustomerSheetResult> => {\n try {\n return await NativeStripeSdk.retrieveCustomerSheetPaymentOptionSelection();\n } catch (error: any) {\n return {\n error,\n };\n }\n };\n\n/**\n * Props\n */\nexport type Props = {\n /** Whether the sheet is visible. Defaults to false. */\n visible: boolean;\n /** Called when the user submits, dismisses, or cancels the sheet, or when an error occurs. */\n onResult: (result: CustomerSheetResult) => void;\n} & CustomerSheetInitParams &\n CustomerSheetPresentParams;\n\n/**\n * A component wrapper around the Customer Sheet functions. Upon passing `true` to the `visible` prop,\n * Customer Sheet will call `initialize` and `present`, and the result(s) will be passed through to the\n * onResult callback.\n *\n * @example\n * ```ts\n * const [selectedPaymentOption, setSelectedPaymentOption] = React.useState(null);\n * const [customerSheetVisible, setCustomerSheetVisible] = React.useState(false);\n *\n * return (\n * <CustomerSheet\n * visible={customerSheetVisible}\n * customerEphemeralKeySecret={ephemeralKeySecret}\n * customerId={customer}\n * returnURL={'stripe-example://stripe-redirect'}\n * onResult={({ error, paymentOption, paymentMethod }) => {\n * setCustomerSheetVisible(false);\n * if (error) {\n * Alert.alert(error.code, error.localizedMessage);\n * }\n * if (paymentOption) {\n * setSelectedPaymentOption(paymentOption);\n * console.log(JSON.stringify(paymentOption, null, 2));\n * }\n * if (paymentMethod) {\n * console.log(JSON.stringify(paymentMethod, null, 2));\n * }\n * }}\n * />\n * );\n * ```\n * @param __namedParameters Props\n * @returns JSX.Element\n * @category ReactComponents\n */\nfunction CustomerSheet({\n visible,\n presentationStyle,\n animationStyle,\n style,\n appearance,\n setupIntentClientSecret,\n customerId,\n customerEphemeralKeySecret,\n merchantDisplayName,\n headerTextForSelectionScreen,\n defaultBillingDetails,\n billingDetailsCollectionConfiguration,\n returnURL,\n removeSavedPaymentMethodMessage,\n applePayEnabled,\n googlePayEnabled,\n timeout,\n onResult,\n customerAdapter,\n}: Props) {\n React.useEffect(() => {\n if (visible) {\n initialize({\n style,\n appearance,\n setupIntentClientSecret,\n customerId,\n customerEphemeralKeySecret,\n merchantDisplayName,\n headerTextForSelectionScreen,\n defaultBillingDetails,\n billingDetailsCollectionConfiguration,\n returnURL,\n removeSavedPaymentMethodMessage,\n applePayEnabled,\n googlePayEnabled,\n customerAdapter,\n }).then((initResult) => {\n if (initResult.error) {\n onResult(initResult);\n } else {\n present({\n timeout,\n presentationStyle,\n animationStyle,\n }).then((presentResult) => {\n onResult(presentResult);\n });\n }\n });\n }\n // Only run this hook when visible prop changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [visible]);\n\n return null;\n}\n\n/**\n * The Customer Sheet is a prebuilt UI component that lets your customers manage their saved payment methods.\n */\nexport const CustomerSheetBeta = {\n CustomerSheet,\n initialize,\n present,\n retrievePaymentOptionSelection,\n};\n"],"mappings":"+QAAA,oDACA,yCAKA,2EAUA,GAAMA,aAAY,CAAG,GAAIC,gCAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC,CACpE,GAAIC,4BAAuD,CAAG,IAAI,CAClE,GAAIC,4BAAuD,CAAG,IAAI,CAClE,GAAIC,4BAAuD,CAAG,IAAI,CAClE,GAAIC,iCAA4D,CAAG,IAAI,CACvE,GAAIC,mCAA8D,CAAG,IAAI,CACzE,GAAIC,iDAA4E,CAC9E,IAAI,CAGN,GAAMC,WAAU,oDAAG,UACjBC,MAA+B,CAC0B,CACzD,GAAIC,yBAAwB,CAAG,CAAC,CAAC,CACjC,GAAID,MAAM,CAACE,eAAe,CAAE,CAC1BD,wBAAwB,CAAGE,sCAAsC,CAC/DH,MAAM,CAACE,eAAe,CACvB,CACH,CAEA,GAAI,CACF,+BAAwBE,yBAAe,CAACC,iBAAiB,CACvDL,MAAM,CACNC,wBAAwB,CACzB,CAHOK,KAAK,uBAALA,KAAK,CAIb,GAAIA,KAAK,CAAE,CACT,MAAO,CAAEA,KAAK,CAALA,KAAM,CAAC,CAClB,CACA,MAAO,CAAC,CAAC,CACX,CAAE,MAAOA,KAAU,CAAE,CACnB,MAAO,CACLA,KAAK,CAALA,KACF,CAAC,CACH,CACF,CAAC,iBAxBKP,WAAU,4CAwBf,CAED,GAAMI,uCAAsC,CAAG,QAAzCA,uCAAsC,CAC1CD,eAAgC,CACqB,CACrD,GAAIA,eAAe,CAACK,mBAAmB,CAAE,2BACvC,uBAAAd,2BAA2B,eAA3B,sBAA6Be,MAAM,EAAE,CACrCf,2BAA2B,CAAGJ,YAAY,CAACoB,WAAW,CACpD,8CAA8C,gCAC9C,WAAY,CACV,GAAIP,eAAe,CAACK,mBAAmB,CAAE,CACvC,GAAMG,eAAc,MAASR,gBAAe,CAACK,mBAAmB,EAAE,CAClE,KAAMH,yBAAe,CAACO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O,CAAE,CACXjC,UAAU,CAAC,CACToC,KAAK,CAALA,KAAK,CACLC,UAAU,CAAVA,UAAU,CACVC,uBAAuB,CAAvBA,uBAAuB,CACvBC,UAAU,CAAVA,UAAU,CACVC,0BAA0B,CAA1BA,0BAA0B,CAC1BC,mBAAmB,CAAnBA,mBAAmB,CACnBC,4BAA4B,CAA5BA,4BAA4B,CAC5BC,qBAAqB,CAArBA,qBAAqB,CACrBC,qCAAqC,CAArCA,qCAAqC,CACrCC,SAAS,CAATA,SAAS,CACTC,+BAA+B,CAA/BA,+BAA+B,CAC/BC,eAAe,CAAfA,eAAe,CACfC,gBAAgB,CAAhBA,gBAAgB,CAChB7C,eAAe,CAAfA,eACF,CAAC,CAAC,CAACkD,IAAI,CAAC,SAACC,UAAU,CAAK,CACtB,GAAIA,UAAU,CAAC/C,KAAK,CAAE,CACpB2C,QAAQ,CAACI,UAAU,CAAC,CACtB,CAAC,IAAM,CACL1B,OAAO,CAAC,CACNqB,OAAO,CAAPA,OAAO,CACPf,iBAAiB,CAAjBA,iBAAiB,CACjBC,cAAc,CAAdA,cACF,CAAC,CAAC,CAACkB,IAAI,CAAC,SAACE,aAAa,CAAK,CACzBL,QAAQ,CAACK,aAAa,CAAC,CACzB,CAAC,CAAC,CACJ,CACF,CAAC,CAAC,CACJ,CAGF,CAAC,CAAE,CAACtB,OAAO,CAAC,CAAC,CAEb,MAAO,KAAI,CACb,CAKO,GAAMuB,kBAAiB,CAAG,CAC/BxB,aAAa,CAAbA,aAAa,CACbhC,UAAU,CAAVA,UAAU,CACV4B,OAAO,CAAPA,OAAO,CACPE,8BAA8B,CAA9BA,8BACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"names":["eventEmitter","NativeEventEmitter","NativeModules","StripeSdk","fetchPaymentMethodsCallback","attachPaymentMethodCallback","detachPaymentMethodCallback","setSelectedPaymentOptionCallback","fetchSelectedPaymentOptionCallback","setupIntentClientSecretForCustomerAttachCallback","initialize","params","customerAdapterOverrides","customerAdapter","configureCustomerAdapterEventListeners","NativeStripeSdk","initCustomerSheet","error","fetchPaymentMethods","remove","addListener","paymentMethods","customerAdapterFetchPaymentMethodsCallback","Error","attachPaymentMethod","paymentMethodId","paymentMethod","customerAdapterAttachPaymentMethodCallback","detachPaymentMethod","customerAdapterDetachPaymentMethodCallback","setSelectedPaymentOption","paymentOption","customerAdapterSetSelectedPaymentOptionCallback","fetchSelectedPaymentOption","customerAdapterFetchSelectedPaymentOptionCallback","setupIntentClientSecretForCustomerAttach","clientSecret","customerAdapterSetupIntentClientSecretForCustomerAttachCallback","present","presentCustomerSheet","retrievePaymentOptionSelection","retrieveCustomerSheetPaymentOptionSelection","Component","visible","presentationStyle","animationStyle","style","appearance","setupIntentClientSecret","customerId","customerEphemeralKeySecret","merchantDisplayName","headerTextForSelectionScreen","defaultBillingDetails","billingDetailsCollectionConfiguration","returnURL","removeSavedPaymentMethodMessage","applePayEnabled","googlePayEnabled","timeout","onResult","React","useEffect","then","initResult","presentResult","CustomerSheet"],"sources":["CustomerSheet.tsx"],"sourcesContent":["import React from 'react';\nimport {\n NativeEventEmitter,\n NativeModules,\n EmitterSubscription,\n} from 'react-native';\nimport NativeStripeSdk from '../NativeStripeSdk';\nimport type {\n CustomerSheetInitParams,\n CustomerSheetPresentParams,\n CustomerSheetResult,\n CustomerSheetError,\n StripeError,\n CustomerAdapter,\n} from '../types';\n\nconst eventEmitter = new NativeEventEmitter(NativeModules.StripeSdk);\nlet fetchPaymentMethodsCallback: EmitterSubscription | null = null;\nlet attachPaymentMethodCallback: EmitterSubscription | null = null;\nlet detachPaymentMethodCallback: EmitterSubscription | null = null;\nlet setSelectedPaymentOptionCallback: EmitterSubscription | null = null;\nlet fetchSelectedPaymentOptionCallback: EmitterSubscription | null = null;\nlet setupIntentClientSecretForCustomerAttachCallback: EmitterSubscription | null =\n null;\n\n/** Initialize an instance of Customer Sheet with your desired configuration. */\nconst initialize = async (\n params: CustomerSheetInitParams\n): Promise<{ error?: StripeError<CustomerSheetError> }> => {\n let customerAdapterOverrides = {};\n if (params.customerAdapter) {\n customerAdapterOverrides = configureCustomerAdapterEventListeners(\n params.customerAdapter\n );\n }\n\n try {\n const { error } = await NativeStripeSdk.initCustomerSheet(\n params,\n customerAdapterOverrides\n );\n if (error) {\n return { error };\n }\n return {};\n } catch (error: any) {\n return {\n error,\n };\n }\n};\n\nconst configureCustomerAdapterEventListeners = (\n customerAdapter: CustomerAdapter\n): { [Property in keyof CustomerAdapter]: boolean } => {\n if (customerAdapter.fetchPaymentMethods) {\n fetchPaymentMethodsCallback?.remove();\n fetchPaymentMethodsCallback = eventEmitter.addListener(\n 'onCustomerAdapterFetchPaymentMethodsCallback',\n async () => {\n if (customerAdapter.fetchPaymentMethods) {\n const paymentMethods = await customerAdapter.fetchPaymentMethods();\n await NativeStripeSdk.customerAdapterFetchPaymentMethodsCallback(\n paymentMethods\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `fetchPaymentMethods` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.attachPaymentMethod) {\n attachPaymentMethodCallback?.remove();\n attachPaymentMethodCallback = eventEmitter.addListener(\n 'onCustomerAdapterAttachPaymentMethodCallback',\n async ({ paymentMethodId }: { paymentMethodId: string }) => {\n if (customerAdapter.attachPaymentMethod) {\n const paymentMethod = await customerAdapter.attachPaymentMethod(\n paymentMethodId\n );\n await NativeStripeSdk.customerAdapterAttachPaymentMethodCallback(\n paymentMethod\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `attachPaymentMethod` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.detachPaymentMethod) {\n detachPaymentMethodCallback?.remove();\n detachPaymentMethodCallback = eventEmitter.addListener(\n 'onCustomerAdapterDetachPaymentMethodCallback',\n async ({ paymentMethodId }: { paymentMethodId: string }) => {\n if (customerAdapter.detachPaymentMethod) {\n const paymentMethod = await customerAdapter.detachPaymentMethod(\n paymentMethodId\n );\n await NativeStripeSdk.customerAdapterDetachPaymentMethodCallback(\n paymentMethod\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `detachPaymentMethod` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.setSelectedPaymentOption) {\n setSelectedPaymentOptionCallback?.remove();\n setSelectedPaymentOptionCallback = eventEmitter.addListener(\n 'onCustomerAdapterSetSelectedPaymentOptionCallback',\n async ({ paymentOption }: { paymentOption: string }) => {\n if (customerAdapter.setSelectedPaymentOption) {\n await customerAdapter.setSelectedPaymentOption(paymentOption);\n await NativeStripeSdk.customerAdapterSetSelectedPaymentOptionCallback();\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `setSelectedPaymentOption` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.fetchSelectedPaymentOption) {\n fetchSelectedPaymentOptionCallback?.remove();\n fetchSelectedPaymentOptionCallback = eventEmitter.addListener(\n 'onCustomerAdapterFetchSelectedPaymentOptionCallback',\n async () => {\n if (customerAdapter.fetchSelectedPaymentOption) {\n const paymentOption =\n await customerAdapter.fetchSelectedPaymentOption();\n await NativeStripeSdk.customerAdapterFetchSelectedPaymentOptionCallback(\n paymentOption\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `fetchSelectedPaymentOption` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n if (customerAdapter.setupIntentClientSecretForCustomerAttach) {\n setupIntentClientSecretForCustomerAttachCallback?.remove();\n setupIntentClientSecretForCustomerAttachCallback = eventEmitter.addListener(\n 'onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback',\n async () => {\n if (customerAdapter.setupIntentClientSecretForCustomerAttach) {\n const clientSecret =\n await customerAdapter.setupIntentClientSecretForCustomerAttach();\n await NativeStripeSdk.customerAdapterSetupIntentClientSecretForCustomerAttachCallback(\n clientSecret\n );\n } else {\n throw new Error(\n '[@stripe/stripe-react-native] Tried to call `setupIntentClientSecretForCustomerAttach` on your CustomerAdapter, but no matching method was found.'\n );\n }\n }\n );\n }\n\n return {\n fetchPaymentMethods: !!customerAdapter.fetchPaymentMethods,\n attachPaymentMethod: !!customerAdapter.attachPaymentMethod,\n detachPaymentMethod: !!customerAdapter.detachPaymentMethod,\n setSelectedPaymentOption: !!customerAdapter.setSelectedPaymentOption,\n fetchSelectedPaymentOption: !!customerAdapter.fetchSelectedPaymentOption,\n setupIntentClientSecretForCustomerAttach:\n !!customerAdapter.setupIntentClientSecretForCustomerAttach,\n };\n};\n\n/** Launches the Customer Sheet UI. */\nconst present = async (\n params: CustomerSheetPresentParams = {}\n): Promise<CustomerSheetResult> => {\n try {\n return await NativeStripeSdk.presentCustomerSheet(params);\n } catch (error: any) {\n return {\n error,\n };\n }\n};\n\n/**\n * You can use this to obtain the selected payment method without presenting the CustomerSheet.\n * This will return an error if you have not called `.initialize`\n */\nconst retrievePaymentOptionSelection =\n async (): Promise<CustomerSheetResult> => {\n try {\n return await NativeStripeSdk.retrieveCustomerSheetPaymentOptionSelection();\n } catch (error: any) {\n return {\n error,\n };\n }\n };\n\n/**\n * Props\n */\nexport type Props = {\n /** Whether the sheet is visible. Defaults to false. */\n visible: boolean;\n /** Called when the user submits, dismisses, or cancels the sheet, or when an error occurs. */\n onResult: (result: CustomerSheetResult) => void;\n} & CustomerSheetInitParams &\n CustomerSheetPresentParams;\n\n/**\n * A component wrapper around the Customer Sheet functions. Upon passing `true` to the `visible` prop,\n * Customer Sheet will call `initialize` and `present`, and the result(s) will be passed through to the\n * onResult callback.\n *\n * @example\n * ```ts\n * const [selectedPaymentOption, setSelectedPaymentOption] = React.useState(null);\n * const [customerSheetVisible, setCustomerSheetVisible] = React.useState(false);\n *\n * return (\n * <CustomerSheet\n * visible={customerSheetVisible}\n * customerEphemeralKeySecret={ephemeralKeySecret}\n * customerId={customer}\n * returnURL={'stripe-example://stripe-redirect'}\n * onResult={({ error, paymentOption, paymentMethod }) => {\n * setCustomerSheetVisible(false);\n * if (error) {\n * Alert.alert(error.code, error.localizedMessage);\n * }\n * if (paymentOption) {\n * setSelectedPaymentOption(paymentOption);\n * console.log(JSON.stringify(paymentOption, null, 2));\n * }\n * if (paymentMethod) {\n * console.log(JSON.stringify(paymentMethod, null, 2));\n * }\n * }}\n * />\n * );\n * ```\n * @param __namedParameters Props\n * @returns JSX.Element\n * @category ReactComponents\n */\nfunction Component({\n visible,\n presentationStyle,\n animationStyle,\n style,\n appearance,\n setupIntentClientSecret,\n customerId,\n customerEphemeralKeySecret,\n merchantDisplayName,\n headerTextForSelectionScreen,\n defaultBillingDetails,\n billingDetailsCollectionConfiguration,\n returnURL,\n removeSavedPaymentMethodMessage,\n applePayEnabled,\n googlePayEnabled,\n timeout,\n onResult,\n customerAdapter,\n}: Props) {\n React.useEffect(() => {\n if (visible) {\n initialize({\n style,\n appearance,\n setupIntentClientSecret,\n customerId,\n customerEphemeralKeySecret,\n merchantDisplayName,\n headerTextForSelectionScreen,\n defaultBillingDetails,\n billingDetailsCollectionConfiguration,\n returnURL,\n removeSavedPaymentMethodMessage,\n applePayEnabled,\n googlePayEnabled,\n customerAdapter,\n }).then((initResult) => {\n if (initResult.error) {\n onResult(initResult);\n } else {\n present({\n timeout,\n presentationStyle,\n animationStyle,\n }).then((presentResult) => {\n onResult(presentResult);\n });\n }\n });\n }\n // Only run this hook when visible prop changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [visible]);\n\n return null;\n}\n\n/**\n * The Customer Sheet is a prebuilt UI component that lets your customers manage their saved payment methods.\n */\nexport const CustomerSheet = {\n Component,\n initialize,\n present,\n retrievePaymentOptionSelection,\n};\n"],"mappings":"2QAAA,oDACA,yCAKA,2EAUA,GAAMA,aAAY,CAAG,GAAIC,gCAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC,CACpE,GAAIC,4BAAuD,CAAG,IAAI,CAClE,GAAIC,4BAAuD,CAAG,IAAI,CAClE,GAAIC,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,qBAAqB,CACrBC,qCAAqC,CAArCA,qCAAqC,CACrCC,SAAS,CAATA,SAAS,CACTC,+BAA+B,CAA/BA,+BAA+B,CAC/BC,eAAe,CAAfA,eAAe,CACfC,gBAAgB,CAAhBA,gBAAgB,CAChB7C,eAAe,CAAfA,eACF,CAAC,CAAC,CAACkD,IAAI,CAAC,SAACC,UAAU,CAAK,CACtB,GAAIA,UAAU,CAAC/C,KAAK,CAAE,CACpB2C,QAAQ,CAACI,UAAU,CAAC,CACtB,CAAC,IAAM,CACL1B,OAAO,CAAC,CACNqB,OAAO,CAAPA,OAAO,CACPf,iBAAiB,CAAjBA,iBAAiB,CACjBC,cAAc,CAAdA,cACF,CAAC,CAAC,CAACkB,IAAI,CAAC,SAACE,aAAa,CAAK,CACzBL,QAAQ,CAACK,aAAa,CAAC,CACzB,CAAC,CAAC,CACJ,CACF,CAAC,CAAC,CACJ,CAGF,CAAC,CAAE,CAACtB,OAAO,CAAC,CAAC,CAEb,MAAO,KAAI,CACb,CAKO,GAAMuB,cAAa,CAAG,CAC3BxB,SAAS,CAATA,SAAS,CACThC,UAAU,CAAVA,UAAU,CACV4B,OAAO,CAAPA,OAAO,CACPE,8BAA8B,CAA9BA,8BACF,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.CollectionMode=exports.CaptureMethod=exports.AddressCollectionMode=void 0;var CollectionMode;exports.CollectionMode=CollectionMode;(function(CollectionMode){CollectionMode["AUTOMATIC"]="automatic";CollectionMode["NEVER"]="never";CollectionMode["ALWAYS"]="always";})(CollectionMode||(exports.CollectionMode=CollectionMode={}));var AddressCollectionMode;exports.AddressCollectionMode=AddressCollectionMode;(function(AddressCollectionMode){AddressCollectionMode["AUTOMATIC"]="automatic";AddressCollectionMode["NEVER"]="never";AddressCollectionMode["FULL"]="full";})(AddressCollectionMode||(exports.AddressCollectionMode=AddressCollectionMode={}));var CaptureMethod;exports.CaptureMethod=CaptureMethod;(function(CaptureMethod){CaptureMethod["Automatic"]="Automatic";CaptureMethod["Manual"]="Manual";CaptureMethod["AutomaticAsync"]="AutomaticAsync";})(CaptureMethod||(exports.CaptureMethod=CaptureMethod={}));
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.PaymentMethodLayout=exports.CollectionMode=exports.CaptureMethod=exports.AddressCollectionMode=void 0;var CollectionMode;exports.CollectionMode=CollectionMode;(function(CollectionMode){CollectionMode["AUTOMATIC"]="automatic";CollectionMode["NEVER"]="never";CollectionMode["ALWAYS"]="always";})(CollectionMode||(exports.CollectionMode=CollectionMode={}));var AddressCollectionMode;exports.AddressCollectionMode=AddressCollectionMode;(function(AddressCollectionMode){AddressCollectionMode["AUTOMATIC"]="automatic";AddressCollectionMode["NEVER"]="never";AddressCollectionMode["FULL"]="full";})(AddressCollectionMode||(exports.AddressCollectionMode=AddressCollectionMode={}));var CaptureMethod;exports.CaptureMethod=CaptureMethod;(function(CaptureMethod){CaptureMethod["Automatic"]="Automatic";CaptureMethod["Manual"]="Manual";CaptureMethod["AutomaticAsync"]="AutomaticAsync";})(CaptureMethod||(exports.CaptureMethod=CaptureMethod={}));var PaymentMethodLayout;exports.PaymentMethodLayout=PaymentMethodLayout;(function(PaymentMethodLayout){PaymentMethodLayout["Horizontal"]="Horizontal";PaymentMethodLayout["Vertical"]="Vertical";PaymentMethodLayout["Automatic"]="Automatic";})(PaymentMethodLayout||(exports.PaymentMethodLayout=PaymentMethodLayout={}));
|
|
2
2
|
//# sourceMappingURL=PaymentSheet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CollectionMode","AddressCollectionMode","CaptureMethod"],"sources":["PaymentSheet.ts"],"sourcesContent":["import type { BillingDetails, AddressDetails, CardBrand } from './Common';\nimport type { CartSummaryItem } from './ApplePay';\nimport type {\n ButtonType,\n RecurringPaymentRequest,\n AutomaticReloadPaymentRequest,\n MultiMerchantRequest,\n} from './PlatformPay';\nimport type { FutureUsage } from './PaymentIntent';\nimport type { Result } from './PaymentMethod';\nimport type { StripeError } from './Errors';\n\nexport type SetupParams = IntentParams & {\n /** Your customer-facing business name. On Android, this is required and cannot be an empty string. */\n merchantDisplayName: string;\n /** The identifier of the Stripe Customer object. See https://stripe.com/docs/api/customers/object#customer_object-id */\n customerId?: string;\n /** A short-lived token that allows the SDK to access a Customer’s payment methods. */\n customerEphemeralKeySecret?: string;\n /** When set to true, separates out the payment method selection & confirmation steps.\n * If true, you must call `confirmPaymentSheetPayment` on your own. Defaults to false. */\n customFlow?: boolean;\n /** iOS only. Enable Apple Pay in the Payment Sheet by passing an ApplePayParams object. */\n applePay?: ApplePayParams;\n /** Android only. Enable Google Pay in the Payment Sheet by passing a GooglePayParams object. */\n googlePay?: GooglePayParams;\n /** The color styling to use for PaymentSheet UI. Defaults to 'automatic'. */\n style?: 'alwaysLight' | 'alwaysDark' | 'automatic';\n /** A URL that redirects back to your app that PaymentSheet can use to auto-dismiss web views used for additional authentication, e.g. 3DS2 */\n returnURL?: string;\n /** Configuration for how billing details are collected during checkout. */\n billingDetailsCollectionConfiguration?: BillingDetailsCollectionConfiguration;\n /** PaymentSheet pre-populates the billing fields that are displayed in the Payment Sheet (only country and postal code, as of this version) with the values provided. */\n defaultBillingDetails?: BillingDetails;\n /**\n * The shipping information for the customer. If set, PaymentSheet will pre-populate the form fields with the values provided.\n * This is used to display a \"Billing address is same as shipping\" checkbox if `defaultBillingDetails` is not provided.\n * If `name` and `line1` are populated, it's also [attached to the PaymentIntent](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-shipping) during payment.\n */\n defaultShippingDetails?: AddressDetails;\n /** If true, allows payment methods that do not move money at the end of the checkout. Defaults to false.\n *\n * Some payment methods can’t guarantee you will receive funds from your customer at the end of the checkout\n * because they take time to settle (eg. most bank debits, like SEPA or ACH) or require customer action to\n * complete (e.g. OXXO, Konbini, Boleto). If this is set to true, make sure your integration listens to webhooks\n * for notifications on whether a payment has succeeded or not.\n */\n allowsDelayedPaymentMethods?: boolean;\n /** Customizes the appearance of PaymentSheet */\n appearance?: AppearanceParams;\n /** The label to use for the primary button. If not set, Payment Sheet will display suitable default labels for payment and setup intents. */\n primaryButtonLabel?: string;\n /** Optional configuration to display a custom message when a saved payment method is removed. iOS only. */\n removeSavedPaymentMethodMessage?: string;\n /** The list of preferred networks that should be used to process payments made with a co-branded card.\n * This value will only be used if your user hasn't selected a network themselves. */\n preferredNetworks?: Array<CardBrand>;\n /** By default, PaymentSheet will use a dynamic ordering that optimizes payment method display for the customer.\n * You can override the default order in which payment methods are displayed in PaymentSheet with a list of payment method types.\n * See https://stripe.com/docs/api/payment_methods/object#payment_method_object-type for the list of valid types. You may also pass external payment methods.\n * - Example: [\"card\", \"external_paypal\", \"klarna\"]\n * - Note: If you omit payment methods from this list, they’ll be automatically ordered by Stripe after the ones you provide. Invalid payment methods are ignored.\n */\n paymentMethodOrder?: Array<String>;\n /** This is an experimental feature that may be removed at any time.\n * Defaults to true. If true, the customer can delete all saved payment methods.\n * If false, the customer can't delete if they only have one saved payment method remaining.\n */\n allowsRemovalOfLastSavedPaymentMethod?: boolean;\n};\n\nexport type IntentParams =\n | {\n paymentIntentClientSecret: string;\n setupIntentClientSecret?: undefined;\n intentConfiguration?: never;\n }\n | {\n setupIntentClientSecret: string;\n paymentIntentClientSecret?: undefined;\n intentConfiguration?: never;\n }\n | {\n setupIntentClientSecret?: never;\n paymentIntentClientSecret?: never;\n intentConfiguration: IntentConfiguration;\n };\n\nexport type ApplePayParams = {\n /** The two-letter ISO 3166 code of the country of your business, e.g. \"US\" */\n merchantCountryCode: string;\n /**\n * An array of CartSummaryItem item objects that summarize the amount of the payment. If you're using a SetupIntent\n * for a recurring payment, you should set this to display the amount you intend to charge. */\n cartItems?: CartSummaryItem[];\n /** Sets the text displayed by the call to action button in the Apple Pay sheet. */\n buttonType?: ButtonType;\n /** A typical request is for a one-time payment. To support different types of payment requests, include a PaymentRequestType. Only supported on iOS 16 and up. */\n request?:\n | RecurringPaymentRequest\n | AutomaticReloadPaymentRequest\n | MultiMerchantRequest;\n /** Callback function for setting the order details (retrieved from your server) to give users the\n * ability to track and manage their purchases in Wallet. Stripe calls your implementation after the\n * payment is complete, but before iOS dismisses the Apple Pay sheet. You must call the `completion`\n * function, or else the Apple Pay sheet will hang. */\n setOrderTracking?: (\n completion: (\n orderIdentifier: string,\n orderTypeIdentifier: string,\n authenticationToken: string,\n webServiceUrl: string\n ) => void\n ) => void;\n};\n\nexport type GooglePayParams = {\n /** The two-letter ISO 3166 code of the country of your business, e.g. \"US\" */\n merchantCountryCode: string;\n /** The three-letter ISO 4217 alphabetic currency code, e.g. \"USD\" or \"EUR\". Required in order to support Google Pay when processing a Setup Intent. */\n currencyCode?: string;\n /** Whether or not to use the Google Pay test environment. Set to `true` until you have applied for and been granted access to the Production environment. */\n testEnv?: boolean;\n /** An optional label to display with the amount. Google Pay may or may not display this label depending on its own internal logic. Defaults to a generic label if none is provided. */\n label?: string;\n /** An optional amount to display for setup intents. Google Pay may or may not display this amount depending on its own internal logic. Defaults to 0 if none is provided. */\n amount?: string;\n /** The Google Pay button type to use. Set to \"Pay\" by default. See\n * [Google's documentation](https://developers.google.com/android/reference/com/google/android/gms/wallet/Wallet.WalletOptions#environment)\n * for more information on button types. */\n buttonType?: ButtonType;\n};\n\n/**\n * Used to customize the appearance of your PaymentSheet\n */\nexport type AppearanceParams = RecursivePartial<{\n /** Describes the appearance of fonts in your PaymentSheet */\n font: FontConfig;\n /** Describes the colors in your PaymentSheet. Provide either a base config, or both `light` and `dark` configs, which will be useed based on whether the user is in Light or Dark mode. */\n colors:\n | GlobalColorConfig\n | { light: GlobalColorConfig; dark: GlobalColorConfig };\n /** Describes the appearance of shapes in the PaymentSheet, such as buttons, inputs, and tabs. */\n shapes: {\n /** The border radius used for buttons, inputs, and tabs in your PaymentSheet.\n * @default 6.0\n */\n borderRadius: number;\n /** The border width used for inputs and tabs in your PaymentSheet.\n * @default 1.0\n */\n borderWidth: number;\n /** iOS only. The shadow used for buttons, inputs, and tabs in your PaymentSheet */\n shadow: ShadowConfig;\n };\n /** Describes the appearance of the primary \"Pay\" button at the bottom of your Payment Sheet */\n primaryButton: PrimaryButtonConfig;\n}>;\n\nexport type FontConfig = {\n /**\n * The font used for regular text. PaymentSheet will attempt to use medium and bold versions of this font if they exist.\n *\n * On iOS, this should be the \"PostScript name\" found in Font Book after installing the font.\n * On Android, this should be the name of the font file (containing only lowercase alphanumeric characters) in android/app/src/main/res/font\n *\n * @default The OS's system font\n */\n family: string;\n /** The scale factor for all fonts in your PaymentSheet. This value is required to be greater than 0. Font sizes are multiplied by this value before being displayed. For example, setting this to 1.2 increases the size of all text by 20%.\n * @default 1.0\n */\n scale: number;\n};\n\nexport type ShadowConfig = {\n /** The color of the shadow.\n * @default \"#000000\"\n * */\n color: string;\n /** The alpha or opacity of the shadow.\n * @default 0.05\n */\n opacity: number;\n /** The positioning of the shadow relative to the component. For example, a negative x and y will result in a shadow placed below and to the left of the component.\n * @default {x: 0, y: 2}\n */\n offset: { x: number; y: number };\n /** The blur radius of the shadow.\n * @default 4\n */\n blurRadius: number;\n};\n\nexport type GlobalColorConfig = {\n /** A primary color used throughout your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System blue color on iOS, and \"#007AFF\" (light) / \"#0074D4\" (dark) on Android.\n */\n primary: string;\n /** The color used for the background of your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System background color on iOS, and \"#ffffff\" (light) / \"#2e2e2e\" (dark) on Android.\n */\n background: string;\n /** The color used for the background of inputs, tabs, and other components in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System background color (light) / System secondary background color (dark) on iOS, and \"#ffffff\" (light) / \"#a9a9a9\" (dark) on Android.\n */\n componentBackground: string;\n /** The color used for the external border of inputs, tabs, and other components in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System gray (3) color on iOS, and \"#33787880\" (light) / \"#787880\" (dark) on Android.\n */\n componentBorder: string;\n /** The color used for the internal border (meaning the border is shared with another component) of inputs, tabs, and other components in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System gray (3) color on iOS, and \"#33787880\" (light) / \"#787880\" (dark) on Android.\n */\n componentDivider: string;\n /** The color of the header text in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System label color on iOS, and \"#000000\" (light) / \"#ffffff\" (dark) on Android.\n */\n primaryText: string;\n /** The color of the label text of input fields, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System seconday label color on iOS, and \"#000000\" (light) / \"#ffffff\" (dark) on Android.\n */\n secondaryText: string;\n /** The color of the input text in your PaymentSheet components, such as the user's card number or zip code, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default \"#000000\"\n */\n componentText: string;\n /** The color of the placeholder text of input fields, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System label color on iOS, and \"#99000000\" (light) / \"#99ffffff\" (dark) on Android.\n */\n placeholderText: string;\n /** The color used for icons in your Payment Sheet, such as the close or back icons, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System seconday label color on iOS, and \"#99000000\" (light) / \"#ffffff\" (dark) on Android.\n */\n icon: string;\n /** The color used to indicate errors or destructive actions in your Payment Sheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System red color on iOS, and \"#ff0000\" (light) / \"#ff0000\" (dark) on Android.\n */\n error: string;\n};\n\nexport type PrimaryButtonConfig = {\n /** The font family used specifically for the primary button.\n * @default The root `appearance.font.family`\n */\n font: Pick<FontConfig, 'family'>;\n /** The colors used specifically for the primary button. Provide either a base config, or both `light` and `dark` configs, which will be useed based on whether the user is in Light or Dark mode. */\n colors:\n | PrimaryButtonColorConfig\n | { light: PrimaryButtonColorConfig; dark: PrimaryButtonColorConfig };\n /** Describes the border and shadow of the primary button. */\n shapes: {\n /** The border radius used for the primary button in your PaymentSheet\n * @default The root `appearance.shapes.borderRadius`\n */\n borderRadius: number;\n /** The border width used for the primary button in your PaymentSheet\n * @default The root `appearance.shapes.borderWidth`\n */\n borderWidth: number;\n /** iOS only. The shadow used for the primary button in your PaymentSheet\n * @default The root `appearance.shapes.shadow`\n */\n shadow: ShadowConfig;\n };\n};\n\nexport type PrimaryButtonColorConfig = {\n /** The background color used for the primary button in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The root `appearance.colors.primary`\n */\n background: string;\n /** The color of the text for the primary button in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default White or black, depending on the color of the button.\n */\n text: string;\n /** The border color used for the primary button in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System quaternary label on iOS, transparent on Android.\n */\n border: string;\n};\n\ntype RecursivePartial<T> = {\n [P in keyof T]?: T[P] extends (infer U)[]\n ? RecursivePartial<U>[]\n : T[P] extends object\n ? RecursivePartial<T[P]>\n : T[P];\n};\nexport interface PaymentOption {\n label: string;\n image: string;\n}\n\nexport type PresentOptions = {\n /** The number of milliseconds (after presenting) before the Payment Sheet closes automatically, at which point\n *`presentPaymentSheet` will resolve with an `error.code` of `PaymentSheetError.Timeout`. The default is no timeout.\n */\n timeout?: number;\n};\n\nexport type BillingDetailsCollectionConfiguration = {\n /** How to collect the name field. Defaults to `CollectionMode.automatic`. */\n name?: CollectionMode;\n /** How to collect the phone field. Defaults to `CollectionMode.automatic`. */\n phone?: CollectionMode;\n /** How to collect the email field. Defaults to `CollectionMode.automatic`. */\n email?: CollectionMode;\n /** How to collect the billing address. Defaults to `CollectionMode.automatic`. */\n address?: AddressCollectionMode;\n /** Whether the values included in `Configuration.defaultBillingDetails` should be attached to the payment method, this includes fields that aren't displayed in the form. If `false` (the default), those values will only be used to prefill the corresponding fields in the form. */\n attachDefaultsToPaymentMethod?: Boolean;\n};\n\nexport enum CollectionMode {\n /** The field may or may not be collected depending on the Payment Method's requirements. */\n AUTOMATIC = 'automatic',\n /** The field will never be collected. If this field is required by the Payment Method, you must provide it as part of `defaultBillingDetails`. */\n NEVER = 'never',\n /** The field will always be collected, even if it isn't required for the Payment Method. */\n ALWAYS = 'always',\n}\n\nexport enum AddressCollectionMode {\n /** Only the fields required by the Payment Method will be collected, which may be none. */\n AUTOMATIC = 'automatic',\n /** Billing address will never be collected. If the Payment Method requires a billing address, you must provide it as part of `defaultBillingDetails`. */\n NEVER = 'never',\n /** Collect the full billing address, regardless of the Payment Method's requirements. */\n FULL = 'full',\n}\n\nexport type IntentCreationError = StripeError<'Failed'>;\n\nexport type IntentCreationCallbackParams =\n | {\n clientSecret: string;\n error?: never;\n }\n | {\n clientSecret?: never;\n error: IntentCreationError;\n };\n\nexport type IntentConfiguration = {\n /*\n Called when the customer confirms payment. Your implementation should create a PaymentIntent or SetupIntent on your server and call the `intentCreationCallback` with its client secret or an error if one occurred.\n - Note: You must create the PaymentIntent or SetupIntent with the same values used as the `IntentConfiguration` e.g. the same amount, currency, etc.\n - Parameters:\n - paymentMethod: The PaymentMethod representing the customer's payment details.\n - shouldSavePaymentMethod: This is `true` if the customer selected the \"Save this payment method for future use\" checkbox. Set `setup_future_usage` on the PaymentIntent to `off_session` if this is `true`.\n - intentCreationCallback: Call this with the `client_secret` of the PaymentIntent or SetupIntent created by your server or the error that occurred. If you're using customFlow: false (default), the error's localizedMessage will be displayed to the customer in the sheet. If you're using customFlow: true, the `confirm` method fails with the error.\n */\n confirmHandler: (\n paymentMethod: Result,\n shouldSavePaymentMethod: boolean,\n intentCreationCallback: (result: IntentCreationCallbackParams) => void\n ) => void;\n /* Information about the payment (PaymentIntent) or setup (SetupIntent).*/\n mode: Mode;\n /* A list of payment method types to display to the customer. If undefined or empty, we dynamically determine the payment methods using your Stripe Dashboard settings. */\n paymentMethodTypes?: Array<string>;\n};\n\nexport type Mode = PaymentMode | SetupMode;\n\n/**\n * Controls when the funds will be captured. Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-capture_method\n */\nexport enum CaptureMethod {\n /** (Default) Stripe automatically captures funds when the customer authorizes the payment. */\n Automatic = 'Automatic',\n /** Place a hold on the funds when the customer authorizes the payment, but don’t capture the funds until later. (Not all payment methods support this.) */\n Manual = 'Manual',\n /** Asynchronously capture funds when the customer authorizes the payment.\n - Note: Recommended over `CaptureMethod.Automatic` due to improved latency, but may require additional integration changes.\n - Seealso: https://stripe.com/docs/payments/payment-intents/asynchronous-capture-automatic-async */\n AutomaticAsync = 'AutomaticAsync',\n}\n\n/* Use this if your integration creates a PaymentIntent */\nexport type PaymentMode = {\n /* Amount intended to be collected in the smallest currency unit (e.g. 100 cents to charge $1.00). Shown in Apple Pay, Google Pay, Buy now pay later UIs, the Pay button, and influences available payment methods.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-amount */\n amount: number;\n /* Three-letter ISO currency code. Filters out payment methods based on supported currency.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-currency */\n currencyCode: string;\n /* Indicates that you intend to make future payments.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage */\n setupFutureUsage?: FutureUsage;\n /* Controls when the funds will be captured.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-capture_method */\n captureMethod?: CaptureMethod;\n};\n\n/* Use this if your integration creates a SetupIntent */\nexport type SetupMode = {\n /* Three-letter ISO currency code. Filters out payment methods based on supported currency.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-currency */\n currencyCode?: string;\n /* Indicates that you intend to make future payments.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage */\n setupFutureUsage: FutureUsage;\n};\n"],"mappings":"8IA2TYA,eAAc,iDAAdA,cAAc,EAAdA,cAAc,0BAAdA,cAAc,kBAAdA,cAAc,uBAAdA,cAAc,0BAAdA,cAAc,SASdC,sBAAqB,+DAArBA,qBAAqB,EAArBA,qBAAqB,0BAArBA,qBAAqB,kBAArBA,qBAAqB,mBAArBA,qBAAqB,iCAArBA,qBAAqB,SA8CrBC,cAAa,+CAAbA,aAAa,EAAbA,aAAa,0BAAbA,aAAa,oBAAbA,aAAa,uCAAbA,aAAa,yBAAbA,aAAa"}
|
|
1
|
+
{"version":3,"names":["CollectionMode","AddressCollectionMode","CaptureMethod","PaymentMethodLayout"],"sources":["PaymentSheet.ts"],"sourcesContent":["import type { BillingDetails, AddressDetails, CardBrand } from './Common';\nimport type { CartSummaryItem } from './ApplePay';\nimport type {\n ButtonType,\n RecurringPaymentRequest,\n AutomaticReloadPaymentRequest,\n MultiMerchantRequest,\n} from './PlatformPay';\nimport type { FutureUsage } from './PaymentIntent';\nimport type { Result } from './PaymentMethod';\nimport type { StripeError } from './Errors';\n\ntype SetupParamsBase = IntentParams & {\n /** Your customer-facing business name. On Android, this is required and cannot be an empty string. */\n merchantDisplayName: string;\n /** The identifier of the Stripe Customer object. See https://stripe.com/docs/api/customers/object#customer_object-id */\n customerId?: string;\n /** When set to true, separates out the payment method selection & confirmation steps.\n * If true, you must call `confirmPaymentSheetPayment` on your own. Defaults to false. */\n customFlow?: boolean;\n /** iOS only. Enable Apple Pay in the Payment Sheet by passing an ApplePayParams object. */\n applePay?: ApplePayParams;\n /** Android only. Enable Google Pay in the Payment Sheet by passing a GooglePayParams object. */\n googlePay?: GooglePayParams;\n /** The color styling to use for PaymentSheet UI. Defaults to 'automatic'. */\n style?: 'alwaysLight' | 'alwaysDark' | 'automatic';\n /** A URL that redirects back to your app that PaymentSheet can use to auto-dismiss web views used for additional authentication, e.g. 3DS2 */\n returnURL?: string;\n /** Configuration for how billing details are collected during checkout. */\n billingDetailsCollectionConfiguration?: BillingDetailsCollectionConfiguration;\n /** PaymentSheet pre-populates the billing fields that are displayed in the Payment Sheet (only country and postal code, as of this version) with the values provided. */\n defaultBillingDetails?: BillingDetails;\n /**\n * The shipping information for the customer. If set, PaymentSheet will pre-populate the form fields with the values provided.\n * This is used to display a \"Billing address is same as shipping\" checkbox if `defaultBillingDetails` is not provided.\n * If `name` and `line1` are populated, it's also [attached to the PaymentIntent](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-shipping) during payment.\n */\n defaultShippingDetails?: AddressDetails;\n /** If true, allows payment methods that do not move money at the end of the checkout. Defaults to false.\n *\n * Some payment methods can’t guarantee you will receive funds from your customer at the end of the checkout\n * because they take time to settle (eg. most bank debits, like SEPA or ACH) or require customer action to\n * complete (e.g. OXXO, Konbini, Boleto). If this is set to true, make sure your integration listens to webhooks\n * for notifications on whether a payment has succeeded or not.\n */\n allowsDelayedPaymentMethods?: boolean;\n /** Customizes the appearance of PaymentSheet */\n appearance?: AppearanceParams;\n /** The label to use for the primary button. If not set, Payment Sheet will display suitable default labels for payment and setup intents. */\n primaryButtonLabel?: string;\n /** Optional configuration to display a custom message when a saved payment method is removed. iOS only. */\n removeSavedPaymentMethodMessage?: string;\n /** The list of preferred networks that should be used to process payments made with a co-branded card.\n * This value will only be used if your user hasn't selected a network themselves. */\n preferredNetworks?: Array<CardBrand>;\n /** By default, PaymentSheet will use a dynamic ordering that optimizes payment method display for the customer.\n * You can override the default order in which payment methods are displayed in PaymentSheet with a list of payment method types.\n * See https://stripe.com/docs/api/payment_methods/object#payment_method_object-type for the list of valid types. You may also pass external payment methods.\n * - Example: [\"card\", \"external_paypal\", \"klarna\"]\n * - Note: If you omit payment methods from this list, they’ll be automatically ordered by Stripe after the ones you provide. Invalid payment methods are ignored.\n */\n paymentMethodOrder?: Array<String>;\n /** This is an experimental feature that may be removed at any time.\n * Defaults to true. If true, the customer can delete all saved payment methods.\n * If false, the customer can't delete if they only have one saved payment method remaining.\n */\n allowsRemovalOfLastSavedPaymentMethod?: boolean;\n /**\n * Defines the layout orientations available for displaying payment methods in PaymentSheet.\n * - Note: Defaults to `Automatic` if not set\n */\n paymentMethodLayout?: PaymentMethodLayout;\n};\n\nexport type SetupParams =\n | (SetupParamsBase & {\n /** A short-lived token that allows the SDK to access a Customer’s payment methods. */\n customerEphemeralKeySecret: string;\n customerSessionClientSecret?: never;\n })\n | (SetupParamsBase & {\n customerEphemeralKeySecret?: never;\n /** (Experimental) This parameter can be changed or removed at any time (use at your own risk).\n * The client secret of this Customer Session. Used on the client to set up secure access to the given customer.\n */\n customerSessionClientSecret: string;\n })\n | SetupParamsBase;\n\nexport type IntentParams =\n | {\n paymentIntentClientSecret: string;\n setupIntentClientSecret?: undefined;\n intentConfiguration?: never;\n }\n | {\n setupIntentClientSecret: string;\n paymentIntentClientSecret?: undefined;\n intentConfiguration?: never;\n }\n | {\n setupIntentClientSecret?: never;\n paymentIntentClientSecret?: never;\n intentConfiguration: IntentConfiguration;\n };\n\nexport type ApplePayParams = {\n /** The two-letter ISO 3166 code of the country of your business, e.g. \"US\" */\n merchantCountryCode: string;\n /**\n * An array of CartSummaryItem item objects that summarize the amount of the payment. If you're using a SetupIntent\n * for a recurring payment, you should set this to display the amount you intend to charge. */\n cartItems?: CartSummaryItem[];\n /** Sets the text displayed by the call to action button in the Apple Pay sheet. */\n buttonType?: ButtonType;\n /** A typical request is for a one-time payment. To support different types of payment requests, include a PaymentRequestType. Only supported on iOS 16 and up. */\n request?:\n | RecurringPaymentRequest\n | AutomaticReloadPaymentRequest\n | MultiMerchantRequest;\n /** Callback function for setting the order details (retrieved from your server) to give users the\n * ability to track and manage their purchases in Wallet. Stripe calls your implementation after the\n * payment is complete, but before iOS dismisses the Apple Pay sheet. You must call the `completion`\n * function, or else the Apple Pay sheet will hang. */\n setOrderTracking?: (\n completion: (\n orderIdentifier: string,\n orderTypeIdentifier: string,\n authenticationToken: string,\n webServiceUrl: string\n ) => void\n ) => void;\n};\n\nexport type GooglePayParams = {\n /** The two-letter ISO 3166 code of the country of your business, e.g. \"US\" */\n merchantCountryCode: string;\n /** The three-letter ISO 4217 alphabetic currency code, e.g. \"USD\" or \"EUR\". Required in order to support Google Pay when processing a Setup Intent. */\n currencyCode?: string;\n /** Whether or not to use the Google Pay test environment. Set to `true` until you have applied for and been granted access to the Production environment. */\n testEnv?: boolean;\n /** An optional label to display with the amount. Google Pay may or may not display this label depending on its own internal logic. Defaults to a generic label if none is provided. */\n label?: string;\n /** An optional amount to display for setup intents. Google Pay may or may not display this amount depending on its own internal logic. Defaults to 0 if none is provided. */\n amount?: string;\n /** The Google Pay button type to use. Set to \"Pay\" by default. See\n * [Google's documentation](https://developers.google.com/android/reference/com/google/android/gms/wallet/Wallet.WalletOptions#environment)\n * for more information on button types. */\n buttonType?: ButtonType;\n};\n\n/**\n * Used to customize the appearance of your PaymentSheet\n */\nexport type AppearanceParams = RecursivePartial<{\n /** Describes the appearance of fonts in your PaymentSheet */\n font: FontConfig;\n /** Describes the colors in your PaymentSheet. Provide either a base config, or both `light` and `dark` configs, which will be useed based on whether the user is in Light or Dark mode. */\n colors:\n | GlobalColorConfig\n | { light: GlobalColorConfig; dark: GlobalColorConfig };\n /** Describes the appearance of shapes in the PaymentSheet, such as buttons, inputs, and tabs. */\n shapes: {\n /** The border radius used for buttons, inputs, and tabs in your PaymentSheet.\n * @default 6.0\n */\n borderRadius: number;\n /** The border width used for inputs and tabs in your PaymentSheet.\n * @default 1.0\n */\n borderWidth: number;\n /** iOS only. The shadow used for buttons, inputs, and tabs in your PaymentSheet */\n shadow: ShadowConfig;\n };\n /** Describes the appearance of the primary \"Pay\" button at the bottom of your Payment Sheet */\n primaryButton: PrimaryButtonConfig;\n}>;\n\nexport type FontConfig = {\n /**\n * The font used for regular text. PaymentSheet will attempt to use medium and bold versions of this font if they exist.\n *\n * On iOS, this should be the \"PostScript name\" found in Font Book after installing the font.\n * On Android, this should be the name of the font file (containing only lowercase alphanumeric characters) in android/app/src/main/res/font\n *\n * @default The OS's system font\n */\n family: string;\n /** The scale factor for all fonts in your PaymentSheet. This value is required to be greater than 0. Font sizes are multiplied by this value before being displayed. For example, setting this to 1.2 increases the size of all text by 20%.\n * @default 1.0\n */\n scale: number;\n};\n\nexport type ShadowConfig = {\n /** The color of the shadow.\n * @default \"#000000\"\n * */\n color: string;\n /** The alpha or opacity of the shadow.\n * @default 0.05\n */\n opacity: number;\n /** The positioning of the shadow relative to the component. For example, a negative x and y will result in a shadow placed below and to the left of the component.\n * @default {x: 0, y: 2}\n */\n offset: { x: number; y: number };\n /** The blur radius of the shadow.\n * @default 4\n */\n blurRadius: number;\n};\n\nexport type GlobalColorConfig = {\n /** A primary color used throughout your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System blue color on iOS, and \"#007AFF\" (light) / \"#0074D4\" (dark) on Android.\n */\n primary: string;\n /** The color used for the background of your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System background color on iOS, and \"#ffffff\" (light) / \"#2e2e2e\" (dark) on Android.\n */\n background: string;\n /** The color used for the background of inputs, tabs, and other components in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System background color (light) / System secondary background color (dark) on iOS, and \"#ffffff\" (light) / \"#a9a9a9\" (dark) on Android.\n */\n componentBackground: string;\n /** The color used for the external border of inputs, tabs, and other components in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System gray (3) color on iOS, and \"#33787880\" (light) / \"#787880\" (dark) on Android.\n */\n componentBorder: string;\n /** The color used for the internal border (meaning the border is shared with another component) of inputs, tabs, and other components in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System gray (3) color on iOS, and \"#33787880\" (light) / \"#787880\" (dark) on Android.\n */\n componentDivider: string;\n /** The color of the header text in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System label color on iOS, and \"#000000\" (light) / \"#ffffff\" (dark) on Android.\n */\n primaryText: string;\n /** The color of the label text of input fields, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System seconday label color on iOS, and \"#000000\" (light) / \"#ffffff\" (dark) on Android.\n */\n secondaryText: string;\n /** The color of the input text in your PaymentSheet components, such as the user's card number or zip code, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default \"#000000\"\n */\n componentText: string;\n /** The color of the placeholder text of input fields, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System label color on iOS, and \"#99000000\" (light) / \"#99ffffff\" (dark) on Android.\n */\n placeholderText: string;\n /** The color used for icons in your Payment Sheet, such as the close or back icons, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System seconday label color on iOS, and \"#99000000\" (light) / \"#ffffff\" (dark) on Android.\n */\n icon: string;\n /** The color used to indicate errors or destructive actions in your Payment Sheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System red color on iOS, and \"#ff0000\" (light) / \"#ff0000\" (dark) on Android.\n */\n error: string;\n};\n\nexport type PrimaryButtonConfig = {\n /** The font family used specifically for the primary button.\n * @default The root `appearance.font.family`\n */\n font: Pick<FontConfig, 'family'>;\n /** The colors used specifically for the primary button. Provide either a base config, or both `light` and `dark` configs, which will be useed based on whether the user is in Light or Dark mode. */\n colors:\n | PrimaryButtonColorConfig\n | { light: PrimaryButtonColorConfig; dark: PrimaryButtonColorConfig };\n /** Describes the border and shadow of the primary button. */\n shapes: {\n /** The border radius used for the primary button in your PaymentSheet\n * @default The root `appearance.shapes.borderRadius`\n */\n borderRadius: number;\n /** The border width used for the primary button in your PaymentSheet\n * @default The root `appearance.shapes.borderWidth`\n */\n borderWidth: number;\n /** iOS only. The shadow used for the primary button in your PaymentSheet\n * @default The root `appearance.shapes.shadow`\n */\n shadow: ShadowConfig;\n };\n};\n\nexport type PrimaryButtonColorConfig = {\n /** The background color used for the primary button in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The root `appearance.colors.primary`\n */\n background: string;\n /** The color of the text for the primary button in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default White or black, depending on the color of the button.\n */\n text: string;\n /** The border color used for the primary button in your PaymentSheet, represented as a hex string with format #RRGGBB or #AARRGGBB.\n * @default The System quaternary label on iOS, transparent on Android.\n */\n border: string;\n};\n\ntype RecursivePartial<T> = {\n [P in keyof T]?: T[P] extends (infer U)[]\n ? RecursivePartial<U>[]\n : T[P] extends object\n ? RecursivePartial<T[P]>\n : T[P];\n};\nexport interface PaymentOption {\n label: string;\n image: string;\n}\n\nexport type PresentOptions = {\n /** The number of milliseconds (after presenting) before the Payment Sheet closes automatically, at which point\n *`presentPaymentSheet` will resolve with an `error.code` of `PaymentSheetError.Timeout`. The default is no timeout.\n */\n timeout?: number;\n};\n\nexport type BillingDetailsCollectionConfiguration = {\n /** How to collect the name field. Defaults to `CollectionMode.automatic`. */\n name?: CollectionMode;\n /** How to collect the phone field. Defaults to `CollectionMode.automatic`. */\n phone?: CollectionMode;\n /** How to collect the email field. Defaults to `CollectionMode.automatic`. */\n email?: CollectionMode;\n /** How to collect the billing address. Defaults to `CollectionMode.automatic`. */\n address?: AddressCollectionMode;\n /** Whether the values included in `Configuration.defaultBillingDetails` should be attached to the payment method, this includes fields that aren't displayed in the form. If `false` (the default), those values will only be used to prefill the corresponding fields in the form. */\n attachDefaultsToPaymentMethod?: Boolean;\n};\n\nexport enum CollectionMode {\n /** The field may or may not be collected depending on the Payment Method's requirements. */\n AUTOMATIC = 'automatic',\n /** The field will never be collected. If this field is required by the Payment Method, you must provide it as part of `defaultBillingDetails`. */\n NEVER = 'never',\n /** The field will always be collected, even if it isn't required for the Payment Method. */\n ALWAYS = 'always',\n}\n\nexport enum AddressCollectionMode {\n /** Only the fields required by the Payment Method will be collected, which may be none. */\n AUTOMATIC = 'automatic',\n /** Billing address will never be collected. If the Payment Method requires a billing address, you must provide it as part of `defaultBillingDetails`. */\n NEVER = 'never',\n /** Collect the full billing address, regardless of the Payment Method's requirements. */\n FULL = 'full',\n}\n\nexport type IntentCreationError = StripeError<'Failed'>;\n\nexport type IntentCreationCallbackParams =\n | {\n clientSecret: string;\n error?: never;\n }\n | {\n clientSecret?: never;\n error: IntentCreationError;\n };\n\nexport type IntentConfiguration = {\n /*\n Called when the customer confirms payment. Your implementation should create a PaymentIntent or SetupIntent on your server and call the `intentCreationCallback` with its client secret or an error if one occurred.\n - Note: You must create the PaymentIntent or SetupIntent with the same values used as the `IntentConfiguration` e.g. the same amount, currency, etc.\n - Parameters:\n - paymentMethod: The PaymentMethod representing the customer's payment details.\n - shouldSavePaymentMethod: This is `true` if the customer selected the \"Save this payment method for future use\" checkbox. Set `setup_future_usage` on the PaymentIntent to `off_session` if this is `true`.\n - intentCreationCallback: Call this with the `client_secret` of the PaymentIntent or SetupIntent created by your server or the error that occurred. If you're using customFlow: false (default), the error's localizedMessage will be displayed to the customer in the sheet. If you're using customFlow: true, the `confirm` method fails with the error.\n */\n confirmHandler: (\n paymentMethod: Result,\n shouldSavePaymentMethod: boolean,\n intentCreationCallback: (result: IntentCreationCallbackParams) => void\n ) => void;\n /* Information about the payment (PaymentIntent) or setup (SetupIntent).*/\n mode: Mode;\n /* A list of payment method types to display to the customer. If undefined or empty, we dynamically determine the payment methods using your Stripe Dashboard settings. */\n paymentMethodTypes?: Array<string>;\n};\n\nexport type Mode = PaymentMode | SetupMode;\n\n/**\n * Controls when the funds will be captured. Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-capture_method\n */\nexport enum CaptureMethod {\n /** (Default) Stripe automatically captures funds when the customer authorizes the payment. */\n Automatic = 'Automatic',\n /** Place a hold on the funds when the customer authorizes the payment, but don’t capture the funds until later. (Not all payment methods support this.) */\n Manual = 'Manual',\n /** Asynchronously capture funds when the customer authorizes the payment.\n - Note: Recommended over `CaptureMethod.Automatic` due to improved latency, but may require additional integration changes.\n - Seealso: https://stripe.com/docs/payments/payment-intents/asynchronous-capture-automatic-async */\n AutomaticAsync = 'AutomaticAsync',\n}\n\n/* Use this if your integration creates a PaymentIntent */\nexport type PaymentMode = {\n /* Amount intended to be collected in the smallest currency unit (e.g. 100 cents to charge $1.00). Shown in Apple Pay, Google Pay, Buy now pay later UIs, the Pay button, and influences available payment methods.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-amount */\n amount: number;\n /* Three-letter ISO currency code. Filters out payment methods based on supported currency.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-currency */\n currencyCode: string;\n /* Indicates that you intend to make future payments.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage */\n setupFutureUsage?: FutureUsage;\n /* Controls when the funds will be captured.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-capture_method */\n captureMethod?: CaptureMethod;\n};\n\n/* Use this if your integration creates a SetupIntent */\nexport type SetupMode = {\n /* Three-letter ISO currency code. Filters out payment methods based on supported currency.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-currency */\n currencyCode?: string;\n /* Indicates that you intend to make future payments.\n Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage */\n setupFutureUsage: FutureUsage;\n};\n\nexport enum PaymentMethodLayout {\n /**\n * Payment methods are arranged horizontally.\n * Users can swipe left or right to navigate through different payment methods.\n */\n Horizontal = 'Horizontal',\n\n /**\n * Payment methods are arranged vertically.\n * Users can scroll up or down to navigate through different payment methods.\n */\n Vertical = 'Vertical',\n\n /**\n * This lets Stripe choose the best layout for payment methods in the sheet.\n */\n Automatic = 'Automatic',\n}\n"],"mappings":"0KA6UYA,eAAc,iDAAdA,cAAc,EAAdA,cAAc,0BAAdA,cAAc,kBAAdA,cAAc,uBAAdA,cAAc,0BAAdA,cAAc,SASdC,sBAAqB,+DAArBA,qBAAqB,EAArBA,qBAAqB,0BAArBA,qBAAqB,kBAArBA,qBAAqB,mBAArBA,qBAAqB,iCAArBA,qBAAqB,SA8CrBC,cAAa,+CAAbA,aAAa,EAAbA,aAAa,0BAAbA,aAAa,oBAAbA,aAAa,uCAAbA,aAAa,yBAAbA,aAAa,SAqCbC,oBAAmB,2DAAnBA,mBAAmB,EAAnBA,mBAAmB,4BAAnBA,mBAAmB,wBAAnBA,mBAAmB,6BAAnBA,mBAAmB,+BAAnBA,mBAAmB"}
|