@stripe/stripe-js 4.10.0 → 5.0.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.
Files changed (33) hide show
  1. package/dist/api/confirmation-tokens.d.mts +0 -3
  2. package/dist/api/confirmation-tokens.d.ts +0 -3
  3. package/dist/index.js +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/dist/pure.js +1 -1
  6. package/dist/pure.mjs +1 -1
  7. package/dist/stripe-js/checkout.d.mts +462 -126
  8. package/dist/stripe-js/checkout.d.ts +462 -126
  9. package/dist/stripe-js/elements/currency-selector.d.mts +93 -0
  10. package/dist/stripe-js/elements/currency-selector.d.ts +93 -0
  11. package/dist/stripe-js/elements/express-checkout.d.mts +3 -0
  12. package/dist/stripe-js/elements/express-checkout.d.ts +3 -0
  13. package/dist/stripe-js/elements/index.d.mts +1 -0
  14. package/dist/stripe-js/elements/index.d.ts +1 -0
  15. package/dist/stripe-js/elements/payment.d.mts +136 -0
  16. package/dist/stripe-js/elements/payment.d.ts +136 -0
  17. package/dist/stripe-js/elements-group.d.mts +37 -7
  18. package/dist/stripe-js/elements-group.d.ts +37 -7
  19. package/dist/stripe-js/embedded-checkout.d.mts +30 -0
  20. package/dist/stripe-js/embedded-checkout.d.ts +30 -0
  21. package/dist/stripe-js/hosted-checkout.d.mts +153 -0
  22. package/dist/stripe-js/hosted-checkout.d.ts +153 -0
  23. package/dist/stripe-js/index.d.mts +1 -1
  24. package/dist/stripe-js/index.d.ts +1 -1
  25. package/dist/stripe-js/payment-intents.d.mts +79 -3
  26. package/dist/stripe-js/payment-intents.d.ts +79 -3
  27. package/dist/stripe-js/setup-intents.d.mts +0 -3
  28. package/dist/stripe-js/setup-intents.d.ts +0 -3
  29. package/dist/stripe-js/stripe.d.mts +38 -8
  30. package/dist/stripe-js/stripe.d.ts +38 -8
  31. package/package.json +1 -1
  32. package/dist/stripe-js/custom-checkout.d.mts +0 -437
  33. package/dist/stripe-js/custom-checkout.d.ts +0 -437
@@ -84,9 +84,6 @@ export interface ConfirmationTokenCreateParams {
84
84
  billing_details?: PaymentMethodCreateParams.BillingDetails;
85
85
 
86
86
  /**
87
- * Requires beta access:
88
- * Contact [Stripe support](https://support.stripe.com/) for more information.
89
- *
90
87
  * Specifies if the PaymentMethod should be redisplayed when using the Saved Payment Method feature
91
88
  */
92
89
  allow_redisplay?: 'always' | 'limited' | 'unspecified';
@@ -84,9 +84,6 @@ export interface ConfirmationTokenCreateParams {
84
84
  billing_details?: PaymentMethodCreateParams.BillingDetails;
85
85
 
86
86
  /**
87
- * Requires beta access:
88
- * Contact [Stripe support](https://support.stripe.com/) for more information.
89
- *
90
87
  * Specifies if the PaymentMethod should be redisplayed when using the Saved Payment Method feature
91
88
  */
92
89
  allow_redisplay?: 'always' | 'limited' | 'unspecified';
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
42
42
 
43
43
  stripe._registerWrapper({
44
44
  name: 'stripe-js',
45
- version: "4.6.0",
45
+ version: "4.10.0",
46
46
  startTime: startTime
47
47
  });
48
48
  };
package/dist/index.mjs CHANGED
@@ -38,7 +38,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
38
38
 
39
39
  stripe._registerWrapper({
40
40
  name: 'stripe-js',
41
- version: "4.6.0",
41
+ version: "4.10.0",
42
42
  startTime: startTime
43
43
  });
44
44
  };
package/dist/pure.js CHANGED
@@ -58,7 +58,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
58
58
 
59
59
  stripe._registerWrapper({
60
60
  name: 'stripe-js',
61
- version: "4.6.0",
61
+ version: "4.10.0",
62
62
  startTime: startTime
63
63
  });
