@stripe/stripe-js 5.6.0 → 5.7.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/index.js +12 -5
- package/dist/index.mjs +12 -5
- package/dist/pure.js +12 -5
- package/dist/pure.mjs +12 -5
- package/dist/stripe-js/elements/express-checkout.d.mts +82 -0
- package/dist/stripe-js/elements/express-checkout.d.ts +82 -0
- package/package.json +1 -1
- package/src/shared.test.ts +9 -0
- package/src/shared.ts +9 -4
package/dist/index.js
CHANGED
|
@@ -2,16 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var ORIGIN = 'https://js.stripe.com';
|
|
6
|
+
var STRIPE_JS_URL = "".concat(ORIGIN, "/v3");
|
|
6
7
|
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
8
|
+
var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
|
|
7
9
|
var EXISTING_SCRIPT_MESSAGE = 'loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used';
|
|
10
|
+
|
|
11
|
+
var isStripeJSURL = function isStripeJSURL(url) {
|
|
12
|
+
return V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
|
|
13
|
+
};
|
|
14
|
+
|
|
8
15
|
var findScript = function findScript() {
|
|
9
|
-
var scripts = document.querySelectorAll("script[src^=\"".concat(
|
|
16
|
+
var scripts = document.querySelectorAll("script[src^=\"".concat(ORIGIN, "\"]"));
|
|
10
17
|
|
|
11
18
|
for (var i = 0; i < scripts.length; i++) {
|
|
12
19
|
var script = scripts[i];
|
|
13
20
|
|
|
14
|
-
if (!
|
|
21
|
+
if (!isStripeJSURL(script.src)) {
|
|
15
22
|
continue;
|
|
16
23
|
}
|
|
17
24
|
|
|
@@ -24,7 +31,7 @@ var findScript = function findScript() {
|
|
|
24
31
|
var injectScript = function injectScript(params) {
|
|
25
32
|
var queryString = params && !params.advancedFraudSignals ? '?advancedFraudSignals=false' : '';
|
|
26
33
|
var script = document.createElement('script');
|
|
27
|
-
script.src = "".concat(
|
|
34
|
+
script.src = "".concat(STRIPE_JS_URL).concat(queryString);
|
|
28
35
|
var headOrBody = document.head || document.body;
|
|
29
36
|
|
|
30
37
|
if (!headOrBody) {
|
|
@@ -42,7 +49,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
42
49
|
|
|
43
50
|
stripe._registerWrapper({
|
|
44
51
|
name: 'stripe-js',
|
|
45
|
-
version: "5.
|
|
52
|
+
version: "5.7.0",
|
|
46
53
|
startTime: startTime
|
|
47
54
|
});
|
|
48
55
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ORIGIN = 'https://js.stripe.com';
|
|
2
|
+
var STRIPE_JS_URL = "".concat(ORIGIN, "/v3");
|
|
2
3
|
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
4
|
+
var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
|
|
3
5
|
var EXISTING_SCRIPT_MESSAGE = 'loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used';
|
|
6
|
+
|
|
7
|
+
var isStripeJSURL = function isStripeJSURL(url) {
|
|
8
|
+
return V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
|
|
9
|
+
};
|
|
10
|
+
|
|
4
11
|
var findScript = function findScript() {
|
|
5
|
-
var scripts = document.querySelectorAll("script[src^=\"".concat(
|
|
12
|
+
var scripts = document.querySelectorAll("script[src^=\"".concat(ORIGIN, "\"]"));
|
|
6
13
|
|
|
7
14
|
for (var i = 0; i < scripts.length; i++) {
|
|
8
15
|
var script = scripts[i];
|
|
9
16
|
|
|
10
|
-
if (!
|
|
17
|
+
if (!isStripeJSURL(script.src)) {
|
|
11
18
|
continue;
|
|
12
19
|
}
|
|
13
20
|
|
|
@@ -20,7 +27,7 @@ var findScript = function findScript() {
|
|
|
20
27
|
var injectScript = function injectScript(params) {
|
|
21
28
|
var queryString = params && !params.advancedFraudSignals ? '?advancedFraudSignals=false' : '';
|
|
22
29
|
var script = document.createElement('script');
|
|
23
|
-
script.src = "".concat(
|
|
30
|
+
script.src = "".concat(STRIPE_JS_URL).concat(queryString);
|
|
24
31
|
var headOrBody = document.head || document.body;
|
|
25
32
|
|
|
26
33
|
if (!headOrBody) {
|
|
@@ -38,7 +45,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
38
45
|
|
|
39
46
|
stripe._registerWrapper({
|
|
40
47
|
name: 'stripe-js',
|
|
41
|
-
version: "5.
|
|
48
|
+
version: "5.7.0",
|
|
42
49
|
startTime: startTime
|
|
43
50
|
});
|
|
44
51
|
};
|
package/dist/pure.js
CHANGED
|
@@ -18,16 +18,23 @@ function _typeof(obj) {
|
|
|
18
18
|
return _typeof(obj);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var ORIGIN = 'https://js.stripe.com';
|
|
22
|
+
var STRIPE_JS_URL = "".concat(ORIGIN, "/v3");
|
|
22
23
|
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
24
|
+
var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
|
|
23
25
|
var EXISTING_SCRIPT_MESSAGE = 'loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used';
|
|
26
|
+
|
|
27
|
+
var isStripeJSURL = function isStripeJSURL(url) {
|
|
28
|
+
return V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
|
|
29
|
+
};
|
|
30
|
+
|
|
24
31
|
var findScript = function findScript() {
|
|
25
|
-
var scripts = document.querySelectorAll("script[src^=\"".concat(
|
|
32
|
+
var scripts = document.querySelectorAll("script[src^=\"".concat(ORIGIN, "\"]"));
|
|
26
33
|
|
|
27
34
|
for (var i = 0; i < scripts.length; i++) {
|
|
28
35
|
var script = scripts[i];
|
|
29
36
|
|
|
30
|
-
if (!
|
|
37
|
+
if (!isStripeJSURL(script.src)) {
|
|
31
38
|
continue;
|
|
32
39
|
}
|
|
33
40
|
|
|
@@ -40,7 +47,7 @@ var findScript = function findScript() {
|
|
|
40
47
|
var injectScript = function injectScript(params) {
|
|
41
48
|
var queryString = params && !params.advancedFraudSignals ? '?advancedFraudSignals=false' : '';
|
|
42
49
|
var script = document.createElement('script');
|
|
43
|
-
script.src = "".concat(
|
|
50
|
+
script.src = "".concat(STRIPE_JS_URL).concat(queryString);
|
|
44
51
|
var headOrBody = document.head || document.body;
|
|
45
52
|
|
|
46
53
|
if (!headOrBody) {
|
|
@@ -58,7 +65,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
58
65
|
|
|
59
66
|
stripe._registerWrapper({
|
|
60
67
|
name: 'stripe-js',
|
|
61
|
-
version: "5.
|
|
68
|
+
version: "5.7.0",
|
|
62
69
|
startTime: startTime
|
|
63
70
|
});
|
|
64
71
|
};
|
package/dist/pure.mjs
CHANGED
|
@@ -14,16 +14,23 @@ function _typeof(obj) {
|
|
|
14
14
|
return _typeof(obj);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var ORIGIN = 'https://js.stripe.com';
|
|
18
|
+
var STRIPE_JS_URL = "".concat(ORIGIN, "/v3");
|
|
18
19
|
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
20
|
+
var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
|
|
19
21
|
var EXISTING_SCRIPT_MESSAGE = 'loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used';
|
|
22
|
+
|
|
23
|
+
var isStripeJSURL = function isStripeJSURL(url) {
|
|
24
|
+
return V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
|
|
25
|
+
};
|
|
26
|
+
|
|
20
27
|
var findScript = function findScript() {
|
|
21
|
-
var scripts = document.querySelectorAll("script[src^=\"".concat(
|
|
28
|
+
var scripts = document.querySelectorAll("script[src^=\"".concat(ORIGIN, "\"]"));
|
|
22
29
|
|
|
23
30
|
for (var i = 0; i < scripts.length; i++) {
|
|
24
31
|
var script = scripts[i];
|
|
25
32
|
|
|
26
|
-
if (!
|
|
33
|
+
if (!isStripeJSURL(script.src)) {
|
|
27
34
|
continue;
|
|
28
35
|
}
|
|
29
36
|
|
|
@@ -36,7 +43,7 @@ var findScript = function findScript() {
|
|
|
36
43
|
var injectScript = function injectScript(params) {
|
|
37
44
|
var queryString = params && !params.advancedFraudSignals ? '?advancedFraudSignals=false' : '';
|
|
38
45
|
var script = document.createElement('script');
|
|
39
|
-
script.src = "".concat(
|
|
46
|
+
script.src = "".concat(STRIPE_JS_URL).concat(queryString);
|
|
40
47
|
var headOrBody = document.head || document.body;
|
|
41
48
|
|
|
42
49
|
if (!headOrBody) {
|
|
@@ -54,7 +61,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
54
61
|
|
|
55
62
|
stripe._registerWrapper({
|
|
56
63
|
name: 'stripe-js',
|
|
57
|
-
version: "5.
|
|
64
|
+
version: "5.7.0",
|
|
58
65
|
startTime: startTime
|
|
59
66
|
});
|
|
60
67
|
};
|
|
@@ -315,6 +315,25 @@ export type ButtonTypeOption = {
|
|
|
315
315
|
};
|
|
316
316
|
|
|
317
317
|
export interface StripeExpressCheckoutElementOptions {
|
|
318
|
+
/**
|
|
319
|
+
* An array of two-letter ISO country codes representing which countries
|
|
320
|
+
* are eligible shipping locations.
|
|
321
|
+
*/
|
|
322
|
+
allowedShippingCountries?: string[];
|
|
323
|
+
|
|
324
|
+
applePay?: ApplePayOption;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Whether the billing address should be collected in the payment interface.
|
|
328
|
+
*/
|
|
329
|
+
billingAddressRequired?: boolean;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Provide information about your business that will be displayed in the payment interface.
|
|
333
|
+
* This information will be retrieved from your Stripe account if not provided.
|
|
334
|
+
*/
|
|
335
|
+
business?: {name: string};
|
|
336
|
+
|
|
318
337
|
/**
|
|
319
338
|
* Manually sets the height of the buttons shown.
|
|
320
339
|
*/
|
|
@@ -330,11 +349,18 @@ export interface StripeExpressCheckoutElementOptions {
|
|
|
330
349
|
*/
|
|
331
350
|
buttonType?: ButtonTypeOption;
|
|
332
351
|
|
|
352
|
+
/**
|
|
353
|
+
* Whether the email address should be collected in the payment interface.
|
|
354
|
+
*/
|
|
355
|
+
emailRequired?: boolean;
|
|
356
|
+
|
|
333
357
|
/**
|
|
334
358
|
* Specifies how buttons should be laid out in relation to each other.
|
|
335
359
|
*/
|
|
336
360
|
layout?: LayoutOption;
|
|
337
361
|
|
|
362
|
+
lineItems?: Array<LineItem>;
|
|
363
|
+
|
|
338
364
|
/**
|
|
339
365
|
* Override the order in which payment methods are displayed in the Express Checkout Element.
|
|
340
366
|
* By default, the Express Checkout Element will use a dynamic ordering that optimizes payment method display for each user.
|
|
@@ -346,6 +372,18 @@ export interface StripeExpressCheckoutElementOptions {
|
|
|
346
372
|
*/
|
|
347
373
|
paymentMethods?: ExpressCheckoutPaymentMethodsOption;
|
|
348
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Whether the phone number should be collected in the payment interface.
|
|
377
|
+
*/
|
|
378
|
+
phoneNumberRequired?: boolean;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Whether the shipping address should be collected in the payment interface.
|
|
382
|
+
*/
|
|
383
|
+
shippingAddressRequired?: boolean;
|
|
384
|
+
|
|
385
|
+
shippingRates?: Array<ShippingRate>;
|
|
386
|
+
|
|
349
387
|
/**
|
|
350
388
|
* @deprecated
|
|
351
389
|
* Use `paymentMethods` instead.
|
|
@@ -359,11 +397,27 @@ export interface StripeExpressCheckoutElementOptions {
|
|
|
359
397
|
* Updatable options for an `Elements` instance
|
|
360
398
|
*/
|
|
361
399
|
export interface StripeExpressCheckoutElementUpdateOptions {
|
|
400
|
+
/**
|
|
401
|
+
* An array of two-letter ISO country codes representing which countries
|
|
402
|
+
* are eligible shipping locations.
|
|
403
|
+
*/
|
|
404
|
+
allowedShippingCountries?: string[];
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Whether the billing address should be collected in the payment interface.
|
|
408
|
+
*/
|
|
409
|
+
billingAddressRequired?: boolean;
|
|
410
|
+
|
|
362
411
|
/**
|
|
363
412
|
* Manually sets the height of the buttons shown.
|
|
364
413
|
*/
|
|
365
414
|
buttonHeight?: number;
|
|
366
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Whether the email address should be collected in the payment interface.
|
|
418
|
+
*/
|
|
419
|
+
emailRequired?: boolean;
|
|
420
|
+
|
|
367
421
|
/**
|
|
368
422
|
* Specifies how buttons should be laid out in relation to each other.
|
|
369
423
|
*/
|
|
@@ -374,6 +428,16 @@ export interface StripeExpressCheckoutElementUpdateOptions {
|
|
|
374
428
|
* By default, the Express Checkout Element will use a dynamic ordering that optimizes payment method display for each user.
|
|
375
429
|
*/
|
|
376
430
|
paymentMethodOrder?: string[];
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Whether the phone number should be collected in the payment interface.
|
|
434
|
+
*/
|
|
435
|
+
phoneNumberRequired?: boolean;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Whether the shipping address should be collected in the payment interface.
|
|
439
|
+
*/
|
|
440
|
+
shippingAddressRequired?: boolean;
|
|
377
441
|
}
|
|
378
442
|
|
|
379
443
|
export type AvailablePaymentMethods = {
|
|
@@ -398,25 +462,43 @@ export interface StripeExpressCheckoutElementReadyEvent {
|
|
|
398
462
|
|
|
399
463
|
export type ClickResolveDetails = {
|
|
400
464
|
/**
|
|
465
|
+
* @deprecated
|
|
401
466
|
* An array of two-letter ISO country codes representing which countries
|
|
402
467
|
* are eligible shipping locations.
|
|
403
468
|
*/
|
|
404
469
|
allowedShippingCountries?: string[];
|
|
405
470
|
|
|
471
|
+
/**
|
|
472
|
+
* @deprecated
|
|
473
|
+
* Whether the billing address should be collected in the payment interface.
|
|
474
|
+
*/
|
|
406
475
|
billingAddressRequired?: boolean;
|
|
407
476
|
|
|
408
477
|
/**
|
|
478
|
+
* @deprecated
|
|
409
479
|
* Provide information about your business that will be displayed in the payment interface.
|
|
410
480
|
* This information will be retrieved from your Stripe account if not provided.
|
|
411
481
|
*/
|
|
412
482
|
business?: {name: string};
|
|
413
483
|
|
|
484
|
+
/**
|
|
485
|
+
* @deprecated
|
|
486
|
+
* Whether the email address should be collected in the payment interface.
|
|
487
|
+
*/
|
|
414
488
|
emailRequired?: boolean;
|
|
415
489
|
|
|
416
490
|
lineItems?: Array<LineItem>;
|
|
417
491
|
|
|
492
|
+
/**
|
|
493
|
+
* @deprecated
|
|
494
|
+
* Whether the phone number should be collected in the payment interface.
|
|
495
|
+
*/
|
|
418
496
|
phoneNumberRequired?: boolean;
|
|
419
497
|
|
|
498
|
+
/**
|
|
499
|
+
* @deprecated
|
|
500
|
+
* Whether the shipping address should be collected in the payment interface.
|
|
501
|
+
*/
|
|
420
502
|
shippingAddressRequired?: boolean;
|
|
421
503
|
|
|
422
504
|
shippingRates?: Array<ShippingRate>;
|
|
@@ -315,6 +315,25 @@ export type ButtonTypeOption = {
|
|
|
315
315
|
};
|
|
316
316
|
|
|
317
317
|
export interface StripeExpressCheckoutElementOptions {
|
|
318
|
+
/**
|
|
319
|
+
* An array of two-letter ISO country codes representing which countries
|
|
320
|
+
* are eligible shipping locations.
|
|
321
|
+
*/
|
|
322
|
+
allowedShippingCountries?: string[];
|
|
323
|
+
|
|
324
|
+
applePay?: ApplePayOption;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Whether the billing address should be collected in the payment interface.
|
|
328
|
+
*/
|
|
329
|
+
billingAddressRequired?: boolean;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Provide information about your business that will be displayed in the payment interface.
|
|
333
|
+
* This information will be retrieved from your Stripe account if not provided.
|
|
334
|
+
*/
|
|
335
|
+
business?: {name: string};
|
|
336
|
+
|
|
318
337
|
/**
|
|
319
338
|
* Manually sets the height of the buttons shown.
|
|
320
339
|
*/
|
|
@@ -330,11 +349,18 @@ export interface StripeExpressCheckoutElementOptions {
|
|
|
330
349
|
*/
|
|
331
350
|
buttonType?: ButtonTypeOption;
|
|
332
351
|
|
|
352
|
+
/**
|
|
353
|
+
* Whether the email address should be collected in the payment interface.
|
|
354
|
+
*/
|
|
355
|
+
emailRequired?: boolean;
|
|
356
|
+
|
|
333
357
|
/**
|
|
334
358
|
* Specifies how buttons should be laid out in relation to each other.
|
|
335
359
|
*/
|
|
336
360
|
layout?: LayoutOption;
|
|
337
361
|
|
|
362
|
+
lineItems?: Array<LineItem>;
|
|
363
|
+
|
|
338
364
|
/**
|
|
339
365
|
* Override the order in which payment methods are displayed in the Express Checkout Element.
|
|
340
366
|
* By default, the Express Checkout Element will use a dynamic ordering that optimizes payment method display for each user.
|
|
@@ -346,6 +372,18 @@ export interface StripeExpressCheckoutElementOptions {
|
|
|
346
372
|
*/
|
|
347
373
|
paymentMethods?: ExpressCheckoutPaymentMethodsOption;
|
|
348
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Whether the phone number should be collected in the payment interface.
|
|
377
|
+
*/
|
|
378
|
+
phoneNumberRequired?: boolean;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Whether the shipping address should be collected in the payment interface.
|
|
382
|
+
*/
|
|
383
|
+
shippingAddressRequired?: boolean;
|
|
384
|
+
|
|
385
|
+
shippingRates?: Array<ShippingRate>;
|
|
386
|
+
|
|
349
387
|
/**
|
|
350
388
|
* @deprecated
|
|
351
389
|
* Use `paymentMethods` instead.
|
|
@@ -359,11 +397,27 @@ export interface StripeExpressCheckoutElementOptions {
|
|
|
359
397
|
* Updatable options for an `Elements` instance
|
|
360
398
|
*/
|
|
361
399
|
export interface StripeExpressCheckoutElementUpdateOptions {
|
|
400
|
+
/**
|
|
401
|
+
* An array of two-letter ISO country codes representing which countries
|
|
402
|
+
* are eligible shipping locations.
|
|
403
|
+
*/
|
|
404
|
+
allowedShippingCountries?: string[];
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Whether the billing address should be collected in the payment interface.
|
|
408
|
+
*/
|
|
409
|
+
billingAddressRequired?: boolean;
|
|
410
|
+
|
|
362
411
|
/**
|
|
363
412
|
* Manually sets the height of the buttons shown.
|
|
364
413
|
*/
|
|
365
414
|
buttonHeight?: number;
|
|
366
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Whether the email address should be collected in the payment interface.
|
|
418
|
+
*/
|
|
419
|
+
emailRequired?: boolean;
|
|
420
|
+
|
|
367
421
|
/**
|
|
368
422
|
* Specifies how buttons should be laid out in relation to each other.
|
|
369
423
|
*/
|
|
@@ -374,6 +428,16 @@ export interface StripeExpressCheckoutElementUpdateOptions {
|
|
|
374
428
|
* By default, the Express Checkout Element will use a dynamic ordering that optimizes payment method display for each user.
|
|
375
429
|
*/
|
|
376
430
|
paymentMethodOrder?: string[];
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Whether the phone number should be collected in the payment interface.
|
|
434
|
+
*/
|
|
435
|
+
phoneNumberRequired?: boolean;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Whether the shipping address should be collected in the payment interface.
|
|
439
|
+
*/
|
|
440
|
+
shippingAddressRequired?: boolean;
|
|
377
441
|
}
|
|
378
442
|
|
|
379
443
|
export type AvailablePaymentMethods = {
|
|
@@ -398,25 +462,43 @@ export interface StripeExpressCheckoutElementReadyEvent {
|
|
|
398
462
|
|
|
399
463
|
export type ClickResolveDetails = {
|
|
400
464
|
/**
|
|
465
|
+
* @deprecated
|
|
401
466
|
* An array of two-letter ISO country codes representing which countries
|
|
402
467
|
* are eligible shipping locations.
|
|
403
468
|
*/
|
|
404
469
|
allowedShippingCountries?: string[];
|
|
405
470
|
|
|
471
|
+
/**
|
|
472
|
+
* @deprecated
|
|
473
|
+
* Whether the billing address should be collected in the payment interface.
|
|
474
|
+
*/
|
|
406
475
|
billingAddressRequired?: boolean;
|
|
407
476
|
|
|
408
477
|
/**
|
|
478
|
+
* @deprecated
|
|
409
479
|
* Provide information about your business that will be displayed in the payment interface.
|
|
410
480
|
* This information will be retrieved from your Stripe account if not provided.
|
|
411
481
|
*/
|
|
412
482
|
business?: {name: string};
|
|
413
483
|
|
|
484
|
+
/**
|
|
485
|
+
* @deprecated
|
|
486
|
+
* Whether the email address should be collected in the payment interface.
|
|
487
|
+
*/
|
|
414
488
|
emailRequired?: boolean;
|
|
415
489
|
|
|
416
490
|
lineItems?: Array<LineItem>;
|
|
417
491
|
|
|
492
|
+
/**
|
|
493
|
+
* @deprecated
|
|
494
|
+
* Whether the phone number should be collected in the payment interface.
|
|
495
|
+
*/
|
|
418
496
|
phoneNumberRequired?: boolean;
|
|
419
497
|
|
|
498
|
+
/**
|
|
499
|
+
* @deprecated
|
|
500
|
+
* Whether the shipping address should be collected in the payment interface.
|
|
501
|
+
*/
|
|
420
502
|
shippingAddressRequired?: boolean;
|
|
421
503
|
|
|
422
504
|
shippingRates?: Array<ShippingRate>;
|
package/package.json
CHANGED
package/src/shared.test.ts
CHANGED
|
@@ -33,11 +33,20 @@ describe('findScript', () => {
|
|
|
33
33
|
['https://js.stripe.com/v3?advancedFraudSignals=true', true],
|
|
34
34
|
['https://js.stripe.com/v3', true],
|
|
35
35
|
['https://js.stripe.com/v3/', true],
|
|
36
|
+
['https://js.stripe.com/v3/stripe.js', true],
|
|
37
|
+
['https://js.stripe.com/v2/stripe.js', false],
|
|
38
|
+
['https://js.stripe.com/versionname/stripe.js', true],
|
|
39
|
+
['https://js.stripe.com/versionname/stripe.js', true],
|
|
40
|
+
['https://js.stripe.com/versionname/', false],
|
|
41
|
+
['https://js.stripe.com/versionname', false],
|
|
42
|
+
['https://js.stripe.com/v2/', false],
|
|
43
|
+
['https://js.stripe.com/v2', false],
|
|
36
44
|
['https://js.stripe.com/v3?advancedFraudSignals=false', true],
|
|
37
45
|
['https://js.stripe.com/v3?ab=cd', true],
|
|
38
46
|
['https://js.stripe.com/v3/something.js', false],
|
|
39
47
|
['https://js.stripe.com/v3/something.js?advancedFraudSignals=false', false],
|
|
40
48
|
['https://js.stripe.com/v3/something.js?ab=cd', false],
|
|
49
|
+
['https://js.stripe.com/versionname/stripe.js?ab=cd', true],
|
|
41
50
|
];
|
|
42
51
|
|
|
43
52
|
afterEach(() => {
|
package/src/shared.ts
CHANGED
|
@@ -12,20 +12,25 @@ export interface LoadParams {
|
|
|
12
12
|
// containing the package.json version
|
|
13
13
|
declare const _VERSION: string;
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const ORIGIN = 'https://js.stripe.com';
|
|
16
|
+
const STRIPE_JS_URL = `${ORIGIN}/v3`;
|
|
16
17
|
const V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
18
|
+
const STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
|
|
17
19
|
const EXISTING_SCRIPT_MESSAGE =
|
|
18
20
|
'loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used';
|
|
19
21
|
|
|
22
|
+
const isStripeJSURL = (url: string): boolean =>
|
|
23
|
+
V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
|
|
24
|
+
|
|
20
25
|
export const findScript = (): HTMLScriptElement | null => {
|
|
21
26
|
const scripts = document.querySelectorAll<HTMLScriptElement>(
|
|
22
|
-
`script[src^="${
|
|
27
|
+
`script[src^="${ORIGIN}"]`
|
|
23
28
|
);
|
|
24
29
|
|
|
25
30
|
for (let i = 0; i < scripts.length; i++) {
|
|
26
31
|
const script = scripts[i];
|
|
27
32
|
|
|
28
|
-
if (!
|
|
33
|
+
if (!isStripeJSURL(script.src)) {
|
|
29
34
|
continue;
|
|
30
35
|
}
|
|
31
36
|
|
|
@@ -39,7 +44,7 @@ const injectScript = (params: null | LoadParams): HTMLScriptElement => {
|
|
|
39
44
|
const queryString =
|
|
40
45
|
params && !params.advancedFraudSignals ? '?advancedFraudSignals=false' : '';
|
|
41
46
|
const script = document.createElement('script');
|
|
42
|
-
script.src = `${
|
|
47
|
+
script.src = `${STRIPE_JS_URL}${queryString}`;
|
|
43
48
|
|
|
44
49
|
const headOrBody = document.head || document.body;
|
|
45
50
|
|