@stripe/stripe-react-native 0.38.6 → 0.39.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 CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.39.0 - 2024-10-15
6
+
7
+ **Features**
8
+
9
+ - Adds support for CustomerSession in private beta [1744](https://github.com/stripe/stripe-react-native/pull/1744)
10
+ - Added `onBehalfOf` prop to CardField
11
+
12
+ **Fixes**
13
+
14
+ * Updated `stripe-ios` to 23.30.\*
15
+ * Updated `stripe-android` to 20.52.\*
16
+
5
17
  ## 0.38.6 - 2024-09-04
6
18
 
7
19
  **Fixes**
package/android/.project CHANGED
@@ -14,15 +14,4 @@
14
14
  <natures>
15
15
  <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16
16
  </natures>
17
- <filteredResources>
18
- <filter>
19
- <id>1725490136547</id>
20
- <name></name>
21
- <type>30</type>
22
- <matcher>
23
- <id>org.eclipse.core.resources.regexFilterMatcher</id>
24
- <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25
- </matcher>
26
- </filter>
27
- </filteredResources>
28
17
  </projectDescription>
@@ -1,11 +1,11 @@
1
- arguments=--init-script /var/folders/qg/5wmspvx516145k8z2q01c8_m0000gn/T/db3b08fc4a9ef609cb16b96b200fa13e563f396e9bb1ed0905fdab7bc3bc513b.gradle --init-script /var/folders/qg/5wmspvx516145k8z2q01c8_m0000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
1
+ arguments=
2
2
  auto.sync=false
3
3
  build.scans.enabled=false
4
- connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(8.9))
4
+ connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.0))
5
5
  connection.project.dir=
6
6
  eclipse.preferences.version=1
7
7
  gradle.user.home=
8
- java.home=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
8
+ java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
9
9
  jvm.arguments=
10
10
  offline.mode=false
11
11
  override.workspace.settings=true
@@ -1,3 +1,3 @@
1
1
  StripeSdk_kotlinVersion=1.8.0
2
2
  # Keep StripeSdk_stripeVersion in sync with https://github.com/stripe/stripe-identity-react-native/blob/main/android/gradle.properties
3
- StripeSdk_stripeVersion=20.48.+
3
+ StripeSdk_stripeVersion=20.52.+
@@ -219,6 +219,10 @@ class CardFieldView(context: ThemedReactContext) : FrameLayout(context) {
219
219
  mCardWidget.setPreferredNetworks(mapToPreferredNetworks(preferredNetworks))
220
220
  }
221
221
 
