@funnelsgrove/payments 0.7.18 → 0.7.19
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.
|
@@ -86,6 +86,7 @@ const safeDestroyPaymentForm = (instance) => {
|
|
|
86
86
|
};
|
|
87
87
|
function SolidgatePaymentForm({ buttonColor, cardSubmitLabel, checkout, hidden, loadingLabel, onError, onMounted, onSubmit, onVerify, }) {
|
|
88
88
|
const instanceRef = useRef(null);
|
|
89
|
+
const submittedRef = useRef(false);
|
|
89
90
|
const paymentBoundaryRef = useRef(null);
|
|
90
91
|
const mountedReportedRef = useRef(false);
|
|
91
92
|
const onMountedRef = useRef(onMounted);
|
|
@@ -112,9 +113,12 @@ function SolidgatePaymentForm({ buttonColor, cardSubmitLabel, checkout, hidden,
|
|
|
112
113
|
observer.observe(boundary, { childList: true, subtree: true });
|
|
113
114
|
return () => observer.disconnect();
|
|
114
115
|
}, [checkout.attemptId]);
|
|
115
|
-
useEffect(() =>
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
submittedRef.current = false;
|
|
118
|
+
return () => {
|
|
119
|
+
safeDestroyPaymentForm(instanceRef.current);
|
|
120
|
+
instanceRef.current = null;
|
|
121
|
+
};
|
|
118
122
|
}, [checkout.attemptId]);
|
|
119
123
|
const walletButtonType = checkout.display.billingInterval ? 'subscribe' : 'buy';
|
|
120
124
|
return (_jsxs("div", { ref: paymentBoundaryRef, className: 'solidgate-checkout-payment', "data-solidgate-attempt-id": checkout.attemptId, hidden: hidden, "aria-hidden": hidden || undefined, children: [_jsxs("div", { className: 'solidgate-checkout-wallets', children: [_jsx("div", { ref: applePayContainerRef, "data-solidgate-wallet": 'apple-pay' }), _jsx("div", { ref: googlePayContainerRef, "data-solidgate-wallet": 'google-pay' })] }), _jsx(Suspense, { fallback: (_jsx("p", { role: 'status', className: 'solidgate-checkout-status-text', children: loadingLabel })), children: _jsx(SolidgatePayment, { merchantData: checkout.initialization.merchantData, width: '100%', formParams: {
|
|
@@ -162,7 +166,16 @@ function SolidgatePaymentForm({ buttonColor, cardSubmitLabel, checkout, hidden,
|
|
|
162
166
|
mountedReportedRef.current = true;
|
|
163
167
|
onMountedRef.current();
|
|
164
168
|
}
|
|
165
|
-
}, onSubmit:
|
|
169
|
+
}, onSubmit: () => {
|
|
170
|
+
submittedRef.current = true;
|
|
171
|
+
onSubmit();
|
|
172
|
+
}, onVerify: onVerify, onSuccess: onVerify, onFail: onVerify, onError: () => {
|
|
173
|
+
if (submittedRef.current) {
|
|
174
|
+
onVerify();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
onError();
|
|
178
|
+
} }, checkout.attemptId) })] }));
|
|
166
179
|
}
|
|
167
180
|
export function SolidgateCheckoutDialog({ open, request, customerEmail, checkoutAnalytics, content, presentation, onClose, onCustomerEmailCommit, onSuccess, onRetry, onError, onStateChange, }) {
|
|
168
181
|
const copy = useMemo(() => (Object.assign(Object.assign({}, defaultContent), content)), [content]);
|