@stripe/stripe-js 9.9.0 → 9.12.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/dist/index.js CHANGED
@@ -71,7 +71,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
71
71
 
72
72
  stripe._registerWrapper({
73
73
  name: 'stripe-js',
74
- version: "9.9.0",
74
+ version: "9.12.0",
75
75
  startTime: startTime
76
76
  });
77
77
  };
@@ -172,7 +172,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
172
172
  var expectedVersion = RELEASE_TRAIN;
173
173
 
174
174
  if (isTestKey && version !== expectedVersion) {
175
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.9.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
175
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.12.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
176
176
  }
177
177
 
178
178
  var stripe = maybeStripe.apply(undefined, args);
package/dist/index.mjs CHANGED
@@ -67,7 +67,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
67
67
 
68
68
  stripe._registerWrapper({
69
69
  name: 'stripe-js',
70
- version: "9.9.0",
70
+ version: "9.12.0",
71
71
  startTime: startTime
72
72
  });
73
73
  };
@@ -168,7 +168,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
168
168
  var expectedVersion = RELEASE_TRAIN;
169
169
 
170
170
  if (isTestKey && version !== expectedVersion) {
171
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.9.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
171
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.12.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
172
172
  }
173
173
 
174
174
  var stripe = maybeStripe.apply(undefined, args);
package/dist/pure.js CHANGED
@@ -71,7 +71,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
71
71
 
72
72
  stripe._registerWrapper({
73
73
  name: 'stripe-js',
74
- version: "9.9.0",
74
+ version: "9.12.0",
75
75
  startTime: startTime
76
76
  });
77
77
  };
@@ -172,7 +172,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
172
172
  var expectedVersion = RELEASE_TRAIN;
173
173
 
174
174
  if (isTestKey && version !== expectedVersion) {
175
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.9.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
175
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.12.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
176
176
  }
177
177
 
178
178
  var stripe = maybeStripe.apply(undefined, args);
package/dist/pure.mjs CHANGED
@@ -67,7 +67,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
67
67
 
68
68
  stripe._registerWrapper({
69
69
  name: 'stripe-js',
70
- version: "9.9.0",
70
+ version: "9.12.0",
71
71
  startTime: startTime
72
72
  });
73
73
  };
@@ -168,7 +168,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
168
168
  var expectedVersion = RELEASE_TRAIN;
169
169
 
170
170
  if (isTestKey && version !== expectedVersion) {
171
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.9.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
171
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.12.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
172
172
  }
173
173
 
174
174
  var stripe = maybeStripe.apply(undefined, args);
@@ -22,6 +22,7 @@ import {
22
22
  StripeCheckoutFormConfirmEvent,
23
23
  ExpressCheckoutPaymentMethodsOption,
24
24
  StripeContactDetailsElement,
25
+ StripeTermsElement,
25
26
  } from './elements';
26
27
 
27
28
  type SavedPaymentMethodOption = {
@@ -174,6 +175,8 @@ export type StripeCheckoutLineItem = {
174
175
  } | null;
175
176
  adjustableQuantity: StripeCheckoutAdjustableQuantity | null;
176
177
  images: string[];
178
+ priceId: string;
179
+ isRemovable: boolean;
177
180
  };
178
181
 