222
+ fun setOnBehalfOf(onBehalfOf: String?) {
223
+ mCardWidget.onBehalfOf = onBehalfOf
224
+ }
225
+
222
226
  /**
223
227
  * We can reliable assume that setPostalCodeEnabled is called before
224
228
  * setCountryCode because of the order of the props in CardField.tsx
@@ -51,6 +51,11 @@ class CardFieldViewManager : SimpleViewManager<CardFieldView>() {
51
51
  view.setCountryCode(countryCode)
52
52
  }
53
53
 
54
+ @ReactProp(name = "onBehalfOf")
55
+ fun setOnBehalfOf(view: CardFieldView, onBehalfOf: String?) {
56
+ view.setOnBehalfOf(onBehalfOf)
57
+ }
58
+
54
59
  @ReactProp(name = "placeholders")
55
60
  fun setPlaceHolders(view: CardFieldView, placeholders: ReadableMap) {
56
61
  view.setPlaceHolders(placeholders)
@@ -63,8 +63,6 @@ class PaymentSheetFragment(
63
63
  return
64
64
  }
65
65
  val primaryButtonLabel = arguments?.getString("primaryButtonLabel")
66
- val customerId = arguments?.getString("customerId").orEmpty()
67
- val customerEphemeralKeySecret = arguments?.getString("customerEphemeralKeySecret").orEmpty()
68
66
  val googlePayConfig = buildGooglePayConfig(arguments?.getBundle("googlePay"))
69
67
  val allowsDelayedPaymentMethods = arguments?.getBoolean("allowsDelayedPaymentMethods")
70
68
  val billingDetailsBundle = arguments?.getBundle("defaultBillingDetails")
@@ -86,6 +84,13 @@ class PaymentSheetFragment(
86
84
  return
87
85
  }
88
86
 
87
+ val customerConfiguration = try {
88
+ buildCustomerConfiguration(arguments)
89
+ } catch (error: PaymentSheetException) {
90
+ initPromise.resolve(createError(ErrorType.Failed.toString(), error))
91
+ return
92
+ }
93
+
89
94
  val shippingDetails = arguments?.getBundle("defaultShippingDetails")?.let {
90
95
  AddressSheetView.buildAddressDetails(it)
91
96
  }
@@ -190,12 +195,7 @@ class PaymentSheetFragment(
190
195
  val configurationBuilder = PaymentSheet.Configuration.Builder(merchantDisplayName)
191
196
  .allowsDelayedPaymentMethods(allowsDelayedPaymentMethods ?: false)
192
197
  .defaultBillingDetails(defaultBillingDetails)
193
- .customer(
194
- if (customerId.isNotEmpty() && customerEphemeralKeySecret.isNotEmpty()) PaymentSheet.CustomerConfiguration(
195
- id = customerId,
196
- ephemeralKeySecret = customerEphemeralKeySecret
197
- ) else null
198
- )
198
+ .customer(customerConfiguration)
199
199
  .googlePay(googlePayConfig)
200
200
  .appearance(appearance)
201
201
  .shippingDetails(shippingDetails)
@@ -428,6 +428,28 @@ class PaymentSheetFragment(
428
428
  )
429
429
  }
430
430
  }
431
+
432
+ @OptIn(ExperimentalCustomerSessionApi::class)
433
+ @Throws(PaymentSheetException::class)
434
+ private fun buildCustomerConfiguration(bundle: Bundle?): PaymentSheet.CustomerConfiguration? {
435
+ val customerId = bundle?.getString("customerId").orEmpty()
436
+ val customerEphemeralKeySecret = bundle?.getString("customerEphemeralKeySecret").orEmpty()
437
+ val customerSessionClientSecret = bundle?.getString("customerSessionClientSecret").orEmpty()
438
+ return if (customerSessionClientSecret.isNotEmpty() && customerEphemeralKeySecret.isNotEmpty()) {
439
+ throw PaymentSheetException("`customerEphemeralKeySecret` and `customerSessionClientSecret` cannot both be set")
440
+ } else if (customerId.isNotEmpty() && customerSessionClientSecret.isNotEmpty()) {
441
+ PaymentSheet.CustomerConfiguration.createWithCustomerSession(
442
+ id = customerId,
443
+ clientSecret = customerSessionClientSecret
444
+ )
445
+ }
446
+ else if (customerId.isNotEmpty() && customerEphemeralKeySecret.isNotEmpty()) {
447
+ PaymentSheet.CustomerConfiguration(
448
+ id = customerId,
449
+ ephemeralKeySecret = customerEphemeralKeySecret
450
+ )
451
+ } else null
452
+ }
431
453
  }
432
454
  }
433
455
 
@@ -20,7 +20,6 @@ import com.stripe.android.customersheet.CustomerAdapter
20
20
  import com.stripe.android.customersheet.CustomerEphemeralKey
21
21
  import com.stripe.android.customersheet.CustomerSheet
22
22
  import com.stripe.android.customersheet.CustomerSheetResult
23
- import com.stripe.android.customersheet.ExperimentalCustomerSheetApi
24
23
  import com.stripe.android.customersheet.PaymentOptionSelection
25
24
  import com.stripe.android.model.PaymentMethod
26
25
  import com.stripe.android.paymentsheet.*
@@ -29,7 +28,7 @@ import kotlinx.coroutines.Dispatchers
29
28
  import kotlinx.coroutines.launch
30
29
 
31
30
 
32
- @OptIn(ExperimentalCustomerSheetApi::class, ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi::class)
31
+ @OptIn(ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi::class)
33
32
  class CustomerSheetFragment : Fragment() {
34
33
  private var customerSheet: CustomerSheet? = null
35
34
  internal var customerAdapter: ReactNativeCustomerAdapter? = null
@@ -111,11 +110,12 @@ class CustomerSheetFragment : Fragment() {
111
110
 
112
111
  customerSheet = CustomerSheet.create(
113
112
  fragment = this,
114
- configuration = configuration.build(),
115
113
  customerAdapter = customerAdapter,
116
114
  callback = ::handleResult
117
115
  )
118
116
 
117
+ customerSheet?.configure(configuration.build())
118
+
119
119
  initPromise.resolve(WritableNativeMap())
120
120
  }
121
121
 
@@ -7,11 +7,9 @@ import com.facebook.react.bridge.ReadableMap
7
7
  import com.facebook.react.bridge.WritableMap
8
8
  import com.reactnativestripesdk.StripeSdkModule
9
9
  import com.stripe.android.customersheet.CustomerAdapter
10
- import com.stripe.android.customersheet.ExperimentalCustomerSheetApi
11
10
  import com.stripe.android.model.PaymentMethod
12
11
  import kotlinx.coroutines.CompletableDeferred
13
12
 
14
- @OptIn(ExperimentalCustomerSheetApi::class)
15
13
  class ReactNativeCustomerAdapter (
16
14
  private val context: ReactApplicationContext,
17
15
  private val adapter: CustomerAdapter,
@@ -12,6 +12,7 @@ RCT_EXPORT_VIEW_PROPERTY(placeholders, NSDictionary)
12
12
  RCT_EXPORT_VIEW_PROPERTY(autofocus, BOOL)
13
13
  RCT_EXPORT_VIEW_PROPERTY(disabled, BOOL)
14
14
  RCT_EXPORT_VIEW_PROPERTY(dangerouslyGetFullCardDetails, BOOL)
15
+ RCT_EXPORT_VIEW_PROPERTY(onBehalfOf, NSString)
15
16
  RCT_EXPORT_VIEW_PROPERTY(preferredNetworks, NSArray)
16
17
  RCT_EXTERN_METHOD(focus:(nonnull NSNumber*) reactTag)
17
18
  RCT_EXTERN_METHOD(blur:(nonnull NSNumber*) reactTag)
@@ -6,9 +6,9 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
6
6
  @objc var onCardChange: RCTDirectEventBlock?
7
7
  @objc var onFocusChange: RCTDirectEventBlock?
8
8
  @objc var dangerouslyGetFullCardDetails: Bool = false
9
-
9
+
10
10
  private var cardField = STPPaymentCardTextField()
11
-
11
+
12
12
  public var cardParams: STPPaymentMethodParams? = nil
13
13
  public var cardPostalCode: String? = nil
14
14
 
@@ -17,19 +17,25 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
17
17
  cardField.isUserInteractionEnabled = !disabled
18
18
  }
19
19
  }
20
-
20
+
21
21
  @objc var postalCodeEnabled: Bool = true {
22
22
  didSet {
23
23
  cardField.postalCodeEntryEnabled = postalCodeEnabled
24
24
  }
25
25
  }
26
-
26
+
27
27
  @objc var countryCode: String? {
28
28
  didSet {
29
29
  cardField.countryCode = countryCode
30
30
  }
31
31
  }
32
-
32
+
33
+ @objc var onBehalfOf: String? {
34
+ didSet {
35
+ cardField.onBehalfOf = onBehalfOf
36
+ }
37
+ }
38
+
33
39
  @objc var preferredNetworks: Array<Int>? {
34
40
  didSet {
35
41
  if let preferredNetworks = preferredNetworks {
@@ -37,7 +43,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
37
43
  }
38
44
  }
39
45
  }
40
-
46
+
41
47
  @objc var placeholders: NSDictionary = NSDictionary() {
42
48
  didSet {
43
49
  if let numberPlaceholder = placeholders["number"] as? String {
@@ -56,7 +62,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
56
62
  }
57
63
  }
58
64
  }
59
-
65
+
60
66
  @objc var autofocus: Bool = false {
61
67
  didSet {
62
68
  if autofocus == true {
@@ -64,7 +70,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
64
70
  }
65
71
  }
66
72
  }
67
-
73
+
68
74
  @objc var cardStyle: NSDictionary = NSDictionary() {
69
75
  didSet {
70
76
  if let borderWidth = cardStyle["borderWidth"] as? Int {
@@ -91,7 +97,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
91
97
  cardField.textErrorColor = UIColor(hexString: textErrorColor)
92
98
  }
93
99
  let fontSize = cardStyle["fontSize"] as? Int ?? 14
94
-
100
+
95
101
  if let fontFamily = cardStyle["fontFamily"] as? String {
96
102
  cardField.font = UIFont(name: fontFamily, size: CGFloat(fontSize)) ?? UIFont.systemFont(ofSize: CGFloat(fontSize))
97
103
  } else {
@@ -104,46 +110,46 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
104
110
  }
105
111
  }
106
112
  }
107
-
113
+
108
114
  override init(frame: CGRect) {
109
115
  super.init(frame: frame)
110
116
  cardField.delegate = self
111
-
117
+
112
118
  self.addSubview(cardField)
113
119
  }
114
-
120
+
115
121
  func focus() {
116
122
  cardField.becomeFirstResponder()
117
123
  }
118
-
124
+
119
125
  func blur() {
120
126
  cardField.resignFirstResponder()
121
127
  }
122
-
128
+
123
129
  func clear() {
124
130
  cardField.clear()
125
131
  }
126
-
132
+
127
133
  func paymentCardTextFieldDidEndEditing(_ textField: STPPaymentCardTextField) {
128
134
  onFocusChange?(["focusedField": NSNull()])
129
135
  }
130
-
136
+
131
137
  func paymentCardTextFieldDidBeginEditingNumber(_ textField: STPPaymentCardTextField) {
132
138
  onFocusChange?(["focusedField": "CardNumber"])
133
139
  }
134
-
140
+
135
141
  func paymentCardTextFieldDidBeginEditingCVC(_ textField: STPPaymentCardTextField) {
136
142
  onFocusChange?(["focusedField": "Cvc"])
137
143
  }
138
-
144
+
139
145
  func paymentCardTextFieldDidBeginEditingExpiration(_ textField: STPPaymentCardTextField) {
140
146
  onFocusChange?(["focusedField": "ExpiryDate"])
141
147
  }
142
-
148
+
143
149
  func paymentCardTextFieldDidBeginEditingPostalCode(_ textField: STPPaymentCardTextField) {
144
150
  onFocusChange?(["focusedField": "PostalCode"])
145
151
  }
146
-
152
+
147
153
  func paymentCardTextFieldDidChange(_ textField: STPPaymentCardTextField) {
148
154
  if onCardChange != nil {
149
155
  let brand = STPCardValidator.brand(forNumber: textField.cardNumber ?? "")
@@ -180,29 +186,29 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
180
186
  self.cardPostalCode = nil
181
187
  }
182
188
  }
183
-
189
+
184
190
  override func layoutSubviews() {
185
191
  cardField.frame = self.bounds
186
192
  }
187
-
193
+
188
194
  required init?(coder: NSCoder) {
189
195
  fatalError("init(coder:) has not been implemented")
190
196
  }
191
-
197
+
192
198
  func paymentContext(_ paymentContext: STPPaymentContext, didFailToLoadWithError error: Error) {
193
199
  //
194
200
  }
195
-
201
+
196
202
  func paymentContextDidChange(_ paymentContext: STPPaymentContext) {
197
203
  //
198
204
  }
199
-
205
+
200
206
  func paymentContext(_ paymentContext: STPPaymentContext, didCreatePaymentResult paymentResult: STPPaymentResult, completion: @escaping STPPaymentStatusBlock) {
201
207
  //
202
208
  }
203
-
209
+
204
210
  func paymentContext(_ paymentContext: STPPaymentContext, didFinishWith status: STPPaymentStatus, error: Error?) {
205
211
  //
206
212
  }
207
-
213
+
208
214
  }
@@ -9,6 +9,7 @@ RCT_EXPORT_VIEW_PROPERTY(autofocus, BOOL)
9
9
  RCT_EXPORT_VIEW_PROPERTY(cardStyle, NSDictionary)
10
10
  RCT_EXPORT_VIEW_PROPERTY(disabled, BOOL)
11
11
  RCT_EXPORT_VIEW_PROPERTY(preferredNetworks, NSArray)
12
+ RCT_EXPORT_VIEW_PROPERTY(onBehalfOf, NSString)
12
13
  RCT_EXTERN_METHOD(focus:(nonnull NSNumber*) reactTag)
13
14
  RCT_EXTERN_METHOD(blur:(nonnull NSNumber*) reactTag)
14
15
  @end
@@ -6,7 +6,7 @@
6
6
  //
7
7
 
8
8
  import Foundation
9
- @_spi(ExperimentalAllowsRemovalOfLastSavedPaymentMethodAPI) @_spi(STP) import StripePaymentSheet
9
+ @_spi(ExperimentalAllowsRemovalOfLastSavedPaymentMethodAPI) @_spi(CustomerSessionBetaAccess) @_spi(STP) import StripePaymentSheet
10
10
 
11
11
  extension StripeSdk {
12
12
  internal func buildPaymentSheetConfiguration(
@@ -91,11 +91,17 @@ extension StripeSdk {
91
91
  }
92
92
 
93
93
  if let customerId = params["customerId"] as? String {
94
- if let customerEphemeralKeySecret = params["customerEphemeralKeySecret"] as? String {
94
+ var customerEphemeralKeySecret = params["customerEphemeralKeySecret"] as? String
95
+ var customerClientSecret = params["customerSessionClientSecret"] as? String
96
+ if let customerEphemeralKeySecret, let customerClientSecret {
97
+ return(error: Errors.createError(ErrorType.Failed, "`customerEphemeralKeySecret` and `customerSessionClientSecret cannot both be set"), configuration: nil)
98
+ } else if let customerEphemeralKeySecret {
95
99
  if (!Errors.isEKClientSecretValid(clientSecret: customerEphemeralKeySecret)) {
96
100
  return(error: Errors.createError(ErrorType.Failed, "`customerEphemeralKeySecret` format does not match expected client secret formatting."), configuration: nil)
97
101
  }
98
102
  configuration.customer = .init(id: customerId, ephemeralKeySecret: customerEphemeralKeySecret)
103
+ } else if let customerClientSecret {
104
+ configuration.customer = .init(id: customerId, customerSessionClientSecret: customerClientSecret)
99
105
  }
100
106
  }
101
107
 
@@ -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:182,columnNumber:7}}));});exports.CardField=CardField;
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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B+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,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,CAE9B,GAAMC,KAA4B,CAAG,CACnCC,KAAK,CAAEH,IAAI,CAACG,KAAK,CACjBC,WAAW,CAAEJ,IAAI,CAACI,WAAW,CAC7BC,UAAU,CAAEL,IAAI,CAACK,UAAU,CAC3BC,QAAQ,CAAEN,IAAI,CAACM,QAAQ,CACvBC,KAAK,CAAEP,IAAI,CAACO,KAAK,CACjBC,eAAe,CAAER,IAAI,CAACQ,eAAe,CACrCC,WAAW,CAAET,IAAI,CAACS,WAAW,CAC7BC,QAAQ,CAAEV,IAAI,CAACU,QACjB,CAAC,CAED,GAAIV,IAAI,CAACW,cAAc,CAAC,YAAY,CAAC,CAAE,CACrCT,IAAI,CAACU,UAAU,CAAGZ,IAAI,CAACY,UAAU,EAAI,EAAE,CACzC,CACA,GAAIZ,IAAI,CAACW,cAAc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EmD,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 +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"],"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\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"],"mappings":"8IAwUYA,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,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:182,columnNumber:7}}));});exports.CardField=CardField;
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,CAE9B,GAAMC,KAA4B,CAAG,CACnCC,KAAK,CAAEH,IAAI,CAACG,KAAK,CACjBC,WAAW,CAAEJ,IAAI,CAACI,WAAW,CAC7BC,UAAU,CAAEL,IAAI,CAACK,UAAU,CAC3BC,QAAQ,CAAEN,IAAI,CAACM,QAAQ,CACvBC,KAAK,CAAEP,IAAI,CAACO,KAAK,CACjBC,eAAe,CAAER,IAAI,CAACQ,eAAe,CACrCC,WAAW,CAAET,IAAI,CAACS,WAAW,CAC7BC,QAAQ,CAAEV,IAAI,CAACU,QACjB,CAAC,CAED,GAAIV,IAAI,CAACW,cAAc,CAAC,YAAY,CAAC,CAAE,CACrCT,IAAI,CAACU,UAAU,CAAGZ,IAAI,CAACY,UAAU,EAAI,EAAE,CACzC,CACA,GAAIZ,IAAI,CAACW,cAAc,CAAC,QAAQ,CAAC,EAAIX,IAAI,CAACW,cAAc,CAAC,KAAK,CAAC,CAAE,CAC/DT,IA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AAErD,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,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,CAE9B,GAAMC,KAA4B,CAAG,CACnCC,KAAK,CAAEH,IAAI,CAACG,KAAK,CACjBC,WAAW,CAAEJ,IAAI,CAACI,WAAW,CAC7BC,UAAU,CAAEL,IAAI,CAACK,UAAU,CAC3BC,QAAQ,CAAEN,IAAI,CAACM,QAAQ,CACvBC,KAAK,CAAEP,IAAI,CAACO,KAAK,CACjBC,eAAe,CAAER,IAAI,CAACQ,eAAe,CACrCC,WAAW,CAAET,IAAI,CAACS,WAAW,CAC7BC,QAAQ,CAAEV,IAAI,CAACU,QACjB,CAAC,CAED,GAAIV,IAAI,CAACW,cAAc,C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AS,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 +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"],"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\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"],"mappings":"8IAwUYA,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"}
@@ -22,6 +22,8 @@ export interface Props extends AccessibilityProps {
22
22
  /** The list of preferred networks that should be used to process payments made with a co-branded card.
23
23
  * This value will only be used if your user hasn't selected a network themselves. */
