@stripe/stripe-js 4.10.0 → 5.1.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 +467 -126
  8. package/dist/stripe-js/checkout.d.ts +467 -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
@@ -0,0 +1,93 @@
1
+ import {StripeElementBase} from './base';
2
+ import {StripeError} from '../stripe';
3
+
4
+ export type StripeCurrencySelectorElement = StripeElementBase & {
5
+ /**
6
+ * Triggered when the element is fully rendered and can accept `element.focus` calls.
7
+ */
8
+ on(
9
+ eventType: 'ready',
10
+ handler: (event: {elementType: 'currencySelector'}) => any
11
+ ): StripeCurrencySelectorElement;
12
+ once(
13
+ eventType: 'ready',
14
+ handler: (event: {elementType: 'currencySelector'}) => any
15
+ ): StripeCurrencySelectorElement;
16
+ off(
17
+ eventType: 'ready',
18
+ handler?: (event: {elementType: 'currencySelector'}) => any
19
+ ): StripeCurrencySelectorElement;
20
+
21
+ /**
22
+ * Triggered when the element gains focus.
23
+ */
24
+ on(
25
+ eventType: 'focus',
26
+ handler: (event: {elementType: 'currencySelector'}) => any
27
+ ): StripeCurrencySelectorElement;
28
+ once(
29
+ eventType: 'focus',
30
+ handler: (event: {elementType: 'currencySelector'}) => any
31
+ ): StripeCurrencySelectorElement;
32
+ off(
33
+ eventType: 'focus',
34
+ handler?: (event: {elementType: 'currencySelector'}) => any
35
+ ): StripeCurrencySelectorElement;
36
+
37
+ /**
38
+ * Triggered when the element loses focus.
39
+ */
40
+ on(
41
+ eventType: 'blur',
42
+ handler: (event: {elementType: 'currencySelector'}) => any
43
+ ): StripeCurrencySelectorElement;
44
+ once(
45
+ eventType: 'blur',
46
+ handler: (event: {elementType: 'currencySelector'}) => any
47
+ ): StripeCurrencySelectorElement;
48
+ off(
49
+ eventType: 'blur',
50
+ handler?: (event: {elementType: 'currencySelector'}) => any
51
+ ): StripeCurrencySelectorElement;
52
+
53
+ /**
54
+ * Triggered when the escape key is pressed within the element.
55
+ */
56
+ on(
57
+ eventType: 'escape',
58
+ handler: (event: {elementType: 'currencySelector'}) => any
59
+ ): StripeCurrencySelectorElement;
60
+ once(
61
+ eventType: 'escape',
62
+ handler: (event: {elementType: 'currencySelector'}) => any
63
+ ): StripeCurrencySelectorElement;
64
+ off(
65
+ eventType: 'escape',
66
+ handler?: (event: {elementType: 'currencySelector'}) => any
67
+ ): StripeCurrencySelectorElement;
68
+
69
+ /**
70
+ * Triggered when the element fails to load.
71
+ */
72
+ on(
73
+ eventType: 'loaderror',
74
+ handler: (event: {
75
+ elementType: 'currencySelector';
76
+ error: StripeError;
77
+ }) => any
78
+ ): StripeCurrencySelectorElement;
79
+ once(
80
+ eventType: 'loaderror',
81
+ handler: (event: {
82
+ elementType: 'currencySelector';
83
+ error: StripeError;
84
+ }) => any
85
+ ): StripeCurrencySelectorElement;
86
+ off(
87
+ eventType: 'loaderror',
88
+ handler?: (event: {
89
+ elementType: 'currencySelector';
90
+ error: StripeError;
91
+ }) => any
92
+ ): StripeCurrencySelectorElement;
93
+ };
@@ -0,0 +1,93 @@
1
+ import {StripeElementBase} from './base';
2
+ import {StripeError} from '../stripe';
3
+
4
+ export type StripeCurrencySelectorElement = StripeElementBase & {
5
+ /**
6
+ * Triggered when the element is fully rendered and can accept `element.focus` calls.
7
+ */
8
+ on(
9
+ eventType: 'ready',
10
+ handler: (event: {elementType: 'currencySelector'}) => any
11
+ ): StripeCurrencySelectorElement;
12
+ once(
13
+ eventType: 'ready',
14
+ handler: (event: {elementType: 'currencySelector'}) => any
15
+ ): StripeCurrencySelectorElement;
16
+ off(
17
+ eventType: 'ready',
18
+ handler?: (event: {elementType: 'currencySelector'}) => any
19
+ ): StripeCurrencySelectorElement;
20
+
21
+ /**
22
+ * Triggered when the element gains focus.
23
+ */
24
+ on(
25
+ eventType: 'focus',
26
+ handler: (event: {elementType: 'currencySelector'}) => any
27
+ ): StripeCurrencySelectorElement;
28
+ once(
29
+ eventType: 'focus',
30
+ handler: (event: {elementType: 'currencySelector'}) => any
31
+ ): StripeCurrencySelectorElement;
32
+ off(
33
+ eventType: 'focus',
34
+ handler?: (event: {elementType: 'currencySelector'}) => any
35
+ ): StripeCurrencySelectorElement;
36
+
37
+ /**
38
+ * Triggered when the element loses focus.
39
+ */
40
+ on(
41
+ eventType: 'blur',
42
+ handler: (event: {elementType: 'currencySelector'}) => any
43
+ ): StripeCurrencySelectorElement;
44
+ once(
45
+ eventType: 'blur',
46
+ handler: (event: {elementType: 'currencySelector'}) => any
47
+ ): StripeCurrencySelectorElement;
48
+ off(
49
+ eventType: 'blur',
50
+ handler?: (event: {elementType: 'currencySelector'}) => any
51
+ ): StripeCurrencySelectorElement;
52
+
53
+ /**
54
+ * Triggered when the escape key is pressed within the element.
55
+ */
56
+ on(
57
+ eventType: 'escape',
58
+ handler: (event: {elementType: 'currencySelector'}) => any
59
+ ): StripeCurrencySelectorElement;
60
+ once(
61
+ eventType: 'escape',
62
+ handler: (event: {elementType: 'currencySelector'}) => any
63
+ ): StripeCurrencySelectorElement;
64
+ off(
65
+ eventType: 'escape',
66
+ handler?: (event: {elementType: 'currencySelector'}) => any
67
+ ): StripeCurrencySelectorElement;
68
+
69
+ /**
70
+ * Triggered when the element fails to load.
71
+ */
72
+ on(
73
+ eventType: 'loaderror',
74
+ handler: (event: {
75
+ elementType: 'currencySelector';
76
+ error: StripeError;
77
+ }) => any
78
+ ): StripeCurrencySelectorElement;
79
+ once(
80
+ eventType: 'loaderror',
81
+ handler: (event: {
82
+ elementType: 'currencySelector';
83
+ error: StripeError;
84
+ }) => any
85
+ ): StripeCurrencySelectorElement;
86
+ off(
87
+ eventType: 'loaderror',
88
+ handler?: (event: {
89
+ elementType: 'currencySelector';
90
+ error: StripeError;
91
+ }) => any
92
+ ): StripeCurrencySelectorElement;
93
+ };
@@ -374,8 +374,11 @@ export interface StripeExpressCheckoutElementUpdateOptions {
374
374
  }
