@stripe/stripe-js 1.20.3 → 1.21.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.
Files changed (53) hide show
  1. package/dist/pure.esm.js +1 -1
  2. package/dist/pure.js +1 -1
  3. package/dist/stripe.esm.js +1 -1
  4. package/dist/stripe.js +1 -1
  5. package/package.json +5 -5
  6. package/src/shared.ts +1 -2
  7. package/types/api/bank-accounts.d.ts +61 -0
  8. package/types/api/cards.d.ts +130 -0
  9. package/types/api/index.d.ts +9 -9
  10. package/types/api/payment-intents.d.ts +330 -0
  11. package/types/api/payment-methods.d.ts +349 -0
  12. package/types/api/setup-intents.d.ts +184 -0
  13. package/types/api/shared.d.ts +124 -126
  14. package/types/api/sources.d.ts +1045 -0
  15. package/types/api/tokens.d.ts +634 -0
  16. package/types/api/verification-sessions.d.ts +9 -0
  17. package/types/index.d.ts +14 -12
  18. package/types/stripe-js/checkout.d.ts +134 -136
  19. package/types/stripe-js/elements/affirm-message.d.ts +59 -61
  20. package/types/stripe-js/elements/afterpay-clearpay-message.d.ts +118 -120
  21. package/types/stripe-js/elements/au-bank-account.d.ts +123 -120
  22. package/types/stripe-js/elements/base.d.ts +263 -263
  23. package/types/stripe-js/elements/card-cvc.d.ts +107 -103
  24. package/types/stripe-js/elements/card-expiry.d.ts +107 -104
  25. package/types/stripe-js/elements/card-number.d.ts +128 -125
  26. package/types/stripe-js/elements/card.d.ts +157 -154
  27. package/types/stripe-js/elements/eps-bank.d.ts +125 -121
  28. package/types/stripe-js/elements/fpx-bank.d.ts +120 -116
  29. package/types/stripe-js/elements/iban.d.ts +134 -131
  30. package/types/stripe-js/elements/ideal-bank.d.ts +125 -121
  31. package/types/stripe-js/elements/index.d.ts +17 -0
  32. package/types/stripe-js/elements/link-authentication.d.ts +92 -94
  33. package/types/stripe-js/elements/p24-bank.d.ts +125 -121
  34. package/types/stripe-js/elements/payment-request-button.d.ts +127 -127
  35. package/types/stripe-js/elements/payment.d.ts +190 -180
  36. package/types/stripe-js/elements/shipping-address.d.ts +123 -125
  37. package/types/stripe-js/elements-group.d.ts +617 -0
  38. package/types/stripe-js/index.d.ts +7 -1069
  39. package/types/stripe-js/payment-intents.d.ts +951 -919
  40. package/types/stripe-js/payment-request.d.ts +503 -503
  41. package/types/stripe-js/setup-intents.d.ts +149 -135
  42. package/types/stripe-js/stripe.d.ts +1070 -0
  43. package/types/stripe-js/token-and-sources.d.ts +80 -80
  44. package/types/utils.d.ts +2 -0
  45. package/types/api/BankAccounts.d.ts +0 -63
  46. package/types/api/Cards.d.ts +0 -130
  47. package/types/api/PaymentIntents.d.ts +0 -329
  48. package/types/api/PaymentMethods.d.ts +0 -349
  49. package/types/api/SetupIntents.d.ts +0 -184
  50. package/types/api/Sources.d.ts +0 -1045
  51. package/types/api/Tokens.d.ts +0 -632
  52. package/types/api/VerificationSessions.d.ts +0 -11
  53. package/types/stripe-js/elements.d.ts +0 -604