24
24
  preferredNetworks?: Array<CardBrand>;
25
+ /** The account (if any) for which the funds of the intent are intended. */
26
+ onBehalfOf?: string;
25
27
  /**
26
28
  * WARNING: If set to `true` the full card number will be returned in the `onCardChange` handler.
27
29
  * Only do this if you're certain that you fulfill the necessary PCI compliance requirements.
@@ -4,13 +4,11 @@ import type { ButtonType, RecurringPaymentRequest, AutomaticReloadPaymentRequest
4
4
  import type { FutureUsage } from './PaymentIntent';
5
5
  import type { Result } from './PaymentMethod';
6
6
  import type { StripeError } from './Errors';
7
- export declare type SetupParams = IntentParams & {
7
+ declare type SetupParamsBase = IntentParams & {
8
8
  /** Your customer-facing business name. On Android, this is required and cannot be an empty string. */
9
9
  merchantDisplayName: string;
10
10
  /** The identifier of the Stripe Customer object. See https://stripe.com/docs/api/customers/object#customer_object-id */
11
11
  customerId?: string;
12
- /** A short-lived token that allows the SDK to access a Customer’s payment methods. */
13
- customerEphemeralKeySecret?: string;
14
12
  /** When set to true, separates out the payment method selection & confirmation steps.
15
13
  * If true, you must call `confirmPaymentSheetPayment` on your own. Defaults to false. */
