@stripe/stripe-js 1.29.0 → 1.32.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/pure.esm.js CHANGED
@@ -54,7 +54,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
54
54
 
55
55
  stripe._registerWrapper({
56
56
  name: 'stripe-js',
57
- version: "1.29.0",
57
+ version: "1.32.0",
58
58
  startTime: startTime
59
59
  });
60
60
  };
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: "1.29.0",
61
+ version: "1.32.0",
62
62
  startTime: startTime
63
63
  });
64
64
  };
@@ -38,7 +38,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
38
38
 
39
39
  stripe._registerWrapper({
40
40
  name: 'stripe-js',
41
- version: "1.29.0",
41
+ version: "1.32.0",
42
42
  startTime: startTime
43
43
  });
44
44
  };
package/dist/stripe.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: "1.29.0",
45
+ version: "1.32.0",
46
46
  startTime: startTime
47
47
  });
48
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/stripe-js",
3
- "version": "1.29.0",
3
+ "version": "1.32.0",
4
4
  "description": "Stripe.js loading utility",
5
5
  "main": "dist/stripe.js",
6
6
  "module": "dist/stripe.esm.js",
@@ -1,6 +1,7 @@
1
1
  export * from './shared';
2
2
  export * from './payment-methods';
3
3
  export * from './payment-intents';
4
+ export * from './orders';
4
5
  export * from './setup-intents';
5
6
  export * from './sources';
6
7
  export * from './tokens';
@@ -0,0 +1,122 @@
1
+ import {Address} from './shared';
2
+ import {PaymentIntent} from './payment-intents';
3
+
4
+ /**
5
+ * The Order object.
6
+ */
7
+ export interface Order {
8
+ /**
9
+ * Unique identifier for the object.
10
+ */
11
+ id: string;
12
+
13
+ /**
14
+ * String representing the object's type. Objects of the same type share the same value.
15
+ */
16
+ object: 'order';
17
+
18
+ /**
19
+ * Total order cost after discounts and taxes are applied. A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). To submit an order, the total must be either 0 or at least $0.50 USD or [equivalent in charge currency](https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts).
20
+ */
21
+ amount_total: number;
22
+
23
+ /**
24
+ * Order cost before any discounts or taxes are applied. A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency).
25
+ */
26
+ amount_subtotal: number;
27
+
28
+ /**
29
+ * Customer billing details associated with the order.
30
+ */
31
+ billing_details: Order.Billing | null;
32
+
33
+ /**
34
+ * Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
35
+ */
36
+ currency: string;
37
+
38
+ /**
39
+ * Time at which the object was created. Measured in seconds since the Unix epoch.
40
+ */
41
+ created: number;
42
+
43
+ /**
44
+ * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
45
+ */
46
+ livemode: boolean;
47
+
48
+ /**
49
+ * Customer shipping information associated with the order.
50
+ */
51
+ shipping_details: Order.Shipping | null;
52
+
53
+ /**
54
+ * Payment information associated with the order.
55
+ */
56
+ payment: Order.Payment;
57
+
58
+ /**
59
+ * The overall status of the order.
60
+ */
61
+ status: Order.Status;
62
+ }
63
+
64
+ export namespace Order {
65
+ export interface Billing {
66
+ /**
67
+ * Billing address for the order.
68
+ */
69
+ address?: Address;
70
+
71
+ /**
72
+ * Email address for the order.
73
+ */
74
+ email?: string | null;
75
+
76
+ /**
77
+ * Full name for the order.
78
+ */
79
+ name?: string | null;
80
+
81
+ /**
82
+ * Billing phone number for the order (including extension).
83
+ */
84
+ phone?: string | null;
85
+ }
86
+
87
+ export interface Shipping {
88
+ /**
89
+ * Recipient shipping address. Required if the order includes products that are shippable.
90
+ */
91
+ address?: Address;
92
+
93
+ /**
94
+ * Recipient name.
95
+ */
96
+ name?: string | null;
97
+
98
+ /**
99
+ * Recipient phone (including extension).
100
+ */
101
+ phone?: string | null;
102
+ }
103
+
104
+ export interface Payment {
105
+ /**
106
+ * Payment intent associated with this order. Null when the order is `open`.
107
+ */
108
+ payment_intent?: PaymentIntent | null;
109
+
110
+ /**
111
+ * The status of the underlying payment associated with this order, if any. Null when the order is `open`.
112
+ */
113
+ status?: PaymentIntent.Status | null;
114
+ }
115
+
116
+ export type Status =
117
+ | 'open'
118
+ | 'submitted'
119
+ | 'processing'
120
+ | 'complete'
121
+ | 'canceled';
122
+ }
@@ -1,4 +1,5 @@
1
1
  import {StripeElementBase, StripeElementChangeEvent} from './base';
