@stripe/stripe-js 1.35.0 → 1.37.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.35.0",
57
+ version: "1.37.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.35.0",
61
+ version: "1.37.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.35.0",
41
+ version: "1.37.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.35.0",
45
+ version: "1.37.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.35.0",
3
+ "version": "1.37.0",
4
4
  "description": "Stripe.js loading utility",
5
5
  "main": "dist/stripe.js",
6
6
  "module": "dist/stripe.esm.js",
@@ -1,3 +1,4 @@
1
+ import {Omit} from '../utils';
1
2
  import {Card} from './cards';
2
3
  import {BankAccount} from './bank-accounts';
3
4
  import {JapanAddressParam, MetadataParam} from './shared';
@@ -46,6 +47,10 @@ export interface Token {
46
47
  used: boolean;
47
48
  }
48
49
 
50
+ export type BankAccountToken = Omit<Token, 'card'> & {
51
+ bank_account: BankAccount;
52
+ };
53
+
49
54
  export namespace TokenCreateParams {
50
55
  export interface Account {
51
56
  /**
@@ -0,0 +1,244 @@
1
+ import {StripeElementBase, StripeElementChangeEvent} from './base';
2
+ import {StripeError} from '../stripe';
3
+
4
+ export type StripeAddressElement = StripeElementBase & {
5
+ /**
6
+ * The change event is triggered when the `Element`'s value changes.
7
+ */
8
+ on(
9
+ eventType: 'change',
10
+ handler: (event: StripeAddressElementChangeEvent) => any
11
+ ): StripeAddressElement;
12
+ once(
13
+ eventType: 'change',
14
+ handler: (event: StripeAddressElementChangeEvent) => any
15
+ ): StripeAddressElement;
16
+ off(
17
+ eventType: 'change',
18
+ handler?: (event: StripeAddressElementChangeEvent) => any
19
+ ): StripeAddressElement;
20
+
21
+ /**
22
+ * Triggered when the element is fully rendered and can accept `element.focus` calls.
23
+ */
24
+ on(
25
+ eventType: 'ready',
26
+ handler: (event: {elementType: 'address'}) => any
27
+ ): StripeAddressElement;
28
+ once(
29
+ eventType: 'ready',
30
+ handler: (event: {elementType: 'address'}) => any
31
+ ): StripeAddressElement;
32
+ off(
33
+ eventType: 'ready',
34
+ handler?: (event: {elementType: 'address'}) => any
35
+ ): StripeAddressElement;
36
+
37
+ /**
38
+ * Triggered when the element gains focus.
39
+ */
40
+ on(
41
+ eventType: 'focus',
42
+ handler: (event: {elementType: 'address'}) => any
43
+ ): StripeAddressElement;
44
+ once(
45
+ eventType: 'focus',
46
+ handler: (event: {elementType: 'address'}) => any
47
+ ): StripeAddressElement;
48
+ off(
49
+ eventType: 'focus',
50
+ handler?: (event: {elementType: 'address'}) => any
51
+ ): StripeAddressElement;
52
+
53
+ /**
54
+ * Triggered when the element loses focus.
55
+ */
56
+ on(
57
+ eventType: 'blur',
58
+ handler: (event: {elementType: 'address'}) => any
59
+ ): StripeAddressElement;
60
+ once(
61
+ eventType: 'blur',
62
+ handler: (event: {elementType: 'address'}) => any
63
+ ): StripeAddressElement;
64
+ off(
65
+ eventType: 'blur',
66
+ handler?: (event: {elementType: 'address'}) => any
67
+ ): StripeAddressElement;
68
+
69
+ /**
70
+ * Triggered when the escape key is pressed within the element.
71
+ */
72
+ on(
73
+ eventType: 'escape',
74
+ handler: (event: {elementType: 'address'}) => any
75
+ ): StripeAddressElement;
76
+ once(
77
+ eventType: 'escape',
78
+ handler: (event: {elementType: 'address'}) => any
79
+ ): StripeAddressElement;
80
+ off(
81
+ eventType: 'escape',
82
+ handler?: (event: {elementType: 'address'}) => any
83
+ ): StripeAddressElement;
84
+
85
+ /**
86
+ * Triggered when the element fails to load.
87
+ */
88
+ on(
89
+ eventType: 'loaderror',
90
+ handler: (event: {elementType: 'address'; error: StripeError}) => any
91
+ ): StripeAddressElement;
92
+ once(
93
+ eventType: 'loaderror',
94
+ handler: (event: {elementType: 'address'; error: StripeError}) => any
95
+ ): StripeAddressElement;
96
+ off(
97
+ eventType: 'loaderror',
98
+ handler?: (event: {elementType: 'address'; error: StripeError}) => any
99
+ ): StripeAddressElement;
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: 'address'}) => any
107
+ ): StripeAddressElement;
108
+ once(
109
+ eventType: 'loaderstart',
110
+ handler: (event: {elementType: 'address'}) => any
111
+ ): StripeAddressElement;
112
+ off(
113
+ eventType: 'loaderstart',
114
+ handler?: (event: {elementType: 'address'}) => any
115
+ ): StripeAddressElement;
116
+
117
+ /**
118
+ * Updates the options the `AddressElement` was initialized with.
119
+ * Updates are merged into the existing configuration.
120
+ */
121
+ update(options: Partial<StripeAddressElementOptions>): StripeAddressElement;
122
+ };
123
+
124
+ export interface ContactOption {
125
+ name: string;
126
+ phone?: string;
127
+ address: {
128
+ line1: string;
129
+ line2?: string;
130
+ city: string;
131
+ state: string;
132
+ postal_code: string;
133
+ country: string;
134
+ };
135
+ }
136
+
137
+ export type AddressMode = 'shipping' | 'billing';
138
+
139
+ export interface StripeAddressElementOptions {
140
+ /**
141
+ * Control which mode the AddressElement will be used for.
142
+ */
143
+ mode: AddressMode;
144
+
145
+ /**
146
+ * An array of two-letter ISO country codes representing which countries
147
+ * are displayed in the AddressElement.
148
+ */
149
+ allowedCountries?: string[] | null;
150
+
151
+ /**
152
+ * Control autocomplete settings in the AddressElement.
153
+ */
154
+ autocomplete?:
155
+ | {mode: 'automatic'}
156
+ | {mode: 'disabled'}
157
+ | {mode: 'google_maps_api'; apiKey: string};
158
+
159
+ /**
160
+ * Whether or not AddressElement accepts PO boxes
161
+ */
162
+ blockPoBox?: boolean;
163
+
164
+ /**
165
+ * An array of saved addresses.
166
+ */
167
+ contacts?: ContactOption[];
168
+
169
+ /**
170
+ * Default value for AddressElement fields
171
+ */
172
+ defaultValues?: {
173
+ name?: string | null;
174
+ address?: {
175
+ line1?: string | null;
176
+ line2?: string | null;
177
+ city?: string | null;
178
+ state?: string | null;
179
+ postal_code?: string | null;
180
+ country: string;
181
+ };
182
+ phone?: string | null;
183
+ };
184
+
185
+ /**
186
+ * Control which additional fields to display in the AddressElement.
187
+ */
188
+ fields?: {
189
+ phone?: 'always' | 'never' | 'auto';
190
+ };
191
+
192
+ /**
193
+ * Specify validation rules for the above additional fields.
194
+ */
195
+ validation?: {
196
+ phone?: {
197
+ required: 'always' | 'never' | 'auto';
198
+ };
199
+ };
200
+ }
201
+
202
+ export interface StripeAddressElementChangeEvent
203
+ extends StripeElementChangeEvent {
204
+ /**
205
+ * The type of element that emitted this event.
206
+ */
207
+ elementType: 'address';
208
+
209
+ /**
210
+ * The mode of the AddressElement that emitted this event.
211
+ */
212
+ elementMode: AddressMode;
213
+
214
+ /**
215
+ * Whether or not the AddressElement is currently empty.
216
+ */
217
+ empty: boolean;
218
+
219
+ /**
220
+ * Whether or not the AddressElement is complete.
221
+ */
222
+ complete: boolean;
223
+
224
+ /**
225
+ * Whether or not the address is new.
226
+ */
227
+ isNewAddress: boolean;
228
+
229
+ /**
230
+ * An object containing the current address.
231
+ */
232
+ value: {
233
+ name: string;
234
+ address: {
235
+ line1: string;
236
+ line2: string | null;
237
+ city: string;
238
+ state: string;
239
+ postal_code: string;
240
+ country: string;
241
+ };
242
+ phone?: string;
243
+ };
244
+ }
@@ -86,6 +86,22 @@ export type StripeCardNumberElement = StripeElementBase & {
86
86
  handler?: (event: {elementType: 'cardNumber'}) => any
87
87
  ): StripeCardNumberElement;
