@stripe/stripe-js 1.36.0 → 1.38.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.36.0",
57
+ version: "1.38.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.36.0",
61
+ version: "1.38.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.36.0",
41
+ version: "1.38.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.36.0",
45
+ version: "1.38.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.36.0",
3
+ "version": "1.38.0",
4
4
  "description": "Stripe.js loading utility",
5
5
  "main": "dist/stripe.js",
6
6
  "module": "dist/stripe.esm.js",
@@ -0,0 +1,255 @@
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
+ firstName?: string | null;
175
+ lastName?: string | null;
176
+ address?: {
177
+ line1?: string | null;
178
+ line2?: string | null;
179
+ city?: string | null;
180
+ state?: string | null;
181
+ postal_code?: string | null;
182
+ country: string;
183
+ };
184
+ phone?: string | null;
185
+ };
186
+
187
+ /**
188
+ * Control which additional fields to display in the AddressElement.
189
+ */
190
+ fields?: {
191
+ phone?: 'always' | 'never' | 'auto';
192
+ };
193
+
194
+ /**
195
+ * Specify validation rules for the above additional fields.
196
+ */
197
+ validation?: {
198
+ phone?: {
199
+ required: 'always' | 'never' | 'auto';
200
+ };
201
+ };
202
+
203
+ /**
204
+ * Specify display options in the AddressElement
205
+ */
206
+ display?: {
207
+ name?: 'full' | 'split' | 'organization';
208
+ };
209
+ }
210
+
211
+ export interface StripeAddressElementChangeEvent
212
+ extends StripeElementChangeEvent {
213
+ /**
214
+ * The type of element that emitted this event.
215
+ */
216
+ elementType: 'address';
217
+
218
+ /**
219
+ * The mode of the AddressElement that emitted this event.
220
+ */
221
+ elementMode: AddressMode;
222
+
223
+ /**
224
+ * Whether or not the AddressElement is currently empty.
225
+ */
226
+ empty: boolean;
227
+
228
+ /**
229
+ * Whether or not the AddressElement is complete.
230
+ */
231
+ complete: boolean;
232
+
233
+ /**
234
+ * Whether or not the address is new.
235
+ */
236
+ isNewAddress: boolean;
237
+
238
+ /**
239
+ * An object containing the current address.
240
+ */
241
+ value: {
242
+ name: string;
243
+ firstName?: string;
244
+ lastName?: string;
245
+ address: {
246
+ line1: string;
247
+ line2: string | null;
248
+ city: string;
249
+ state: string;
250
+ postal_code: string;
251
+ country: string;
252
+ };
253
+ phone?: string;
254
+ };
255
+ }
@@ -1,3 +1,5 @@
1
+ export * from './address';
2
+ export * from './payment-method-messaging';
1
3
  export * from './affirm-message';
2
4
  export * from './afterpay-clearpay-message';
3
5
  export * from './au-bank-account';
@@ -0,0 +1,93 @@
1
+ export type StripePaymentMethodMessagingElement = {
2
+ /**
3
+ * The `element.mount` method attaches your [Element](https://stripe.com/docs/js/element) to the DOM.
4
+ * `element.mount` accepts either a CSS Selector (e.g., `'#payment-method-messaging'`) or a DOM element.
5
+ */
6
+ mount(domElement: string | HTMLElement): void;
7
+
8
+ /**
9
+ * Removes the element from the DOM and destroys it.
10
+ * A destroyed element can not be re-activated or re-mounted to the DOM.
11
+ */
12
+ destroy(): void;
13
+
14
+ /**
15
+ * Unmounts the element from the DOM.
16
+ * Call `element.mount` to re-attach it to the DOM.
17
+ */
18
+ unmount(): void;
19
+
20
+ /**
21
+ * Updates the options the `PaymentMethodMessagingElement` was initialized with.
22
+ * Updates are merged into the existing configuration.
23
+ */
24
+ update(options: Partial<StripePaymentMethodMessagingElementOptions>): void;
25
+
26
+ /**
27
+ * Triggered when the element is fully loaded and ready to perform method calls.
28
+ */
29
+ on(
30
+ eventType: 'ready',
31
+ handler: (event: {elementType: 'paymentMethodMessaging'}) => any
32
+ ): StripePaymentMethodMessagingElement;
33
+ };
34
+
35
+ export interface StripePaymentMethodMessagingElementOptions {
36
+ /**
37
+ * The total amount in the smallest currency unit.
38
+ */
39
+ amount: number;
40
+
41
+ /**
42
+ * The currency to display.
43
+ */
44
+ currency:
45
+ | 'USD'
46
+ | 'GBP'
47
+ | 'EUR'
48
+ | 'DKK'
49
+ | 'NOK'
50
+ | 'SEK'
51
+ | 'AUD'
52
+ | 'CAD'
53
+ | 'NZD';
54
+
55
+ /**
56
+ * Payment methods to show messaging for.
57
+ */
58
+ paymentMethods: Array<'afterpay_clearpay' | 'klarna'>;
59
+
60
+ /**
61
+ * The country the end-buyer is in.
62
+ */
63
+ countryCode:
64
+ | 'US'
65
+ | 'CA'
66
+ | 'AU'
67
+ | 'NZ'
68
+ | 'GB'
69
+ | 'IE'
70
+ | 'FR'
71
+ | 'ES'
72
+ | 'DE'
73
+ | 'AT'
74
+ | 'BE'
75
+ | 'DK'
76
+ | 'FI'
77
+ | 'IT'
78
+ | 'NL'
79
+ | 'NO'
80
+ | 'SE';
81
+
82
+ /**
83
+ * The font color of the promotional message.
84
+ */
85
+ darkMode?: boolean;
86
+
87
+ /**
88
+ * The font size of the promotional message.
89
+ */
90
+ metaData?: {
91
+ messagingClientReferenceId: string | null;
92
+ };
93
+ }
@@ -194,7 +194,7 @@ export interface StripeShippingAddressElementChangeEvent
194
194
  complete: boolean;