179
182
  export type StripeCheckoutRecurring = {
@@ -231,6 +234,23 @@ export type StripeCheckoutTrial = {
231
234
  trialPeriodDays: number;
232
235
  };
233
236
 
237
+ export type StripeCheckoutOptionalItem = {
238
+ priceId: string;
239
+ name: string;
240
+ description: string | null;
241
+ unitAmount: StripeCheckoutAmount;
242
+ unitAmountDecimal: StripeCheckoutAmount | null;
243
+ unitLabel: string | null;
244
+ quantity: number;
245
+ adjustableQuantity: StripeCheckoutAdjustableQuantity | null;
246
+ recurring: {
247
+ interval: StripeCheckoutBillingInterval;
248
+ intervalCount: number;
249
+ } | null;
250
+ images: string[];
251
+ isSelected: boolean;
252
+ };
253
+
234
254
  export type StripeCheckoutCurrencyOption = StripeCheckoutAmount & {
235
255
  currency: string;
236
256
  currencyConversion?: {fxRate: number; sourceCurrency: string};
@@ -375,6 +395,7 @@ export interface StripeCheckoutSession {
375
395
  taxAmounts: Array<StripeCheckoutTaxAmount> | null;
376
396
  taxIdInfo: StripeCheckoutTaxIdInfo | null;
377
397
  total: StripeCheckoutTotalSummary;
398
+ optionalItems: Array<StripeCheckoutOptionalItem> | null;
378
399
  }
379
400
 
380
401
  export type StripeCheckoutPaymentElementOptions = {
@@ -391,10 +412,23 @@ export type StripeCheckoutAddressElementOptions = {
391
412
  display?: {
392
413
  name?: 'full' | 'split' | 'organization';
393
414
  };
415
+ /**
416
+ * Control which additional fields to display in the AddressElement.
417
+ */
418
+ fields?: {
419
+ phone?: 'always' | 'never' | 'auto';
420
+ /**
421
+ * Requires beta access:
422
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
423
+ */
424
+ name?: 'never' | 'auto';
425
+ };
394
426
  };
395
427
 
396
428
  export type StripeCheckoutContactDetailsElementOptions = Record<string, never>;
397
429
 
430
+ export type StripeCheckoutTermsElementOptions = Record<string, never>;
431
+
398
432
  /**
399
433
  * Wallet button theme options for CheckoutForm.
400
434
  */
@@ -609,6 +643,27 @@ export type StripeCheckoutUpdateLineItemQuantityResult =
609
643
  | {type: 'success'; session: StripeCheckoutSession}
610
644
  | {type: 'error'; error: AnyBuyerError};
611
645
 
646
+ export type StripeCheckoutAddOptionalLineItemResult =
647
+ | {type: 'success'; session: StripeCheckoutSession}
648
+ | {type: 'error'; error: {message: string; code: null}};
649
+
650
+ export type StripeCheckoutRemoveOptionalLineItemResult =
651
+ | {type: 'success'; session: StripeCheckoutSession}
652
+ | {
653
+ type: 'error';
654
+ error:
655
+ | {
656
+ message: string;
657
+ code: 'promotionCodeAmountInsufficient';
658
+ promotionCodeAmountInsufficient: {
659
+ minimumAmount: number;
660
+ minimumAmountCurrency: string;
661
+ };
662
+ }
663
+ | {message: string; code: 'couponAppliesToNothing'}
664
+ | {message: string; code: null};
665
+ };
666
+
612
667
  export type StripeCheckoutUpdateShippingOptionResult =
613
668
  | {type: 'success'; session: StripeCheckoutSession}
614
669
  | {type: 'error'; error: AnyBuyerError};
@@ -638,6 +693,27 @@ export type StripeCheckoutRunServerUpdateResult =
638
693
  | {type: 'success'; session: StripeCheckoutSession}
639
694
  | {type: 'error'; error: AnyBuyerError};
640
695
 
696
+ type ValidateElementsValidationError = {
697
+ message: string;
698
+ element:
699
+ | 'payment'
700
+ | 'checkoutForm'
701
+ | 'contactDetails'
702
+ | 'shippingAddress'
703
+ | 'billingAddress'
704
+ | 'taxId'
705
+ | 'terms'
706
+ | 'linkAuthentication';
707
+ };
708
+ type ValidateElementsError = {
709
+ code: 'validation_error' | 'no_elements' | null;
710
+ message: string;
711
+ validation_errors: ValidateElementsValidationError[];
712
+ };
713
+ export type StripeCheckoutValidateElementsResult =
714
+ | {type: 'success'; session: StripeCheckoutSession}
715
+ | {type: 'error'; error: ValidateElementsError};
716
+
641
717
  type LoadActionsError = {message: string; code: null};
642
718
  export type StripeCheckoutLoadActionsSuccess = {
643
719
  applyPromotionCode: (
@@ -683,6 +759,13 @@ export type StripeCheckoutLoadActionsSuccess = {
683
759
  runServerUpdate: (
684
760
  userFunction: RunServerUpdateFunction
685
761
  ) => Promise<StripeCheckoutRunServerUpdateResult>;
762
+ validateElements: () => Promise<StripeCheckoutValidateElementsResult>;
763
+ addOptionalLineItem: (
764
+ priceId: string
765
+ ) => Promise<StripeCheckoutAddOptionalLineItemResult>;
766
+ removeOptionalLineItem: (
767
+ priceId: string
768
+ ) => Promise<StripeCheckoutRemoveOptionalLineItemResult>;
686
769
  };
687
770
  export type StripeCheckoutLoadActionsResult =
688
771
  | {type: 'success'; actions: StripeCheckoutLoadActionsSuccess}
@@ -719,6 +802,8 @@ export interface StripeCheckoutElementsSdk {
719
802
  getCurrencySelectorElement(): StripeCurrencySelectorElement | null;
720
803
  /* Requires beta header when initializing Stripe: @docs https://docs.stripe.com/tax/advanced/tax-ids?payment-ui=embedded-components#render-tax-id-element */
721
804
  getTaxIdElement(): StripeTaxIdElement | null;
805
+ /* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
806
+ getTermsElement(): StripeTermsElement | null;
722
807
 
723
808
  createPaymentElement(
724
809
  options?: StripeCheckoutPaymentElementOptions
@@ -738,6 +823,10 @@ export interface StripeCheckoutElementsSdk {
738
823
  createContactDetailsElement(
739
824
  options?: StripeCheckoutContactDetailsElementOptions
740
825
  ): StripeContactDetailsElement;
826
+ /* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
827
+ createTermsElement(
828
+ options?: StripeCheckoutTermsElementOptions
829
+ ): StripeTermsElement;
741
830
  }
742
831
 
743
832
  /* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
@@ -22,6 +22,7 @@ import {
22
22
  StripeCheckoutFormConfirmEvent,
23
23
  ExpressCheckoutPaymentMethodsOption,
24
24
  StripeContactDetailsElement,
25
+ StripeTermsElement,
25
26
  } from './elements';
26
27
 
27
28
  type SavedPaymentMethodOption = {
@@ -174,6 +175,8 @@ export type StripeCheckoutLineItem = {
174
175
  } | null;
175
176
  adjustableQuantity: StripeCheckoutAdjustableQuantity | null;
176
177
  images: string[];
178
+ priceId: string;
179
+ isRemovable: boolean;
177
180
  };
178
181
 
179
182
  export type StripeCheckoutRecurring = {
@@ -231,6 +234,23 @@ export type StripeCheckoutTrial = {
231
234
  trialPeriodDays: number;
232
235
  };
233
236
 
237
+ export type StripeCheckoutOptionalItem = {
238
+ priceId: string;
239
+ name: string;
240
+ description: string | null;
241
+ unitAmount: StripeCheckoutAmount;
242
+ unitAmountDecimal: StripeCheckoutAmount | null;
243
+ unitLabel: string | null;
244
+ quantity: number;
245
+ adjustableQuantity: StripeCheckoutAdjustableQuantity | null;
246
+ recurring: {
247
+ interval: StripeCheckoutBillingInterval;
248
+ intervalCount: number;
249
+ } | null;
250
+ images: string[];
251
+ isSelected: boolean;
252
+ };
253
+
234
254
  export type StripeCheckoutCurrencyOption = StripeCheckoutAmount & {
235
255
  currency: string;
236
256
  currencyConversion?: {fxRate: number; sourceCurrency: string};
@@ -375,6 +395,7 @@ export interface StripeCheckoutSession {
375
395
  taxAmounts: Array<StripeCheckoutTaxAmount> | null;
376
396
  taxIdInfo: StripeCheckoutTaxIdInfo | null;
377
397
  total: StripeCheckoutTotalSummary;
398
+ optionalItems: Array<StripeCheckoutOptionalItem> | null;
378
399
  }
379
400
 
380
401
  export type StripeCheckoutPaymentElementOptions = {
@@ -391,10 +412,23 @@ export type StripeCheckoutAddressElementOptions = {
391
412
  display?: {
392
413
  name?: 'full' | 'split' | 'organization';
393
414
  };
415
+ /**
416
+ * Control which additional fields to display in the AddressElement.
417
+ */
418
+ fields?: {
419
+ phone?: 'always' | 'never' | 'auto';
420
+ /**
421
+ * Requires beta access:
422
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
423
+ */
424
+ name?: 'never' | 'auto';
425
+ };
394
426
  };
395
427
 
396
428
  export type StripeCheckoutContactDetailsElementOptions = Record<string, never>;
397
429
 
430
+ export type StripeCheckoutTermsElementOptions = Record<string, never>;
431
+
398
432
  /**
399
433
  * Wallet button theme options for CheckoutForm.
400
434
  */
@@ -609,6 +643,27 @@ export type StripeCheckoutUpdateLineItemQuantityResult =
609
643
  | {type: 'success'; session: StripeCheckoutSession}
610
644
  | {type: 'error'; error: AnyBuyerError};
611
645
 
646
+ export type StripeCheckoutAddOptionalLineItemResult =
647
+ | {type: 'success'; session: StripeCheckoutSession}
648
+ | {type: 'error'; error: {message: string; code: null}};
649
+
650
+ export type StripeCheckoutRemoveOptionalLineItemResult =
651
+ | {type: 'success'; session: StripeCheckoutSession}
652
+ | {
653
+ type: 'error';
654
+ error:
655
+ | {
656
+ message: string;
657
+ code: 'promotionCodeAmountInsufficient';
658
+ promotionCodeAmountInsufficient: {
659
+ minimumAmount: number;
660
+ minimumAmountCurrency: string;
661
+ };
662
+ }
663
+ | {message: string; code: 'couponAppliesToNothing'}
664
+ | {message: string; code: null};
665
+ };
666
+
612
667
  export type StripeCheckoutUpdateShippingOptionResult =
613
668
  | {type: 'success'; session: StripeCheckoutSession}
614
669
  | {type: 'error'; error: AnyBuyerError};
@@ -638,6 +693,27 @@ export type StripeCheckoutRunServerUpdateResult =
638
693
  | {type: 'success'; session: StripeCheckoutSession}
639
694
  | {type: 'error'; error: AnyBuyerError};
640
695
 
696
+ type ValidateElementsValidationError = {
697
+ message: string;
698
+ element:
699
+ | 'payment'
700
+ | 'checkoutForm'
701
+ | 'contactDetails'
702
+ | 'shippingAddress'
703
+ | 'billingAddress'
704
+ | 'taxId'
705
+ | 'terms'
706
+ | 'linkAuthentication';
707
+ };
708
+ type ValidateElementsError = {
709
+ code: 'validation_error' | 'no_elements' | null;
710
+ message: string;
711
+ validation_errors: ValidateElementsValidationError[];
712
+ };
713
+ export type StripeCheckoutValidateElementsResult =
714
+ | {type: 'success'; session: StripeCheckoutSession}
715
+ | {type: 'error'; error: ValidateElementsError};
716
+
641
717
  type LoadActionsError = {message: string; code: null};
642
718
  export type StripeCheckoutLoadActionsSuccess = {
643
719
  applyPromotionCode: (
@@ -683,6 +759,13 @@ export type StripeCheckoutLoadActionsSuccess = {
683
759
  runServerUpdate: (
684
760
  userFunction: RunServerUpdateFunction
685
761
  ) => Promise<StripeCheckoutRunServerUpdateResult>;
762
+ validateElements: () => Promise<StripeCheckoutValidateElementsResult>;
763
+ addOptionalLineItem: (
764
+ priceId: string
765
+ ) => Promise<StripeCheckoutAddOptionalLineItemResult>;
766
+ removeOptionalLineItem: (
767
+ priceId: string
768
+ ) => Promise<StripeCheckoutRemoveOptionalLineItemResult>;
686
769
  };
687
770
  export type StripeCheckoutLoadActionsResult =
688
771
  | {type: 'success'; actions: StripeCheckoutLoadActionsSuccess}
@@ -719,6 +802,8 @@ export interface StripeCheckoutElementsSdk {
719
802
  getCurrencySelectorElement(): StripeCurrencySelectorElement | null;
720
803
  /* Requires beta header when initializing Stripe: @docs https://docs.stripe.com/tax/advanced/tax-ids?payment-ui=embedded-components#render-tax-id-element */
721
804
  getTaxIdElement(): StripeTaxIdElement | null;
805
+ /* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
806
+ getTermsElement(): StripeTermsElement | null;
722
807
 
723
808
  createPaymentElement(
724
809
  options?: StripeCheckoutPaymentElementOptions
@@ -738,6 +823,10 @@ export interface StripeCheckoutElementsSdk {
738
823
  createContactDetailsElement(
739
824
  options?: StripeCheckoutContactDetailsElementOptions
740
825
  ): StripeContactDetailsElement;
826
+ /* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
827
+ createTermsElement(
828
+ options?: StripeCheckoutTermsElementOptions
829
+ ): StripeTermsElement;
741
830
  }
742
831
 
743
832
  /* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
@@ -198,6 +198,11 @@ export interface StripeAddressElementOptions {
198
198
  */
199
199
  fields?: {
200
200
  phone?: 'always' | 'never' | 'auto';
201
+ /**
202
+ * Requires beta access:
203
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
204
+ */
205
+ name?: 'never' | 'auto';
201
206
  };
202
207
 
203
208
  /**
@@ -198,6 +198,11 @@ export interface StripeAddressElementOptions {
198
198
  */
199
199
  fields?: {
200
200
  phone?: 'always' | 'never' | 'auto';
201
+ /**
202
+ * Requires beta access:
203
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
204
+ */
205
+ name?: 'never' | 'auto';
201
206
  };
202
207
 
203
208
  /**
@@ -17,3 +17,4 @@ export * from './payment';
17
17
  export * from './shipping-address';
18
18
  export * from './issuing';
19
19
  export * from './tax-id';
20
+ export * from './terms';
@@ -17,3 +17,4 @@ export * from './payment';
17
17
  export * from './shipping-address';
18
18
  export * from './issuing';
19
19
  export * from './tax-id';
20
+ export * from './terms';
@@ -16,6 +16,88 @@ export type CheckoutFormAddress = {
16
16
  country?: string | null;
17
17
  };
18
18
 
19
+ /**
20
+ * The `value` payload returned in the change event and getValue() method.
21
+ */
22
+ export type CheckoutFormValues = {
23
+ customerDetails: {
24
+ email: string;
25
+ name?: string;
26
+ businessName?: string;
27
+ phone?: string;
28
+ };
29
+ shippingOption?: {
30
+ id: string;
31
+ displayName: string;
32
+ amount: string;
33
+ };
34
+ shippingAddress?: {
35
+ name: string;
36
+ address: CheckoutFormAddress;
37
+ };
38
+ billingAddress?: {
39
+ name: string;
40
+ address: CheckoutFormAddress;
41
+ };
42
+ tax?: {
43
+ businessName?: string;
44
+ taxId: string;
45
+ taxIdType: TaxIdType;
46
+ externalTaxIdType: ExternalTaxIdType;
47
+ };
48
+ payment?: {
49
+ collapsed: boolean;
50
+ type: string;
51
+ country?: string | null;
52
+ billingDetails?: {
53
+ address?: {
54
+ country?: string;
55
+ postal_code?: string;
56
+ };
57
+ } | null;
58
+ payment_method?: {
59
+ id: string;
60
+ type: string;
61
+ billing_details: {
62
+ address: CheckoutFormAddress;
63
+ name: string | null;
64
+ email: string | null;
65
+ phone: string | null;
66
+ };
67
+ } | null;
68
+ savePaymentMethod?: boolean;
69
+ };
70
+ adaptivePricing?: {
71
+ /**
72
+ * The currently selected local currency code (e.g. 'eur', 'gbp').
73
+ */
74
+ currency: string;
75
+ };
76
+ customFields?: Record<string, string | number>;
77
+ customComponents?: Record<string, string | number>;
78
+ };
79
+
80
+ /**
81
+ * The items in the `value` object that have a corresponding status object.
82
+ */
83
+ type CheckoutFormValueSectionsWithStatuses = Omit<
84
+ CheckoutFormValues,
85
+ 'adaptivePricing' | 'shippingOption'
86
+ >;
87
+
88
+ type SectionStatus = {complete: boolean; empty: boolean};
89
+
90
+ /**
91
+ * The `status` payload returned in the change event and getValue() method.
92
+ * - each section in the values object has a corresponding status object: {complete: boolean, empty: boolean}.
93
+ * - customComponents includes the status of each component: {"id of custom component": {complete: boolean, empty: boolean}} .
94
+ */
95
+ export type CheckoutFormStatus = {
96
+ [K in keyof CheckoutFormValueSectionsWithStatuses]: K extends 'customComponents'
97
+ ? Record<string, SectionStatus>
98
+ : SectionStatus;
99
+ };
100
+
19
101
  /**
20
102
  * The change event payload for the CheckoutForm.
21
103
  */
@@ -38,62 +120,18 @@ export interface StripeCheckoutFormChangeEvent {
38
120
  /**
39
121
  * An object containing the current form values.
40
122
  */
41
- value: {
42
- customerDetails: {
43
- email: string;
44
- name?: string;
45
- businessName?: string;
46
- phone?: string;
47
- };
48
- shippingOption?: {
49
- id: string;
50
- displayName: string;
51
- amount: string;
52
- };
53
- shippingAddress?: {
54
- name: string;
55
- address: CheckoutFormAddress;
56
- };
57
- billingAddress?: {
58
- name: string;
59
- address: CheckoutFormAddress;
60
- };
61
- tax?: {
62
- businessName?: string;
63
- taxId: string;
64
- taxIdType: TaxIdType;
65
- externalTaxIdType: ExternalTaxIdType;
66
- };
67
- customFields?: Record<string, string | number>;
68
- payment?: {
69
- collapsed: boolean;
70
- type: string;
71
- country?: string | null;
72
- billingDetails?: {
73
- address?: {
74
- country?: string;
75
- postal_code?: string;
76
- };
77
- } | null;
78
- payment_method?: {
79
- id: string;
80
- type: string;
81
- billing_details: {
82
- address: CheckoutFormAddress;
83
- name: string | null;
84
- email: string | null;
85
- phone: string | null;
86
- };
87
- } | null;
88
- savePaymentMethod?: boolean;
89
- };
90
- adaptivePricing?: {
91
- /**
92
- * The currently selected local currency code (e.g. 'eur', 'gbp').
93
- */
94
- currency: string;
95
- };
96
- };
123
+ value: CheckoutFormValues;
124
+
125
+ /**
126
+ * An object containing the current status (complete/empty) of each section in the values object.
127
+ *
128
+ * Ex.
129
+ * - when all values in the `values.customerDetails` object are empty,
130
+ * `status.customerDetails.empty` will be true.
131
+ * - when all values in the `values.customerDetails` object are complete,
132
+ * `status.customerDetails.complete` will be true.
133
+ */
134
+ status: CheckoutFormStatus;
97
135
 
98
136
  /**
99
137
  * Array of views in compact layout. Only defined for compact layout.
@@ -16,6 +16,88 @@ export type CheckoutFormAddress = {
16
16
  country?: string | null;
17
17
  };
18
18
 
19
+ /**
20
+ * The `value` payload returned in the change event and getValue() method.
21
+ */
22
+ export type CheckoutFormValues = {
23
+ customerDetails: {
24
+ email: string;
25
+ name?: string;
26
+ businessName?: string;
27
+ phone?: string;
28
+ };
29
+ shippingOption?: {
30
+ id: string;
31
+ displayName: string;
32
+ amount: string;
33
+ };
34
+ shippingAddress?: {
35
+ name: string;
36
+ address: CheckoutFormAddress;
37
+ };
38
+ billingAddress?: {
39
+ name: string;
40
+ address: CheckoutFormAddress;
41
+ };
42
+ tax?: {
43
+ businessName?: string;
44
+ taxId: string;
45
+ taxIdType: TaxIdType;
46
+ externalTaxIdType: ExternalTaxIdType;
47
+ };
48
+ payment?: {
49
+ collapsed: boolean;
50
+ type: string;
51
+ country?: string | null;
52
+ billingDetails?: {
53
+ address?: {
54
+ country?: string;
55
+ postal_code?: string;
56
+ };
57
+ } | null;
58
+ payment_method?: {
59
+ id: string;
60
+ type: string;
61
+ billing_details: {
62
+ address: CheckoutFormAddress;
63
+ name: string | null;
64
+ email: string | null;
65
+ phone: string | null;
66
+ };
67
+ } | null;
68
+ savePaymentMethod?: boolean;
69
+ };
70
+ adaptivePricing?: {
71
+ /**
72
+ * The currently selected local currency code (e.g. 'eur', 'gbp').
73
+ */
74
+ currency: string;
75
+ };
76
+ customFields?: Record<string, string | number>;
77
+ customComponents?: Record<string, string | number>;
78
+ };
79
+
80
+ /**
81
+ * The items in the `value` object that have a corresponding status object.
82
+ */
83
+ type CheckoutFormValueSectionsWithStatuses = Omit<
84
+ CheckoutFormValues,
85
+ 'adaptivePricing' | 'shippingOption'
86
+ >;
87
+
88
+ type SectionStatus = {complete: boolean; empty: boolean};
89
+
90
+ /**
91
+ * The `status` payload returned in the change event and getValue() method.
92
+ * - each section in the values object has a corresponding status object: {complete: boolean, empty: boolean}.
93
+ * - customComponents includes the status of each component: {"id of custom component": {complete: boolean, empty: boolean}} .
94
+ */
95
+ export type CheckoutFormStatus = {
96
+ [K in keyof CheckoutFormValueSectionsWithStatuses]: K extends 'customComponents'
97
+ ? Record<string, SectionStatus>
98
+ : SectionStatus;
99
+ };
100
+
19
101
  /**
20
102
  * The change event payload for the CheckoutForm.
21
103
  */
@@ -38,62 +120,18 @@ export interface StripeCheckoutFormChangeEvent {
38
120
  /**
39
121
  * An object containing the current form values.
40
122
  */
41
- value: {
42
- customerDetails: {
43
- email: string;
44
- name?: string;
45
- businessName?: string;
46
- phone?: string;
47
- };
48
- shippingOption?: {
49
- id: string;
50
- displayName: string;
51
- amount: string;
52
- };
53
- shippingAddress?: {
54
- name: string;
55
- address: CheckoutFormAddress;
56
- };
57
- billingAddress?: {
58
- name: string;
59
- address: CheckoutFormAddress;
60
- };
61
- tax?: {
62
- businessName?: string;
63
- taxId: string;
64
- taxIdType: TaxIdType;
65
- externalTaxIdType: ExternalTaxIdType;
66
- };
67
- customFields?: Record<string, string | number>;
68
- payment?: {
69
- collapsed: boolean;
70
- type: string;
71
- country?: string | null;
72
- billingDetails?: {
73
- address?: {
74
- country?: string;
75
- postal_code?: string;
76
- };
77
- } | null;
78
- payment_method?: {
79
- id: string;
80
- type: string;
81
- billing_details: {
82
- address: CheckoutFormAddress;
83
- name: string | null;
84
- email: string | null;
85
- phone: string | null;
86
- };
87
- } | null;
88
- savePaymentMethod?: boolean;
89
- };
90
- adaptivePricing?: {
91
- /**
92
- * The currently selected local currency code (e.g. 'eur', 'gbp').
93
- */
94
- currency: string;
95
- };
96
- };
123
+ value: CheckoutFormValues;
124
+
125
+ /**
126
+ * An object containing the current status (complete/empty) of each section in the values object.
127
+ *
128
+ * Ex.
129
+ * - when all values in the `values.customerDetails` object are empty,
130
+ * `status.customerDetails.empty` will be true.
131
+ * - when all values in the `values.customerDetails` object are complete,
132
+ * `status.customerDetails.complete` will be true.
133
+ */
134
+ status: CheckoutFormStatus;
97
135
 
98
136
  /**
99
137
  * Array of views in compact layout. Only defined for compact layout.
@@ -0,0 +1,102 @@
1
+ import {StripeElementBase} from './base';
2
+ import {StripeError} from '../stripe';
3
+
4
+ export type StripeTermsElement = 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: 'terms'}) => any
11
+ ): StripeTermsElement;
12
+ once(
13
+ eventType: 'ready',
14
+ handler: (event: {elementType: 'terms'}) => any
15
+ ): StripeTermsElement;
16
+ off(
17
+ eventType: 'ready',
18
+ handler?: (event: {elementType: 'terms'}) => any
19
+ ): StripeTermsElement;
20
+
21
+ /**
22
+ * Triggered when the element gains focus.
23
+ */
24
+ on(
25
+ eventType: 'focus',
26
+ handler: (event: {elementType: 'terms'}) => any
27
+ ): StripeTermsElement;
28
+ once(
29
+ eventType: 'focus',
30
+ handler: (event: {elementType: 'terms'}) => any
31
+ ): StripeTermsElement;
32
+ off(
33
+ eventType: 'focus',
34
+ handler?: (event: {elementType: 'terms'}) => any
35
+ ): StripeTermsElement;
36
+
37
+ /**
38
+ * Triggered when the element loses focus.
39
+ */
40
+ on(
41
+ eventType: 'blur',
42
+ handler: (event: {elementType: 'terms'}) => any
43
+ ): StripeTermsElement;
44
+ once(
45
+ eventType: 'blur',
46
+ handler: (event: {elementType: 'terms'}) => any
47
+ ): StripeTermsElement;
48
+ off(
49
+ eventType: 'blur',
50
+ handler?: (event: {elementType: 'terms'}) => any
51
+ ): StripeTermsElement;
52
+
53
+ /**
54
+ * Triggered when the escape key is pressed within the element.
55
+ */
56
+ on(
57
+ eventType: 'escape',
58
+ handler: (event: {elementType: 'terms'}) => any
59
+ ): StripeTermsElement;
60
+ once(
61
+ eventType: 'escape',
62
+ handler: (event: {elementType: 'terms'}) => any
63
+ ): StripeTermsElement;
64
+ off(
65
+ eventType: 'escape',
66
+ handler?: (event: {elementType: 'terms'}) => any
67
+ ): StripeTermsElement;
68
+
69
+ /**
70
+ * Triggered when the element fails to load.
71
+ */
72
+ on(
73
+ eventType: 'loaderror',
74
+ handler: (event: {elementType: 'terms'; error: StripeError}) => any
75
+ ): StripeTermsElement;
76
+ once(
77
+ eventType: 'loaderror',
78
+ handler: (event: {elementType: 'terms'; error: StripeError}) => any
79
+ ): StripeTermsElement;
80
+ off(
81
+ eventType: 'loaderror',
82
+ handler?: (event: {elementType: 'terms'; error: StripeError}) => any
83
+ ): StripeTermsElement;
84
+
85
+ /**
86
+ * Triggered when the loader UI is mounted to the DOM and ready to be displayed.
87
+ */
88
+ on(
89
+ eventType: 'loaderstart',
90
+ handler: (event: {elementType: 'terms'}) => any
91
+ ): StripeTermsElement;
92
+ once(
93
+ eventType: 'loaderstart',
94
+ handler: (event: {elementType: 'terms'}) => any
95
+ ): StripeTermsElement;
96
+ off(
97
+ eventType: 'loaderstart',
98
+ handler?: (event: {elementType: 'terms'}) => any
99
+ ): StripeTermsElement;
100
+ };
101
+
102
+ export interface StripeTermsElementOptions {}
@@ -0,0 +1,102 @@
1
+ import {StripeElementBase} from './base';
2
+ import {StripeError} from '../stripe';
3
+
4
+ export type StripeTermsElement = 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: 'terms'}) => any
11
+ ): StripeTermsElement;
12
+ once(
13
+ eventType: 'ready',
14
+ handler: (event: {elementType: 'terms'}) => any
15
+ ): StripeTermsElement;
16
+ off(
17
+ eventType: 'ready',
18
+ handler?: (event: {elementType: 'terms'}) => any
19
+ ): StripeTermsElement;
20
+
21
+ /**
22
+ * Triggered when the element gains focus.
23
+ */
24
+ on(
25
+ eventType: 'focus',
26
+ handler: (event: {elementType: 'terms'}) => any
27
+ ): StripeTermsElement;
28
+ once(
29
+ eventType: 'focus',
30
+ handler: (event: {elementType: 'terms'}) => any
31
+ ): StripeTermsElement;
32
+ off(
33
+ eventType: 'focus',
34
+ handler?: (event: {elementType: 'terms'}) => any
35
+ ): StripeTermsElement;
36
+
37
+ /**
38
+ * Triggered when the element loses focus.
39
+ */
40
+ on(
41
+ eventType: 'blur',
42
+ handler: (event: {elementType: 'terms'}) => any
43
+ ): StripeTermsElement;
44
+ once(
45
+ eventType: 'blur',
46
+ handler: (event: {elementType: 'terms'}) => any
47
+ ): StripeTermsElement;
48
+ off(
49
+ eventType: 'blur',
50
+ handler?: (event: {elementType: 'terms'}) => any
51
+ ): StripeTermsElement;
52
+
53
+ /**
54
+ * Triggered when the escape key is pressed within the element.
55
+ */
56
+ on(
57
+ eventType: 'escape',
58
+ handler: (event: {elementType: 'terms'}) => any
59
+ ): StripeTermsElement;
60
+ once(
61
+ eventType: 'escape',
62
+ handler: (event: {elementType: 'terms'}) => any
63
+ ): StripeTermsElement;
64
+ off(
65
+ eventType: 'escape',
66
+ handler?: (event: {elementType: 'terms'}) => any
67
+ ): StripeTermsElement;
68
+
69
+ /**
70
+ * Triggered when the element fails to load.
71
+ */
72
+ on(
73
+ eventType: 'loaderror',
74
+ handler: (event: {elementType: 'terms'; error: StripeError}) => any
75
+ ): StripeTermsElement;
76
+ once(
77
+ eventType: 'loaderror',
78
+ handler: (event: {elementType: 'terms'; error: StripeError}) => any
79
+ ): StripeTermsElement;
80
+ off(
81
+ eventType: 'loaderror',
82
+ handler?: (event: {elementType: 'terms'; error: StripeError}) => any
83
+ ): StripeTermsElement;
84
+
85
+ /**
86
+ * Triggered when the loader UI is mounted to the DOM and ready to be displayed.
87
+ */
88
+ on(
89
+ eventType: 'loaderstart',
90
+ handler: (event: {elementType: 'terms'}) => any
91
+ ): StripeTermsElement;
92
+ once(
93
+ eventType: 'loaderstart',
94
+ handler: (event: {elementType: 'terms'}) => any
95
+ ): StripeTermsElement;
96
+ off(
97
+ eventType: 'loaderstart',
98
+ handler?: (event: {elementType: 'terms'}) => any
99
+ ): StripeTermsElement;
100
+ };
101
+
102
+ export interface StripeTermsElementOptions {}
@@ -43,6 +43,8 @@ import {
43
43
  StripeAddressElementGetElementOptions,
44
44
  StripeTaxIdElement,
45
45
  StripeTaxIdElementOptions,
46
+ StripeTermsElement,
47
+ StripeTermsElementOptions,
46
48
  } from './elements';
47
49
  import {StripeError} from './stripe';
48
50
 
@@ -445,6 +447,29 @@ export interface StripeElements {
445
447
  getElement(
446
448
  elementType: 'currencySelector'
447
449
  ): StripeCurrencySelectorElement | null;
450
+
451
+ /////////////////////////////
452
+ /// terms
453
+ /////////////////////////////
454
+
455
+ /**
456
+ * Requires beta access:
457
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
458
+ *
459
+ * Creates a `TermsElement`.
460
+ */
461
+ create(
462
+ elementType: 'terms',
463
+ options?: StripeTermsElementOptions
464
+ ): StripeTermsElement;
465
+
466
+ /**
467
+ * Requires beta access:
468
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
469
+ *
470
+ * Looks up a previously created `Element` by its type.
471
+ */
472
+ getElement(elementType: 'terms'): StripeTermsElement | null;
448
473
  }
449
474
 
450
475
  export type StripeElementType =
@@ -470,6 +495,7 @@ export type StripeElementType =
470
495
  | 'issuingCardPinDisplay'
471
496
  | 'issuingCardCopyButton'
472
497
  | 'taxId'
498
+ | 'terms'
473
499
  | 'issuingAddToWalletButton';
474
500
 
475
501
  export type StripeElement =
@@ -493,7 +519,8 @@ export type StripeElement =
493
519
  | StripeIssuingCardPinDisplayElement
494
520
  | StripeIssuingCardCopyButtonElement
495
521
  | StripeShippingAddressElement
496
- | StripeTaxIdElement;
522
+ | StripeTaxIdElement
523
+ | StripeTermsElement;
497
524
 
498
525
  export type StripeElementLocale =
499
526
  | 'auto'
@@ -43,6 +43,8 @@ import {
43
43
  StripeAddressElementGetElementOptions,
44
44
  StripeTaxIdElement,
45
45
  StripeTaxIdElementOptions,
46
+ StripeTermsElement,
47
+ StripeTermsElementOptions,
46
48
  } from './elements';
47
49
  import {StripeError} from './stripe';
48
50
 
@@ -445,6 +447,29 @@ export interface StripeElements {
445
447
  getElement(
446
448
  elementType: 'currencySelector'
447
449
  ): StripeCurrencySelectorElement | null;
450
+
451
+ /////////////////////////////
452
+ /// terms
453
+ /////////////////////////////
454
+
455
+ /**
456
+ * Requires beta access:
457
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
458
+ *
459
+ * Creates a `TermsElement`.
460
+ */
461
+ create(
462
+ elementType: 'terms',
463
+ options?: StripeTermsElementOptions
464
+ ): StripeTermsElement;
465
+
466
+ /**
467
+ * Requires beta access:
468
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
469
+ *
470
+ * Looks up a previously created `Element` by its type.
471
+ */
472
+ getElement(elementType: 'terms'): StripeTermsElement | null;
448
473
  }
449
474
 
450
475
  export type StripeElementType =
@@ -470,6 +495,7 @@ export type StripeElementType =
470
495
  | 'issuingCardPinDisplay'
471
496
  | 'issuingCardCopyButton'
472
497
  | 'taxId'
498
+ | 'terms'
473
499
  | 'issuingAddToWalletButton';
474
500
 
475
501
  export type StripeElement =
@@ -493,7 +519,8 @@ export type StripeElement =
493
519
  | StripeIssuingCardPinDisplayElement
494
520
  | StripeIssuingCardCopyButtonElement
495
521
  | StripeShippingAddressElement
496
- | StripeTaxIdElement;
522
+ | StripeTaxIdElement
523
+ | StripeTermsElement;
497
524
 
498
525
  export type StripeElementLocale =
499
526
  | 'auto'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/stripe-js",
3
- "version": "9.9.0",
3
+ "version": "9.12.0",
4
4
  "description": "Stripe.js loading utility",
5
5
  "repository": "github:stripe/stripe-js",
6
6
  "main": "lib/index.js",