@funnelsgrove/payments 0.60.0 → 0.61.0
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.
- package/dist/generated/package-version.d.ts +1 -1
- package/dist/generated/package-version.js +1 -1
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.js +10 -2
- package/dist/providers/solidgate/components/SolidgatePaymentForm.d.ts +3 -1
- package/dist/providers/solidgate/components/SolidgatePaymentForm.js +7 -2
- package/dist/providers/solidgate/components/useSolidgateWalletReadiness.d.ts +16 -0
- package/dist/providers/solidgate/components/useSolidgateWalletReadiness.js +87 -0
- package/dist/providers/stripe/components/SharedStripeCheckoutV2Form.internal.js +2 -1
- package/dist/providers/stripe/components/StripeCheckoutExpressCheckoutButton.js +2 -1
- package/dist/providers/stripe/hooks/useStripeSubscriptionWalletFirstRequest.js +2 -1
- package/dist/providers/stripe/services/checkout/checkoutReturnUrl.d.ts +5 -0
- package/dist/providers/stripe/services/checkout/checkoutReturnUrl.js +14 -0
- package/dist/services/checkoutObservability.service.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PAYMENTS_PACKAGE_VERSION = "0.
|
|
1
|
+
export declare const PAYMENTS_PACKAGE_VERSION = "0.61.0";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by scripts/generate-package-version.mjs.
|
|
2
|
-
export const PAYMENTS_PACKAGE_VERSION = "0.
|
|
2
|
+
export const PAYMENTS_PACKAGE_VERSION = "0.61.0";
|
|
@@ -9,6 +9,7 @@ import { isSolidgateCustomerDecline, solidgateDeclineMessage } from '../services
|
|
|
9
9
|
import { solidgateFailureDetails } from '../services/solidgateFailureDetails.js';
|
|
10
10
|
import { SolidgateCheckoutSummary } from './SolidgateCheckoutSummary.js';
|
|
11
11
|
import { SolidgatePaymentForm } from './SolidgatePaymentForm.js';
|
|
12
|
+
import { useSolidgateWalletReadiness } from './useSolidgateWalletReadiness.js';
|
|
12
13
|
import { solidgateCheckoutDialogStyles } from './SolidgateCheckoutDialog.styles.js';
|
|
13
14
|
const defaultContent = {
|
|
14
15
|
title: 'Secure checkout',
|
|
@@ -42,6 +43,7 @@ const initialView = {
|
|
|
42
43
|
};
|
|
43
44
|
const isAbortError = (error) => (error instanceof DOMException && error.name === 'AbortError');
|
|
44
45
|
export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, customerEmail, checkoutAnalytics, content, presentation, onClose, onCustomerEmailCommit, onSuccess, onRetry, onError, onPreparationStart, onStateChange, onPaymentPendingChange, }) {
|
|
46
|
+
var _a;
|
|
45
47
|
const copy = useMemo(() => (Object.assign(Object.assign({}, defaultContent), content)), [content]);
|
|
46
48
|
const [view, setView] = useState(initialView);
|
|
47
49
|
const [retryRequest, setRetryRequest] = useState(null);
|
|
@@ -149,6 +151,8 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
149
151
|
}, []);
|
|
150
152
|
const requiresEmailCommit = Boolean(onCustomerEmailCommit);
|
|
151
153
|
const startedAttemptRef = useRef(null);
|
|
154
|
+
const walletReadiness = useSolidgateWalletReadiness(checkoutAnalyticsRef, layout === 'wallet' && view.state === 'ready' ? (_a = view.checkout) === null || _a === void 0 ? void 0 : _a.attemptId : undefined);
|
|
155
|
+
const { startPreparation: startWalletPreparation, finishPreparation: finishWalletPreparation } = walletReadiness;
|
|
152
156
|
const active = open && (layout !== 'wallet' || Boolean(normalizedCustomerEmail));
|
|
153
157
|
useEffect(() => {
|
|
154
158
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -182,10 +186,13 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
182
186
|
setState(initialView);
|
|
183
187
|
}
|
|
184
188
|
});
|
|
189
|
+
const walletPreparation = layout === 'wallet' ? startWalletPreparation() : null;
|
|
185
190
|
void prepareSolidgateCheckout(Object.assign(Object.assign({}, preparedRequest), { signal: controller.signal }))
|
|
186
191
|
.then((checkout) => {
|
|
187
192
|
if (!controller.signal.aborted) {
|
|
188
193
|
declinedAttemptRef.current = null;
|
|
194
|
+
if (walletPreparation)
|
|
195
|
+
finishWalletPreparation(walletPreparation, checkout.attemptId);
|
|
189
196
|
setState({ state: 'ready', checkout, canResumeVerification: false });
|
|
190
197
|
if (layout !== 'wallet') {
|
|
191
198
|
void trackSolidgateCheckoutEvent('checkout_started', checkout.attemptId, checkoutAnalyticsRef.current);
|
|
@@ -207,7 +214,8 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
207
214
|
}
|
|
208
215
|
});
|
|
209
216
|
return () => controller.abort();
|
|
210
|
-
}, [checkoutKey, committedEmail, layout, onPreparationStart, active, requiresEmailCommit, setState, trackFailure
|
|
217
|
+
}, [checkoutKey, committedEmail, layout, onPreparationStart, active, requiresEmailCommit, setState, trackFailure,
|
|
218
|
+
startWalletPreparation, finishWalletPreparation]);
|
|
211
219
|
const paymentFormMounted = Boolean(view.checkout && mountedPaymentAttemptId === view.checkout.attemptId);
|
|
212
220
|
const showPreparingLoader = view.state === 'loading'
|
|
213
221
|
|| (view.state === 'ready' && !paymentFormMounted);
|
|
@@ -403,7 +411,7 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
403
411
|
void trackSolidgateCheckoutEvent('add_payment_info', ((_c = view.checkout) === null || _c === void 0 ? void 0 : _c.attemptId) || '', checkoutAnalyticsRef.current);
|
|
404
412
|
}
|
|
405
413
|
setState(Object.assign(Object.assign({}, view), { state: 'submitting' }));
|
|
406
|
-
}, onVerify: () => void verifyCanonicalStatus(true), onPaymentResult: () => void verifyCanonicalStatus(false), onError: (error) => {
|
|
414
|
+
}, onVerify: () => void verifyCanonicalStatus(true), onPaymentResult: () => void verifyCanonicalStatus(false), onWalletsChange: layout === 'wallet' ? walletReadiness.reportWalletsReady : undefined, onError: (error) => {
|
|
407
415
|
var _a, _b;
|
|
408
416
|
setState(Object.assign(Object.assign({}, view), { state: 'recoverable_error', canResumeVerification: false }));
|
|
409
417
|
trackFailure(copyRef.current.error, 'payment_form', (_a = view.checkout) === null || _a === void 0 ? void 0 : _a.attemptId, solidgateFailureDetails(error));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SolidgateCheckoutPreparation } from '../services/solidgate.service.js';
|
|
2
|
-
|
|
2
|
+
import type { SolidgateWalletPaymentMethod } from './useSolidgateWalletReadiness.js';
|
|
3
|
+
export declare function SolidgatePaymentForm({ buttonColor, walletOnly, cardSubmitLabel, secureLabel, cardLabel, paymentMethodLabel, checkout, hidden, challengeActive, paymentPending, onError, onMounted, onSubmit, onVerify, onPaymentResult, onWalletsChange, }: {
|
|
3
4
|
buttonColor: string;
|
|
4
5
|
walletOnly?: boolean;
|
|
5
6
|
cardSubmitLabel: string;
|
|
@@ -16,4 +17,5 @@ export declare function SolidgatePaymentForm({ buttonColor, walletOnly, cardSubm
|
|
|
16
17
|
onSubmit: () => void;
|
|
17
18
|
onVerify: () => void;
|
|
18
19
|
onPaymentResult: () => void;
|
|
20
|
+
onWalletsChange?: (methods: readonly SolidgateWalletPaymentMethod[]) => void;
|
|
19
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useId, useRef, useState } from 'react';
|
|
4
4
|
import { PaymentBrandMark, SecurityLockIcon } from '../../stripe/components/CheckoutBrandAssets.js';
|
|
5
5
|
import { SolidgateSdkPayment } from './SolidgateSdkPayment.js';
|
|
6
|
-
export function SolidgatePaymentForm({ buttonColor, walletOnly = false, cardSubmitLabel, secureLabel, cardLabel = 'Credit card', paymentMethodLabel = 'Payment method', checkout, hidden, challengeActive = false, paymentPending = false, onError, onMounted, onSubmit, onVerify, onPaymentResult, }) {
|
|
6
|
+
export function SolidgatePaymentForm({ buttonColor, walletOnly = false, cardSubmitLabel, secureLabel, cardLabel = 'Credit card', paymentMethodLabel = 'Payment method', checkout, hidden, challengeActive = false, paymentPending = false, onError, onMounted, onSubmit, onVerify, onPaymentResult, onWalletsChange, }) {
|
|
7
7
|
const panelId = useId();
|
|
8
8
|
const [wallets, setWallets] = useState([]);
|
|
9
9
|
const [selectedMethod, setSelectedMethod] = useState('wallet');
|
|
@@ -19,6 +19,9 @@ export function SolidgatePaymentForm({ buttonColor, walletOnly = false, cardSubm
|
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
onMountedRef.current = onMounted;
|
|
21
21
|
}, [onMounted]);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
onWalletsChange === null || onWalletsChange === void 0 ? void 0 : onWalletsChange(wallets.map((label) => label === 'Apple Pay' ? 'apple_pay' : 'google_pay'));
|
|
24
|
+
}, [onWalletsChange, wallets]);
|
|
22
25
|
useEffect(() => {
|
|
23
26
|
mountedReportedRef.current = false;
|
|
24
27
|
const boundary = paymentBoundaryRef.current;
|
|
@@ -44,7 +47,9 @@ export function SolidgatePaymentForm({ buttonColor, walletOnly = false, cardSubm
|
|
|
44
47
|
return () => observer.disconnect();
|
|
45
48
|
}, [checkout.attemptId]);
|
|
46
49
|
const walletButtonType = checkout.display.billingInterval ? 'subscribe' : 'buy';
|
|
47
|
-
return (_jsxs("div", { ref: paymentBoundaryRef, className: `solidgate-checkout-payment${secureLabel && !walletOnly ? ' is-branded' : ''}`, "data-solidgate-attempt-id": checkout.attemptId, hidden: hidden, "aria-hidden": hidden || undefined, children: [showTabs ? (_jsxs("div", { className: 'solidgate-checkout-methods', role: 'tablist', "aria-label": paymentMethodLabel, children: [_jsx("button", { type: 'button', role: 'tab', id: `${panelId}-wallet-tab`, "aria-label": wallets.join(' / '), disabled: paymentPending, "aria-selected": selectedMethod === 'wallet', "aria-controls": `${panelId}-wallet`, className: 'solidgate-checkout-method', onClick: () => setSelectedMethod('wallet'), children: wallets.map((label) => _jsx(PaymentBrandMark, { label: label, className: 'solidgate-checkout-tab-wallet' }, label)) }), _jsxs("button", { type: 'button', role: 'tab', id: `${panelId}-card-tab`, disabled: paymentPending, "aria-selected": selectedMethod === 'card', "aria-controls": `${panelId}-card`, className: 'solidgate-checkout-method', onClick: () => setSelectedMethod('card'), children: [_jsx("strong", { children: cardLabel }), _jsx("span", { className: 'solidgate-checkout-tab-brands', "aria-hidden": 'true', children: ['Visa', 'Mastercard', 'Maestro', 'Discover'].map((label) => (_jsx(PaymentBrandMark, { label: label, className: 'solidgate-checkout-tab-brand' }, label))) })] })] })) : null, !walletOnly && secureLabel && wallets.length > 0 && showWallet ? (_jsxs("p", { className: 'solidgate-checkout-secure', children: [_jsx(SecurityLockIcon, {}), secureLabel] })) : null, _jsxs("div", { className: 'solidgate-checkout-wallets', id: `${panelId}-wallet`, role: showTabs ? 'tabpanel' : undefined, "aria-labelledby": showTabs ? `${panelId}-wallet-tab` : undefined, hidden: !showWallet, inert: paymentPending, children: [_jsx("div", { ref: applePayContainerRef, "data-solidgate-wallet": 'apple-pay' }), _jsx("div", { ref: googlePayContainerRef, "data-solidgate-wallet": 'google-pay' })] }), _jsx("div", { className: 'solidgate-checkout-card', id: `${panelId}-card`, role: showTabs ? 'tabpanel' : undefined, "aria-labelledby": showTabs ? `${panelId}-card-tab` : undefined,
|
|
50
|
+
return (_jsxs("div", { ref: paymentBoundaryRef, className: `solidgate-checkout-payment${secureLabel && !walletOnly ? ' is-branded' : ''}`, "data-solidgate-attempt-id": checkout.attemptId, hidden: hidden, "aria-hidden": hidden || undefined, children: [showTabs ? (_jsxs("div", { className: 'solidgate-checkout-methods', role: 'tablist', "aria-label": paymentMethodLabel, children: [_jsx("button", { type: 'button', role: 'tab', id: `${panelId}-wallet-tab`, "aria-label": wallets.join(' / '), disabled: paymentPending, "aria-selected": selectedMethod === 'wallet', "aria-controls": `${panelId}-wallet`, className: 'solidgate-checkout-method', onClick: () => setSelectedMethod('wallet'), children: wallets.map((label) => _jsx(PaymentBrandMark, { label: label, className: 'solidgate-checkout-tab-wallet' }, label)) }), _jsxs("button", { type: 'button', role: 'tab', id: `${panelId}-card-tab`, disabled: paymentPending, "aria-selected": selectedMethod === 'card', "aria-controls": `${panelId}-card`, className: 'solidgate-checkout-method', onClick: () => setSelectedMethod('card'), children: [_jsx("strong", { children: cardLabel }), _jsx("span", { className: 'solidgate-checkout-tab-brands', "aria-hidden": 'true', children: ['Visa', 'Mastercard', 'Maestro', 'Discover'].map((label) => (_jsx(PaymentBrandMark, { label: label, className: 'solidgate-checkout-tab-brand' }, label))) })] })] })) : null, !walletOnly && secureLabel && wallets.length > 0 && showWallet ? (_jsxs("p", { className: 'solidgate-checkout-secure', children: [_jsx(SecurityLockIcon, {}), secureLabel] })) : null, _jsxs("div", { className: 'solidgate-checkout-wallets', id: `${panelId}-wallet`, role: showTabs ? 'tabpanel' : undefined, "aria-labelledby": showTabs ? `${panelId}-wallet-tab` : undefined, hidden: !showWallet, inert: paymentPending, children: [_jsx("div", { ref: applePayContainerRef, "data-solidgate-wallet": 'apple-pay' }), _jsx("div", { ref: googlePayContainerRef, "data-solidgate-wallet": 'google-pay' })] }), _jsx("div", { className: 'solidgate-checkout-card', id: `${panelId}-card`, role: showTabs ? 'tabpanel' : undefined, "aria-labelledby": showTabs ? `${panelId}-card-tab` : undefined,
|
|
51
|
+
// Wallet buttons wait for this iframe; iOS Safari throttles it under display:none. The SDK keeps a disabled form invisible.
|
|
52
|
+
hidden: !showCard && !walletOnly, children: _jsx(SolidgateSdkPayment, { onInitializationError: onError, merchantData: checkout.initialization.merchantData, width: '100%', formParams: Object.assign({ autoFocus: false, enabled: !walletOnly, isSolidLogoVisible: false, submitButtonText: cardSubmitLabel }, (secureLabel ? { cardNumberLabel: 'Card number', cardExpiryDateLabel: 'Expiration date', cardCvvLabel: 'Security code' } : {})), styles: {
|
|
48
53
|
form_body: {
|
|
49
54
|
'font-family': 'Inter, Arial, sans-serif',
|
|
50
55
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { SolidgateCheckoutAnalyticsContext } from './SolidgateCheckoutDialog.types.js';
|
|
3
|
+
export type SolidgateWalletPaymentMethod = 'apple_pay' | 'google_pay';
|
|
4
|
+
type WalletPreparation = {
|
|
5
|
+
attemptId: string | null;
|
|
6
|
+
mountedAtMs: number;
|
|
7
|
+
requestStartedAtMs: number;
|
|
8
|
+
preparedAtMs: number | null;
|
|
9
|
+
};
|
|
10
|
+
/** Reports when Solidgate inserts inline wallet buttons, or that the platform wallet is still missing after 15 seconds. */
|
|
11
|
+
export declare function useSolidgateWalletReadiness(analyticsRef: RefObject<SolidgateCheckoutAnalyticsContext | null | undefined>, readyAttemptId: string | undefined): {
|
|
12
|
+
startPreparation: () => WalletPreparation;
|
|
13
|
+
finishPreparation: (preparation: WalletPreparation, attemptId: string) => void;
|
|
14
|
+
reportWalletsReady: (methods: readonly SolidgateWalletPaymentMethod[]) => void;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
3
|
+
import { trackCheckoutWalletReady, trackCheckoutWalletSlow } from '../../../services/checkoutObservability.service.js';
|
|
4
|
+
import { getPlatformWalletPaymentMethods, resolveWalletPlatform } from '../../stripe/components/walletPlatform.js';
|
|
5
|
+
const WALLET_SLOW_THRESHOLD_MS = 15000;
|
|
6
|
+
/** Reports when Solidgate inserts inline wallet buttons, or that the platform wallet is still missing after 15 seconds. */
|
|
7
|
+
export function useSolidgateWalletReadiness(analyticsRef, readyAttemptId) {
|
|
8
|
+
const mountedAtRef = useRef(null);
|
|
9
|
+
const preparationRef = useRef(null);
|
|
10
|
+
// Keyed by `${attemptId}:${method}` so a re-prepared attempt is never reported twice.
|
|
11
|
+
const readyRef = useRef(new Set());
|
|
12
|
+
const slowRef = useRef(new Set());
|
|
13
|
+
const startPreparation = useCallback(() => {
|
|
14
|
+
var _a;
|
|
15
|
+
const requestStartedAtMs = performance.now();
|
|
16
|
+
const preparation = {
|
|
17
|
+
attemptId: null,
|
|
18
|
+
mountedAtMs: (_a = mountedAtRef.current) !== null && _a !== void 0 ? _a : (mountedAtRef.current = requestStartedAtMs),
|
|
19
|
+
requestStartedAtMs,
|
|
20
|
+
preparedAtMs: null,
|
|
21
|
+
};
|
|
22
|
+
preparationRef.current = preparation;
|
|
23
|
+
return preparation;
|
|
24
|
+
}, []);
|
|
25
|
+
const finishPreparation = useCallback((preparation, attemptId) => {
|
|
26
|
+
preparation.attemptId = attemptId;
|
|
27
|
+
preparation.preparedAtMs = performance.now();
|
|
28
|
+
}, []);
|
|
29
|
+
const reportWalletsReady = useCallback((methods) => {
|
|
30
|
+
const preparation = preparationRef.current;
|
|
31
|
+
const analytics = analyticsRef.current;
|
|
32
|
+
if (!analytics || !(preparation === null || preparation === void 0 ? void 0 : preparation.attemptId) || preparation.preparedAtMs === null) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const readyAtMs = performance.now();
|
|
36
|
+
for (const paymentMethod of methods) {
|
|
37
|
+
const key = `${preparation.attemptId}:${paymentMethod}`;
|
|
38
|
+
if (readyRef.current.has(key))
|
|
39
|
+
continue;
|
|
40
|
+
readyRef.current.add(key);
|
|
41
|
+
trackCheckoutWalletReady({
|
|
42
|
+
analytics,
|
|
43
|
+
checkoutSessionId: preparation.attemptId,
|
|
44
|
+
paymentMethod,
|
|
45
|
+
provider: 'solidgate',
|
|
46
|
+
walletTimingOrigin: 'prepared_here',
|
|
47
|
+
walletClientSecretToReadyMs: Math.max(0, readyAtMs - preparation.preparedAtMs),
|
|
48
|
+
walletMountToReadyMs: Math.max(0, readyAtMs - preparation.mountedAtMs),
|
|
49
|
+
walletMountToRequestMs: Math.max(0, preparation.requestStartedAtMs - preparation.mountedAtMs),
|
|
50
|
+
walletRequestMs: Math.max(0, preparation.preparedAtMs - preparation.requestStartedAtMs),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}, [analyticsRef]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!readyAttemptId) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const timer = setTimeout(() => {
|
|
59
|
+
const preparation = preparationRef.current;
|
|
60
|
+
const analytics = analyticsRef.current;
|
|
61
|
+
if (!analytics || (preparation === null || preparation === void 0 ? void 0 : preparation.attemptId) !== readyAttemptId || preparation.preparedAtMs === null) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const platform = resolveWalletPlatform({
|
|
65
|
+
maxTouchPoints: navigator.maxTouchPoints,
|
|
66
|
+
userAgent: navigator.userAgent,
|
|
67
|
+
});
|
|
68
|
+
for (const method of getPlatformWalletPaymentMethods(platform)) {
|
|
69
|
+
const paymentMethod = method === 'applePay' ? 'apple_pay' : 'google_pay';
|
|
70
|
+
const key = `${readyAttemptId}:${paymentMethod}`;
|
|
71
|
+
if (readyRef.current.has(key) || slowRef.current.has(key))
|
|
72
|
+
continue;
|
|
73
|
+
slowRef.current.add(key);
|
|
74
|
+
trackCheckoutWalletSlow({
|
|
75
|
+
analytics,
|
|
76
|
+
checkoutSessionId: readyAttemptId,
|
|
77
|
+
paymentMethod,
|
|
78
|
+
provider: 'solidgate',
|
|
79
|
+
walletTimingOrigin: 'prepared_here',
|
|
80
|
+
walletClientSecretToSlowMs: Math.max(0, performance.now() - preparation.preparedAtMs),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, WALLET_SLOW_THRESHOLD_MS);
|
|
84
|
+
return () => clearTimeout(timer);
|
|
85
|
+
}, [analyticsRef, readyAttemptId]);
|
|
86
|
+
return { startPreparation, finishPreparation, reportWalletsReady };
|
|
87
|
+
}
|
|
@@ -4,6 +4,7 @@ import { completePaywallCheckout } from '@funnelsgrove/runtime';
|
|
|
4
4
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import { PaymentElement, useCheckout } from '@stripe/react-stripe-js/checkout';
|
|
6
6
|
import { isValidCheckoutEmail as isValidEmail, isCheckoutEmailError } from '../../../services/checkoutEmail.js';
|
|
7
|
+
import { resolveCheckoutReturnUrl } from '../services/checkout/checkoutReturnUrl.js';
|
|
7
8
|
import { PaymentBrandMark, SecurityLockIcon } from './CheckoutBrandAssets.js';
|
|
8
9
|
import { StripeCheckoutExpressCheckoutButton } from './StripeCheckoutExpressCheckoutButton.js';
|
|
9
10
|
import { getUnsupportedCheckoutCountryMessage, normalizeSupportedCheckoutCountries } from './checkoutCountries.js';
|
|
@@ -251,7 +252,7 @@ export function SharedStripeCheckoutV2CheckoutSessionForm({ copy = defaultChecko
|
|
|
251
252
|
return;
|
|
252
253
|
}
|
|
253
254
|
await trackCheckoutSuccess();
|
|
254
|
-
window.location.assign(returnUrl);
|
|
255
|
+
window.location.assign(resolveCheckoutReturnUrl(returnUrl, checkoutSessionId));
|
|
255
256
|
return;
|
|
256
257
|
}
|
|
257
258
|
finishSubmitting();
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { completePaywallCheckout } from '@funnelsgrove/runtime';
|
|
4
4
|
import { isValidCheckoutEmail, isCheckoutEmailError } from '../../../services/checkoutEmail.js';
|
|
5
|
+
import { resolveCheckoutReturnUrl } from '../services/checkout/checkoutReturnUrl.js';
|
|
5
6
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
7
|
import { ExpressCheckoutElement, useCheckout, } from '@stripe/react-stripe-js/checkout';
|
|
7
8
|
import { queueStripeSubscriptionCheckoutStarted, trackPaidStripeSubscriptionCheckoutCompleted, trackStripeSubscriptionPaymentInfoSubmitted, } from '../services/checkoutCompletionAnalytics.service.js';
|
|
@@ -286,7 +287,7 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
|
|
|
286
287
|
if (await verifyPaywall(event.expressPaymentType))
|
|
287
288
|
return;
|
|
288
289
|
await trackCheckoutSuccess();
|
|
289
|
-
window.location.assign(returnUrl);
|
|
290
|
+
window.location.assign(resolveCheckoutReturnUrl(returnUrl, checkoutSessionId));
|
|
290
291
|
}
|
|
291
292
|
};
|
|
292
293
|
const handleClick = async (event) => {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
3
|
import { queueStripeSubscriptionCheckoutStarted, trackStripeSubscriptionPaymentInfoSubmitted, trackPaidStripeSubscriptionCheckoutCompleted, } from '../services/checkoutCompletionAnalytics.service.js';
|
|
4
4
|
import { isValidCheckoutEmail, isCheckoutEmailError } from '../../../services/checkoutEmail.js';
|
|
5
|
+
import { resolveCheckoutReturnUrl } from '../services/checkout/checkoutReturnUrl.js';
|
|
5
6
|
const normalizeCurrency = (currency) => currency.trim().toLowerCase() || 'usd';
|
|
6
7
|
export function useStripeSubscriptionWalletFirstRequest({ amountCents, checkoutAnalytics, currency = 'usd', merchantCountry = 'US', onError, onCancel, onSuccess, onPayerEmail, onPaymentInfoSubmitted, paymentMethod, returnUrl, session, summaryLabel, }) {
|
|
7
8
|
const requestKey = [session.planKey, paymentMethod, currency, merchantCountry, amountCents].join('|');
|
|
@@ -111,7 +112,7 @@ export function useStripeSubscriptionWalletFirstRequest({ amountCents, checkoutA
|
|
|
111
112
|
await trackPaidStripeSubscriptionCheckoutCompleted(Object.assign(Object.assign({}, callbacks.checkoutAnalytics), { checkoutSessionId })).catch(() => 'analytics_rejected');
|
|
112
113
|
}
|
|
113
114
|
await callbacks.onSuccess({ checkoutSessionId });
|
|
114
|
-
window.location.assign(callbacks.returnUrl);
|
|
115
|
+
window.location.assign(resolveCheckoutReturnUrl(callbacks.returnUrl, checkoutSessionId));
|
|
115
116
|
}
|
|
116
117
|
catch (error) {
|
|
117
118
|
completeWallet('fail');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fills Stripe's `{CHECKOUT_SESSION_ID}` return-URL template before a client-side redirect.
|
|
3
|
+
* Stripe fills it only on its own redirects; funnels build the template URL-encoded via URLSearchParams.
|
|
4
|
+
*/
|
|
5
|
+
export declare const resolveCheckoutReturnUrl: (returnUrl: string, checkoutSessionId: string | null | undefined) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const CHECKOUT_SESSION_TEMPLATE = '{CHECKOUT_SESSION_ID}';
|
|
2
|
+
/**
|
|
3
|
+
* Fills Stripe's `{CHECKOUT_SESSION_ID}` return-URL template before a client-side redirect.
|
|
4
|
+
* Stripe fills it only on its own redirects; funnels build the template URL-encoded via URLSearchParams.
|
|
5
|
+
*/
|
|
6
|
+
export const resolveCheckoutReturnUrl = (returnUrl, checkoutSessionId) => {
|
|
7
|
+
const sessionId = checkoutSessionId === null || checkoutSessionId === void 0 ? void 0 : checkoutSessionId.trim();
|
|
8
|
+
if (!sessionId)
|
|
9
|
+
return returnUrl;
|
|
10
|
+
const encodedSessionId = encodeURIComponent(sessionId);
|
|
11
|
+
return returnUrl
|
|
12
|
+
.replaceAll(CHECKOUT_SESSION_TEMPLATE, encodedSessionId)
|
|
13
|
+
.replaceAll(encodeURIComponent(CHECKOUT_SESSION_TEMPLATE), encodedSessionId);
|
|
14
|
+
};
|
|
@@ -40,7 +40,7 @@ export type CheckoutWalletReadyInput = {
|
|
|
40
40
|
analytics: CheckoutObservabilityAnalyticsContext;
|
|
41
41
|
checkoutSessionId: string;
|
|
42
42
|
paymentMethod: unknown;
|
|
43
|
-
provider: 'stripe';
|
|
43
|
+
provider: 'solidgate' | 'stripe';
|
|
44
44
|
walletTimingOrigin?: 'prepared_here' | 'already_active';
|
|
45
45
|
walletClientSecretToReadyMs?: number;
|
|
46
46
|
walletClientSecretToElementMountMs?: number;
|
|
@@ -58,7 +58,7 @@ export declare const trackCheckoutWalletSlow: (input: {
|
|
|
58
58
|
analytics: CheckoutObservabilityAnalyticsContext;
|
|
59
59
|
checkoutSessionId: string;
|
|
60
60
|
paymentMethod: unknown;
|
|
61
|
-
provider: "stripe";
|
|
61
|
+
provider: "solidgate" | "stripe";
|
|
62
62
|
walletTimingOrigin: "prepared_here" | "already_active";
|
|
63
63
|
walletClientSecretToSlowMs: number;
|
|
64
64
|
}) => string | null;
|