88
88
 
89
+ /**
90
+ * Triggered when there is a change to the available networks the provided card can run on.
91
+ */
92
+ on(
93
+ eventType: 'networkschange',
94
+ handler: (event: {elementType: 'cardNumber'}) => any
95
+ ): StripeCardNumberElement;
96
+ once(
97
+ eventType: 'networkschange',
98
+ handler: (event: {elementType: 'cardNumber'}) => any
99
+ ): StripeCardNumberElement;
100
+ off(
101
+ eventType: 'networkschange',
102
+ handler?: (event: {elementType: 'cardNumber'}) => any
103
+ ): StripeCardNumberElement;
104
+
89
105
  /**
90
106
  * Updates the options the `CardNumberElement` was initialized with.
91
107
  * Updates are merged into the existing configuration.
@@ -86,6 +86,22 @@ export type StripeCardElement = StripeElementBase & {
86
86
  handler?: (event: {elementType: 'card'}) => any
87
87
  ): StripeCardElement;
88
88
 
89
+ /**
90
+ * Triggered when there is a change to the available networks the provided card can run on.
91
+ */
92
+ on(
93
+ eventType: 'networkschange',
94
+ handler: (event: {elementType: 'card'}) => any
95
+ ): StripeCardElement;
96
+ once(
97
+ eventType: 'networkschange',
98
+ handler: (event: {elementType: 'card'}) => any
99
+ ): StripeCardElement;
100
+ off(
101
+ eventType: 'networkschange',
102
+ handler?: (event: {elementType: 'card'}) => any
103
+ ): StripeCardElement;
104
+
89
105
  /**
90
106
  * Updates the options the `CardElement` was initialized with.
91
107
  * Updates are merged into the existing configuration.
@@ -1,3 +1,4 @@
1
+ export * from './address';
1
2
  export * from './affirm-message';
2
3
  export * from './afterpay-clearpay-message';
3
4
  export * from './au-bank-account';
@@ -159,11 +159,6 @@ export interface StripeShippingAddressElementOptions {
159
159
  phone?: string | null;
160
160
  };
161
161
 
162
- /**
163
- * Whether or not ShippingAddressElement provides autocomplete suggestions
164
- */
165
- disableAutocomplete?: boolean;
166
-
167
162
  /**
168
163
  * Control which additional fields to display in the shippingAddress Element.
169
164
  */
