@stripe/stripe-js 1.43.0 → 1.44.1

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.43.0",
57
+ version: "1.44.1",
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.43.0",
61
+ version: "1.44.1",
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.43.0",
41
+ version: "1.44.1",
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.43.0",
45
+ version: "1.44.1",
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.43.0",
3
+ "version": "1.44.1",
4
4
  "description": "Stripe.js loading utility",
5
5
  "main": "dist/stripe.js",
6
6
  "module": "dist/stripe.esm.js",
@@ -15,6 +15,7 @@ export * from './iban';
15
15
  export * from './ideal-bank';
16
16
  export * from './link-authentication';
17
17
  export * from './p24-bank';
18
+ export * from './pay-button';
18
19
  export * from './payment-request-button';
19
20
  export * from './payment';
20
21
  export * from './shipping-address';
@@ -0,0 +1,449 @@
1
+ import {StripeElementBase} from './base';
2
+ import {StripeError} from '../stripe';
3
+
4
+ export type StripePayButtonElement = StripeElementBase & {
5
+ /**
6
+ * Triggered when the element is fully rendered and can accept `element.focus` calls.
7
+ */
8
+ on(
9
+ eventType: 'ready',
10
+ handler: (event: StripePayButtonElementReadyEvent) => any
11
+ ): StripePayButtonElement;
12
+ once(
13
+ eventType: 'ready',
14
+ handler: (event: StripePayButtonElementReadyEvent) => any
15
+ ): StripePayButtonElement;
16
+ off(
17
+ eventType: 'ready',
18
+ handler?: (event: StripePayButtonElementReadyEvent) => any
19
+ ): StripePayButtonElement;
20
+
21
+ /**
22
+ * Triggered when a button on the element is clicked.
23
+ */
24
+ on(
25
+ eventType: 'click',
26
+ handler: (event: StripePayButtonElementClickEvent) => any
27
+ ): StripePayButtonElement;
28
+ once(
29
+ eventType: 'click',
30
+ handler: (event: StripePayButtonElementClickEvent) => any
31
+ ): StripePayButtonElement;
32
+ off(
33
+ eventType: 'click',
34
+ handler?: (event: StripePayButtonElementClickEvent) => any
35
+ ): StripePayButtonElement;
36
+
37
+ /**
38
+ * Triggered when the element gains focus.
39
+ */
40
+ on(
41
+ eventType: 'focus',
42
+ handler: (event: {elementType: 'payButton'}) => any
43
+ ): StripePayButtonElement;
44
+ once(
45
+ eventType: 'focus',
46
+ handler: (event: {elementType: 'payButton'}) => any
47
+ ): StripePayButtonElement;
48
+ off(
49
+ eventType: 'focus',
50
+ handler?: (event: {elementType: 'payButton'}) => any
51
+ ): StripePayButtonElement;
52
+
53
+ /**
54
+ * Triggered when the element loses focus.
55
+ */
56
+ on(
57
+ eventType: 'blur',
58
+ handler: (event: {elementType: 'payButton'}) => any
59
+ ): StripePayButtonElement;
60
+ once(
61
+ eventType: 'blur',
62
+ handler: (event: {elementType: 'payButton'}) => any
63
+ ): StripePayButtonElement;
64
+ off(
65
+ eventType: 'blur',
66
+ handler?: (event: {elementType: 'payButton'}) => any
67
+ ): StripePayButtonElement;
68
+
69
+ /**
70
+ * Triggered when the escape key is pressed within the element.
71
+ */
72
+ on(
73
+ eventType: 'escape',
74
+ handler: (event: {elementType: 'payButton'}) => any
75
+ ): StripePayButtonElement;
76
+ once(
77
+ eventType: 'escape',
78
+ handler: (event: {elementType: 'payButton'}) => any
79
+ ): StripePayButtonElement;
80
+ off(
81
+ eventType: 'escape',
82
+ handler?: (event: {elementType: 'payButton'}) => any
83
+ ): StripePayButtonElement;
84
+
85
+ /**
86
+ * Triggered when the element fails to load.
87
+ */
88
+ on(
89
+ eventType: 'loaderror',
90
+ handler: (event: {elementType: 'payButton'; error: StripeError}) => any
91
+ ): StripePayButtonElement;
92
+ once(
93
+ eventType: 'loaderror',
94
+ handler: (event: {elementType: 'payButton'; error: StripeError}) => any
95
+ ): StripePayButtonElement;
96
+ off(
97
+ eventType: 'loaderror',
98
+ handler?: (event: {elementType: 'payButton'; error: StripeError}) => any
99
+ ): StripePayButtonElement;
100
+
101
+ /**
102
+ * Triggered when a buyer authorizes a payment within a supported payment method.
103
+ */
104
+ on(
105
+ eventType: 'confirm',
106
+ handler: (event: StripePayButtonElementConfirmEvent) => any
107
+ ): StripePayButtonElement;
108
+ once(
109
+ eventType: 'confirm',
110
+ handler: (event: StripePayButtonElementConfirmEvent) => any
111
+ ): StripePayButtonElement;
112
+ off(
113
+ eventType: 'confirm',
114
+ handler?: (event: StripePayButtonElementConfirmEvent) => any
115
+ ): StripePayButtonElement;
116
+
117
+ /**
118
+ * Triggered when a payment interface is dismissed (e.g., a buyer closes the payment interface)
119
+ */
120
+ on(
121
+ eventType: 'cancel',
122
+ handler: (event: {elementType: 'payButton'}) => any
123
+ ): StripePayButtonElement;
124
+ once(
125
+ eventType: 'cancel',
126
+ handler: (event: {elementType: 'payButton'}) => any
127
+ ): StripePayButtonElement;
128
+ off(
129
+ eventType: 'cancel',
130
+ handler?: (event: {elementType: 'payButton'}) => any
131
+ ): StripePayButtonElement;
132
+
133
+ /**
134
+ * Triggered when a buyer selects a different shipping address.
135
+ */
136
+ on(
137
+ eventType: 'shippingaddresschange',
138
+ handler: (event: StripePayButtonElementShippingAddressChangeEvent) => any
139
+ ): StripePayButtonElement;
140
+ once(
141
+ eventType: 'shippingaddresschange',
142
+ handler: (event: StripePayButtonElementShippingAddressChangeEvent) => any
143
+ ): StripePayButtonElement;
144
+ off(
145
+ eventType: 'shippingaddresschange',
146
+ handler?: (event: StripePayButtonElementShippingAddressChangeEvent) => any
147
+ ): StripePayButtonElement;
148
+
149
+ /**
150
+ * Triggered when a buyer selects a different shipping rate.
151
+ */
152
+ on(
153
+ eventType: 'shippingratechange',
154
+ handler: (event: StripePayButtonElementShippingRateChangeEvent) => any
155
+ ): StripePayButtonElement;
156
+ once(
157
+ eventType: 'shippingratechange',
158
+ handler: (event: StripePayButtonElementShippingRateChangeEvent) => any
159
+ ): StripePayButtonElement;
160
+ off(
161
+ eventType: 'shippingratechange',
162
+ handler?: (event: StripePayButtonElementShippingRateChangeEvent) => any
163
+ ): StripePayButtonElement;
164
+
165
+ /**
166
+ * Updates the options the `PayButtonElement` was initialized with.
167
+ * Updates are merged into the existing configuration.
168
+ */
169
+ update(options: StripePayButtonElementUpdateOptions): StripePayButtonElement;
170
+ };
171
+
172
+ export type PaymentMethodType = 'google_pay' | 'apple_pay';
173
+
174
+ export type PayButtonPartialAddress = {
175
+ city: string;
176
+ state: string;
177
+ postal_code: string;
178
+ country: string;
179
+ };
180
+
181
+ export type PayButtonAddress = PayButtonPartialAddress & {
182
+ line1: string;
183
+ line2: string | null;
184
+ };
185
+
186
+ export type BillingDetails = {
187
+ name: string;
188
+ email?: string;
189
+ phone?: string;
190
+ address: PayButtonAddress;
191
+ };
192
+
193
+ export type ShippingAddress = {
194
+ name: string;
195
+ address: PayButtonAddress;
196
+ };
197
+
198
+ export type LineItem = {
199
+ name: string;
200
+ amount: number;
201
+ };
202
+
203
+ export type DeliveryUnit = 'hour' | 'day' | 'business_day' | 'week' | 'month';
204
+
205
+ export type DeliveryEstimate = {
206
+ unit: DeliveryUnit;
207
+ value: number;
208
+ };
209
+
210
+ export type ShippingRate = {
211
+ id: string;
212
+ amount: number;
213
+ displayName: string;
214
+ deliveryEstimate?: {
215
+ maximum?: DeliveryEstimate;
216
+ minimum?: DeliveryEstimate;
217
+ };
218
+ };
219
+
220
+ export type LayoutType = 'auto' | 'horizontal' | 'vertical';
221
+
222
+ export type LayoutOption =
223
+ | LayoutType
224
+ | {
225
+ type: LayoutType;
226
+ visibleButtonCount?: number;
227
+ };
228
+
229
+ export type PayButtonWalletOption = 'always' | 'auto' | 'never';
230
+
231
+ export type PayButtonWalletsOption = {
232
+ applePay?: PayButtonWalletOption;
233
+ googlePay?: PayButtonWalletOption;
234
+ };
235
+
236
+ export type ApplePayButtonTheme = 'black' | 'white' | 'white-outline';
237
+
238
+ export type GooglePayButtonTheme = 'black' | 'white';
239
+
240
+ export type ButtonThemeOption = {
241
+ applePay?: ApplePayButtonTheme;
242
+ googlePay?: GooglePayButtonTheme;
243
+ };
244
+
245
+ export type ApplePayButtonType =
246
+ | 'add-money'
247
+ | 'book'
248
+ | 'buy'
249
+ | 'check-out'
250
+ | 'contribute'
251
+ | 'donate'
252
+ | 'order'
253
+ | 'plain'
254
+ | 'reload'
255
+ | 'rent'
256
+ | 'subscribe'
257
+ | 'support'
258
+ | 'tip'
259
+ | 'top-up';
260
+
261
+ export type GooglePayButtonType =
262
+ | 'book'
263
+ | 'buy'
264
+ | 'checkout'
265
+ | 'donate'
266
+ | 'order'
267
+ | 'pay'
268
+ | 'plain'
269
+ | 'subscribe';
270
+
271
+ export type ButtonTypeOption = {
272
+ applePay?: ApplePayButtonType;
273
+ googlePay?: GooglePayButtonType;
274
+ };
275
+
276
+ export interface StripePayButtonElementOptions {
277
+ /**
278
+ * Manually sets the height of the buttons shown.
279
+ */
280
+ buttonHeight?: number;
281
+
282
+ /**
283
+ * Controls the color of each button.
284
+ */
285
+ buttonTheme?: ButtonThemeOption;
286
+
287
+ /**
288
+ * Specifies the type of each button.
289
+ */
290
+ buttonType?: ButtonTypeOption;
291
+
292
+ /**
293
+ * Specifies how buttons should be laid out in relation to each other.
294
+ */
295
+ layout?: LayoutOption;
296
+
297
+ /**
298
+ * Override the order in which payment methods are displayed in the Pay Button Element.
299
+ * By default, the Pay Button Element will use a dynamic ordering that optimizes payment method display for each user.
300
+ */
301
+ paymentMethodOrder?: string[];
302
+
303
+ /**
304
+ * Control wallets display in the Pay Button Element.
305
+ */
306
+ wallets?: PayButtonWalletsOption;
307
+ }
308
+
309
+ /*
310
+ * Updatable options for an `Elements` instance
311
+ */
312
+ export interface StripePayButtonElementUpdateOptions {
313
+ /**
314
+ * Manually sets the height of the buttons shown.
315
+ */
316
+ buttonHeight?: number;
317
+
318
+ /**
319
+ * Specifies how buttons should be laid out in relation to each other.
320
+ */
321
+ layout?: LayoutOption;
322
+
323
+ /**
324
+ * Override the order in which payment methods are displayed in the Pay Button Element.
325
+ * By default, the Pay Button Element will use a dynamic ordering that optimizes payment method display for each user.
326
+ */
327
+ paymentMethodOrder?: string[];
328
+ }
329
+
330
+ export type AvailablePaymentMethods = {
331
+ applePay: boolean;
332
+ googlePay: boolean;
333
+ };
334
+
335
+ export interface StripePayButtonElementReadyEvent {
336
+ /**
337
+ * The type of element that emitted this event.
338
+ */
339
+ elementType: 'payButton';
340
+
341
+ /**
342
+ * The list of payment methods that could possibly show in the element, or undefined if no payment methods can show.
343
+ */
344
+ availablePaymentMethods: undefined | AvailablePaymentMethods;
345
+ }
346
+
347
+ export type RecurringPaymentIntervalUnit =
348
+ | 'year'
349
+ | 'month'
350
+ | 'day'
351
+ | 'hour'
352
+ | 'minute';
353
+
354
+ export type ApplePayOption = {
355
+ recurringPaymentRequest?: {
356
+ paymentDescription: string;
357
+ managementURL: string;
358
+ regularBilling: {
359
+ amount: number;
360
+ label: string;
361
+ recurringPaymentStartDate?: Date;
362
+ recurringPaymentEndDate?: Date;
363
+ recurringPaymentIntervalUnit?: RecurringPaymentIntervalUnit;
364
+ recurringPaymentIntervalCount?: number;
365
+ };
366
+ billingAgreement?: string;
367
+ };
368
+ };
369
+
370
+ export type ClickResolveDetails = {
371
+ /**
372
+ * An array of two-letter ISO country codes representing which countries
373
+ * are eligible shipping locations.
374
+ */
375
+ allowedShippingCountries?: string[];
376
+
377
+ billingAddressRequired?: boolean;
378
+
379
+ /**
380
+ * Provide information about your business that will be displayed in the payment interface.
381
+ * This information will be retrieved from your Stripe account if not provided.
382
+ */
383
+ business?: {name: string};
384
+
385
+ emailRequired?: boolean;
386
+
387
+ lineItems?: Array<LineItem>;
388
+
389
+ phoneNumberRequired?: boolean;
390
+
391
+ shippingAddressRequired?: boolean;
392
+
393
+ shippingRates?: Array<ShippingRate>;
394
+
395
+ applePay?: ApplePayOption;
396
+ };
397
+
398
+ export interface StripePayButtonElementClickEvent {
399
+ /**
400
+ * The type of element that emitted this event.
401
+ */
402
+ elementType: 'payButton';
403
+
404
+ /**
405
+ * The payment method associated with the button that was clicked.
406
+ */
407
+ paymentMethodType: PaymentMethodType;
408
+
409
+ /**
410
+ * Callback to configure the details shown on a payment interface, including which fields to collect.
411
+ * This must be called within 1 second of the 'click' event being emitted.
412
+ */
413
+ resolve: (resolveDetails?: ClickResolveDetails) => void;
414
+ }
415
+
416
+ export interface StripePayButtonElementConfirmEvent {
417
+ /**
418
+ * Callback when a payment is unsuccessful. Optionally, specifying a reason will show a more detailed error in the payment interface.
419
+ */
420
+ paymentFailed: (payload?: {
421
+ reason?: 'fail' | 'invalid_shipping_address';
422
+ }) => void;
423
+
424
+ billingDetails?: BillingDetails;
425
+
426
+ shippingAddress?: ShippingAddress;
427
+
428
+ shippingRate?: ShippingRate;
429
+
430
+ paymentMethodType: PaymentMethodType;
431
+ }
432
+
433
+ export type ChangeResolveDetails = {
434
+ lineItems?: Array<LineItem>;
435
+ shippingRates?: Array<ShippingRate>;
436
+ };
437
+
438
+ export interface StripePayButtonElementShippingAddressChangeEvent {
439
+ name: string;
440
+ address: PayButtonPartialAddress;
441
+ resolve: (resolveDetails?: ChangeResolveDetails) => void;
442
+ reject: () => void;
443
+ }
444
+
445
+ export interface StripePayButtonElementShippingRateChangeEvent {
446
+ shippingRate: ShippingRate;
447
+ resolve: (resolveDetails?: ChangeResolveDetails) => void;
448
+ reject: () => void;
449
+ }
@@ -176,11 +176,11 @@ export interface TermsOption {
176
176
  usBankAccount?: TermOption;
177
177
  }
