@funnelsgrove/payments 0.7.16 → 0.7.18
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,14 +86,38 @@ 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 paymentBoundaryRef = useRef(null);
|
|
90
|
+
const mountedReportedRef = useRef(false);
|
|
91
|
+
const onMountedRef = useRef(onMounted);
|
|
89
92
|
const applePayContainerRef = useRef(null);
|
|
90
93
|
const googlePayContainerRef = useRef(null);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
onMountedRef.current = onMounted;
|
|
96
|
+
}, [onMounted]);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
mountedReportedRef.current = false;
|
|
99
|
+
const boundary = paymentBoundaryRef.current;
|
|
100
|
+
if (!boundary) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const reportIframeMounted = () => {
|
|
104
|
+
if (!mountedReportedRef.current
|
|
105
|
+
&& boundary.querySelector('iframe#solid-payment-form-iframe, iframe[name="solid-payment-form-iframe"]')) {
|
|
106
|
+
mountedReportedRef.current = true;
|
|
107
|
+
onMountedRef.current();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
reportIframeMounted();
|
|
111
|
+
const observer = new MutationObserver(reportIframeMounted);
|
|
112
|
+
observer.observe(boundary, { childList: true, subtree: true });
|
|
113
|
+
return () => observer.disconnect();
|
|
114
|
+
}, [checkout.attemptId]);
|
|
91
115
|
useEffect(() => () => {
|
|
92
116
|
safeDestroyPaymentForm(instanceRef.current);
|
|
93
117
|
instanceRef.current = null;
|
|
94
118
|
}, [checkout.attemptId]);
|
|
95
119
|
const walletButtonType = checkout.display.billingInterval ? 'subscribe' : 'buy';
|
|
96
|
-
return (_jsxs("div", { 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: {
|
|
120
|
+
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: {
|
|
97
121
|
autoFocus: false,
|
|
98
122
|
isSolidLogoVisible: true,
|
|
99
123
|
submitButtonText: cardSubmitLabel,
|
|
@@ -133,7 +157,12 @@ function SolidgatePaymentForm({ buttonColor, cardSubmitLabel, checkout, hidden,
|
|
|
133
157
|
}
|
|
134
158
|
}
|
|
135
159
|
instanceRef.current = instance;
|
|
136
|
-
}, onMounted:
|
|
160
|
+
}, onMounted: () => {
|
|
161
|
+
if (!mountedReportedRef.current) {
|
|
162
|
+
mountedReportedRef.current = true;
|
|
163
|
+
onMountedRef.current();
|
|
164
|
+
}
|
|
165
|
+
}, onSubmit: onSubmit, onVerify: onVerify, onSuccess: onVerify, onFail: onVerify, onError: onError }, checkout.attemptId) })] }));
|
|
137
166
|
}
|
|
138
167
|
export function SolidgateCheckoutDialog({ open, request, customerEmail, checkoutAnalytics, content, presentation, onClose, onCustomerEmailCommit, onSuccess, onRetry, onError, onStateChange, }) {
|
|
139
168
|
const copy = useMemo(() => (Object.assign(Object.assign({}, defaultContent), content)), [content]);
|
|
@@ -361,8 +390,7 @@ export function SolidgateCheckoutDialog({ open, request, customerEmail, checkout
|
|
|
361
390
|
return null;
|
|
362
391
|
}
|
|
363
392
|
const showForm = view.state === 'ready'
|
|
364
|
-
|| view.state === 'submitting'
|
|
365
|
-
|| view.state === 'verifying';
|
|
393
|
+
|| view.state === 'submitting';
|
|
366
394
|
const statusMessage = view.state === 'loading'
|
|
367
395
|
? copy.loading
|
|
368
396
|
: view.state === 'submitting'
|