195
195
 
196
196
  /**
197
- * Whether or not the the shipping address is new.
197
+ * Whether or not the shipping address is new.
198
198
  */
199
199
  isNewAddress: boolean;
200
200
 
@@ -1,4 +1,6 @@
1
1
  import {
2
+ StripeAddressElement,
3
+ StripeAddressElementOptions,
2
4
  StripeShippingAddressElement,
3
5
  StripeShippingAddressElementOptions,
4
6
  StripePaymentRequestButtonElement,
@@ -29,6 +31,8 @@ import {
29
31
  StripeAfterpayClearpayMessageElementOptions,
30
32
  StripeAffirmMessageElement,
31
33
  StripeAffirmMessageElementOptions,
34
+ StripePaymentMethodMessagingElementOptions,
35
+ StripePaymentMethodMessagingElement,
32
36
  StripeAfterpayClearpayMessageElement,
33
37
  StripeAuBankAccountElementOptions,
34
38
  } from './elements';
@@ -46,6 +50,48 @@ export interface StripeElements {
46
50
  */
47
51
  fetchUpdates(): Promise<{error?: {message: string; status?: string}}>;
48
52
 
53
+ /////////////////////////////
54
+ /// address
55
+ /////////////////////////////
56
+
57
+ /**
58
+ * Requires beta access:
59
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
60
+ *
61
+ * Creates a `AddressElement`.
62
+ */
63
+ create(
64
+ elementType: 'address',
65
+ options: StripeAddressElementOptions
66
+ ): StripeAddressElement;
67
+
68
+ /**
69
+ * Requires beta access:
70
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
71
+ *
72
+ * Looks up a previously created `Element` by its type.
73
+ */
74
+ getElement(elementType: 'address'): StripeAddressElement | null;
75
+
76
+ /////////////////////////////
77
+ /// paymentMethodMessaging
78
+ /////////////////////////////
79
+
80
+ /**
81
+ * Creates an `paymentMethodMessagingElement`.
82
+ */
83
+ create(
84
+ elementType: 'paymentMethodMessaging',
85
+ options: StripePaymentMethodMessagingElementOptions
86
+ ): StripePaymentMethodMessagingElement;
87
+
88
+ /**
89
+ * Looks up a previously created `Element` by its type.
90
+ */
91
+ getElement(
92
+ elementType: 'paymentMethodMessaging'
93
+ ): StripePaymentMethodMessagingElement | null;
94
+
49
95
  /////////////////////////////
50
96
  /// affirmMessage
51
97
  /////////////////////////////
@@ -329,9 +375,13 @@ export interface StripeElements {
329
375
  elementType: 'paymentRequestButton'
330
376
  ): StripePaymentRequestButtonElement | null;
331
377
 
378
+ /////////////////////////////
379
+ /// shippingAddress
380
+ /////////////////////////////
381
+
332
382
  /**
333
- * Requires beta access:
334
- * Contact [Stripe support](https://support.stripe.com/) for more information.
383
+ * @deprecated
384
+ * Use `Address` element instead.
335
385
  *
336
386
  * Creates a `ShippingAddressElement`.
337
387
  */
@@ -341,8 +391,8 @@ export interface StripeElements {
341
391
  ): StripeShippingAddressElement;
342
392
 
343
393
  /**
344
- * Requires beta access:
345
- * Contact [Stripe support](https://support.stripe.com/) for more information.
394
+ * @deprecated
395
+ * Use `Address` element instead.
346
396
  *
347
397
  * Looks up a previously created `Element` by its type.
348
398
  */
@@ -352,6 +402,7 @@ export interface StripeElements {
352
402
  }
353
403
 
354
404
  export type StripeElementType =
405
+ | 'address'
355
406
  | 'affirmMessage'
356
407
  | 'afterpayClearpayMessage'
357
408
  | 'auBankAccount'