178
178
 
179
- export type WalletOption = 'auto' | 'never';
179
+ export type PaymentWalletOption = 'auto' | 'never';
180
180
 
181
- export interface WalletsOption {
182
- applePay?: WalletOption;
183
- googlePay?: WalletOption;
181
+ export interface PaymentWalletsOption {
182
+ applePay?: PaymentWalletOption;
183
+ googlePay?: PaymentWalletOption;
184
184
  }
185
185
 
186
186
  export interface StripePaymentElementOptions {
@@ -220,7 +220,7 @@ export interface StripePaymentElementOptions {
220
220
  /**
221
221
  * Control wallets display in the Payment Element.
222
222
  */
223
- wallets?: WalletsOption;
223
+ wallets?: PaymentWalletsOption;
224
224
  }
225
225
 
226
226
  export interface StripePaymentElementChangeEvent {
@@ -47,6 +47,8 @@ import {
47
47
  StripeIssuingCardPinDisplayElementOptions,
48
48
  StripeIssuingCardCopyButtonElement,
49
49
  StripeIssuingCardCopyButtonElementOptions,
50
+ StripePayButtonElement,
51
+ StripePayButtonElementOptions,
50
52
  } from './elements';
51
53
 
52
54
  export interface StripeElements {
@@ -370,6 +372,29 @@ export interface StripeElements {
370
372
  elementType: 'linkAuthentication'
371
373
  ): StripeLinkAuthenticationElement | null;
372
374
 
375
+ /////////////////////////////
376
+ /// payButton
377
+ /////////////////////////////
378
+
379
+ /**
380
+ * Requires beta access:
381
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
382
+ *
383
+ * Creates a `PayButtonElement`.
384
+ */
385
+ create(
386
+ elementType: 'payButton',
387
+ options?: StripePayButtonElementOptions
388
+ ): StripePayButtonElement;
389
+
390
+ /**
391
+ * Requires beta access:
392
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
393
+ *
394
+ * Looks up a previously created `Element` by its type.
395
+ */
396
+ getElement(elementType: 'payButton'): StripePayButtonElement | null;
397
+
373
398
  /////////////////////////////
374
399
  /// payment
375
400
  /////////////////////////////
@@ -505,6 +530,7 @@ export type StripeElementType =
505
530
  | 'iban'
506
531
  | 'idealBank'
507
532
  | 'p24Bank'
533
+ | 'payButton'
508
534
  | 'payment'
509
535
  | 'paymentMethodMessaging'
510
536
  | 'paymentRequestButton'
@@ -531,6 +557,7 @@ export type StripeElement =
531
557
  | StripeIbanElement
532
558
  | StripeIdealBankElement
533
559
  | StripeP24BankElement
560
+ | StripePayButtonElement
534
561
  | StripePaymentElement
535
562
  | StripePaymentMethodMessagingElement
536
563
  | StripePaymentRequestButtonElement