2
+ import {StripeError} from '../stripe';
2
3
 
3
4
  export type StripeLinkAuthenticationElement = StripeElementBase & {
4
5
  /**
@@ -80,6 +81,31 @@ export type StripeLinkAuthenticationElement = StripeElementBase & {
80
81
  eventType: 'escape',
81
82
  handler?: (event: {elementType: 'linkAuthentication'}) => any
82
83
  ): StripeLinkAuthenticationElement;
84
+
85
+ /**
86
+ * Triggered when the element fails to load.
87
+ */
88
+ on(
89
+ eventType: 'loaderror',
90
+ handler: (event: {
91
+ elementType: 'linkAuthentication';
92
+ error: StripeError;
93
+ }) => any
94
+ ): StripeLinkAuthenticationElement;
95
+ once(
96
+ eventType: 'loaderror',
97
+ handler: (event: {
98
+ elementType: 'linkAuthentication';
99
+ error: StripeError;
100
+ }) => any
101
+ ): StripeLinkAuthenticationElement;
102
+ off(
103
+ eventType: 'loaderror',
104
+ handler?: (event: {
105
+ elementType: 'linkAuthentication';
106
+ error: StripeError;
107
+ }) => any
108
+ ): StripeLinkAuthenticationElement;
83
109
  };
84
110
 
