@funnelsgrove/payments 0.15.1 → 0.15.4
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.
|
@@ -53,6 +53,15 @@ const normalizeStripeCheckoutProviderError = (error) => {
|
|
|
53
53
|
};
|
|
54
54
|
export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAnalytics, checkoutSessionId, returnUrl, confirmEmail = true, customerEmail, className, options, availabilityPaymentMethods = ['applePay'], initialAvailable, keepInitialAvailableOnReady = false, serverUpdateKey, supportedCountries, onServerUpdate, onAvailabilityChange, onCancel, onError, onPaymentInfoSubmitted, onPaymentRejected, onSuccess, unsupportedCountryMessage, }) {
|
|
55
55
|
const checkoutState = useCheckout();
|
|
56
|
+
const [loadRetry, setLoadRetry] = useState(0);
|
|
57
|
+
const loadRetryUsedRef = useRef(false);
|
|
58
|
+
const walletReadyRef = useRef(false);
|
|
59
|
+
const loadRetryTimerRef = useRef(null);
|
|
60
|
+
useEffect(() => () => {
|
|
61
|
+
if (loadRetryTimerRef.current !== null) {
|
|
62
|
+
clearTimeout(loadRetryTimerRef.current);
|
|
63
|
+
}
|
|
64
|
+
}, []);
|
|
56
65
|
const appliedServerUpdateKeyRef = useRef('');
|
|
57
66
|
const [appliedServerUpdateKey, setAppliedServerUpdateKey] = useState('');
|
|
58
67
|
const serverUpdatePromiseRef = useRef(null);
|
|
@@ -312,10 +321,27 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
|
|
|
312
321
|
]
|
|
313
322
|
.filter(Boolean)
|
|
314
323
|
.join(' '), children: _jsx(ExpressCheckoutElementWithCancel, { options: resolvedOptions, onCancel: handleCancel, onClick: handleClick, onConfirm: (event) => void handleConfirm(event), onLoadError: ({ error }) => {
|
|
324
|
+
if (loadRetryTimerRef.current !== null) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (!walletReadyRef.current && !loadRetryUsedRef.current) {
|
|
328
|
+
loadRetryUsedRef.current = true;
|
|
329
|
+
// Replace only the failed Element, retaining the Checkout Session.
|
|
330
|
+
loadRetryTimerRef.current = setTimeout(() => {
|
|
331
|
+
loadRetryTimerRef.current = null;
|
|
332
|
+
setLoadRetry(1);
|
|
333
|
+
}, 1000);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
315
336
|
setWalletAvailable(false);
|
|
316
337
|
onAvailabilityChange === null || onAvailabilityChange === void 0 ? void 0 : onAvailabilityChange(false);
|
|
317
338
|
reportFailure(error.message || 'Unable to load wallet checkout.', 'wallet_load');
|
|
318
339
|
}, onReady: ({ availablePaymentMethods: availablePaymentMethodsMap }) => {
|
|
340
|
+
walletReadyRef.current = true;
|
|
341
|
+
if (loadRetryTimerRef.current !== null) {
|
|
342
|
+
clearTimeout(loadRetryTimerRef.current);
|
|
343
|
+
loadRetryTimerRef.current = null;
|
|
344
|
+
}
|
|
319
345
|
const available = Boolean(availabilityPaymentMethods.some((paymentMethod) => availablePaymentMethodsMap === null || availablePaymentMethodsMap === void 0 ? void 0 : availablePaymentMethodsMap[paymentMethod]));
|
|
320
346
|
const resolvedAvailable = available || (keepInitialAvailableOnReady && initialAvailable === true);
|
|
321
347
|
setWalletAvailable(resolvedAvailable);
|
|
@@ -323,7 +349,7 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
|
|
|
323
349
|
if (resolvedAvailable) {
|
|
324
350
|
onError === null || onError === void 0 ? void 0 : onError(null);
|
|
325
351
|
}
|
|
326
|
-
} }) })), _jsx("style", { children: stripeExpressCheckoutButtonStyles })] }));
|
|
352
|
+
} }, loadRetry) })), _jsx("style", { children: stripeExpressCheckoutButtonStyles })] }));
|
|
327
353
|
}
|
|
328
354
|
const stripeExpressCheckoutButtonStyles = `
|
|
329
355
|
.stripe-express-checkout-button {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelsgrove/payments",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"test:run": "vitest run --passWithNoTests"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@funnelsgrove/analytics": "^0.1.
|
|
36
|
-
"@funnelsgrove/runtime": "
|
|
35
|
+
"@funnelsgrove/analytics": "^0.1.101",
|
|
36
|
+
"@funnelsgrove/runtime": "0.14.1",
|
|
37
37
|
"@solidgate/react-sdk": "1.34.0",
|
|
38
38
|
"@stripe/react-stripe-js": "^5.6.0",
|
|
39
39
|
"@stripe/stripe-js": "^8.7.0",
|