@stripe/stripe-js 1.30.0 → 1.33.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.30.0",
57
+ version: "1.33.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.30.0",
61
+ version: "1.33.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.30.0",
41
+ version: "1.33.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.30.0",
45
+ version: "1.33.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.30.0",
3
+ "version": "1.33.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,47 @@ 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;
109
+
110
+ /**
111
+ * Triggered when the loader UI is mounted to the DOM and ready to be displayed.
112
+ */
113
+ on(
114
+ eventType: 'loaderstart',
115
+ handler: (event: {elementType: 'linkAuthentication'}) => any
116
+ ): StripeLinkAuthenticationElement;
117
+ once(
118
+ eventType: 'loaderstart',
119
+ handler: (event: {elementType: 'linkAuthentication'}) => any
120
+ ): StripeLinkAuthenticationElement;
121
+ off(
122
+ eventType: 'loaderstart',
123
+ handler?: (event: {elementType: 'linkAuthentication'}) => any
124
+ ): StripeLinkAuthenticationElement;
83
125
  };
84
126
 
85
127
  export interface StripeLinkAuthenticationElementOptions {
@@ -98,6 +98,22 @@ export type StripePaymentElement = StripeElementBase & {
98
98
  handler?: (event: {elementType: 'payment'; error: StripeError}) => any
99
99
  ): StripePaymentElement;
100
100
 
101
+ /**
102
+ * Triggered when the loader UI is mounted to the DOM and ready to be displayed.
103
+ */
104
+ on(
105
+ eventType: 'loaderstart',
106
+ handler: (event: {elementType: 'payment'}) => any
107
+ ): StripePaymentElement;
108
+ once(
109
+ eventType: 'loaderstart',
110
+ handler: (event: {elementType: 'payment'}) => any
111
+ ): StripePaymentElement;
112
+ off(
113
+ eventType: 'loaderstart',
114
+ handler?: (event: {elementType: 'payment'}) => any
115
+ ): StripePaymentElement;
116
+
101
117
  /**
102
118
  * Updates the options the `PaymentElement` was initialized with.
103
119
  * Updates are merged into the existing configuration.
@@ -110,6 +126,22 @@ export type StripePaymentElement = StripeElementBase & {
110
126
  collapse(): StripePaymentElement;
111
127
  };
112
128
 
129
+ export interface DefaultValuesOption {
130
+ billingDetails?: {
131
+ name?: string;
132
+ email?: string;
133
+ phone?: string;
134
+ address?: {
135
+ country?: string;
136
+ postal_code?: string;
137
+ state?: string;
138
+ city?: string;
139
+ line1?: string;
140
+ line2?: string;
141
+ };
142
+ };
143
+ }
144
+
113
145
  export type FieldOption = 'auto' | 'never';
114
146
 
115
147
  export interface FieldsOption {
@@ -152,6 +184,11 @@ export interface WalletsOption {
152
184
  }
153
185
 
154
186
  export interface StripePaymentElementOptions {
187
+ /**
188
+ * Provide initial customer information that will be displayed in the Payment Element.
189
+ */
190
+ defaultValues?: DefaultValuesOption;
191
+
155
192
  /**
156
193
  * Override the business name displayed in the Payment Element.
157
194
  * By default the PaymentElement will use your Stripe account or business name.
@@ -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
  /**
@@ -80,6 +81,47 @@ export type StripeShippingAddressElement = StripeElementBase & {
80
81
  eventType: 'escape',
81
82
  handler?: (event: {elementType: 'shippingAddress'}) => any
82
83
  ): StripeShippingAddressElement;
84
+
85
+ /**
86
+ * Triggered when the element fails to load.
87
+ */
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
108
+ ): StripeShippingAddressElement;
109
+
110
+ /**
111
+ * Triggered when the loader UI is mounted to the DOM and ready to be displayed.
112
+ */
113
+ on(
114
+ eventType: 'loaderstart',
115
+ handler: (event: {elementType: 'shippingAddress'}) => any
116
+ ): StripeShippingAddressElement;
117
+ once(
118
+ eventType: 'loaderstart',
119
+ handler: (event: {elementType: 'shippingAddress'}) => any
120
+ ): StripeShippingAddressElement;
121
+ off(
122
+ eventType: 'loaderstart',
123
+ handler?: (event: {elementType: 'shippingAddress'}) => any
124
+ ): StripeShippingAddressElement;
83
125
  };
84
126
 
85
127
  export interface StripeShippingAddressElementOptions {
@@ -143,7 +185,7 @@ export interface StripeShippingAddressElementChangeEvent
143
185
  name: string;
144
186
  address: {
145
187
  line1: string;
146
- line2: string;
188
+ line2: string | null;
147
189
  city: string;
148
190
  state: string;
149
191
  postal_code: string;
@@ -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
+ }
@@ -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};