@@ -199,7 +194,7 @@ export interface StripeShippingAddressElementChangeEvent
199
194
  complete: boolean;
200
195
 
201
196
  /**
202
- * Whether or not the the shipping address is new.
197
+ * Whether or not the shipping address is new.
203
198
  */
204
199
  isNewAddress: boolean;
205
200
 
@@ -1,4 +1,6 @@
1
1
  import {
2
+ StripeAddressElement,
3
+ StripeAddressElementOptions,
2
4
  StripeShippingAddressElement,
3
5
  StripeShippingAddressElementOptions,
4
6
  StripePaymentRequestButtonElement,
@@ -46,6 +48,29 @@ export interface StripeElements {
46
48
  */
47
49
  fetchUpdates(): Promise<{error?: {message: string; status?: string}}>;
48
50
 
51
+ /////////////////////////////
52
+ /// address
53
+ /////////////////////////////
54
+
55
+ /**
56
+ * Requires beta access:
57
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
58
+ *
59
+ * Creates a `AddressElement`.
60
+ */
61
+ create(
62
+ elementType: 'address',
63
+ options: StripeAddressElementOptions
64
+ ): StripeAddressElement;
65
+
66
+ /**
67
+ * Requires beta access:
68
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
69
+ *
70
+ * Looks up a previously created `Element` by its type.
71
+ */
72
+ getElement(elementType: 'address'): StripeAddressElement | null;
73
+
49
74
  /////////////////////////////
50
75
  /// affirmMessage
51
76
  /////////////////////////////
@@ -329,9 +354,13 @@ export interface StripeElements {
329
354
  elementType: 'paymentRequestButton'
330
355
  ): StripePaymentRequestButtonElement | null;
331
356
 
357
+ /////////////////////////////
358
+ /// shippingAddress
359
+ /////////////////////////////
360
+
332
361
  /**
333
- * Requires beta access:
334
- * Contact [Stripe support](https://support.stripe.com/) for more information.
362
+ * @deprecated
363
+ * Use `Address` element instead.
335
364
  *
336
365
  * Creates a `ShippingAddressElement`.
337
366
  */
@@ -341,8 +370,8 @@ export interface StripeElements {
341
370
  ): StripeShippingAddressElement;
342
371
 
343
372
  /**
344
- * Requires beta access:
345
- * Contact [Stripe support](https://support.stripe.com/) for more information.
373
+ * @deprecated
374
+ * Use `Address` element instead.
346
375
  *
347
376
  * Looks up a previously created `Element` by its type.
348
377
  */
@@ -352,6 +381,7 @@ export interface StripeElements {
352
381
  }
353
382
 
354
383
  export type StripeElementType =
384
+ | 'address'
355
385
  | 'affirmMessage'
356
386
  | 'afterpayClearpayMessage'
357
387
  | 'auBankAccount'
@@ -7,10 +7,9 @@ import * as elements from './elements';
7
7
  import * as financialConnections from './financial-connections';
8
8
 
9
9
  import {StripeElements, StripeElementsOptions} from './elements-group';
10
- import {RedirectToCheckoutOptions} from './checkout';
10
+ import {CheckoutLocale, RedirectToCheckoutOptions} from './checkout';
11
11
  import {PaymentRequestOptions, PaymentRequest} from './payment-request';
12
12
  import {StripeElement, StripeElementLocale} from './elements-group';
13
- import {CheckoutLocale} from './checkout';
14
13
 
15
14
  export interface Stripe {
16
15
  /////////////////////////////
@@ -508,6 +507,14 @@ export interface Stripe {
508
507
  data?: paymentIntents.VerifyMicrodepositsForPaymentData
509
508
  ): Promise<PaymentIntentResult>;
510
509
 
510
+ /**
511
+ * Use stripe.createRadarSession to create a [Radar Session](https://stripe.com/docs/radar/radar-session) in your checkout flow or when saving card details.
512
+ * A Radar Session is a snapshot of the browser metadata and device details that helps Radar make more accurate predictions on your payments.
513
+ * This metadata includes information like IP address, browser, screen or device information, and other device characteristics.
514
+ * By using Radar Sessions, you can capture critical fraud information without tokenizing on Stripe.
515
+ */
516
+ createRadarSession(): Promise<RadarSessionPayload>;
517
+
511
518
  /**
512
519
  * Use `stripe.collectBankAccountForPayment` in the [Accept a payment flow](https://stripe.com/docs/payments/ach-debit/accept-a-payment) for the [ACH Direct Debit](https://stripe.com/docs/payments/ach-debit)
513
520
  * payment method to collect the customer’s bank account in your payment form.
@@ -1044,7 +1051,7 @@ export type FinancialConnectionsSessionResult =
1044
1051
  export type CollectBankAccountTokenResult =
1045
1052
  | {
1046
1053
  financialConnectionsSession: api.FinancialConnectionsSession;
1047
- token: string;
1054
+ token: api.BankAccountToken;
1048
1055
  error?: undefined;
1049
1056
  }
1050
1057
  | {
@@ -1053,6 +1060,14 @@ export type CollectBankAccountTokenResult =
1053
1060
  error: StripeError;
1054
1061
  };
1055
1062
 
1063
+ /* A Radar Session is a snapshot of the browser metadata and device details that helps Radar make more accurate predictions on your payments.
1064
+ This metadata includes information like IP address, browser, screen or device information, and other device characteristics.
1065
+ You can find more details about how Radar uses this data by reading about how Radar performs [advanced fraud detection](https://stripe.com/docs/disputes/prevention/advanced-fraud-detection).
1066
+ */
1067
+ export type RadarSessionPayload =
1068
+ | {radarSession: Record<any, any>; error?: undefined}
1069
+ | {radarSession?: undefined; error: StripeError};
1070
+
1056
1071
  export interface WrapperLibrary {
1057
1072
  /**
1058
1073
  * Your library’s name, maximum length is 30