375
375
 
376
376
  export type AvailablePaymentMethods = {
377
+ amazonPay: boolean;
377
378
  applePay: boolean;
378
379
  googlePay: boolean;
380
+ link: boolean;
381
+ paypal: boolean;
379
382
  };
380
383
 
381
384
  export interface StripeExpressCheckoutElementReadyEvent {
@@ -374,8 +374,11 @@ export interface StripeExpressCheckoutElementUpdateOptions {
374
374
  }
375
375
 
376
376
  export type AvailablePaymentMethods = {
377
+ amazonPay: boolean;
377
378
  applePay: boolean;
378
379
  googlePay: boolean;
380
+ link: boolean;
381
+ paypal: boolean;
379
382
  };
380
383
 
381
384
  export interface StripeExpressCheckoutElementReadyEvent {
@@ -8,6 +8,7 @@ export * from './card-cvc';
8
8
  export * from './card-expiry';
9
9
  export * from './card-number';
10
10
  export * from './card';
11
+ export * from './currency-selector';
11
12
  export * from './eps-bank';
12
13
  export * from './express-checkout';
13
14
  export * from './fpx-bank';
@@ -8,6 +8,7 @@ export * from './card-cvc';
8
8
  export * from './card-expiry';
9
9
  export * from './card-number';
10
10
  export * from './card';
11
+ export * from './currency-selector';
11
12
  export * from './eps-bank';
12
13
  export * from './express-checkout';
13
14
  export * from './fpx-bank';
@@ -116,6 +116,31 @@ export type StripePaymentElement = StripeElementBase & {
116
116
  handler?: (event: {elementType: 'payment'}) => any
117
117
  ): StripePaymentElement;
118
118
 
119
+ /**
120
+ * The change event is triggered when the `Element`'s value changes.
121
+ * Represents the details of a selected Card payment method.
122
+ */
123
+ on(
124
+ eventType: 'carddetailschange',
125
+ handler: (event: StripePaymentElementCardDetailsChangeEvent) => any
126
+ ): StripePaymentElement;
127
+
128
+ /**
129
+ * Triggered when a Saved Payment Method is updated.
130
+ */
131
+ on(
132
+ eventType: 'savedpaymentmethodupdate',
133
+ handler: (event: StripePaymentElementSavedPaymentMethodUpdateEvent) => any
134
+ ): StripePaymentElement;
135
+
136
+ /**
137
+ * Triggered when a Saved Payment Method is removed.
138
+ */
139
+ on(
140
+ eventType: 'savedpaymentmethodremove',
141
+ handler: (event: StripePaymentElementSavedPaymentMethodRemoveEvent) => any
142
+ ): StripePaymentElement;
143
+
119
144
  /**
120
145
  * Updates the options the `PaymentElement` was initialized with.
121
146
  * Updates are merged into the existing configuration.
@@ -158,6 +183,7 @@ export interface FieldsOption {
158
183
  phone?: FieldOption;
159
184
  address?:
160
185
  | FieldOption
186
+ | 'if_required'
161
187
  | {
162
188
  country?: FieldOption;
163
189
  postalCode?: FieldOption;
@@ -199,6 +225,7 @@ export interface LayoutObject {
199
225
  defaultCollapsed?: boolean;
200
226
  radios?: boolean;
201
227
  spacedAccordionItems?: boolean;
228
+ visibleAccordionItemsCount?: number;
202
229
  }
203
230
 
204
231
  export interface StripePaymentElementOptions {
@@ -297,3 +324,112 @@ export interface StripePaymentElementChangeEvent {
297
324
  };
298
325
  };
299
326
  }
327
+
328
+ type CardBrand =
329
+ | 'amex'
330
+ | 'diners'
331
+ | 'discover'
332
+ | 'eftpos_au'
333
+ | 'jcb'
334
+ | 'mastercard'
335
+ | 'unionpay'
336
+ | 'visa'
337
+ | 'unknown';
338
+ type CardFunding = 'credit' | 'debit' | 'prepaid' | 'unknown';
339
+
340
+ export interface StripePaymentElementCardDetailsChangeEvent {
341
+ /**
342
+ * The type of element that emitted this event.
343
+ */
344
+ elementType: 'payment';
345
+
346
+ /**
347
+ * `true` when the card details are loading.
348
+ */
349
+ loading: boolean;
350
+
351
+ /**
352
+ * The card details for the selected payment method.
353
+ * Undefined while loading and for non card payment methods.
354
+ */
355
+ details?: {
356
+ brands: CardBrand[] | null;
357
+ funding: CardFunding | null;
358
+ };
359
+ }
360
+
361
+ export interface StripePaymentElementSavedPaymentMethodUpdateEvent {
362
+ /**
363
+ * The type of element that emitted this event.
364
+ */
365
+ elementType: 'payment';
366
+
367
+ /**
368
+ * `true` when the saved payment method is successfully updated.
369
+ */
370
+ success: boolean;
371
+
372
+ /**
373
+ * Error message if the saved payment method update fails.
374
+ */
375
+ error?: string;
376
+
377
+ /**
378
+ * The updated saved payment method.
379
+ */
380
+ payment_method: {
381
+ id: string;
382
+ type: string;
383
+ billing_details: {
384
+ address: {
385
+ city: null | string;
386
+ country: null | string;
387
+ line1: null | string;
388
+ line2: null | string;
389
+ postal_code: null | string;
390
+ state: null | string;
391
+ };
392
+ name: null | string;
393
+ email: null | string;
394
+ phone: null | string;
395
+ };
396
+ };
397
+ }
398
+
399
+ export interface StripePaymentElementSavedPaymentMethodRemoveEvent {
400
+ /**
401
+ * The type of element that emitted this event.
402
+ */
403
+ elementType: 'payment';
404
+
405
+ /**
406
+ * `true` when the saved payment method is successfully removed.
407
+ */
408
+ success: boolean;
409
+
410
+ /**
411
+ * Error message if the saved payment method removal fails.
412
+ */
413
+ error?: string;
414
+
415
+ /**
416
+ * The removed saved payment method.
417
+ */
418
+ payment_method: {
419
+ id: string;
420
+ type: string;
421
+ billing_details: {
422
+ address: {
423
+ city: null | string;
424
+ country: null | string;
425
+ line1: null | string;
426
+ line2: null | string;
427
+ postal_code: null | string;
428
+ state: null | string;
429
+ };
430
+ name: null | string;
431
+ email: null | string;
432
+ phone: null | string;
433
+ };
434
+ };
435
+ }
@@ -116,6 +116,31 @@ export type StripePaymentElement = StripeElementBase & {
116
116
  handler?: (event: {elementType: 'payment'}) => any
117
117
  ): StripePaymentElement;
118
118
 
119
+ /**
120
+ * The change event is triggered when the `Element`'s value changes.
121
+ * Represents the details of a selected Card payment method.
122
+ */
123
+ on(
124
+ eventType: 'carddetailschange',
125
+ handler: (event: StripePaymentElementCardDetailsChangeEvent) => any
126
+ ): StripePaymentElement;
127
+
128
+ /**
129
+ * Triggered when a Saved Payment Method is updated.
130
+ */
131
+ on(
132
+ eventType: 'savedpaymentmethodupdate',
133
+ handler: (event: StripePaymentElementSavedPaymentMethodUpdateEvent) => any
134
+ ): StripePaymentElement;
135
+
136
+ /**
137
+ * Triggered when a Saved Payment Method is removed.
138
+ */
139
+ on(
140
+ eventType: 'savedpaymentmethodremove',
141
+ handler: (event: StripePaymentElementSavedPaymentMethodRemoveEvent) => any
142
+ ): StripePaymentElement;
143
+
119
144
  /**
120
145
  * Updates the options the `PaymentElement` was initialized with.
121
146
  * Updates are merged into the existing configuration.
@@ -158,6 +183,7 @@ export interface FieldsOption {
158
183
  phone?: FieldOption;
159
184
  address?:
160
185
  | FieldOption
186
+ | 'if_required'
161
187
  | {
162
188
  country?: FieldOption;
163
189
  postalCode?: FieldOption;
@@ -199,6 +225,7 @@ export interface LayoutObject {
199
225
  defaultCollapsed?: boolean;
200
226
  radios?: boolean;
201
227
  spacedAccordionItems?: boolean;
228
+ visibleAccordionItemsCount?: number;
202
229
  }
203
230
 
204
231
  export interface StripePaymentElementOptions {
@@ -297,3 +324,112 @@ export interface StripePaymentElementChangeEvent {
297
324
  };
298
325
  };
299
326
  }
327
+
328
+ type CardBrand =
329
+ | 'amex'
330
+ | 'diners'
331
+ | 'discover'
332
+ | 'eftpos_au'
333
+ | 'jcb'
334
+ | 'mastercard'
335
+ | 'unionpay'
336
+ | 'visa'
337
+ | 'unknown';
338
+ type CardFunding = 'credit' | 'debit' | 'prepaid' | 'unknown';
339
+
340
+ export interface StripePaymentElementCardDetailsChangeEvent {
341
+ /**
342
+ * The type of element that emitted this event.
343
+ */
344
+ elementType: 'payment';
345
+
346
+ /**
347
+ * `true` when the card details are loading.
348
+ */
349
+ loading: boolean;
350
+
351
+ /**
352
+ * The card details for the selected payment method.
353
+ * Undefined while loading and for non card payment methods.
354
+ */
355
+ details?: {
356
+ brands: CardBrand[] | null;
357
+ funding: CardFunding | null;
358
+ };
359
+ }
360
+
361
+ export interface StripePaymentElementSavedPaymentMethodUpdateEvent {
362
+ /**
363
+ * The type of element that emitted this event.
364
+ */
365
+ elementType: 'payment';
366
+
367
+ /**
368
+ * `true` when the saved payment method is successfully updated.
369
+ */
370
+ success: boolean;
371
+
372
+ /**
373
+ * Error message if the saved payment method update fails.
374
+ */
375
+ error?: string;
376
+
377
+ /**
378
+ * The updated saved payment method.
379
+ */
380
+ payment_method: {
381
+ id: string;
382
+ type: string;
383
+ billing_details: {
384
+ address: {
385
+ city: null | string;
386
+ country: null | string;
387
+ line1: null | string;
388
+ line2: null | string;
389
+ postal_code: null | string;
390
+ state: null | string;
391
+ };
392
+ name: null | string;
393
+ email: null | string;
394
+ phone: null | string;
395
+ };
396
+ };
397
+ }
398
+
399
+ export interface StripePaymentElementSavedPaymentMethodRemoveEvent {
400
+ /**
401
+ * The type of element that emitted this event.
402
+ */
403
+ elementType: 'payment';
404
+
405
+ /**
406
+ * `true` when the saved payment method is successfully removed.
407
+ */
408
+ success: boolean;
409
+
410
+ /**
411
+ * Error message if the saved payment method removal fails.
412
+ */
413
+ error?: string;
414
+
415
+ /**
416
+ * The removed saved payment method.
417
+ */
418
+ payment_method: {
419
+ id: string;
420
+ type: string;
421
+ billing_details: {
422
+ address: {
423
+ city: null | string;
424
+ country: null | string;
425
+ line1: null | string;
426
+ line2: null | string;
427
+ postal_code: null | string;
428
+ state: null | string;
429
+ };
430
+ name: null | string;
431
+ email: null | string;
432
+ phone: null | string;
433
+ };
434
+ };
435
+ }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  StripeAddressElement,
3
3
  StripeAddressElementOptions,