@@ -1,504 +1,504 @@
1
- declare module '@stripe/stripe-js' {
2
- interface PaymentRequest {
3
- /**
4
- * Returns a `Promise` that resolves with a truthy value if an enabled wallet is ready to pay.
5
- * If no wallet is available, it resolves with `null`.
6
- */
7
- canMakePayment(): Promise<CanMakePaymentResult | null>;
8
-
9
- /**
10
- * Shows the browser’s payment interface.
11
- * When using the `PaymentRequestButtonElement`, this is called for you automatically.
12
- * This method must be called as the result of a user interaction (for example, in a click handler).
13
- */
14
- show(): void;
15
-
16
- /**
17
- * `true` if the browser’s payment interface is showing.
18
- * When using the `PaymentRequestButtonElement`, this is called for you automatically.
19
- */
20
- isShowing: () => boolean;
21
-
22
- /**
23
- * `PaymentRequest` instances can be updated with an options object.
24
- *
25
- * `paymentRequest.update` can only be called when the browser payment interface is not showing.
26
- * Listen to the [click](https://stripe.com/docs/js/element/events) and [cancel](https://stripe.com/docs/js/element/events) events to detect if the payment interface has been initiated.
27
- * To update the `PaymentRequest` right before the payment interface is initiated, call `paymentRequest.update` in your click event handler.
28
- */
29
- update(options: PaymentRequestUpdateOptions): void;
30
-
31
- /**
32
- * Stripe.js automatically creates a `Token` after the customer is done interacting with the browser’s payment interface.
33
- * To access the created `Token`, listen for this event.
34
- */
35
- on(
36
- eventType: 'token',
37
- handler: (event: PaymentRequestTokenEvent) => any
38
- ): this;
39
- once(
40
- eventType: 'token',
41
- handler: (event: PaymentRequestTokenEvent) => any
42
- ): this;
43
- off(
44
- eventType: 'token',
45
- handler?: (event: PaymentRequestTokenEvent) => any
46
- ): this;
47
-
48
- /**
49
- * Stripe.js automatically creates a `PaymentMethod` after the customer is done interacting with the browser’s payment interface.
50
- * To access the created `PaymentMethod`, listen for this event.
51
- */
52
- on(
53
- eventType: 'paymentmethod',
54
- handler: (event: PaymentRequestPaymentMethodEvent) => any
55
- ): this;
56
- once(
57
- eventType: 'paymentmethod',
58
- handler: (event: PaymentRequestPaymentMethodEvent) => any
59
- ): this;
60
- off(
61
- eventType: 'paymentmethod',
62
- handler?: (event: PaymentRequestPaymentMethodEvent) => any
63
- ): this;
64
-
65
- /**
66
- * Stripe.js automatically creates a `Source` after the customer is done interacting with the browser’s payment interface.
67
- * To access the created `Source`, listen for this event.
68
- */
69
- on(
70
- eventType: 'source',
71
- handler: (event: PaymentRequestSourceEvent) => any
72
- ): this;
73
- once(
74
- eventType: 'source',
75
- handler: (event: PaymentRequestSourceEvent) => any
76
- ): this;
77
- off(
78
- eventType: 'source',
79
- handler?: (event: PaymentRequestSourceEvent) => any
80
- ): this;
81
-
82
- /**
83
- * The cancel event is emitted from a `PaymentRequest` when the browser's payment interface is dismissed.
84
- *
85
- * Note that in some browsers, the payment interface may be dismissed by the customer even after they authorize the payment.
86
- * This means that you may receive a cancel event on your `PaymentRequest` object after receiving a `token`, `paymentmethod`, or `source` event.
87
- * If you’re using the cancel event as a hook for canceling the customer’s order, make sure you also refund the payment that you just created.
88
- */
89
- on(eventType: 'cancel', handler: () => any): this;
90
- once(eventType: 'cancel', handler: () => any): this;
91
- off(eventType: 'cancel', handler?: () => any): this;
92
-
93
- /**
94
- * The `shippingaddresschange` event is emitted from a `PaymentRequest` whenever the customer selects a new address in the browser's payment interface.
95
- */
96
- on(
97
- eventType: 'shippingaddresschange',
98
- handler: (event: PaymentRequestShippingAddressEvent) => any
99
- ): this;
100
- once(
101
- eventType: 'shippingaddresschange',
102
- handler: (event: PaymentRequestShippingAddressEvent) => any
103
- ): this;
104
- off(
105
- eventType: 'shippingaddresschange',
106
- handler?: (event: PaymentRequestShippingAddressEvent) => any
107
- ): this;
108
-
109
- /**
110
- * The `shippingoptionchange` event is emitted from a `PaymentRequest` whenever the customer selects a new shipping option in the browser's payment interface.
111
- */
112
- on(
113
- eventType: 'shippingoptionchange',
114
- handler: (event: PaymentRequestShippingOptionEvent) => any
115
- ): this;
116
- once(
117
- eventType: 'shippingoptionchange',
118
- handler: (event: PaymentRequestShippingOptionEvent) => any
119
- ): this;
120
- off(
121
- eventType: 'shippingoptionchange',
122
- handler?: (event: PaymentRequestShippingOptionEvent) => any
123
- ): this;
124
- }
125
-
126
- type CanMakePaymentResult = Record<string, boolean>;
127
-
128
- interface PaymentRequestUpdateOptions {
129
- /**
130
- * Three character currency code (e.g., `usd`).
131
- */
132
- currency?: string;
133
-
134
- /**
135
- * This `PaymentRequestItem` is shown to the customer in the browser’s payment interface.
136
- */
137
- total?: PaymentRequestItem;
138
-
139
- /**
140
- * An array of PaymentRequestItem objects.
141
- * These objects are shown as line items in the browser’s payment interface.
142
- * Note that the sum of the line item amounts does not need to add up to the `total` amount above.
143
- */
144
- displayItems?: PaymentRequestItem[];
145
- /**
146
- * An array of `ShippingOption` objects.
147
- * The first shipping option listed appears in the browser payment interface as the default option.
148
- */
149
-
150
- shippingOptions?: PaymentRequestShippingOption[];
151
- }
152
-
153
- /**
154
- * An set of options to create this `PaymentRequest` instance with.
155
- * These options can be updated using `paymentRequest.update`.
156
- */
157
- interface PaymentRequestOptions {
158
- /**
159
- * The two-letter country code of your Stripe account (e.g., `US`).
160
- */
161
- country: string;
162
-
163
- /**
164
- * Three character currency code (e.g., `usd`).
165
- */
166
- currency: string;
167
-
168
- /**
169
- * This `PaymentRequestItem` is shown to the customer in the browser’s payment interface.
170
- */
171
- total: PaymentRequestItem;
172
-
173
- /**
174
- * An array of PaymentRequestItem objects.
175
- * These objects are shown as line items in the browser’s payment interface.
176
- * Note that the sum of the line item amounts does not need to add up to the `total` amount above.
177
- */
178
- displayItems?: PaymentRequestItem[];
179
-
180
- /**
181
- * By default, the browser's payment interface only asks the customer for actual payment information.
182
- * A customer name can be collected by setting this option to `true`.
183
- * This collected name will appears in the `PaymentRequestEvent` object.
184
- *
185
- * We highly recommend you collect at least one of name, email, or phone as this also results in collection of billing address for Apple Pay.
186
- * The billing address can be used to perform address verification and block fraudulent payments.
187
- * For all other payment methods, the billing address is automatically collected when available.
188
- */
189
- requestPayerName?: boolean;
190
-
191
- /**
192
- * See the `requestPayerName` option.
193
- */
194
- requestPayerPhone?: boolean;
195
-
196
- /**
197
- * See the `requestPayerName` option.
198
- */
199
- requestPayerEmail?: boolean;
200
-
201
- /**
202
- * Collect shipping address by setting this option to `true`.
203
- * The address appears in the `PaymentRequestEvent`.
204
- *
205
- * You must also supply a valid `PaymentRequestShippingOption` to the `shippingOptions` property.
206
- * This can be up front at the time `stripe.paymentRequest` is called, or in response to a `shippingaddresschange` event using the `updateWith` callback.
207
- */
208
- requestShipping?: boolean;
209
-
210
- /**
211
- * An array of `ShippingOption` objects.
212
- * The first shipping option listed appears in the browser payment interface as the default option.
213
- */
214
- shippingOptions?: PaymentRequestShippingOption[];
215
-
216
- /**
217
- * An array of wallet strings.
218
- * Can be one or more of `applePay`, `googlePay` and `browserCard`.
219
- * Use this option to disable Google Pay, Apple Pay and/or browser-saved cards.
220
- */
221
- disableWallets?: PaymentRequestWallet[];
222
-
223
- /**
224
- * @deprecated
225
- * Use disableWallets instead.
226
- */
227
- wallets?: PaymentRequestWallet[];
228
- }
229
-
230
- /**
231
- * A `PaymentRequestItem` object is used to configure a `PaymentRequest`.
232
- */
233
- interface PaymentRequestItem {
234
- /**
235
- * The amount in the currency's subunit (e.g. cents, yen, etc.)
236
- */
237
- amount: number;
238
-
239
- /**
240
- * A name that the browser shows the customer in the payment interface.
241
- */
242
- label: string;
243
-
244
- /**
245
- * If you might change this amount later (for example, after you have calcluated shipping costs), set this to `true`.
246
- * Note that browsers treat this as a hint for how to display things, and not necessarily as something that will prevent submission.
247
- */
248
- pending?: boolean;
249
- }
250
-
251
- /**
252
- * The `ShippingOption` object describes a shipping method used with a `PaymentRequest`.
253
- */
254
- interface PaymentRequestShippingOption {
255
- /**
256
- * A unique ID you create to keep track of this shipping option.
257
- * You’ll be told the ID of the selected option on changes and on completion.
258
- */
259
- id: string;
260
-
261
- /**
262
- * A short label for this shipping option.
263
- */
264
- label: string;
265
-
266
- /**
267
- * A longer description of this shipping option.
268
- */
269
- detail: string;
270
-
271
- /**
272
- * The amount to show for this shipping option.
273
- * If the cost of this shipping option depends on the shipping address the customer enters, listen for the `shippingaddresschange` event.
274
- */
275
- amount: number;
276
- }
277
-
278
- type PaymentRequestWallet = 'applePay' | 'googlePay' | 'browserCard';
279
-
280
- type PaymentRequestCompleteStatus =
281
- /**
282
- * Report to the browser that the payment was successful, and that it can close any active payment interface.
283
- */
284
- | 'success'
285
-
286
- /**
287
- * Report to the browser that you were unable to process the customer‘s payment.
288
- * Browsers may re-show the payment interface, or simply show a message and close.
289
- */
290
- | 'fail'
291
-
292
- /**
293
- * Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
294
- */
295
- | 'invalid_payer_name'
296
-
297
- /**
298
- * Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
299
- */
300
- | 'invalid_payer_phone'
301
-
302
- /**
303
- * Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
304
- */
305
- | 'invalid_payer_email'
306
-
307
- /**
308
- * Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
309
- */
310
- | 'invalid_shipping_address';
311
-
312
- interface PaymentRequestEvent {
313
- /**
314
- * Call this function with a `CompleteStatus` when you have processed the token data provided by the API.
315
- * Note that you must must call complete within 30 seconds.
316
- */
317
- complete: (status: PaymentRequestCompleteStatus) => void;
318
-
319
- /**
320
- * The customer's name.
321
- * Only present if it was explicitly asked for [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create).
322
- */
323
- payerName?: string;
324
-
325
- /**
326
- * The customer's email.
327
- * Only present if it was explicitly asked for [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create).
328
- */
329
- payerEmail?: string;
330
-
331
- /**
332
- * The customer's phone.
333
- * Only present if it was explicitly asked for [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create).
334
- */
335
- payerPhone?: string;
336
-
337
- /**
338
- * The final `ShippingAddress` the customer selected.
339
- * Only present when `requestShipping` is `true` when [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create), and you've supplied at least one `ShippingOption`.
340
- */
341
- shippingAddress?: PaymentRequestShippingAddress;
342
-
343
- /**
344
- * The final `ShippingOption` the customer selected.
345
- * Only present when `requestShipping` is `true` when [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create), and you've supplied at least one `ShippingOption`.
346
- */
347
- shippingOption?: PaymentRequestShippingOption;
348
-
349
- /**
350
- * The unique name of the wallet the customer chose to authorize payment.
351
- * For example, `browserCard`.
352
- */
353
- walletName: PaymentRequestWallet | string;
354
-
355
- /**
356
- * @deprecated
357
- * Use walletName instead.
358
- */
359
- methodName: string;
360
- }
361
-
362
- /**
363
- * Describes a shipping address collected with a `PaymentRequest`.
364
- */
365
- interface PaymentRequestShippingAddress {
366
- /**
367
- * Two-letter country code, capitalized.
368
- * Valid two-letter country codes are specified by ISO3166 alpha-2.
369
- */
370
- country?: string;
371
-
372
- /**
373
- * An array of address line items.
374
- * For example, `185 Berry St.`, `Suite 500`, `P.O. Box 12345`, etc.
375
- */
376
- addressLine?: string[];
377
-
378
- /**
379
- * The most coarse subdivision of a country.
380
- * Depending on the country, this might correspond to a state, a province, an oblast, a prefecture, or something else along these lines.
381
- */
382
- region?: string;
383
-
384
- /**
385
- * The name of a city, town, village, etc.
386
- */
387
- city?: string;
388
-
389
- /**
390
- * The postal code or ZIP code, also known as PIN code in India.
391
- */
392
- postalCode?: string;
393
-
394
- /**
395
- * The name of the recipient.
396
- * This might be a person, a business name, or contain “care of (c/o) instructions.
397
- */
398
- recipient?: string;
399
-
400
- /**
401
- * The phone number of the recipient.
402
- * Note that this might be different from any phone number you collect with `requestPayerPhone`.
403
- */
404
- phone?: string;
405
-
406
- /**
407
- * The sorting code as used in, for example, France.
408
- * Not present on Apple platforms.
409
- */
410
- sortingCode?: string;
411
-
412
- /**
413
- * A logical subdivision of a city.
414
- * Can be used for things like neighborhoods, boroughs, districts, or UK dependent localities.
415
- * Not present on Apple platforms.
416
- */
417
- dependentLocality?: string;
418
- }
419
-
420
- interface PaymentRequestTokenEvent extends PaymentRequestEvent {
421
- token: Token;
422
- }
423
-
424
- interface PaymentRequestPaymentMethodEvent extends PaymentRequestEvent {
425
- paymentMethod: PaymentMethod;
426
- }
427
-
428
- interface PaymentRequestSourceEvent extends PaymentRequestEvent {
429
- source: Source;
430
- }
431
-
432
- interface PaymentRequestShippingAddressEvent {
433
- /**
434
- * Call this with an `UpdateDetails` object to merge updates into the current `PaymentRequest` object.
435
- * Note that if you subscribe to `shippingaddresschange` events, then you must call `updateWith` within 30 seconds.
436
- */
437
- updateWith: (details: PaymentRequestUpdateDetails) => void;
438
-
439
- /**
440
- * The customer's selected `ShippingAddress`.
441
- * To maintain privacy, browsers may anonymize the shipping address by removing sensitive information that is not necessary to calculate shipping costs.
442
- * Depending on the country, some fields can be missing or partially redacted.
443
- * For example, the shipping address in the U.S. may only contain a city, state, and ZIP code.
444
- * The full shipping address appears in the `PaymentRequestEvent` object after the purchase is confirmed in the browser’s payment interface
445
- */
446
- shippingAddress: PaymentRequestShippingAddress;
447
- }
448
-
449
- type PaymentRequestUpdateDetailsStatus =
450
- /**
451
- * Let the customer proceed.
452
- */
453
- | 'success'
454
-
455
- /**
456
- * Prevent the customer from making the change they just made.
457
- */
458
- | 'fail'
459
-
460
- /**
461
- * Equivalent to `fail`, except we show a more specific error message.
462
- * Can only be used in a `shippingaddresschange` handler.
463
- */
464
- | 'invalid_shipping_address';
465
-
466
- /**
467
- * An object to pass to the `updateWith` callback on `shippingaddresschange` and `shippingoptionchange` events.
468
- */
469
- interface PaymentRequestUpdateDetails {
470
- /**
471
- * The browser uses this value to show an error message to the customer if they've taken an action that invalidates the payment request.
472
- */
473
- status?: PaymentRequestUpdateDetailsStatus;
474
-
475
- /**
476
- * The new total amount, if applicable.
477
- */
478
- total?: PaymentRequestItem;
479
-
480
- /**
481
- * These `PaymentRequestItem`s are shown as line items in the browser's payment interface.
482
- * Note that the sum of the line item amounts does not need to add up to the `total` amount.
483
- */
484
- displayItems?: PaymentRequestItem[];
485
-
486
- /**
487
- * The first shipping option listed appears in the browser payment interface as the default option.
488
- */
489
- shippingOptions?: PaymentRequestShippingOption[];
490
- }
491
-
492
- interface PaymentRequestShippingOptionEvent {
493
- /**
494
- * Call this with an `UpdateDetails` object to merge updates into the current `PaymentRequest` object.
495
- * Note that if you subscribe to `shippingaddresschange` events, then you must call `updateWith` within 30 seconds.
496
- */
497
- updateWith: (details: PaymentRequestUpdateDetails) => void;
498
-
499
- /**
500
- * The customer's selected `ShippingOption`.
501
- */
502
- shippingOption: PaymentRequestShippingOption;
503
- }
1
+ import {Token, PaymentMethod, Source} from '../api';
2
+
3
+ export interface PaymentRequest {
4
+ /**
5
+ * Returns a `Promise` that resolves with a truthy value if an enabled wallet is ready to pay.
6
+ * If no wallet is available, it resolves with `null`.
7
+ */
8
+ canMakePayment(): Promise<CanMakePaymentResult | null>;
9
+
10
+ /**
11
+ * Shows the browser’s payment interface.
12
+ * When using the `PaymentRequestButtonElement`, this is called for you automatically.
13
+ * This method must be called as the result of a user interaction (for example, in a click handler).
14
+ */
15
+ show(): void;
16
+
17
+ /**
18
+ * `true` if the browser’s payment interface is showing.
19
+ * When using the `PaymentRequestButtonElement`, this is called for you automatically.
20
+ */
21
+ isShowing: () => boolean;
22
+
23
+ /**
24
+ * `PaymentRequest` instances can be updated with an options object.
25
+ *
26
+ * `paymentRequest.update` can only be called when the browser payment interface is not showing.
27
+ * Listen to the [click](https://stripe.com/docs/js/element/events) and [cancel](https://stripe.com/docs/js/element/events) events to detect if the payment interface has been initiated.
28
+ * To update the `PaymentRequest` right before the payment interface is initiated, call `paymentRequest.update` in your click event handler.
29
+ */
30
+ update(options: PaymentRequestUpdateOptions): void;
31
+
32
+ /**
33
+ * Stripe.js automatically creates a `Token` after the customer is done interacting with the browser’s payment interface.
34
+ * To access the created `Token`, listen for this event.
35
+ */
36
+ on(
37
+ eventType: 'token',
38
+ handler: (event: PaymentRequestTokenEvent) => any
39
+ ): this;
40
+ once(
41
+ eventType: 'token',
42
+ handler: (event: PaymentRequestTokenEvent) => any
43
+ ): this;
44
+ off(
45
+ eventType: 'token',
46
+ handler?: (event: PaymentRequestTokenEvent) => any
47
+ ): this;
48
+
49
+ /**
50
+ * Stripe.js automatically creates a `PaymentMethod` after the customer is done interacting with the browser’s payment interface.
51
+ * To access the created `PaymentMethod`, listen for this event.
52
+ */
53
+ on(
54
+ eventType: 'paymentmethod',
55
+ handler: (event: PaymentRequestPaymentMethodEvent) => any
56
+ ): this;
57
+ once(
58
+ eventType: 'paymentmethod',
59
+ handler: (event: PaymentRequestPaymentMethodEvent) => any
60
+ ): this;
61
+ off(
62
+ eventType: 'paymentmethod',
63
+ handler?: (event: PaymentRequestPaymentMethodEvent) => any
64
+ ): this;
65
+
66
+ /**
67
+ * Stripe.js automatically creates a `Source` after the customer is done interacting with the browser’s payment interface.
68
+ * To access the created `Source`, listen for this event.
69
+ */
70
+ on(
71
+ eventType: 'source',
72
+ handler: (event: PaymentRequestSourceEvent) => any
73
+ ): this;
74
+ once(
75
+ eventType: 'source',
76
+ handler: (event: PaymentRequestSourceEvent) => any
77
+ ): this;
78
+ off(
79
+ eventType: 'source',
80
+ handler?: (event: PaymentRequestSourceEvent) => any
81
+ ): this;
82
+
83
+ /**
84
+ * The cancel event is emitted from a `PaymentRequest` when the browser's payment interface is dismissed.
85
+ *
86
+ * Note that in some browsers, the payment interface may be dismissed by the customer even after they authorize the payment.
87
+ * This means that you may receive a cancel event on your `PaymentRequest` object after receiving a `token`, `paymentmethod`, or `source` event.
88
+ * If you’re using the cancel event as a hook for canceling the customer’s order, make sure you also refund the payment that you just created.
89
+ */
90
+ on(eventType: 'cancel', handler: () => any): this;
91
+ once(eventType: 'cancel', handler: () => any): this;
92
+ off(eventType: 'cancel', handler?: () => any): this;
93
+
94
+ /**
95
+ * The `shippingaddresschange` event is emitted from a `PaymentRequest` whenever the customer selects a new address in the browser's payment interface.
96
+ */
97
+ on(
98
+ eventType: 'shippingaddresschange',
99
+ handler: (event: PaymentRequestShippingAddressEvent) => any
100
+ ): this;
101
+ once(
102
+ eventType: 'shippingaddresschange',
103
+ handler: (event: PaymentRequestShippingAddressEvent) => any
104
+ ): this;
105
+ off(
106
+ eventType: 'shippingaddresschange',
107
+ handler?: (event: PaymentRequestShippingAddressEvent) => any
108
+ ): this;
109
+
110
+ /**
111
+ * The `shippingoptionchange` event is emitted from a `PaymentRequest` whenever the customer selects a new shipping option in the browser's payment interface.
112
+ */
113
+ on(
114
+ eventType: 'shippingoptionchange',
115
+ handler: (event: PaymentRequestShippingOptionEvent) => any
116
+ ): this;
117
+ once(
118
+ eventType: 'shippingoptionchange',
119
+ handler: (event: PaymentRequestShippingOptionEvent) => any
120
+ ): this;
121
+ off(
122
+ eventType: 'shippingoptionchange',
123
+ handler?: (event: PaymentRequestShippingOptionEvent) => any
124
+ ): this;
125
+ }
126
+
127
+ export type CanMakePaymentResult = Record<string, boolean>;
128
+
129
+ export interface PaymentRequestUpdateOptions {
130
+ /**
131
+ * Three character currency code (e.g., `usd`).
132
+ */
133
+ currency?: string;
134
+
135
+ /**
136
+ * This `PaymentRequestItem` is shown to the customer in the browser’s payment interface.
137
+ */
138
+ total?: PaymentRequestItem;
139
+
140
+ /**
141
+ * An array of PaymentRequestItem objects.
142
+ * These objects are shown as line items in the browser’s payment interface.
143
+ * Note that the sum of the line item amounts does not need to add up to the `total` amount above.
144
+ */
145
+ displayItems?: PaymentRequestItem[];
146
+ /**
147
+ * An array of `ShippingOption` objects.
148
+ * The first shipping option listed appears in the browser payment interface as the default option.
149
+ */
150
+
151
+ shippingOptions?: PaymentRequestShippingOption[];
152
+ }
153
+
154
+ /**
155
+ * An set of options to create this `PaymentRequest` instance with.
156
+ * These options can be updated using `paymentRequest.update`.
157
+ */
158
+ export interface PaymentRequestOptions {
159
+ /**
160
+ * The two-letter country code of your Stripe account (e.g., `US`).
161
+ */
162
+ country: string;
163
+
164
+ /**
165
+ * Three character currency code (e.g., `usd`).
166
+ */
167
+ currency: string;
168
+
169
+ /**
170
+ * This `PaymentRequestItem` is shown to the customer in the browser’s payment interface.
171
+ */
172
+ total: PaymentRequestItem;
173
+
174
+ /**
175
+ * An array of PaymentRequestItem objects.
176
+ * These objects are shown as line items in the browser’s payment interface.
177
+ * Note that the sum of the line item amounts does not need to add up to the `total` amount above.
178
+ */
179
+ displayItems?: PaymentRequestItem[];
180
+
181
+ /**
182
+ * By default, the browser's payment interface only asks the customer for actual payment information.
183
+ * A customer name can be collected by setting this option to `true`.
184
+ * This collected name will appears in the `PaymentRequestEvent` object.
185
+ *
186
+ * We highly recommend you collect at least one of name, email, or phone as this also results in collection of billing address for Apple Pay.
187
+ * The billing address can be used to perform address verification and block fraudulent payments.
188
+ * For all other payment methods, the billing address is automatically collected when available.
189
+ */
190
+ requestPayerName?: boolean;
191
+
192
+ /**
193
+ * See the `requestPayerName` option.
194
+ */
195
+ requestPayerPhone?: boolean;
196
+
197
+ /**
198
+ * See the `requestPayerName` option.
199
+ */
200
+ requestPayerEmail?: boolean;
201
+
202
+ /**
203
+ * Collect shipping address by setting this option to `true`.
204
+ * The address appears in the `PaymentRequestEvent`.
205
+ *
206
+ * You must also supply a valid `PaymentRequestShippingOption` to the `shippingOptions` property.
207
+ * This can be up front at the time `stripe.paymentRequest` is called, or in response to a `shippingaddresschange` event using the `updateWith` callback.
208
+ */
209
+ requestShipping?: boolean;
210
+
211
+ /**
212
+ * An array of `ShippingOption` objects.
213
+ * The first shipping option listed appears in the browser payment interface as the default option.
214
+ */
215
+ shippingOptions?: PaymentRequestShippingOption[];
216
+
217
+ /**
218
+ * An array of wallet strings.
219
+ * Can be one or more of `applePay`, `googlePay` and `browserCard`.
220
+ * Use this option to disable Google Pay, Apple Pay and/or browser-saved cards.
221
+ */
222
+ disableWallets?: PaymentRequestWallet[];
223
+
224
+ /**
225
+ * @deprecated
226
+ * Use disableWallets instead.
227
+ */
228
+ wallets?: PaymentRequestWallet[];
229
+ }
230
+
231
+ /**
232
+ * A `PaymentRequestItem` object is used to configure a `PaymentRequest`.
233
+ */
234
+ export interface PaymentRequestItem {
235
+ /**
236
+ * The amount in the currency's subunit (e.g. cents, yen, etc.)
237
+ */
238
+ amount: number;
239
+
240
+ /**
241
+ * A name that the browser shows the customer in the payment interface.
242
+ */
243
+ label: string;
244
+
245
+ /**
246
+ * If you might change this amount later (for example, after you have calcluated shipping costs), set this to `true`.
247
+ * Note that browsers treat this as a hint for how to display things, and not necessarily as something that will prevent submission.
248
+ */
249
+ pending?: boolean;
250
+ }
251
+
252
+ /**
253
+ * The `ShippingOption` object describes a shipping method used with a `PaymentRequest`.
254
+ */
255
+ export interface PaymentRequestShippingOption {
256
+ /**
257
+ * A unique ID you create to keep track of this shipping option.
258
+ * You’ll be told the ID of the selected option on changes and on completion.
259
+ */
260
+ id: string;
261
+
262
+ /**
263
+ * A short label for this shipping option.
264
+ */
265
+ label: string;
266
+
267
+ /**
268
+ * A longer description of this shipping option.
269
+ */
270
+ detail: string;
271
+
272
+ /**
273
+ * The amount to show for this shipping option.
274
+ * If the cost of this shipping option depends on the shipping address the customer enters, listen for the `shippingaddresschange` event.
275
+ */
276
+ amount: number;
277
+ }
278
+
279
+ export type PaymentRequestWallet = 'applePay' | 'googlePay' | 'browserCard';
280
+
281
+ export type PaymentRequestCompleteStatus =
282
+ /**
283
+ * Report to the browser that the payment was successful, and that it can close any active payment interface.
284
+ */
285
+ | 'success'
286
+
287
+ /**
288
+ * Report to the browser that you were unable to process the customer‘s payment.
289
+ * Browsers may re-show the payment interface, or simply show a message and close.
290
+ */
291
+ | 'fail'
292
+
293
+ /**
294
+ * Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
295
+ */
296
+ | 'invalid_payer_name'
297
+
298
+ /**
299
+ * Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
300
+ */
301
+ | 'invalid_payer_phone'
302
+
303
+ /**
304
+ * Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
305
+ */
306
+ | 'invalid_payer_email'
307
+
308
+ /**
309
+ * Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
310
+ */
311
+ | 'invalid_shipping_address';
312
+
313
+ export interface PaymentRequestEvent {
314
+ /**
315
+ * Call this function with a `CompleteStatus` when you have processed the token data provided by the API.
316
+ * Note that you must must call complete within 30 seconds.
317
+ */
318
+ complete: (status: PaymentRequestCompleteStatus) => void;
319
+
320
+ /**
321
+ * The customer's name.
322
+ * Only present if it was explicitly asked for [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create).
323
+ */
324
+ payerName?: string;
325
+
326
+ /**
327
+ * The customer's email.
328
+ * Only present if it was explicitly asked for [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create).
329
+ */
330
+ payerEmail?: string;
331
+
332
+ /**
333
+ * The customer's phone.
334
+ * Only present if it was explicitly asked for [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create).
335
+ */
336
+ payerPhone?: string;
337
+
338
+ /**
339
+ * The final `ShippingAddress` the customer selected.
340
+ * Only present when `requestShipping` is `true` when [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create), and you've supplied at least one `ShippingOption`.
341
+ */
342
+ shippingAddress?: PaymentRequestShippingAddress;
343
+
344
+ /**
345
+ * The final `ShippingOption` the customer selected.
346
+ * Only present when `requestShipping` is `true` when [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create), and you've supplied at least one `ShippingOption`.
347
+ */
348
+ shippingOption?: PaymentRequestShippingOption;
349
+
350
+ /**
351
+ * The unique name of the wallet the customer chose to authorize payment.
352
+ * For example, `browserCard`.
353
+ */
354
+ walletName: PaymentRequestWallet | string;
355
+
356
+ /**
357
+ * @deprecated
358
+ * Use walletName instead.
359
+ */
360
+ methodName: string;
361
+ }
362
+
363
+ /**
364
+ * Describes a shipping address collected with a `PaymentRequest`.
365
+ */
366
+ export interface PaymentRequestShippingAddress {
367
+ /**
368
+ * Two-letter country code, capitalized.
369
+ * Valid two-letter country codes are specified by ISO3166 alpha-2.
370
+ */
371
+ country?: string;
372
+
373
+ /**
374
+ * An array of address line items.
375
+ * For example, `185 Berry St.`, `Suite 500`, `P.O. Box 12345`, etc.
376
+ */
377
+ addressLine?: string[];
378
+
379
+ /**
380
+ * The most coarse subdivision of a country.
381
+ * Depending on the country, this might correspond to a state, a province, an oblast, a prefecture, or something else along these lines.
382
+ */
383
+ region?: string;
384
+
385
+ /**
386
+ * The name of a city, town, village, etc.
387
+ */
388
+ city?: string;
389
+
390
+ /**
391
+ * The postal code or ZIP code, also known as PIN code in India.
392
+ */
393
+ postalCode?: string;
394
+
395
+ /**
396
+ * The name of the recipient.
397
+ * This might be a person, a business name, or contain “care of” (c/o) instructions.
398
+ */
399
+ recipient?: string;
400
+
401
+ /**
402
+ * The phone number of the recipient.
403
+ * Note that this might be different from any phone number you collect with `requestPayerPhone`.
404
+ */
405
+ phone?: string;
406
+
407
+ /**
408
+ * The sorting code as used in, for example, France.
409
+ * Not present on Apple platforms.
410
+ */
411
+ sortingCode?: string;
412
+
413
+ /**
414
+ * A logical subdivision of a city.
415
+ * Can be used for things like neighborhoods, boroughs, districts, or UK dependent localities.
416
+ * Not present on Apple platforms.
417
+ */
418
+ dependentLocality?: string;
419
+ }
420
+
421
+ export interface PaymentRequestTokenEvent extends PaymentRequestEvent {
422
+ token: Token;
423
+ }
424
+
425
+ export interface PaymentRequestPaymentMethodEvent extends PaymentRequestEvent {
426
+ paymentMethod: PaymentMethod;
427
+ }
428
+
429
+ export interface PaymentRequestSourceEvent extends PaymentRequestEvent {
430
+ source: Source;
431
+ }
432
+
433
+ export interface PaymentRequestShippingAddressEvent {
434
+ /**
435
+ * Call this with an `UpdateDetails` object to merge updates into the current `PaymentRequest` object.
436
+ * Note that if you subscribe to `shippingaddresschange` events, then you must call `updateWith` within 30 seconds.
437
+ */
438
+ updateWith: (details: PaymentRequestUpdateDetails) => void;
439
+
440
+ /**
441
+ * The customer's selected `ShippingAddress`.
442
+ * To maintain privacy, browsers may anonymize the shipping address by removing sensitive information that is not necessary to calculate shipping costs.
443
+ * Depending on the country, some fields can be missing or partially redacted.
444
+ * For example, the shipping address in the U.S. may only contain a city, state, and ZIP code.
445
+ * The full shipping address appears in the `PaymentRequestEvent` object after the purchase is confirmed in the browser’s payment interface
446
+ */
447
+ shippingAddress: PaymentRequestShippingAddress;
448
+ }
449
+
450
+ export type PaymentRequestUpdateDetailsStatus =
451
+ /**
452
+ * Let the customer proceed.
453
+ */
454
+ | 'success'
455
+
456
+ /**
457
+ * Prevent the customer from making the change they just made.
458
+ */
459
+ | 'fail'
460
+
461
+ /**
462
+ * Equivalent to `fail`, except we show a more specific error message.
463
+ * Can only be used in a `shippingaddresschange` handler.
464
+ */
465
+ | 'invalid_shipping_address';
466
+
467
+ /**
468
+ * An object to pass to the `updateWith` callback on `shippingaddresschange` and `shippingoptionchange` events.
469
+ */
470
+ export interface PaymentRequestUpdateDetails {
471
+ /**
472
+ * The browser uses this value to show an error message to the customer if they've taken an action that invalidates the payment request.
473
+ */
474
+ status?: PaymentRequestUpdateDetailsStatus;
475
+
476
+ /**
477
+ * The new total amount, if applicable.
478
+ */
479
+ total?: PaymentRequestItem;
480
+
481
+ /**
482
+ * These `PaymentRequestItem`s are shown as line items in the browser's payment interface.
483
+ * Note that the sum of the line item amounts does not need to add up to the `total` amount.
484
+ */
485
+ displayItems?: PaymentRequestItem[];
486
+
487
+ /**
488
+ * The first shipping option listed appears in the browser payment interface as the default option.
489
+ */
490
+ shippingOptions?: PaymentRequestShippingOption[];
491
+ }
492
+
493
+ export interface PaymentRequestShippingOptionEvent {
494
+ /**
495
+ * Call this with an `UpdateDetails` object to merge updates into the current `PaymentRequest` object.
496
+ * Note that if you subscribe to `shippingaddresschange` events, then you must call `updateWith` within 30 seconds.
497
+ */
498
+ updateWith: (details: PaymentRequestUpdateDetails) => void;
499
+
500
+ /**
501
+ * The customer's selected `ShippingOption`.
502
+ */
503
+ shippingOption: PaymentRequestShippingOption;
504
504
  }