64
64
  };
package/dist/pure.mjs CHANGED
@@ -54,7 +54,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
54
54
 
55
55
  stripe._registerWrapper({
56
56
  name: 'stripe-js',
57
- version: "4.6.0",
57
+ version: "4.10.0",
58
58
  startTime: startTime
59
59
  });
60
60
  };
@@ -1,153 +1,489 @@
1
- export interface RedirectToCheckoutServerOptions {
2
- /**
3
- * The ID of the [Checkout Session](https://stripe.com/docs/api/checkout/sessions) that is used in [Checkout's server integration](https://stripe.com/docs/payments/checkout/one-time).
4
- */
5
- sessionId: string;
1
+ import {
2
+ LayoutObject,
3
+ Layout,
4
+ TermsOption,
5
+ StripePaymentElement,
6
+ } from './elements/payment';
7
+ import {
8
+ AddressMode,
9
+ ContactOption,
10
+ StripeAddressElement,
11
+ } from './elements/address';
12
+ import {Appearance, CssFontSource, CustomFontSource} from './elements-group';
13
+ import {StripeError} from './stripe';
14
+ import {
15
+ StripeCurrencySelectorElement,
16
+ FieldsOption,
17
+ StripeElementBase,
18
+ StripeExpressCheckoutElement,
19
+ StripeExpressCheckoutElementConfirmEvent,
20
+ StripeExpressCheckoutElementOptions,
21
+ StripeExpressCheckoutElementReadyEvent,
22
+ } from './elements';
23
+
24
+ /**
25
+ * Requires beta access:
26
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
27
+ */
28
+
29
+ export interface StripeCheckoutElementsOptions {
30
+ appearance?: Appearance;
31
+ loader?: 'auto' | 'always' | 'never';
32
+ fonts?: Array<CssFontSource | CustomFontSource>;
6
33
  }
7
34
 
8
- export interface RedirectToCheckoutClientOptions {
9
- /**
10
- * The URL to which Stripe should send customers when payment is complete.
11
- * If you’d like access to the Checkout Session for the successful payment, read more about it in our guide on [fulfilling your payments with webhooks](https://stripe.com/docs/payments/checkout/fulfillment#webhooks).
12
- */
13
- successUrl: string;
35
+ export interface StripeCheckoutOptions {
36
+ clientSecret: string;
37
+ elementsOptions?: StripeCheckoutElementsOptions;
38
+ }
14
39
 
15
- /**
16
- * The URL to which Stripe should send customers when payment is canceled.
17
- */
18
- cancelUrl: string;
40
+ /* Elements with CheckoutSessions API types */
41
+ export type StripeCheckoutAddress = {
42
+ country: string;
43
+ line1?: string | null;
44
+ line2?: string | null;
45
+ city?: string | null;
46
+ postal_code?: string | null;
47
+ state?: string | null;
48
+ };
19
49
 
20
- /**
21
- * An array of objects representing the items that your customer would like to purchase.
22
- * These items are shown as line items in the Checkout interface and make up the total amount to be collected by Checkout.
23
- */
24
- lineItems?: Array<{
25
- /**
26
- * The ID of the price that the customer would like to purchase. SKU or plan IDs may also be used.
27
- */
28
- price?: string;
29
-
30
- /**
31
- * The quantity of units for the item.
32
- */
33
- quantity?: number;
34
- }>;
50
+ export type StripeCheckoutAdjustableQuantity = {
51
+ maximum: number;
52
+ minimum: number;
53
+ };
35
54
 
36
- /**
37
- * An array of objects representing the items that your customer would like to purchase.
38
- * These items are shown as line items in the Checkout interface and make up the total amount to be collected by Checkout.
39
- *
40
- * @deprecated
41
- */
42
- items?: Array<{
43
- /**
44
- * The ID of the SKU that the customer would like to purchase
45
- */
46
- sku?: string;
47
-
48
- /**
49
- * The ID of the plan that the customer would like to subscribe to.
50
- */
51
- plan?: string;
52
-
53
- /**
54
- * The quantity of units for the item.
55
- */
56
- quantity?: number;
57
- }>;
55
+ export type StripeCheckoutBillingInterval = 'day' | 'month' | 'week' | 'year';
56
+
57
+ export type StripeCheckoutConfirmationRequirement =
58
+ | 'phoneNumber'
59
+ | 'shippingAddress'
60
+ | 'billingAddress'
61
+ | 'paymentDetails'
62
+ | 'email';
63
+
64
+ export type StripeCheckoutContact = {
65
+ name?: string | null;
66
+ address: StripeCheckoutAddress;
67
+ };
68
+
69
+ export type StripeCheckoutDeliveryEstimate = {
70
+ maximum: StripeCheckoutEstimate | null;
71
+ minimum: StripeCheckoutEstimate | null;
72
+ };
73
+
74
+ export type StripeCheckoutDiscountAmount = {
75
+ amount: number;
76
+ displayName: string;
77
+ promotionCode: string | null;
78
+ recurring:
79
+ | {type: 'forever'}
80
+ | {type: 'repeating'; durationInMonths: number}
81
+ | null;
82
+ };
83
+
84
+ export type StripeCheckoutDueNext = {
85
+ amountSubtotal: number;
86
+ amountDiscount: number;
87
+ amountTaxInclusive: number;
88
+ amountTaxExclusive: number;
89
+ billingCycleAnchor: number | null;
90
+ };
91
+
92
+ export type StripeCheckoutEstimate = {
93
+ unit: 'business_day' | 'day' | 'hour' | 'week' | 'month';
94
+ value: number;
95
+ };
96
+
97
+ export type StripeCheckoutLastPaymentError = {
98
+ message: string;
99
+ };
100
+
101
+ export type StripeCheckoutRedirectBehavior = 'always' | 'if_required';
102
+
103
+ export type StripeCheckoutSavedPaymentMethod = {
104
+ id: string;
105
+ type: 'card';
106
+ card: {
107
+ brand: string;
108
+ expMonth: number;
109
+ expYear: number;
110
+ last4: string;
111
+ };
112
+ billingDetails: {
113
+ email?: string | null;
114
+ name?: string | null;
115
+ phone?: string | null;
116
+ address?: {
117
+ line1?: string | null;
118
+ line2?: string | null;
119
+ city?: string | null;
120
+ postal_code?: string | null;
121
+ state?: string | null;
122
+ country?: string | null;
123
+ } | null;
124
+ };
125
+ };
126
+
127
+ export type StripeCheckoutTaxAmount = {
128
+ amount: number;
129
+ inclusive: boolean;
130
+ displayName: string;
131
+ };
132
+
133
+ export type StripeCheckoutLineItem = {
134
+ id: string;
135
+ name: string;
136
+ amountDiscount: number;
137
+ amountSubtotal: number;
138
+ amountTaxExclusive: number;
139
+ amountTaxInclusive: number;
140
+ unitAmount: number;
141
+ description: string | null;
142
+ quantity: number;
143
+ discountAmounts: Array<StripeCheckoutDiscountAmount> | null;
144
+ taxAmounts: Array<StripeCheckoutTaxAmount> | null;
145
+ recurring: {
146
+ interval: StripeCheckoutBillingInterval;
147
+ intervalCount: number;
148
+ isProrated: boolean;
149
+ usageType: 'metered' | 'licensed';
150
+ } | null;
151
+ adjustableQuantity: StripeCheckoutAdjustableQuantity | null;
152
+ images: string[];
153
+ };
154
+
155
+ export type StripeCheckoutRecurring = {
156
+ interval: StripeCheckoutBillingInterval;
157
+ intervalCount: number;
158
+ dueNext: StripeCheckoutDueNext;
159
+ trial: StripeCheckoutTrial | null;
160
+ };
58
161
 
162
+ export type StripeCheckoutShipping = {
163
+ shippingOption: StripeCheckoutShippingOption;
164
+ taxAmounts: Array<StripeCheckoutTaxAmount> | null;
165
+ };
166
+
167
+ export type StripeCheckoutShippingOption = {
168
+ id: string;
169
+ amount: number;
170
+ currency: string;
171
+ displayName: string | null;
172
+ deliveryEstimate: StripeCheckoutDeliveryEstimate | null;
173
+ };
174
+
175
+ export type StripeCheckoutStatus =
176
+ | {type: 'open'}
177
+ | {type: 'expired'}
178
+ | {
179
+ type: 'complete';
180
+ paymentStatus: 'paid' | 'unpaid' | 'no_payment_required';
181
+ };
182
+
183
+ export type StripeCheckoutTaxStatus =
184
+ | {status: 'ready'}
185
+ | {status: 'requires_shipping_address'}
186
+ | {status: 'requires_billing_address'};
187
+
188
+ export type StripeCheckoutTotalSummary = {
189
+ appliedBalance: number;
190
+ balanceAppliedToNextInvoice: boolean;
191
+ discount: number;
192
+ shippingRate: number;
193
+ subtotal: number;
194
+ taxExclusive: number;
195
+ taxInclusive: number;
196
+ total: number;
197
+ };
198
+
199
+ export type StripeCheckoutTrial = {
200
+ trialEnd: number;
201
+ trialPeriodDays: number;
202
+ };
203
+
204
+ export type StripeCheckoutCurrencyOption = {
205
+ amount: number;
206
+ currency: string;
207
+ currencyConversion?: {fxRate: number; sourceCurrency: string};
208
+ };
209
+
210
+ /* Custom Checkout session */
211
+ export interface StripeCheckoutSession {
212
+ billingAddress: StripeCheckoutContact | null;
213
+ businessName: string | null;
214
+ canConfirm: boolean;
215
+ confirmationRequirements: StripeCheckoutConfirmationRequirement[];
216
+ currency: string;
217
+ currencyOptions: Array<StripeCheckoutCurrencyOption> | null;
218
+ discountAmounts: Array<StripeCheckoutDiscountAmount> | null;
219
+ email: string | null;
220
+ id: string;
221
+ lastPaymentError: StripeCheckoutLastPaymentError | null;
222
+ lineItems: Array<StripeCheckoutLineItem>;
223
+ livemode: boolean;
224
+ phoneNumber: string | null;
225
+ recurring: StripeCheckoutRecurring | null;
226
+ savedPaymentMethods: Array<StripeCheckoutSavedPaymentMethod> | null;
227
+ shipping: StripeCheckoutShipping | null;
228
+ shippingAddress: StripeCheckoutContact | null;
229
+ shippingOptions: Array<StripeCheckoutShippingOption>;
230
+ status: StripeCheckoutStatus;
231
+ tax: StripeCheckoutTaxStatus;
232
+ taxAmounts: Array<StripeCheckoutTaxAmount> | null;
233
+ total: StripeCheckoutTotalSummary;
234
+ }
235
+
236
+ export type StripeCheckoutResult =
237
+ | {session: StripeCheckoutSession; error?: undefined}
238
+ | {session?: undefined; error: StripeError};
239
+
240
+ export type StripeCheckoutPaymentElementOptions = {
241
+ layout?: Layout | LayoutObject;
242
+ paymentMethodOrder?: Array<string>;
243
+ readonly?: boolean;
244
+ terms?: TermsOption;
245
+ fields?: FieldsOption;
246
+ };
247
+
248
+ export type StripeCheckoutAddressElementOptions = {
249
+ mode: AddressMode;
250
+ contacts?: ContactOption[];
251
+ display?: {
252
+ name?: 'full' | 'split' | 'organization';
253
+ };
254
+ };
255
+
256
+ export type StripeCheckoutExpressCheckoutElementOptions = {
257
+ buttonHeight: StripeExpressCheckoutElementOptions['buttonHeight'];
258
+ buttonTheme: StripeExpressCheckoutElementOptions['buttonTheme'];
259
+ buttonType: StripeExpressCheckoutElementOptions['buttonType'];
260
+ layout: StripeExpressCheckoutElementOptions['layout'];
261
+ paymentMethodOrder: StripeExpressCheckoutElementOptions['paymentMethodOrder'];
262
+ paymentMethods: StripeExpressCheckoutElementOptions['paymentMethods'];
263
+ };
264
+
265
+ export type StripeCheckoutUpdateHandler = (
266
+ session: StripeCheckoutSession
267
+ ) => void;
268
+
269
+ export type StripeCheckoutExpressCheckoutElement = StripeElementBase & {
59
270
  /**
60
- * The mode of the Checkout Session. Required if using lineItems.
271
+ * Triggered when the element is fully rendered.
61
272
  */
62
- mode?: 'payment' | 'subscription';
273
+ on(
274
+ eventType: 'ready',
275
+ handler: (event: StripeExpressCheckoutElementReadyEvent) => any
276
+ ): StripeCheckoutExpressCheckoutElement;
277
+ once(
278
+ eventType: 'ready',
279
+ handler: (event: StripeExpressCheckoutElementReadyEvent) => any
280
+ ): StripeCheckoutExpressCheckoutElement;
281
+ off(
282
+ eventType: 'ready',
283
+ handler?: (event: StripeExpressCheckoutElementReadyEvent) => any
284
+ ): StripeCheckoutExpressCheckoutElement;
63
285
 
64
286
  /**
65
- * A unique string to reference the Checkout session.
66
- * This can be a customer ID, a cart ID, or similar.
67
- * It is included in the `checkout.session.completed` webhook and can be used to fulfill the purchase.
287
+ * Triggered when the element gains focus.
68
288
  */
69
- clientReferenceId?: string;
289
+ on(
290
+ eventType: 'focus',
291
+ handler: (event: {elementType: 'expressCheckout'}) => any
292
+ ): StripeCheckoutExpressCheckoutElement;
293
+ once(
294
+ eventType: 'focus',
295
+ handler: (event: {elementType: 'expressCheckout'}) => any
296
+ ): StripeCheckoutExpressCheckoutElement;
297
+ off(
298
+ eventType: 'focus',
299
+ handler?: (event: {elementType: 'expressCheckout'}) => any
300
+ ): StripeCheckoutExpressCheckoutElement;
70
301
 
71
302
  /**
72
- * The email address used to create the customer object.
73
- * If you already know your customer's email address, use this attribute to prefill it on Checkout.
303
+ * Triggered when the element loses focus.
74
304
  */
75
- customerEmail?: string;
305
+ on(
306
+ eventType: 'blur',
307
+ handler: (event: {elementType: 'expressCheckout'}) => any
308
+ ): StripeCheckoutExpressCheckoutElement;
309
+ once(
310
+ eventType: 'blur',
311
+ handler: (event: {elementType: 'expressCheckout'}) => any
312
+ ): StripeCheckoutExpressCheckoutElement;
313
+ off(
314
+ eventType: 'blur',
315
+ handler?: (event: {elementType: 'expressCheckout'}) => any
316
+ ): StripeCheckoutExpressCheckoutElement;
76
317
 
77
318
  /**
78
- * Specify whether Checkout should collect the customer’s billing address.
79
- * If set to `required`, Checkout will attempt to collect the customer’s billing address.
80
- * If not set or set to `auto` Checkout will only attempt to collect the billing address when necessary.
319
+ * Triggered when the escape key is pressed within the element.
81
320
  */
82
- billingAddressCollection?: 'auto' | 'required';
321
+ on(
322
+ eventType: 'escape',
323
+ handler: (event: {elementType: 'expressCheckout'}) => any
324
+ ): StripeCheckoutExpressCheckoutElement;
325
+ once(
326
+ eventType: 'escape',
327
+ handler: (event: {elementType: 'expressCheckout'}) => any
328
+ ): StripeCheckoutExpressCheckoutElement;
329
+ off(
330
+ eventType: 'escape',
331
+ handler?: (event: {elementType: 'expressCheckout'}) => any
332
+ ): StripeCheckoutExpressCheckoutElement;
83
333
 
84
334
  /**
85
- * Provides configuration for Checkout to collect a shipping address from a customer.
335
+ * Triggered when the element fails to load.
86
336
  */
87
- shippingAddressCollection?: {
88
- /**
89
- * An array of two-letter ISO country codes representing which countries
90
- * Checkout should provide as options for shipping locations. The codes are
91
- * expected to be uppercase. Unsupported country codes: AS, CX, CC, CU, HM, IR, KP, MH, FM, NF, MP, PW, SD, SY, UM, VI.
92
- */
93
- allowedCountries: string[];
94
- };
337
+ on(
338
+ eventType: 'loaderror',
339
+ handler: (event: {
340
+ elementType: 'expressCheckout';
341
+ error: StripeError;
342
+ }) => any
343
+ ): StripeCheckoutExpressCheckoutElement;
344
+ once(
345
+ eventType: 'loaderror',
346
+ handler: (event: {
347
+ elementType: 'expressCheckout';
348
+ error: StripeError;
349
+ }) => any
350
+ ): StripeCheckoutExpressCheckoutElement;
351
+ off(
352
+ eventType: 'loaderror',
353
+ handler?: (event: {
354
+ elementType: 'expressCheckout';
355
+ error: StripeError;
356
+ }) => any
357
+ ): StripeCheckoutExpressCheckoutElement;
95
358
 
96
359
  /**
97
- * The [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) of the locale to display Checkout in.
98
- * Default is `auto` (Stripe detects the locale of the browser).
360
+ * Triggered when a buyer authorizes a payment within a supported payment method.
99
361
  */
100
- locale?: CheckoutLocale;
362
+ on(
363
+ eventType: 'confirm',
364
+ handler: (event: StripeExpressCheckoutElementConfirmEvent) => any
365
+ ): StripeCheckoutExpressCheckoutElement;
366
+ once(
367
+ eventType: 'confirm',
368
+ handler: (event: StripeExpressCheckoutElementConfirmEvent) => any
369
+ ): StripeCheckoutExpressCheckoutElement;
370
+ off(
371
+ eventType: 'confirm',
372
+ handler?: (event: StripeExpressCheckoutElementConfirmEvent) => any
373
+ ): StripeCheckoutExpressCheckoutElement;
101
374
 
102
375
  /**
103
- * Describes the type of transaction being performed by Checkout in order to customize relevant text on the page, such as the **Submit** button.
104
- * `submitType` can only be specified when using using line items or SKUs, and not subscriptions.
105
- * The default is `auto`.
376
+ * Updates the options the `ExpressCheckoutElement` was initialized with.
377
+ * Updates are merged into the existing configuration.
106
378
  */
107
- submitType?: 'auto' | 'book' | 'donate' | 'pay';
108
- }
379
+ update: StripeExpressCheckoutElement['update'];
380
+ };
381
+
382
+ type AnyBuyerError = {message: string; code: null};
383
+ type ApplyPromotionCodeError =
384
+ | {message: string; code: 'invalidCode'}
385
+ | AnyBuyerError;
386
+ export type StripeCheckoutApplyPromotionCodeResult =
387
+ | {type: 'success'; success: StripeCheckoutSession}
388
+ | {type: 'error'; error: ApplyPromotionCodeError};
389
+
390
+ export type StripeCheckoutRemovePromotionCodeResult =
391
+ | {type: 'success'; success: StripeCheckoutSession}
392
+ | {type: 'error'; error: AnyBuyerError};
393
+
394
+ export type StripeCheckoutUpdateAddressResult =
395
+ | {type: 'success'; success: StripeCheckoutSession}
396
+ | {type: 'error'; error: AnyBuyerError};
109
397
 
110
- export type RedirectToCheckoutOptions =
111
- | RedirectToCheckoutServerOptions
112
- | RedirectToCheckoutClientOptions;
113
-
114
- export type CheckoutLocale =
115
- | 'auto'
116
- | 'bg'
117
- | 'cs'
118
- | 'da'
119
- | 'de'
120
- | 'el'
121
- | 'en'
122
- | 'en-GB'
123
- | 'es'
124
- | 'es-419'
125
- | 'et'
126
- | 'fi'
127
- | 'fil'
128
- | 'fr'
129
- | 'fr-CA'
130
- | 'hr'
131
- | 'hu'
132
- | 'id'
133
- | 'it'
134
- | 'ja'
135
- | 'lt'
136
- | 'lv'
137
- | 'ms'
138
- | 'mt'
139
- | 'nb'
140
- | 'nl'
141
- | 'pl'
142
- | 'pt'
143
- | 'pt-BR'
144
- | 'ro'
145
- | 'ru'
146
- | 'sk'
147
- | 'sl'
148
- | 'sv'
149
- | 'th'
150
- | 'tr'
151
- | 'zh'
152
- | 'zh-HK'
153
- | 'zh-TW';
398
+ export type StripeCheckoutUpdatePhoneNumberResult =
399
+ | {type: 'success'; success: StripeCheckoutSession}
400
+ | {type: 'error'; error: never};
401
+
402
+ type UpdateEmailError =
403
+ | {message: string; code: 'incompleteEmail'}
404
+ | {message: string; code: 'invalidEmail'};
405
+ export type StripeCheckoutUpdateEmailResult =
406
+ | {type: 'success'; success: StripeCheckoutSession}
407
+ | {type: 'error'; error: UpdateEmailError};
408
+
409
+ export type StripeCheckoutUpdateLineItemQuantityResult =
410
+ | {type: 'success'; success: StripeCheckoutSession}
411
+ | {type: 'error'; error: AnyBuyerError};
412
+
413
+ export type StripeCheckoutUpdateShippingOptionResult =
414
+ | {type: 'success'; success: StripeCheckoutSession}
415
+ | {type: 'error'; error: AnyBuyerError};
416
+
417
+ type ConfirmError =
418
+ | {
419
+ message: string;
420
+ code: 'paymentFailed';
421
+ paymentFailed: {
422
+ declineCode: string | null;
423
+ };
424
+ }
425
+ | AnyBuyerError;
426
+ export type StripeCheckoutConfirmResult =
427
+ | {type: 'success'; success: StripeCheckoutSession}
428
+ | {type: 'error'; error: ConfirmError};
429
+ export interface StripeCheckout {
430
+ /* Custom Checkout methods */
431
+ applyPromotionCode: (
432
+ promotionCode: string
433
+ ) => Promise<StripeCheckoutApplyPromotionCodeResult>;
434
+ removePromotionCode: () => Promise<StripeCheckoutRemovePromotionCodeResult>;
435
+ updateShippingAddress: (
436
+ shippingAddress: StripeCheckoutContact | null
437
+ ) => Promise<StripeCheckoutUpdateAddressResult>;
438
+ updateBillingAddress: (
439
+ billingAddress: StripeCheckoutContact | null
440
+ ) => Promise<StripeCheckoutUpdateAddressResult>;
441
+ updatePhoneNumber: (
442
+ phoneNumber: string
443
+ ) => Promise<StripeCheckoutUpdatePhoneNumberResult>;
444
+ updateEmail: (email: string) => Promise<StripeCheckoutUpdateEmailResult>;
445
+ updateLineItemQuantity: (args: {
446
+ lineItem: string;
447
+ quantity: number;
448
+ }) => Promise<StripeCheckoutUpdateLineItemQuantityResult>;
449
+ updateShippingOption: (
450
+ shippingOption: string
451
+ ) => Promise<StripeCheckoutResult>;
452
+ confirm: (args?: {
453
+ returnUrl?: string;
454
+ redirect?: StripeCheckoutRedirectBehavior;
455
+ paymentMethod?: string;
456
+ savePaymentMethod?: boolean;
457
+ }) => Promise<StripeCheckoutConfirmResult>;
458
+ session: () => StripeCheckoutSession;
459
+ on: (event: 'change', handler: StripeCheckoutUpdateHandler) => void;
460
+
461
+ /* Elements methods */
462
+ changeAppearance: (appearance: Appearance) => void;
463
+ getElement(elementType: 'payment'): StripePaymentElement | null;
464
+ getElement(
465
+ elementType: 'address',
466
+ mode: AddressMode
467
+ ): StripeAddressElement | null;
468
+ getElement(
469
+ elementType: 'expressCheckout'
470
+ ): StripeCheckoutExpressCheckoutElement | null;
471
+ /* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
472
+ getElement(
473
+ elementType: 'currencySelector'
474
+ ): StripeCurrencySelectorElement | null;
475
+ createElement(
476
+ elementType: 'payment',
477
+ options?: StripeCheckoutPaymentElementOptions
478
+ ): StripePaymentElement;
479
+ createElement(
480
+ elementType: 'address',
481
+ options: StripeCheckoutAddressElementOptions
482
+ ): StripeAddressElement;
483
+ createElement(
484
+ elementType: 'expressCheckout',
485
+ options: StripeCheckoutExpressCheckoutElementOptions
486
+ ): StripeCheckoutExpressCheckoutElement;
487
+ /* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
488
+ createElement(elementType: 'currencySelector'): StripeCurrencySelectorElement;
489
+ }