85
111
  export interface StripeLinkAuthenticationElementOptions {
@@ -1,4 +1,5 @@
1
1
  import {StripeElementBase} from './base';
2
+ import {StripeError} from '../stripe';
2
3
 
3
4
  export type StripePaymentElement = StripeElementBase & {
4
5
  /**
@@ -81,6 +82,22 @@ export type StripePaymentElement = StripeElementBase & {
81
82
  handler?: (event: {elementType: 'payment'}) => any
82
83
  ): StripePaymentElement;
83
84
 
85
+ /**
86
+ * Triggered when the element fails to load.
87
+ */
88
+ on(
89
+ eventType: 'loaderror',
90
+ handler: (event: {elementType: 'payment'; error: StripeError}) => any
91
+ ): StripePaymentElement;
92
+ once(
93
+ eventType: 'loaderror',
94
+ handler: (event: {elementType: 'payment'; error: StripeError}) => any
95
+ ): StripePaymentElement;
96
+ off(
97
+ eventType: 'loaderror',
98
+ handler?: (event: {elementType: 'payment'; error: StripeError}) => any
99
+ ): StripePaymentElement;
100
+
84
101
  /**
85
102
  * Updates the options the `PaymentElement` was initialized with.
86
103
  * Updates are merged into the existing configuration.
@@ -1,4 +1,5 @@
1
1
  import {StripeElementBase, StripeElementChangeEvent} from './base';
2
+ import {StripeError} from '../stripe';
2
3
 
3
4
  export type StripeShippingAddressElement = StripeElementBase & {
4
5
  /**
@@ -82,11 +83,28 @@ export type StripeShippingAddressElement = StripeElementBase & {
82
83
  ): StripeShippingAddressElement;
83
84
 
84
85
  /**
85
- * Updates the options the `ShippingAddressElement` was initialized with.
86
- * Updates are merged into the existing configuration.
86
+ * Triggered when the element fails to load.
87
87
  */
88
- update(
89
- options: Partial<StripeShippingAddressElementOptions>
88
+ on(
89
+ eventType: 'loaderror',
90
+ handler: (event: {
91
+ elementType: 'shippingAddress';
92
+ error: StripeError;
93
+ }) => any
94
+ ): StripeShippingAddressElement;
95
+ once(
96
+ eventType: 'loaderror',
97
+ handler: (event: {
98
+ elementType: 'shippingAddress';
99
+ error: StripeError;
100
+ }) => any
101
+ ): StripeShippingAddressElement;
102
+ off(
103
+ eventType: 'loaderror',
104
+ handler?: (event: {
105
+ elementType: 'shippingAddress';
106
+ error: StripeError;
107
+ }) => any
90
108
  ): StripeShippingAddressElement;
91
109
  };
92
110
 
@@ -151,7 +169,7 @@ export interface StripeShippingAddressElementChangeEvent
151
169
  name: string;
152
170
  address: {
153
171
  line1: string;
154
- line2: string;
172
+ line2: string | null;
155
173
  city: string;
156
174
  state: string;
157
175
  postal_code: string;
@@ -471,6 +471,15 @@ export interface StripeElementsOptions {
471
471
  * Default is `'auto'` (Stripe determines if a loader UI should be shown).
472
472
  */
473
473
  loader?: 'auto' | 'always' | 'never';
474
+
475
+ /**
476
+ * Requires beta access:
477
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
478
+ *
479
+ * Display saved PaymentMethods and Customer information.
480
+ * Supported for the `payment`, `shippingAddress`, and `linkAuthentication` Elements.
481
+ */
482
+ customerOptions?: CustomerOptions;
474
483
  }
475
484
 
476
485
  /*
@@ -485,9 +494,6 @@ export interface StripeElementsUpdateOptions {
485
494
  locale?: StripeElementLocale;
486
495
 
487
496
  /**
488
- * Used with the Payment Element, requires beta access:
489
- * Contact [Stripe support](https://support.stripe.com/) for more information.
490
- *
491
497
  * Match the design of your site with the appearance option.
492
498
  * The layout of each Element stays consistent, but you can modify colors, fonts, borders, padding, and more.
493
499
  *
@@ -638,3 +644,15 @@ export interface Appearance {
638
644
 
639
645
  labels?: 'above' | 'floating';
640
646
  }
647
+
648
+ export interface CustomerOptions {
649
+ /**
650
+ * The Customer id.
651
+ */
652
+ customer: string;
653
+
654
+ /**
655
+ * The ephemeral key for a Customer that grants temporary access to Customer data.
656
+ */
657
+ ephemeralKey: string;
658
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parameters that will be passed on to the Stripe API to confirm payment for an Order's PaymentIntent.
3
+ */
4
+ export interface ProcessOrderParams {
5
+ /**
6
+ * The url your customer will be directed to after they complete payment.
7
+ */
8
+ return_url: string;
9
+ }
@@ -14,6 +14,11 @@ export interface PaymentRequest {
14
14
  */
15
15
  show(): void;
16
16
 
17
+ /**
18
+ * Closes the browser’s payment interface.
19
+ */
20
+ abort: () => void;
21
+
17
22
  /**
18
23
  * `true` if the browser’s payment interface is showing.
19
24
  * When using the `PaymentRequestButtonElement`, this is called for you automatically.
@@ -187,6 +187,11 @@ export interface VerifyMicrodepositsForSetupData {
187
187
  * An array of two positive integers, in cents, equal to the values of the microdeposits sent to the bank account.
188
188
  */
189
189
  amounts?: Array<number>;
190
+
191
+ /**
192
+ * A six-character code starting with SM present in the microdeposit sent to the bank account.
193
+ */
194
+ descriptor_code?: string;
190
195
  }
191
196
 
192
197
  export interface ConfirmUsBankAccountSetupData
@@ -1,6 +1,7 @@
1
1
  import * as api from '../api';
2
2
  import * as paymentIntents from './payment-intents';
3
3
  import * as setupIntents from './setup-intents';
4
+ import * as orders from './orders';
4
5
  import * as tokens from './token-and-sources';
5
6
  import * as elements from './elements';
6
7
 
@@ -47,7 +48,7 @@ export interface Stripe {
47
48
  * When called, `stripe.confirmPayment` will attempt to complete any [required actions](https://stripe.com/docs/payments/intents), such as authenticating your user by displaying a 3DS dialog or redirecting them to a bank authorization page.
48
49
  * Your user will be redirected to the return_url you pass once the confirmation is complete.
49
50
  *
50
- * By default, stripe.`confirmPayment` will always redirect to your return_url after a successful confirmation.
51
+ * By default, `stripe.confirmPayment` will always redirect to your return_url after a successful confirmation.
51
52
  * If you set `redirect: "if_required"`, then `stripe.confirmPayment` will only redirect if your user chooses a redirect-based payment method.
52
53
  * Setting `if_required` requires that you handle successful confirmations for redirect-based and non-redirect based payment methods separately.
53
54
  *
@@ -795,6 +796,49 @@ export interface Stripe {
795
796
  */
796
797
  retrieveSetupIntent(clientSecret: string): Promise<SetupIntentResult>;
797
798
 
799
+ /////////////////////////////
800
+ /// Orders
801
+ ///
802
+ /// https://stripe.com/docs/js/orders
803
+ /////////////////////////////
804
+
805
+ /**
806
+ * Use `stripe.processOrder` to submit and confirm payment for an [Order](https://stripe.com/docs/api/orders_v2) using data collected by the [Payment Element](https://stripe.com/docs/js/element/payment_element).
807
+ * When called, `stripe.processOrder` will attempt to complete any required actions, such as authenticating your user by displaying a 3DS dialog or redirecting them to a bank authorization page.
808
+ * Your user will be redirected to the return_url you pass once the confirmation is complete.
809
+ *
810
+ * By default, `stripe.processOrder` will always redirect to your return_url after a successful confirmation.
811
+ * If you set `redirect: "if_required"`, then `stripe.processOrder` will only redirect if your user chooses a redirect-based method.
812
+ * Setting `if_required` requires that you handle successful confirmations for redirect-based and non-redirect based payment methods separately.
813
+ *
814
+ * @docs https://stripe.com/docs/js/orders/process_order
815
+ */
816
+ processOrder(options: {
817
+ elements: StripeElements;
818
+ confirmParams?: Partial<orders.ProcessOrderParams>;
819
+ redirect: 'if_required';
820
+ }): Promise<ProcessOrderResult>;
821
+
822
+ /**
823
+ * Use `stripe.processOrder` to submit and confirm payment for an [Order](https://stripe.com/docs/api/orders_v2) using data collected by the [Payment Element](https://stripe.com/docs/js/element/payment_element).
824
+ * When called, `stripe.processOrder` will attempt to complete any required actions, such as authenticating your user by displaying a 3DS dialog or redirecting them to a bank authorization page.
825
+ * Your user will be redirected to the return_url you pass once the confirmation is complete.
826
+ *
827
+ * @docs https://stripe.com/docs/js/orders/process_order
828
+ */
829
+ processOrder(options: {
830
+ elements: StripeElements;
831
+ confirmParams: orders.ProcessOrderParams;
832
+ redirect?: 'always';
833
+ }): Promise<never | {error: StripeError}>;
834
+
835
+ /**
836
+ * Retrieve an [Order](https://stripe.com/docs/api/orders_v2) using its [client secret](https://stripe.com/docs/api/orders_v2/object#order_v2_object-client_secret).
837
+ *
838
+ * @docs https://stripe.com/docs/js/orders/retrieve_order
839
+ */
840
+ retrieveOrder(clientSecret: string): Promise<RetrieveOrderResult>;
841
+
798
842
  /////////////////////////////
799
843
  /// Payment Request
800
844
  ///
@@ -941,6 +985,15 @@ export type SetupIntentResult =
941
985
  | {setupIntent: api.SetupIntent; error?: undefined}
942
986
  | {setupIntent?: undefined; error: StripeError};
943
987
 
988
+ export type ProcessOrderResult =
989
+ | {paymentIntent: api.PaymentIntent; order: api.Order; error?: undefined}
990
+ | {paymentIntent?: undefined; order: api.Order; error?: undefined}
991
+ | {paymentIntent?: undefined; order?: undefined; error: StripeError};
992
+
993
+ export type RetrieveOrderResult =
994
+ | {order: api.Order; error?: undefined}
995
+ | {order?: undefined; error: StripeError};
996
+
944
997
  export type PaymentMethodResult =
945
998
  | {paymentMethod: api.PaymentMethod; error?: undefined}
946
999
  | {paymentMethod?: undefined; error: StripeError};