4
+ StripeCurrencySelectorElement,
4
5
  StripeShippingAddressElement,
5
6
  StripeShippingAddressElementOptions,
6
7
  StripePaymentRequestButtonElement,
@@ -68,7 +69,10 @@ export interface StripeElements {
68
69
  * Before confirming payment, call elements.submit() to validate the state of the
69
70
  * Payment Element and collect any data required for wallets.
70
71
  */
71
- submit(): Promise<{error?: StripeError}>;
72
+ submit(): Promise<
73
+ | {error?: StripeError; selectedPaymentMethod?: undefined}
74
+ | {selectedPaymentMethod: string; error?: undefined}
75
+ >;
72
76
 
73
77
  /////////////////////////////
74
78
  /// address
@@ -332,9 +336,6 @@ export interface StripeElements {
332
336
  /////////////////////////////
333
337
 
334
338
  /**
335
- * Requires beta access:
336
- * Contact [Stripe support](https://support.stripe.com/) for more information.
337
- *
338
339
  * Creates a `LinkAuthenticationElement`.
339
340
  */
340
341
  create(
@@ -343,9 +344,6 @@ export interface StripeElements {
343
344
  ): StripeLinkAuthenticationElement;
344
345
 
345
346
  /**
346
- * Requires beta access:
347
- * Contact [Stripe support](https://support.stripe.com/) for more information.
348
- *
349
347
  * Looks up a previously created `Element` by its type.
350
348
  */
351
349
  getElement(
@@ -500,6 +498,7 @@ export type StripeElementType =
500
498
  | 'cardNumber'
501
499
  | 'cardExpiry'
502
500
  | 'cardCvc'
501
+ | 'currencySelector'
503
502
  | 'epsBank'
504
503
  | 'expressCheckout'
505
504
  | 'fpxBank'
@@ -531,6 +530,7 @@ export type StripeElement =
531
530
  | StripeIbanElement
532
531
  | StripeIdealBankElement
533
532
  | StripeP24BankElement
533
+ | StripeCurrencySelectorElement
534
534
  | StripeExpressCheckoutElement
535
535
  | StripePaymentElement
536
536
  | StripePaymentMethodMessagingElement
@@ -670,6 +670,14 @@ interface BaseStripeElementsOptions {
670
670
  * Display saved PaymentMethods and Customer information.
671
671
  */
672
672
  customerSessionClientSecret?: string;
673
+
674
+ /**
675
+ * Requires beta access:
676
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
677
+ *
678
+ * Display Custom Payment Methods in the Payment Element that you are already registered with.
679
+ */
680
+ customPaymentMethods?: CustomPaymentMethod[];
673
681
  }
674
682
 
675
683
  export interface StripeElementsOptionsClientSecret
@@ -1128,3 +1136,25 @@ export interface CustomerOptions {
1128
1136
  */
1129
1137
  ephemeralKey: string;
1130
1138
  }
1139
+
1140
+ export interface CustomPaymentMethod {
1141
+ /**
1142
+ * The Custom Payment Method id, prefixed with `cpmt_`.
1143
+ */
1144
+ id: string;
1145
+
1146
+ /**
1147
+ * Additional options to configure the Custom Payment Method.
1148
+ */
1149
+ options: {
1150
+ /**
1151
+ * The payment form type.
1152
+ */
1153
+ type: 'static';
1154
+
1155
+ /**
1156
+ * Display additional information about the payment method, max 100 characters.
1157
+ */
1158
+ subtitle?: string;
1159
+ };
1160
+ }