16
14
  customFlow?: boolean;
@@ -62,6 +60,17 @@ export declare type SetupParams = IntentParams & {
62
60
  */
63
61
  allowsRemovalOfLastSavedPaymentMethod?: boolean;
64
62
  };
63
+ export declare type SetupParams = (SetupParamsBase & {
64
+ /** A short-lived token that allows the SDK to access a Customer’s payment methods. */
65
+ customerEphemeralKeySecret: string;
66
+ customerSessionClientSecret?: never;
67
+ }) | (SetupParamsBase & {
68
+ customerEphemeralKeySecret?: never;
69
+ /** (Experimental) This parameter can be changed or removed at any time (use at your own risk).
70
+ * The client secret of this Customer Session. Used on the client to set up secure access to the given customer.
71
+ */
72
+ customerSessionClientSecret: string;
73
+ }) | SetupParamsBase;
65
74
  export declare type IntentParams = {
66
75
  paymentIntentClientSecret: string;
67
76
  setupIntentClientSecret?: undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/stripe-react-native",
3
- "version": "0.38.6",
3
+ "version": "0.39.0",
4
4
  "author": "Stripe",
5
5
  "description": "Stripe SDK for React Native",
6
6
  "main": "lib/commonjs/index",
@@ -46,6 +46,8 @@ export interface Props extends AccessibilityProps {
46
46
  /** The list of preferred networks that should be used to process payments made with a co-branded card.
47
47
  * This value will only be used if your user hasn't selected a network themselves. */
48
48
  preferredNetworks?: Array<CardBrand>;
49
+ /** The account (if any) for which the funds of the intent are intended. */
50
+ onBehalfOf?: string;
49
51
  /**
50
52
  * WARNING: If set to `true` the full card number will be returned in the `onCardChange` handler.
51
53
  * Only do this if you're certain that you fulfill the necessary PCI compliance requirements.
@@ -10,13 +10,11 @@ import type { FutureUsage } from './PaymentIntent';
10
10
  import type { Result } from './PaymentMethod';
11
11
  import type { StripeError } from './Errors';
12
12
 
13
- export type SetupParams = IntentParams & {
13
+ type SetupParamsBase = IntentParams & {
14
14
  /** Your customer-facing business name. On Android, this is required and cannot be an empty string. */
15
15
  merchantDisplayName: string;
16
16
  /** The identifier of the Stripe Customer object. See https://stripe.com/docs/api/customers/object#customer_object-id */
17
17
  customerId?: string;
18
- /** A short-lived token that allows the SDK to access a Customer’s payment methods. */
19
- customerEphemeralKeySecret?: string;
20
18
  /** When set to true, separates out the payment method selection & confirmation steps.
21
19
  * If true, you must call `confirmPaymentSheetPayment` on your own. Defaults to false. */
22
20
  customFlow?: boolean;
@@ -69,6 +67,21 @@ export type SetupParams = IntentParams & {
69
67
  allowsRemovalOfLastSavedPaymentMethod?: boolean;
70
68
  };
71
69
 
70
+ export type SetupParams =
71
+ | (SetupParamsBase & {
72
+ /** A short-lived token that allows the SDK to access a Customer’s payment methods. */
73
+ customerEphemeralKeySecret: string;
74
+ customerSessionClientSecret?: never;
75
+ })
76
+ | (SetupParamsBase & {
77
+ customerEphemeralKeySecret?: never;
78
+ /** (Experimental) This parameter can be changed or removed at any time (use at your own risk).
79
+ * The client secret of this Customer Session. Used on the client to set up secure access to the given customer.
80
+ */
81
+ customerSessionClientSecret: string;
82
+ })
83
+ | SetupParamsBase;
84
+
72
85
  export type IntentParams =
73
86
  | {
74
87
  paymentIntentClientSecret: string;
@@ -2,7 +2,7 @@ require 'json'
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
4
  # Keep stripe_version in sync with https://github.com/stripe/stripe-identity-react-native/blob/main/stripe-identity-react-native.podspec
5
- stripe_version = '~> 23.28.0'
5
+ stripe_version = '~> 23.30.0'
6
6
 
7
7
  Pod::Spec.new do |s|
8
8
  s.name = 'stripe-react-native'