@stripe/stripe-js 1.36.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 +1 -1
- package/dist/pure.js +1 -1
- package/dist/stripe.esm.js +1 -1
- package/dist/stripe.js +1 -1
- package/package.json +1 -1
- package/types/stripe-js/elements/address.d.ts +244 -0
- package/types/stripe-js/elements/index.d.ts +1 -0
- package/types/stripe-js/elements/shipping-address.d.ts +1 -1
- package/types/stripe-js/elements-group.d.ts +34 -4
package/dist/pure.esm.js
CHANGED
package/dist/pure.js
CHANGED
package/dist/stripe.esm.js
CHANGED
package/dist/stripe.js
CHANGED
package/package.json
CHANGED
|
@@ -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
|
+
}
|
|
@@ -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
|
-
*
|
|
334
|
-
*
|
|
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
|
-
*
|
|
345
|
-
*
|
|
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'
|