@funnelsgrove/payments 0.11.13 → 0.11.14
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.
|
@@ -34,9 +34,12 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
|
|
|
34
34
|
const appliedServerUpdateKeyRef = useRef('');
|
|
35
35
|
const [appliedServerUpdateKey, setAppliedServerUpdateKey] = useState('');
|
|
36
36
|
const serverUpdatePromiseRef = useRef(null);
|
|
37
|
+
const [serverUpdateInFlight, setServerUpdateInFlight] = useState(false);
|
|
37
38
|
const [walletAvailable, setWalletAvailable] = useState(initialAvailable !== null && initialAvailable !== void 0 ? initialAvailable : null);
|
|
38
39
|
const normalizedServerUpdateKey = (serverUpdateKey === null || serverUpdateKey === void 0 ? void 0 : serverUpdateKey.trim()) || '';
|
|
39
|
-
const serverUpdatePending =
|
|
40
|
+
const serverUpdatePending = serverUpdateInFlight ||
|
|
41
|
+
Boolean(serverUpdatePromiseRef.current) ||
|
|
42
|
+
Boolean(normalizedServerUpdateKey && appliedServerUpdateKey !== normalizedServerUpdateKey);
|
|
40
43
|
const effectiveWalletAvailable = initialAvailable === true && walletAvailable !== false
|
|
41
44
|
? true
|
|
42
45
|
: walletAvailable;
|
|
@@ -67,6 +70,7 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
|
|
|
67
70
|
return true;
|
|
68
71
|
}
|
|
69
72
|
}
|
|
73
|
+
setServerUpdateInFlight(true);
|
|
70
74
|
const updatePromise = (async () => {
|
|
71
75
|
let updateCallbackFailed = false;
|
|
72
76
|
const updateResult = await checkoutState.checkout.runServerUpdate(async () => {
|
|
@@ -109,6 +113,7 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
|
|
|
109
113
|
finally {
|
|
110
114
|
if (((_a = serverUpdatePromiseRef.current) === null || _a === void 0 ? void 0 : _a.promise) === updatePromise) {
|
|
111
115
|
serverUpdatePromiseRef.current = null;
|
|
116
|
+
setServerUpdateInFlight(false);
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
}, [checkoutAnalytics, checkoutSessionId, checkoutState, normalizedServerUpdateKey, onError, onServerUpdate]);
|