@funnelsgrove/payments 0.7.18 → 0.7.20
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]);
|
|
@@ -75,37 +75,40 @@ export function WalletSubscriptionCheckoutSlot({ amountCents, appearance, availa
|
|
|
75
75
|
intentKey,
|
|
76
76
|
});
|
|
77
77
|
}, []);
|
|
78
|
+
const autoWalletClientSecret = session.activeClientSecret;
|
|
79
|
+
const autoWalletIntentKey = session.intentKey;
|
|
80
|
+
const autoWalletLoading = session.loading.wallet;
|
|
81
|
+
const prepareWalletCheckout = session.prepareWalletCheckout;
|
|
78
82
|
useEffect(() => {
|
|
79
83
|
if (slotDisabled ||
|
|
80
84
|
suspended ||
|
|
81
85
|
!expressCheckoutAllowed ||
|
|
82
86
|
walletAvailable === false ||
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
autoWalletLoading ||
|
|
88
|
+
autoWalletClientSecret) {
|
|
85
89
|
return;
|
|
86
90
|
}
|
|
87
|
-
if (autoWalletPreparationIntentKeyRef.current ===
|
|
91
|
+
if (autoWalletPreparationIntentKeyRef.current === autoWalletIntentKey) {
|
|
88
92
|
return;
|
|
89
93
|
}
|
|
90
|
-
autoWalletPreparationIntentKeyRef.current =
|
|
91
|
-
void
|
|
92
|
-
.prepareWalletCheckout({
|
|
94
|
+
autoWalletPreparationIntentKeyRef.current = autoWalletIntentKey;
|
|
95
|
+
void prepareWalletCheckout({
|
|
93
96
|
checkoutStartSource: 'wallet_render',
|
|
94
97
|
paymentMethod: analyticsPaymentMethod,
|
|
95
98
|
})
|
|
96
99
|
.then((readyClientSecret) => {
|
|
97
100
|
if (!readyClientSecret) {
|
|
98
|
-
reportWalletPreparationFailure(
|
|
101
|
+
reportWalletPreparationFailure(autoWalletIntentKey);
|
|
99
102
|
}
|
|
100
103
|
});
|
|
101
104
|
}, [
|
|
102
105
|
analyticsPaymentMethod,
|
|
106
|
+
autoWalletClientSecret,
|
|
107
|
+
autoWalletIntentKey,
|
|
108
|
+
autoWalletLoading,
|
|
103
109
|
expressCheckoutAllowed,
|
|
110
|
+
prepareWalletCheckout,
|
|
104
111
|
reportWalletPreparationFailure,
|
|
105
|
-
session.activeClientSecret,
|
|
106
|
-
session.intentKey,
|
|
107
|
-
session.loading.wallet,
|
|
108
|
-
session.prepareWalletCheckout,
|
|
109
112
|
slotDisabled,
|
|
110
113
|
suspended,
|
|
111
114
|
walletAvailable,
|
|
@@ -136,7 +139,7 @@ export function WalletSubscriptionCheckoutSlot({ amountCents, appearance, availa
|
|
|
136
139
|
intentKey: session.intentKey,
|
|
137
140
|
});
|
|
138
141
|
void session.restartWalletCheckout({
|
|
139
|
-
checkoutStartSource: '
|
|
142
|
+
checkoutStartSource: 'wallet_click',
|
|
140
143
|
paymentMethod: analyticsPaymentMethod,
|
|
141
144
|
});
|
|
142
145
|
return;
|
|
@@ -157,7 +160,7 @@ export function WalletSubscriptionCheckoutSlot({ amountCents, appearance, availa
|
|
|
157
160
|
}
|
|
158
161
|
setWalletCheckoutStartedAfterClickIntentKey(session.intentKey);
|
|
159
162
|
const readyClientSecret = await session.prepareWalletCheckout({
|
|
160
|
-
checkoutStartSource: '
|
|
163
|
+
checkoutStartSource: 'wallet_click',
|
|
161
164
|
paymentMethod: analyticsPaymentMethod,
|
|
162
165
|
});
|
|
163
166
|
if (!readyClientSecret) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelsgrove/payments",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.20",
|
|
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": "^0.7.
|
|
35
|
+
"@funnelsgrove/analytics": "^0.1.78",
|
|
36
|
+
"@funnelsgrove/runtime": "^0.7.29",
|
|
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",
|