@stripe/stripe-js 10.0.0 → 10.2.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/README.md +1 -0
- package/dist/index.js +11 -12
- package/dist/index.mjs +11 -12
- package/dist/pure.js +11 -12
- package/dist/pure.mjs +11 -12
- package/dist/stripe-js/checkout.d.mts +22 -0
- package/dist/stripe-js/checkout.d.ts +22 -0
- package/dist/stripe-js/elements/payment-method-messaging.d.mts +2 -0
- package/dist/stripe-js/elements/payment-method-messaging.d.ts +2 -0
- package/dist/stripe-js/elements/payment.d.mts +12 -2
- package/dist/stripe-js/elements/payment.d.ts +12 -2
- package/dist/stripe-js/elements-group.d.mts +5 -0
- package/dist/stripe-js/elements-group.d.ts +5 -0
- package/dist/stripe-js/payment-intents.d.mts +1 -1
- package/dist/stripe-js/payment-intents.d.ts +1 -1
- package/package.json +1 -1
- package/src/index.test.ts +26 -0
- package/src/shared.ts +7 -4
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
71
71
|
|
|
72
72
|
stripe._registerWrapper({
|
|
73
73
|
name: 'stripe-js',
|
|
74
|
-
version: "10.
|
|
74
|
+
version: "10.2.0",
|
|
75
75
|
startTime: startTime
|
|
76
76
|
});
|
|
77
77
|
};
|
|
@@ -150,19 +150,18 @@ var loadScript = function loadScript(params) {
|
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return load()["catch"](function (error) {
|
|
157
|
-
stripePromise$1 = null;
|
|
158
|
-
return Promise.reject(error);
|
|
159
|
-
});
|
|
160
|
-
}; // Resets stripePromise on error
|
|
153
|
+
}; // Cache the in-flight load (including its single retry) so that concurrent
|
|
154
|
+
// calls share it, and only clear the cache once the load has finally failed
|
|
155
|
+
// so that a later call can try again.
|
|
161
156
|
|
|
162
157
|
|
|
163
|
-
|
|
164
|
-
return
|
|
158
|
+
stripePromise$1 = load()["catch"](function () {
|
|
159
|
+
return load();
|
|
160
|
+
})["catch"](function (error) {
|
|
161
|
+
stripePromise$1 = null;
|
|
162
|
+
return Promise.reject(error);
|
|
165
163
|
});
|
|
164
|
+
return stripePromise$1;
|
|
166
165
|
};
|
|
167
166
|
var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
168
167
|
if (maybeStripe === null) {
|
|
@@ -181,7 +180,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
181
180
|
var expectedVersion = RELEASE_TRAIN;
|
|
182
181
|
|
|
183
182
|
if (isTestKey && version !== expectedVersion) {
|
|
184
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.
|
|
183
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.2.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
185
184
|
}
|
|
186
185
|
|
|
187
186
|
var stripe = maybeStripe.apply(undefined, args);
|
package/dist/index.mjs
CHANGED
|
@@ -67,7 +67,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
67
67
|
|
|
68
68
|
stripe._registerWrapper({
|
|
69
69
|
name: 'stripe-js',
|
|
70
|
-
version: "10.
|
|
70
|
+
version: "10.2.0",
|
|
71
71
|
startTime: startTime
|
|
72
72
|
});
|
|
73
73
|
};
|
|
@@ -146,19 +146,18 @@ var loadScript = function loadScript(params) {
|
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return load()["catch"](function (error) {
|
|
153
|
-
stripePromise$1 = null;
|
|
154
|
-
return Promise.reject(error);
|
|
155
|
-
});
|
|
156
|
-
}; // Resets stripePromise on error
|
|
149
|
+
}; // Cache the in-flight load (including its single retry) so that concurrent
|
|
150
|
+
// calls share it, and only clear the cache once the load has finally failed
|
|
151
|
+
// so that a later call can try again.
|
|
157
152
|
|
|
158
153
|
|
|
159
|
-
|
|
160
|
-
return
|
|
154
|
+
stripePromise$1 = load()["catch"](function () {
|
|
155
|
+
return load();
|
|
156
|
+
})["catch"](function (error) {
|
|
157
|
+
stripePromise$1 = null;
|
|
158
|
+
return Promise.reject(error);
|
|
161
159
|
});
|
|
160
|
+
return stripePromise$1;
|
|
162
161
|
};
|
|
163
162
|
var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
164
163
|
if (maybeStripe === null) {
|
|
@@ -177,7 +176,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
177
176
|
var expectedVersion = RELEASE_TRAIN;
|
|
178
177
|
|
|
179
178
|
if (isTestKey && version !== expectedVersion) {
|
|
180
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.
|
|
179
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.2.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
181
180
|
}
|
|
182
181
|
|
|
183
182
|
var stripe = maybeStripe.apply(undefined, args);
|
package/dist/pure.js
CHANGED
|
@@ -71,7 +71,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
71
71
|
|
|
72
72
|
stripe._registerWrapper({
|
|
73
73
|
name: 'stripe-js',
|
|
74
|
-
version: "10.
|
|
74
|
+
version: "10.2.0",
|
|
75
75
|
startTime: startTime
|
|
76
76
|
});
|
|
77
77
|
};
|
|
@@ -150,19 +150,18 @@ var loadScript = function loadScript(params) {
|
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return load()["catch"](function (error) {
|
|
157
|
-
stripePromise = null;
|
|
158
|
-
return Promise.reject(error);
|
|
159
|
-
});
|
|
160
|
-
}; // Resets stripePromise on error
|
|
153
|
+
}; // Cache the in-flight load (including its single retry) so that concurrent
|
|
154
|
+
// calls share it, and only clear the cache once the load has finally failed
|
|
155
|
+
// so that a later call can try again.
|
|
161
156
|
|
|
162
157
|
|
|
163
|
-
|
|
164
|
-
return
|
|
158
|
+
stripePromise = load()["catch"](function () {
|
|
159
|
+
return load();
|
|
160
|
+
})["catch"](function (error) {
|
|
161
|
+
stripePromise = null;
|
|
162
|
+
return Promise.reject(error);
|
|
165
163
|
});
|
|
164
|
+
return stripePromise;
|
|
166
165
|
};
|
|
167
166
|
var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
168
167
|
if (maybeStripe === null) {
|
|
@@ -181,7 +180,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
181
180
|
var expectedVersion = RELEASE_TRAIN;
|
|
182
181
|
|
|
183
182
|
if (isTestKey && version !== expectedVersion) {
|
|
184
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.
|
|
183
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.2.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
185
184
|
}
|
|
186
185
|
|
|
187
186
|
var stripe = maybeStripe.apply(undefined, args);
|
package/dist/pure.mjs
CHANGED
|
@@ -67,7 +67,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
67
67
|
|
|
68
68
|
stripe._registerWrapper({
|
|
69
69
|
name: 'stripe-js',
|
|
70
|
-
version: "10.
|
|
70
|
+
version: "10.2.0",
|
|
71
71
|
startTime: startTime
|
|
72
72
|
});
|
|
73
73
|
};
|
|
@@ -146,19 +146,18 @@ var loadScript = function loadScript(params) {
|
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return load()["catch"](function (error) {
|
|
153
|
-
stripePromise = null;
|
|
154
|
-
return Promise.reject(error);
|
|
155
|
-
});
|
|
156
|
-
}; // Resets stripePromise on error
|
|
149
|
+
}; // Cache the in-flight load (including its single retry) so that concurrent
|
|
150
|
+
// calls share it, and only clear the cache once the load has finally failed
|
|
151
|
+
// so that a later call can try again.
|
|
157
152
|
|
|
158
153
|
|
|
159
|
-
|
|
160
|
-
return
|
|
154
|
+
stripePromise = load()["catch"](function () {
|
|
155
|
+
return load();
|
|
156
|
+
})["catch"](function (error) {
|
|
157
|
+
stripePromise = null;
|
|
158
|
+
return Promise.reject(error);
|
|
161
159
|
});
|
|
160
|
+
return stripePromise;
|
|
162
161
|
};
|
|
163
162
|
var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
164
163
|
if (maybeStripe === null) {
|
|
@@ -177,7 +176,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
177
176
|
var expectedVersion = RELEASE_TRAIN;
|
|
178
177
|
|
|
179
178
|
if (isTestKey && version !== expectedVersion) {
|
|
180
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.
|
|
179
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.2.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
181
180
|
}
|
|
182
181
|
|
|
183
182
|
var stripe = maybeStripe.apply(undefined, args);
|
|
@@ -405,6 +405,10 @@ export type StripeCheckoutTaxIdInfo = {
|
|
|
405
405
|
export interface StripeCheckoutSession {
|
|
406
406
|
billingAddress: StripeCheckoutContact | null;
|
|
407
407
|
businessName: string | null;
|
|
408
|
+
nameCollection: {
|
|
409
|
+
individualName: string | null;
|
|
410
|
+
businessName: string | null;
|
|
411
|
+
} | null;
|
|
408
412
|
canConfirm: boolean;
|
|
409
413
|
currency: string;
|
|
410
414
|
currencyOptions: Array<StripeCheckoutCurrencyOption> | null;
|
|
@@ -671,6 +675,7 @@ export type StripeCheckoutExpressCheckoutElement = StripeElementBase & {
|
|
|
671
675
|
type AnyBuyerError = {message: string; code: null};
|
|
672
676
|
type ApplyPromotionCodeError =
|
|
673
677
|
| {message: string; code: 'invalidCode'}
|
|
678
|
+
| {message: string; code: 'promotionCodeAmountInsufficient'}
|
|
674
679
|
| AnyBuyerError;
|
|
675
680
|
export type StripeCheckoutApplyPromotionCodeResult =
|
|
676
681
|
| {type: 'success'; session: StripeCheckoutSession}
|
|
@@ -688,6 +693,14 @@ export type StripeCheckoutUpdatePhoneNumberResult =
|
|
|
688
693
|
| {type: 'success'; session: StripeCheckoutSession}
|
|
689
694
|
| {type: 'error'; error: never};
|
|
690
695
|
|
|
696
|
+
export type StripeCheckoutUpdateIndividualNameResult =
|
|
697
|
+
| {type: 'success'; session: StripeCheckoutSession}
|
|
698
|
+
| {type: 'error'; error: never};
|
|
699
|
+
|
|
700
|
+
export type StripeCheckoutUpdateBusinessNameResult =
|
|
701
|
+
| {type: 'success'; session: StripeCheckoutSession}
|
|
702
|
+
| {type: 'error'; error: never};
|
|
703
|
+
|
|
691
704
|
type UpdateEmailError =
|
|
692
705
|
| {message: string; code: 'incompleteEmail'}
|
|
693
706
|
| {message: string; code: 'invalidEmail'};
|
|
@@ -789,6 +802,12 @@ export type StripeCheckoutLoadActionsSuccess = {
|
|
|
789
802
|
updateEmail: (
|
|
790
803
|
email: string | null
|
|
791
804
|
) => Promise<StripeCheckoutUpdateEmailResult>;
|
|
805
|
+
updateIndividualName: (
|
|
806
|
+
individualName: string | null
|
|
807
|
+
) => Promise<StripeCheckoutUpdateIndividualNameResult>;
|
|
808
|
+
updateBusinessName: (
|
|
809
|
+
businessName: string | null
|
|
810
|
+
) => Promise<StripeCheckoutUpdateBusinessNameResult>;
|
|
792
811
|
updateLineItemQuantity: (args: {
|
|
793
812
|
lineItem: string;
|
|
794
813
|
quantity: number;
|
|
@@ -837,6 +856,8 @@ export type StripeCheckoutFormLoadActionsSuccess = Omit<
|
|
|
837
856
|
StripeCheckoutLoadActionsSuccess,
|
|
838
857
|
| 'updateEmail'
|
|
839
858
|
| 'updatePhoneNumber'
|
|
859
|
+
| 'updateIndividualName'
|
|
860
|
+
| 'updateBusinessName'
|
|
840
861
|
| 'updateShippingAddress'
|
|
841
862
|
| 'updateBillingAddress'
|
|
842
863
|
| 'updateTaxIdInfo'
|
|
@@ -857,6 +878,7 @@ export interface StripeCheckoutElementsSdk {
|
|
|
857
878
|
getShippingAddressElement(): StripeAddressElement | null;
|
|
858
879
|
getExpressCheckoutElement(): StripeCheckoutExpressCheckoutElement | null;
|
|
859
880
|
getCurrencySelectorElement(): StripeCurrencySelectorElement | null;
|
|
881
|
+
getContactDetailsElement(): StripeContactDetailsElement | null;
|
|
860
882
|
/* Requires beta header when initializing Stripe: @docs https://docs.stripe.com/tax/advanced/tax-ids?payment-ui=embedded-components#render-tax-id-element */
|
|
861
883
|
getTaxIdElement(): StripeTaxIdElement | null;
|
|
862
884
|
/* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
|
|
@@ -405,6 +405,10 @@ export type StripeCheckoutTaxIdInfo = {
|
|
|
405
405
|
export interface StripeCheckoutSession {
|
|
406
406
|
billingAddress: StripeCheckoutContact | null;
|
|
407
407
|
businessName: string | null;
|
|
408
|
+
nameCollection: {
|
|
409
|
+
individualName: string | null;
|
|
410
|
+
businessName: string | null;
|
|
411
|
+
} | null;
|
|
408
412
|
canConfirm: boolean;
|
|
409
413
|
currency: string;
|
|
410
414
|
currencyOptions: Array<StripeCheckoutCurrencyOption> | null;
|
|
@@ -671,6 +675,7 @@ export type StripeCheckoutExpressCheckoutElement = StripeElementBase & {
|
|
|
671
675
|
type AnyBuyerError = {message: string; code: null};
|
|
672
676
|
type ApplyPromotionCodeError =
|
|
673
677
|
| {message: string; code: 'invalidCode'}
|
|
678
|
+
| {message: string; code: 'promotionCodeAmountInsufficient'}
|
|
674
679
|
| AnyBuyerError;
|
|
675
680
|
export type StripeCheckoutApplyPromotionCodeResult =
|
|
676
681
|
| {type: 'success'; session: StripeCheckoutSession}
|
|
@@ -688,6 +693,14 @@ export type StripeCheckoutUpdatePhoneNumberResult =
|
|
|
688
693
|
| {type: 'success'; session: StripeCheckoutSession}
|
|
689
694
|
| {type: 'error'; error: never};
|
|
690
695
|
|
|
696
|
+
export type StripeCheckoutUpdateIndividualNameResult =
|
|
697
|
+
| {type: 'success'; session: StripeCheckoutSession}
|
|
698
|
+
| {type: 'error'; error: never};
|
|
699
|
+
|
|
700
|
+
export type StripeCheckoutUpdateBusinessNameResult =
|
|
701
|
+
| {type: 'success'; session: StripeCheckoutSession}
|
|
702
|
+
| {type: 'error'; error: never};
|
|
703
|
+
|
|
691
704
|
type UpdateEmailError =
|
|
692
705
|
| {message: string; code: 'incompleteEmail'}
|
|
693
706
|
| {message: string; code: 'invalidEmail'};
|
|
@@ -789,6 +802,12 @@ export type StripeCheckoutLoadActionsSuccess = {
|
|
|
789
802
|
updateEmail: (
|
|
790
803
|
email: string | null
|
|
791
804
|
) => Promise<StripeCheckoutUpdateEmailResult>;
|
|
805
|
+
updateIndividualName: (
|
|
806
|
+
individualName: string | null
|
|
807
|
+
) => Promise<StripeCheckoutUpdateIndividualNameResult>;
|
|
808
|
+
updateBusinessName: (
|
|
809
|
+
businessName: string | null
|
|
810
|
+
) => Promise<StripeCheckoutUpdateBusinessNameResult>;
|
|
792
811
|
updateLineItemQuantity: (args: {
|
|
793
812
|
lineItem: string;
|
|
794
813
|
quantity: number;
|
|
@@ -837,6 +856,8 @@ export type StripeCheckoutFormLoadActionsSuccess = Omit<
|
|
|
837
856
|
StripeCheckoutLoadActionsSuccess,
|
|
838
857
|
| 'updateEmail'
|
|
839
858
|
| 'updatePhoneNumber'
|
|
859
|
+
| 'updateIndividualName'
|
|
860
|
+
| 'updateBusinessName'
|
|
840
861
|
| 'updateShippingAddress'
|
|
841
862
|
| 'updateBillingAddress'
|
|
842
863
|
| 'updateTaxIdInfo'
|
|
@@ -857,6 +878,7 @@ export interface StripeCheckoutElementsSdk {
|
|
|
857
878
|
getShippingAddressElement(): StripeAddressElement | null;
|
|
858
879
|
getExpressCheckoutElement(): StripeCheckoutExpressCheckoutElement | null;
|
|
859
880
|
getCurrencySelectorElement(): StripeCurrencySelectorElement | null;
|
|
881
|
+
getContactDetailsElement(): StripeContactDetailsElement | null;
|
|
860
882
|
/* Requires beta header when initializing Stripe: @docs https://docs.stripe.com/tax/advanced/tax-ids?payment-ui=embedded-components#render-tax-id-element */
|
|
861
883
|
getTaxIdElement(): StripeTaxIdElement | null;
|
|
862
884
|
/* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
|
|
@@ -40,6 +40,7 @@ export interface StripePaymentMethodMessagingElementOptions {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* The currency to display.
|
|
43
|
+
* @docs https://docs.stripe.com/js/elements_object/create_element?type=paymentMethodMessaging#elements_create-options-currency
|
|
43
44
|
*/
|
|
44
45
|
currency:
|
|
45
46
|
| 'AUD'
|
|
@@ -52,6 +53,7 @@ export interface StripePaymentMethodMessagingElementOptions {
|
|
|
52
53
|
| 'NOK'
|
|
53
54
|
| 'NZD'
|
|
54
55
|
| 'PLN'
|
|
56
|
+
| 'RON'
|
|
55
57
|
| 'SEK'
|
|
56
58
|
| 'USD';
|
|
57
59
|
|
|
@@ -40,6 +40,7 @@ export interface StripePaymentMethodMessagingElementOptions {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* The currency to display.
|
|
43
|
+
* @docs https://docs.stripe.com/js/elements_object/create_element?type=paymentMethodMessaging#elements_create-options-currency
|
|
43
44
|
*/
|
|
44
45
|
currency:
|
|
45
46
|
| 'AUD'
|
|
@@ -52,6 +53,7 @@ export interface StripePaymentMethodMessagingElementOptions {
|
|
|
52
53
|
| 'NOK'
|
|
53
54
|
| 'NZD'
|
|
54
55
|
| 'PLN'
|
|
56
|
+
| 'RON'
|
|
55
57
|
| 'SEK'
|
|
56
58
|
| 'USD';
|
|
57
59
|
|
|
@@ -413,6 +413,11 @@ export interface StripePaymentElementOptions {
|
|
|
413
413
|
applePay?: ApplePayOption;
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
type PaymentElementLayoutObjectUpdateOptions = Omit<
|
|
417
|
+
LayoutObject,
|
|
418
|
+
'defaultCollapsed' | 'paymentMethodLogoPosition'
|
|
419
|
+
>;
|
|
420
|
+
|
|
416
421
|
/**
|
|
417
422
|
* The subset of `StripePaymentElementOptions` that can be updated after the
|
|
418
423
|
* `PaymentElement` has been created.
|
|
@@ -427,10 +432,15 @@ export type StripePaymentElementUpdateOptions = Pick<
|
|
|
427
432
|
| 'fields'
|
|
428
433
|
| 'readOnly'
|
|
429
434
|
| 'terms'
|
|
430
|
-
| 'layout'
|
|
431
435
|
| 'applePay'
|
|
432
436
|
| 'walletOptions'
|
|
433
|
-
|
|
437
|
+
> & {
|
|
438
|
+
/**
|
|
439
|
+
* Specify a layout to use when rendering a Payment Element.
|
|
440
|
+
* `defaultCollapsed` and `paymentMethodLogoPosition` can't be updated.
|
|
441
|
+
*/
|
|
442
|
+
layout?: Layout | PaymentElementLayoutObjectUpdateOptions;
|
|
443
|
+
};
|
|
434
444
|
|
|
435
445
|
export interface StripePaymentElementChangeEvent {
|
|
436
446
|
/**
|
|
@@ -413,6 +413,11 @@ export interface StripePaymentElementOptions {
|
|
|
413
413
|
applePay?: ApplePayOption;
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
type PaymentElementLayoutObjectUpdateOptions = Omit<
|
|
417
|
+
LayoutObject,
|
|
418
|
+
'defaultCollapsed' | 'paymentMethodLogoPosition'
|
|
419
|
+
>;
|
|
420
|
+
|
|
416
421
|
/**
|
|
417
422
|
* The subset of `StripePaymentElementOptions` that can be updated after the
|
|
418
423
|
* `PaymentElement` has been created.
|
|
@@ -427,10 +432,15 @@ export type StripePaymentElementUpdateOptions = Pick<
|
|
|
427
432
|
| 'fields'
|
|
428
433
|
| 'readOnly'
|
|
429
434
|
| 'terms'
|
|
430
|
-
| 'layout'
|
|
431
435
|
| 'applePay'
|
|
432
436
|
| 'walletOptions'
|
|
433
|
-
|
|
437
|
+
> & {
|
|
438
|
+
/**
|
|
439
|
+
* Specify a layout to use when rendering a Payment Element.
|
|
440
|
+
* `defaultCollapsed` and `paymentMethodLogoPosition` can't be updated.
|
|
441
|
+
*/
|
|
442
|
+
layout?: Layout | PaymentElementLayoutObjectUpdateOptions;
|
|
443
|
+
};
|
|
434
444
|
|
|
435
445
|
export interface StripePaymentElementChangeEvent {
|
|
436
446
|
/**
|
|
@@ -1212,6 +1212,11 @@ export interface Appearance {
|
|
|
1212
1212
|
accordionItemLabelSelectedColorText?: string;
|
|
1213
1213
|
accordionItemLabelSelectedFontWeight?: string;
|
|
1214
1214
|
|
|
1215
|
+
// AccordionItem triggers
|
|
1216
|
+
accordionItemTriggerColor?: string;
|
|
1217
|
+
accordionItemTriggerSelectedColor?: string;
|
|
1218
|
+
accordionItemTriggerHoverColor?: string;
|
|
1219
|
+
|
|
1215
1220
|
// Colors
|
|
1216
1221
|
colorPrimary?: string;
|
|
1217
1222
|
colorBackground?: string;
|
|
@@ -1212,6 +1212,11 @@ export interface Appearance {
|
|
|
1212
1212
|
accordionItemLabelSelectedColorText?: string;
|
|
1213
1213
|
accordionItemLabelSelectedFontWeight?: string;
|
|
1214
1214
|
|
|
1215
|
+
// AccordionItem triggers
|
|
1216
|
+
accordionItemTriggerColor?: string;
|
|
1217
|
+
accordionItemTriggerSelectedColor?: string;
|
|
1218
|
+
accordionItemTriggerHoverColor?: string;
|
|
1219
|
+
|
|
1215
1220
|
// Colors
|
|
1216
1221
|
colorPrimary?: string;
|
|
1217
1222
|
colorBackground?: string;
|
package/package.json
CHANGED
package/src/index.test.ts
CHANGED
|
@@ -225,6 +225,32 @@ describe('Stripe module loader', () => {
|
|
|
225
225
|
});
|
|
226
226
|
});
|
|
227
227
|
|
|
228
|
+
describe.each(['./index', './pure'])(
|
|
229
|
+
'concurrent loadStripe calls (%s.ts)',
|
|
230
|
+
(requirePath) => {
|
|
231
|
+
beforeEach(() => {
|
|
232
|
+
jest.spyOn(console, 'warn').mockReturnValue();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('resolves every call made while Stripe.js is loading', async () => {
|
|
236
|
+
const {loadStripe} = require(requirePath);
|
|
237
|
+
const first = loadStripe('pk_test_foo');
|
|
238
|
+
const second = loadStripe('pk_test_bar');
|
|
239
|
+
|
|
240
|
+
await new Promise((resolve) => setTimeout(resolve));
|
|
241
|
+
expect(
|
|
242
|
+
document.querySelectorAll(`script[src="${SCRIPT_SRC}"]`)
|
|
243
|
+
).toHaveLength(1);
|
|
244
|
+
|
|
245
|
+
window.Stripe = jest.fn((key) => ({key})) as any;
|
|
246
|
+
dispatchScriptEvent('load');
|
|
247
|
+
|
|
248
|
+
await expect(second).resolves.toEqual({key: 'pk_test_bar'});
|
|
249
|
+
await expect(first).resolves.toEqual({key: 'pk_test_foo'});
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
|
|
228
254
|
describe('loadStripe (index.ts)', () => {
|
|
229
255
|
beforeEach(() => {
|
|
230
256
|
jest.spyOn(console, 'warn').mockReturnValue();
|
package/src/shared.ts
CHANGED
|
@@ -154,14 +154,17 @@ export const loadScript = (
|
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
// Cache the in-flight load (including its single retry) so that concurrent
|
|
158
|
+
// calls share it, and only clear the cache once the load has finally failed
|
|
159
|
+
// so that a later call can try again.
|
|
160
|
+
stripePromise = load()
|
|
161
|
+
.catch(() => load())
|
|
162
|
+
.catch((error) => {
|
|
159
163
|
stripePromise = null;
|
|
160
164
|
return Promise.reject(error);
|
|
161
165
|
});
|
|
162
166
|
|
|
163
|
-
|
|
164
|
-
return retryableLoad().catch(() => retryableLoad());
|
|
167
|
+
return stripePromise;
|
|
165
168
|
};
|
|
166
169
|
|
|
167
170
|
export const initStripe = (
|