@stripe/stripe-js 10.0.0-rc.4 → 10.1.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/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/dist/stripe-js/setup-intents.d.mts +40 -0
- package/dist/stripe-js/setup-intents.d.ts +40 -0
- package/dist/stripe-js/stripe.d.mts +12 -0
- package/dist/stripe-js/stripe.d.ts +12 -0
- package/package.json +2 -2
- 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.1.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.1.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.1.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.1.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.1.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.1.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.1.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.1.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);
|
|
@@ -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;
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
CreatePaymentMethodAmazonPayData,
|
|
7
7
|
CreatePaymentMethodAuBecsDebitData,
|
|
8
8
|
CreatePaymentMethodBancontactData,
|
|
9
|
+
CreatePaymentMethodBlikData,
|
|
9
10
|
CreatePaymentMethodCardData,
|
|
10
11
|
CreatePaymentMethodCashappData,
|
|
11
12
|
CreatePaymentMethodIdealData,
|
|
@@ -127,6 +128,45 @@ export interface ConfirmCashappSetupOptions {
|
|
|
127
128
|
handleActions?: boolean;
|
|
128
129
|
}
|
|
129
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Data to be sent with a `stripe.confirmBlikSetup` request.
|
|
133
|
+
* Refer to the [Setup Intents API](https://stripe.com/docs/api/setup_intents/confirm) for a full list of parameters.
|
|
134
|
+
*/
|
|
135
|
+
export interface ConfirmBlikSetupData extends SetupIntentConfirmParams {
|
|
136
|
+
/**
|
|
137
|
+
* Either the `id` of an existing [PaymentMethod](https://stripe.com/docs/api/payment_methods), or an object containing data to create a `PaymentMethod` with.
|
|
138
|
+
* This field is optional if a `PaymentMethod` has already been attached to this `SetupIntent`.
|
|
139
|
+
*
|
|
140
|
+
* @recommended
|
|
141
|
+
*/
|
|
142
|
+
payment_method?: string | Omit<CreatePaymentMethodBlikData, 'type'>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* An object containing payment-method-specific configuration to confirm the [SetupIntent](https://stripe.com/docs/api/setup_intents) with.
|
|
146
|
+
*/
|
|
147
|
+
payment_method_options: {
|
|
148
|
+
/**
|
|
149
|
+
* A configuration for this BLIK setup.
|
|
150
|
+
*/
|
|
151
|
+
blik: {
|
|
152
|
+
/**
|
|
153
|
+
* Your customer's 6-digit BLIK code.
|
|
154
|
+
*/
|
|
155
|
+
code: string;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* An options object to control the behavior of `stripe.confirmBlikSetup`.
|
|
162
|
+
*/
|
|
163
|
+
export interface ConfirmBlikSetupOptions {
|
|
164
|
+
/**
|
|
165
|
+
* Set this to `false` if you want to manually determine if the confirmation has succeeded or failed.
|
|
166
|
+
*/
|
|
167
|
+
handleActions?: boolean;
|
|
168
|
+
}
|
|
169
|
+
|
|
130
170
|
/**
|
|
131
171
|
* Data to be sent with a `stripe.confirmIdealSetup` request.
|
|
132
172
|
* Refer to the [Setup Intents API](https://stripe.com/docs/api/setup_intents/confirm) for a full list of parameters.
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
CreatePaymentMethodAmazonPayData,
|
|
7
7
|
CreatePaymentMethodAuBecsDebitData,
|
|
8
8
|
CreatePaymentMethodBancontactData,
|
|
9
|
+
CreatePaymentMethodBlikData,
|
|
9
10
|
CreatePaymentMethodCardData,
|
|
10
11
|
CreatePaymentMethodCashappData,
|
|
11
12
|
CreatePaymentMethodIdealData,
|
|
@@ -127,6 +128,45 @@ export interface ConfirmCashappSetupOptions {
|
|
|
127
128
|
handleActions?: boolean;
|
|
128
129
|
}
|
|
129
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Data to be sent with a `stripe.confirmBlikSetup` request.
|
|
133
|
+
* Refer to the [Setup Intents API](https://stripe.com/docs/api/setup_intents/confirm) for a full list of parameters.
|
|
134
|
+
*/
|
|
135
|
+
export interface ConfirmBlikSetupData extends SetupIntentConfirmParams {
|
|
136
|
+
/**
|
|
137
|
+
* Either the `id` of an existing [PaymentMethod](https://stripe.com/docs/api/payment_methods), or an object containing data to create a `PaymentMethod` with.
|
|
138
|
+
* This field is optional if a `PaymentMethod` has already been attached to this `SetupIntent`.
|
|
139
|
+
*
|
|
140
|
+
* @recommended
|
|
141
|
+
*/
|
|
142
|
+
payment_method?: string | Omit<CreatePaymentMethodBlikData, 'type'>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* An object containing payment-method-specific configuration to confirm the [SetupIntent](https://stripe.com/docs/api/setup_intents) with.
|
|
146
|
+
*/
|
|
147
|
+
payment_method_options: {
|
|
148
|
+
/**
|
|
149
|
+
* A configuration for this BLIK setup.
|
|
150
|
+
*/
|
|
151
|
+
blik: {
|
|
152
|
+
/**
|
|
153
|
+
* Your customer's 6-digit BLIK code.
|
|
154
|
+
*/
|
|
155
|
+
code: string;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* An options object to control the behavior of `stripe.confirmBlikSetup`.
|
|
162
|
+
*/
|
|
163
|
+
export interface ConfirmBlikSetupOptions {
|
|
164
|
+
/**
|
|
165
|
+
* Set this to `false` if you want to manually determine if the confirmation has succeeded or failed.
|
|
166
|
+
*/
|
|
167
|
+
handleActions?: boolean;
|
|
168
|
+
}
|
|
169
|
+
|
|
130
170
|
/**
|
|
131
171
|
* Data to be sent with a `stripe.confirmIdealSetup` request.
|
|
132
172
|
* Refer to the [Setup Intents API](https://stripe.com/docs/api/setup_intents/confirm) for a full list of parameters.
|
|
@@ -930,6 +930,18 @@ export interface Stripe {
|
|
|
930
930
|
data?: setupIntents.ConfirmBancontactSetupData
|
|
931
931
|
): Promise<SetupIntentResult>;
|
|
932
932
|
|
|
933
|
+
/**
|
|
934
|
+
* Use `stripe.confirmBlikSetup` when the customer submits a custom BLIK setup form.
|
|
935
|
+
* When called, it confirms the [SetupIntent](https://stripe.com/docs/api/setup_intents) with the BLIK code and billing details in `data`, then waits for the customer to authorize the mandate in their banking app.
|
|
936
|
+
*
|
|
937
|
+
* @docs https://stripe.com/docs/js/setup_intents/confirm_blik_setup
|
|
938
|
+
*/
|
|
939
|
+
confirmBlikSetup(
|
|
940
|
+
clientSecret: string,
|
|
941
|
+
data: setupIntents.ConfirmBlikSetupData,
|
|
942
|
+
options?: setupIntents.ConfirmBlikSetupOptions
|
|
943
|
+
): Promise<SetupIntentResult>;
|
|
944
|
+
|
|
933
945
|
/**
|
|
934
946
|
* Use `stripe.confirmCardSetup` in the [Setup Intents API flow](https://stripe.com/docs/payments/save-and-reuse) when the customer submits your payment form.
|
|
935
947
|
* When called, it will confirm the [SetupIntent](https://stripe.com/docs/api/setup_intents) with `data` you provide and carry out 3DS or other next actions if they are required.
|
|
@@ -930,6 +930,18 @@ export interface Stripe {
|
|
|
930
930
|
data?: setupIntents.ConfirmBancontactSetupData
|
|
931
931
|
): Promise<SetupIntentResult>;
|
|
932
932
|
|
|
933
|
+
/**
|
|
934
|
+
* Use `stripe.confirmBlikSetup` when the customer submits a custom BLIK setup form.
|
|
935
|
+
* When called, it confirms the [SetupIntent](https://stripe.com/docs/api/setup_intents) with the BLIK code and billing details in `data`, then waits for the customer to authorize the mandate in their banking app.
|
|
936
|
+
*
|
|
937
|
+
* @docs https://stripe.com/docs/js/setup_intents/confirm_blik_setup
|
|
938
|
+
*/
|
|
939
|
+
confirmBlikSetup(
|
|
940
|
+
clientSecret: string,
|
|
941
|
+
data: setupIntents.ConfirmBlikSetupData,
|
|
942
|
+
options?: setupIntents.ConfirmBlikSetupOptions
|
|
943
|
+
): Promise<SetupIntentResult>;
|
|
944
|
+
|
|
933
945
|
/**
|
|
934
946
|
* Use `stripe.confirmCardSetup` in the [Setup Intents API flow](https://stripe.com/docs/payments/save-and-reuse) when the customer submits your payment form.
|
|
935
947
|
* When called, it will confirm the [SetupIntent](https://stripe.com/docs/api/setup_intents) with `data` you provide and carry out 3DS or other next actions if they are required.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stripe/stripe-js",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"description": "Stripe.js loading utility",
|
|
5
5
|
"repository": "github:stripe/stripe-js",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"jsnext:main": "lib/index.mjs",
|
|
9
9
|
"types": "lib/index.d.ts",
|
|
10
10
|
"typings": "lib/index.d.ts",
|
|
11
|
-
"releaseCandidate":
|
|
11
|
+
"releaseCandidate": false,
|
|
12
12
|
"scripts": {
|
|
13
13
|
"test": "yarn lint && yarn test:unit && yarn test:package-types && yarn test:types && yarn typecheck",
|
|
14
14
|
"test:unit": "jest",
|
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 = (
|