@funnelsgrove/payments 0.60.0 → 0.62.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/README.md +10 -6
- package/dist/generated/package-version.d.ts +1 -1
- package/dist/generated/package-version.js +1 -1
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.d.ts +1 -1
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.js +18 -4
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.styles.d.ts +1 -1
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.styles.js +3 -3
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.types.d.ts +7 -1
- package/dist/providers/solidgate/components/SolidgatePaymentForm.d.ts +5 -2
- package/dist/providers/solidgate/components/SolidgatePaymentForm.js +20 -4
- 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
package/README.md
CHANGED
|
@@ -90,15 +90,19 @@ Use `completeStripeOneClickPayment` for normal post-checkout one-click upsells.
|
|
|
90
90
|
Solidgate browser checkout is available for controlled provider-routed funnels through
|
|
91
91
|
`SolidgateCheckoutDialog`, `prepareSolidgateCheckout`, and `pollSolidgateCheckoutStatus`. The dialog
|
|
92
92
|
mounts one official Solidgate form per attempt, destroys the remote form on replacement/unmount,
|
|
93
|
-
and never treats iframe `success` as funnel completion. Its `onSuccess
|
|
94
|
-
provider-neutral status endpoint finds
|
|
93
|
+
and never treats iframe `success` as funnel completion. Its `onSuccess(checkout, { paymentMethod })`
|
|
94
|
+
callback runs only after the provider-neutral status endpoint finds
|
|
95
|
+
canonical shared-ledger payment evidence. `paymentMethod` is `apple_pay`, `google_pay`, `card` or `other`, taken from the Solidgate
|
|
96
|
+
submit event for that attempt, and `null` when this page did not observe the submission.
|
|
95
97
|
|
|
96
98
|
For a Solidgate one-click upsell, call `completeSolidgateOneClickPayment` with the paid checkout's
|
|
97
99
|
`attemptId` as `checkoutSessionId`, the external `userId`, the published selection and a stable
|
|
98
|
-
`idempotencyKey`. It charges
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
`idempotencyKey`. It charges only a card saved by that payment, polls the new attempt, and emits
|
|
101
|
+
`checkout_completed` only for `succeeded`. Apple Pay and Google Pay must show their button again, so
|
|
102
|
+
when `onSuccess` reported `apple_pay` or `google_pay`, render the upsell as `SolidgateCheckoutDialog`
|
|
103
|
+
with `layout: 'wallet'` and `checkoutType: 'one_time'` instead of a one-click button. On
|
|
104
|
+
`SolidgateSavedPaymentMethodUnavailableError` (no reusable card), render `SolidgateCheckoutDialog`
|
|
105
|
+
with `checkoutType: 'one_time'`.
|
|
102
106
|
|
|
103
107
|
## Localized funnel copy
|
|
104
108
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PAYMENTS_PACKAGE_VERSION = "0.
|
|
1
|
+
export declare const PAYMENTS_PACKAGE_VERSION = "0.62.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.62.0";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SolidgateCheckoutDialogProps } from './SolidgateCheckoutDialog.types.js';
|
|
2
|
-
export type { SolidgateCheckoutDialogState, SolidgateCheckoutDialogContent, SolidgateCheckoutDialogPresentation, SolidgateCheckoutDialogProps, SolidgateCheckoutAnalyticsContext, } from './SolidgateCheckoutDialog.types.js';
|
|
2
|
+
export type { SolidgateCheckoutDialogState, SolidgateCheckoutDialogContent, SolidgateCheckoutDialogPresentation, SolidgateCheckoutDialogProps, SolidgateCheckoutAnalyticsContext, SolidgateCheckoutSuccess, SolidgatePaymentMethod, } from './SolidgateCheckoutDialog.types.js';
|
|
3
3
|
export declare function SolidgateCheckoutDialog({ open, layout, request, customerEmail, checkoutAnalytics, content, presentation, onClose, onCustomerEmailCommit, onSuccess, onRetry, onError, onPreparationStart, onStateChange, onPaymentPendingChange, }: SolidgateCheckoutDialogProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -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);
|
|
@@ -57,6 +59,7 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
57
59
|
const statusAbortRef = useRef(null);
|
|
58
60
|
const successAttemptRef = useRef(null);
|
|
59
61
|
const paymentInfoAttemptRef = useRef(null);
|
|
62
|
+
const submittedMethodRef = useRef(null);
|
|
60
63
|
const checkoutAnalyticsRef = useRef(checkoutAnalytics);
|
|
61
64
|
const closeButtonRef = useRef(null);
|
|
62
65
|
const copyRef = useRef(copy);
|
|
@@ -149,6 +152,8 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
149
152
|
}, []);
|
|
150
153
|
const requiresEmailCommit = Boolean(onCustomerEmailCommit);
|
|
151
154
|
const startedAttemptRef = useRef(null);
|
|
155
|
+
const walletReadiness = useSolidgateWalletReadiness(checkoutAnalyticsRef, layout === 'wallet' && view.state === 'ready' ? (_a = view.checkout) === null || _a === void 0 ? void 0 : _a.attemptId : undefined);
|
|
156
|
+
const { startPreparation: startWalletPreparation, finishPreparation: finishWalletPreparation } = walletReadiness;
|
|
152
157
|
const active = open && (layout !== 'wallet' || Boolean(normalizedCustomerEmail));
|
|
153
158
|
useEffect(() => {
|
|
154
159
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -182,10 +187,13 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
182
187
|
setState(initialView);
|
|
183
188
|
}
|
|
184
189
|
});
|
|
190
|
+
const walletPreparation = layout === 'wallet' ? startWalletPreparation() : null;
|
|
185
191
|
void prepareSolidgateCheckout(Object.assign(Object.assign({}, preparedRequest), { signal: controller.signal }))
|
|
186
192
|
.then((checkout) => {
|
|
187
193
|
if (!controller.signal.aborted) {
|
|
188
194
|
declinedAttemptRef.current = null;
|
|
195
|
+
if (walletPreparation)
|
|
196
|
+
finishWalletPreparation(walletPreparation, checkout.attemptId);
|
|
189
197
|
setState({ state: 'ready', checkout, canResumeVerification: false });
|
|
190
198
|
if (layout !== 'wallet') {
|
|
191
199
|
void trackSolidgateCheckoutEvent('checkout_started', checkout.attemptId, checkoutAnalyticsRef.current);
|
|
@@ -207,7 +215,8 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
207
215
|
}
|
|
208
216
|
});
|
|
209
217
|
return () => controller.abort();
|
|
210
|
-
}, [checkoutKey, committedEmail, layout, onPreparationStart, active, requiresEmailCommit, setState, trackFailure
|
|
218
|
+
}, [checkoutKey, committedEmail, layout, onPreparationStart, active, requiresEmailCommit, setState, trackFailure,
|
|
219
|
+
startWalletPreparation, finishWalletPreparation]);
|
|
211
220
|
const paymentFormMounted = Boolean(view.checkout && mountedPaymentAttemptId === view.checkout.attemptId);
|
|
212
221
|
const showPreparingLoader = view.state === 'loading'
|
|
213
222
|
|| (view.state === 'ready' && !paymentFormMounted);
|
|
@@ -278,8 +287,11 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
278
287
|
const embedded = await completePaywallCheckout('solidgate', checkout.attemptId, {
|
|
279
288
|
beforeNotify: () => trackSolidgateCheckoutEvent('checkout_completed', checkout.attemptId, checkoutAnalyticsRef.current),
|
|
280
289
|
});
|
|
290
|
+
const submitted = submittedMethodRef.current;
|
|
281
291
|
if (!embedded)
|
|
282
|
-
await ((_b = onSuccessRef.current) === null || _b === void 0 ? void 0 : _b.call(onSuccessRef, checkout
|
|
292
|
+
await ((_b = onSuccessRef.current) === null || _b === void 0 ? void 0 : _b.call(onSuccessRef, checkout, {
|
|
293
|
+
paymentMethod: (submitted === null || submitted === void 0 ? void 0 : submitted.attemptId) === checkout.attemptId ? submitted.paymentMethod : null,
|
|
294
|
+
}));
|
|
283
295
|
successAttemptRef.current = checkout.attemptId;
|
|
284
296
|
}
|
|
285
297
|
setState({ state: 'success', checkout, canResumeVerification: false });
|
|
@@ -396,14 +408,16 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
396
408
|
const paymentForm = view.checkout ? (_jsx(SolidgatePaymentForm, { walletOnly: layout === 'wallet', secureLabel: presentation === null || presentation === void 0 ? void 0 : presentation.secureLabel, cardLabel: presentation === null || presentation === void 0 ? void 0 : presentation.cardLabel, paymentMethodLabel: presentation === null || presentation === void 0 ? void 0 : presentation.paymentMethodLabel, buttonColor: (presentation === null || presentation === void 0 ? void 0 : presentation.buttonColor) || '#3f51b5', cardSubmitLabel: (presentation === null || presentation === void 0 ? void 0 : presentation.cardSubmitLabel) || 'Pay securely', checkout: view.checkout, hidden: !showForm, challengeActive: view.challengeActive, paymentPending: paymentPending, loadingLabel: copy.loading, onMounted: () => {
|
|
397
409
|
var _a;
|
|
398
410
|
setMountedPaymentAttemptId(((_a = view.checkout) === null || _a === void 0 ? void 0 : _a.attemptId) || null);
|
|
399
|
-
}, onSubmit: () => {
|
|
411
|
+
}, onSubmit: (paymentMethod) => {
|
|
400
412
|
var _a, _b, _c;
|
|
413
|
+
if (view.checkout)
|
|
414
|
+
submittedMethodRef.current = { attemptId: view.checkout.attemptId, paymentMethod };
|
|
401
415
|
if (paymentInfoAttemptRef.current !== ((_a = view.checkout) === null || _a === void 0 ? void 0 : _a.attemptId)) {
|
|
402
416
|
paymentInfoAttemptRef.current = ((_b = view.checkout) === null || _b === void 0 ? void 0 : _b.attemptId) || null;
|
|
403
417
|
void trackSolidgateCheckoutEvent('add_payment_info', ((_c = view.checkout) === null || _c === void 0 ? void 0 : _c.attemptId) || '', checkoutAnalyticsRef.current);
|
|
404
418
|
}
|
|
405
419
|
setState(Object.assign(Object.assign({}, view), { state: 'submitting' }));
|
|
406
|
-
}, onVerify: () => void verifyCanonicalStatus(true), onPaymentResult: () => void verifyCanonicalStatus(false), onError: (error) => {
|
|
420
|
+
}, onVerify: () => void verifyCanonicalStatus(true), onPaymentResult: () => void verifyCanonicalStatus(false), onWalletsChange: layout === 'wallet' ? walletReadiness.reportWalletsReady : undefined, onError: (error) => {
|
|
407
421
|
var _a, _b;
|
|
408
422
|
setState(Object.assign(Object.assign({}, view), { state: 'recoverable_error', canResumeVerification: false }));
|
|
409
423
|
trackFailure(copyRef.current.error, 'payment_form', (_a = view.checkout) === null || _a === void 0 ? void 0 : _a.attemptId, solidgateFailureDetails(error));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const solidgateCheckoutDialogStyles = "\n.solidgate-checkout-overlay {\n position: fixed;\n inset: 0;\n z-index: 100;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n padding: 16px;\n background: rgb(17 24 39 / 60%);\n backdrop-filter: blur(4px);\n}\n\n.solidgate-checkout-overlay.is-branded {\n z-index: 110;\n align-items: stretch;\n padding: 0;\n background: #fff;\n backdrop-filter: none;\n}\n\n.solidgate-checkout-dialog {\n box-sizing: border-box;\n width: min(100%, 512px);\n max-height: calc(100svh - 32px);\n overflow-y: auto;\n border: 1px solid var(--color-border, #d1d5db);\n border-radius: 16px;\n background: var(--color-surface, #fff);\n padding: 20px;\n color: var(--color-text, #111827);\n box-shadow: 0 24px 80px rgb(17 24 39 / 22%);\n}\n\n.solidgate-checkout-dialog.is-branded {\n width: min(100%, 430px);\n height: 100svh;\n max-height: 100svh;\n border: 0;\n border-radius: 0;\n background: #fff;\n padding: 0 17px 28px;\n color: #303136;\n box-shadow: none;\n font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\n}\n\n.solidgate-checkout-dialog.is-preparing {\n position: absolute;\n opacity: 0;\n pointer-events: none;\n}\n\n.solidgate-checkout-loader {\n display: grid;\n place-items: center;\n}\n\n.solidgate-checkout-spinner {\n box-sizing: border-box;\n width: 44px;\n height: 44px;\n border: 4px solid var(--color-border, #d1d5db);\n border-top-color: var(--color-primary, #22c55e);\n border-radius: 50%;\n animation: solidgate-checkout-spin 720ms linear infinite;\n}\n\n.solidgate-checkout-visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n}\n\n@keyframes solidgate-checkout-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .solidgate-checkout-spinner {\n animation-duration: 1.6s;\n }\n}\n\n.solidgate-checkout-header {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 16px;\n margin-bottom: 16px;\n}\n\n.solidgate-checkout-dialog.is-branded .solidgate-checkout-header {\n min-height: 70px;\n margin: 0 -17px;\n padding: 0 56px;\n}\n\n.solidgate-checkout-title {\n margin: 0;\n color: var(--color-text, #111827);\n font-size: 18px;\n font-weight: 600;\n line-height: 1.3;\n}\n\n.solidgate-checkout-dialog.is-branded .solidgate-checkout-title {\n color: #020203;\n font-size: 24px;\n font-weight: 900;\n line-height: 1.15;\n text-align: center;\n}\n\n.solidgate-checkout-close {\n position: absolute;\n left: 0;\n top: 50%;\n width: 36px;\n height: 36px;\n flex: none;\n border: 1px solid var(--color-border, #d1d5db);\n border-radius: 8px;\n background: var(--color-bg, #f9fafb);\n color: var(--color-text, #111827);\n font-size: 22px;\n transform: translateY(-50%);\n cursor: pointer;\n}\n\n.solidgate-checkout-dialog.is-branded .solidgate-checkout-close {\n left: 16px;\n width: 40px;\n height: 40px;\n border: 0;\n border-radius: 999px;\n background: #f2f2f3;\n color: #aaa;\n}\n\n.solidgate-checkout-close span,\n.solidgate-checkout-close span::after {\n position: absolute;\n left: 50%;\n top: 50%;\n width: 22px;\n height: 3px;\n border-radius: 999px;\n background: currentColor;\n content: '';\n}\n\n.solidgate-checkout-close span {\n transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.solidgate-checkout-close span::after {\n transform: translate(-50%, -50%) rotate(90deg);\n}\n\n.solidgate-checkout-close:hover {\n background: var(--color-accent-soft, #eef2ff);\n}\n\n.solidgate-checkout-summary {\n color: #303136;\n}\n\n.solidgate-checkout-countdown {\n min-height: 37px;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0;\n border-radius: 12px;\n background: color-mix(in srgb, var(--solidgate-checkout-theme-color) 10%, #fff);\n color: var(--solidgate-checkout-theme-color);\n font-size: 16px;\n font-weight: 900;\n text-align: center;\n}\n\n.solidgate-checkout-satisfaction {\n margin: 17px 0 21px;\n color: #2f3034;\n font-size: 19px;\n font-weight: 800;\n line-height: 1.15;\n text-align: center;\n}\n\n.solidgate-checkout-satisfaction strong {\n color: var(--solidgate-checkout-theme-color);\n}\n\n.solidgate-checkout-price-stack {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.solidgate-checkout-price-row,\n.solidgate-checkout-promo,\n.solidgate-checkout-total {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n\n.solidgate-checkout-price-row {\n font-size: 17px;\n}\n\n.solidgate-checkout-price-row.is-muted {\n color: #9d9d9f;\n font-weight: 500;\n}\n\n.solidgate-checkout-strike {\n text-decoration: line-through 2px;\n}\n\n.solidgate-checkout-price-row.is-discount {\n color: #040508;\n font-weight: 900;\n}\n\n.solidgate-checkout-price-row.is-discount strong:last-child {\n color: #ff2544;\n}\n\n.solidgate-checkout-promo {\n min-height: 42px;\n border-radius: 13px;\n background: #f0f0f0;\n padding: 0 14px;\n color: #8d8d90;\n font-size: 16px;\n}\n\n.solidgate-checkout-promo strong {\n color: #050609;\n font-weight: 900;\n}\n\n.solidgate-checkout-total {\n min-height: 76px;\n margin-top: 20px;\n border-top: 1px solid #dedede;\n font-size: 23px;\n font-weight: 800;\n}\n\n.solidgate-checkout-total.is-plain {\n margin-top: 0;\n}\n\n.solidgate-checkout-total strong {\n font-size: 25px;\n font-weight: 900;\n}\n\n.solidgate-checkout-total strong {\n display: inline-flex;\n align-items: center;\n gap: 7px;\n}\n.solidgate-checkout-total svg {\n width: 25px;\n height: 25px;\n fill: none;\n stroke: currentColor;\n stroke-width: 2;\n stroke-linejoin: round;\n}\n.solidgate-checkout-saved {\n width: fit-content;\n min-height: 36px;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin: -8px 0 9px auto;\n border-radius: 12px;\n background: #ffdce3;\n padding: 0 14px;\n color: #ff2544;\n font-size: 14px;\n font-weight: 900;\n line-height: 1.1;\n}\n\n.solidgate-checkout-email-form,\n.solidgate-checkout-email-label,\n.solidgate-checkout-wallets {\n display: grid;\n}\n\n.solidgate-checkout-email-form {\n gap: 16px;\n}\n\n.solidgate-checkout-email-label {\n gap: 8px;\n color: var(--color-text, #111827);\n font-size: 14px;\n font-weight: 500;\n}\n\n.solidgate-checkout-email-input {\n box-sizing: border-box;\n width: 100%;\n min-height: 44px;\n border: 1px solid var(--color-border, #d1d5db);\n border-radius: 8px;\n background: var(--color-bg, #fff);\n padding: 8px 12px;\n color: var(--color-text, #111827);\n font: inherit;\n}\n\n.solidgate-checkout-email-input::placeholder,\n.solidgate-checkout-status,\n.solidgate-checkout-status-text {\n color: var(--color-text-muted, #6b7280);\n}\n\n.solidgate-checkout-email-input:focus-visible,\n.solidgate-checkout-close:focus-visible,\n.solidgate-checkout-action:focus-visible {\n outline: 2px solid var(--color-accent, #3f51b5);\n outline-offset: 2px;\n}\n\n.solidgate-checkout-alert {\n margin: 0;\n color: var(--color-danger, #b91c1c);\n font-size: 14px;\n}\n\n.solidgate-checkout-action {\n display: block;\n box-sizing: border-box;\n text-align: center;\n text-decoration: none;\n width: 100%;\n min-height: 44px;\n border: 1px solid var(--color-accent, #3f51b5);\n border-radius: 8px;\n background: var(--color-accent, #3f51b5);\n padding: 8px 16px;\n color: var(--color-primary-text, #fff);\n font: inherit;\n font-weight: 600;\n cursor: pointer;\n}\n\n.solidgate-checkout-action:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n}\n\n.solidgate-checkout-action--spaced {\n margin-top: 16px;\n}\n\n.solidgate-checkout-wallets {\n gap: 12px;\n}\n.solidgate-checkout-wallets > div:empty,\n.solidgate-checkout-wallets:not(:has(> div:not(:empty))) { display: none; }\n.solidgate-checkout-wallets > div:not(:empty) {\n width: 100%;\n height: 54px;\n}\n.solidgate-checkout-wallets apple-pay-button {\n --apple-pay-button-width: 100%;\n --apple-pay-button-height: 54px;\n --apple-pay-button-border-radius: 0;\n width: 100%;\n height: 54px;\n}\n.solidgate-checkout-payment.is-branded {\n display: flex;\n flex-direction: column;\n gap: 12px;\n margin: 0 -17px;\n padding: 9px 17px 32px;\n background: #f2f2f3;\n}\n.solidgate-checkout-methods {\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n gap: 42px;\n}\n.solidgate-checkout-method {\n min-height: 74px;\n border: 2px solid #e6e7eb;\n border-radius: 13px;\n background: #fff;\n color: #303136;\n padding: 9px 8px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 6px;\n font: inherit;\n cursor: pointer;\n}\n.solidgate-checkout-method[aria-selected='true'] { border: 3px solid #050609; }\n.solidgate-checkout-method:focus-visible { outline: 2px solid var(--solidgate-checkout-theme-color, #3f51b5); outline-offset: 2px; }\n.solidgate-checkout-method strong { font-size: 20px; font-weight: 800; line-height: 1.1; }\n.solidgate-checkout-tab-wallet { width: 58px; height: 36px; }\n.solidgate-checkout-tab-brands { display: flex; align-items: center; gap: 4px; }\n.solidgate-checkout-tab-brand { width: 24px; height: 15px; }\n.solidgate-checkout-tab-wallet svg, .solidgate-checkout-tab-brand svg { width: 100%; height: 100%; }\n.solidgate-checkout-secure {\n min-height: 47px;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 9px;\n margin: 0;\n border-radius: 12px;\n background: #dcffd0;\n color: #207733;\n font-size: 18px;\n font-weight: 800;\n}\n.solidgate-checkout-secure svg { width: 23px; height: 23px; }\n.solidgate-checkout-payment.is-branded .solidgate-checkout-card { padding: 10px 14px 0; }\n.solidgate-checkout-secure.is-card { width: fit-content; margin: 14px auto 0; padding: 0 14px; }\n.solidgate-sdk-card-container iframe { border: 0; }\n.solidgate-checkout-payment[hidden],\n.solidgate-checkout-wallets[hidden],\n.solidgate-checkout-card[hidden] { display: none; }\n.solidgate-inline-wallet { width: 100%; }\n.solidgate-inline-wallet .solidgate-checkout-wallets:has(> div:not(:empty)) { margin-bottom: 12px; }\n\n.solidgate-checkout-status {\n margin-top: 12px;\n border: 1px solid var(--color-border, #d1d5db);\n border-radius: 12px;\n background: var(--color-bg, #f9fafb);\n padding: 16px;\n font-size: 14px;\n}\n\n.solidgate-checkout-status p,\n.solidgate-checkout-status-text {\n margin: 0;\n}\n";
|
|
1
|
+
export declare const solidgateCheckoutDialogStyles = "\n.solidgate-checkout-overlay {\n position: fixed;\n inset: 0;\n z-index: 100;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n padding: 16px;\n background: rgb(17 24 39 / 60%);\n backdrop-filter: blur(4px);\n}\n\n.solidgate-checkout-overlay.is-branded {\n z-index: 110;\n align-items: stretch;\n padding: 0;\n background: #fff;\n backdrop-filter: none;\n}\n\n.solidgate-checkout-dialog {\n box-sizing: border-box;\n width: min(100%, 512px);\n max-height: calc(100svh - 32px);\n overflow-y: auto;\n border: 1px solid var(--color-border, #d1d5db);\n border-radius: 16px;\n background: var(--color-surface, #fff);\n padding: 20px;\n color: var(--color-text, #111827);\n box-shadow: 0 24px 80px rgb(17 24 39 / 22%);\n}\n\n.solidgate-checkout-dialog.is-branded {\n width: min(100%, 430px);\n height: 100svh;\n max-height: 100svh;\n border: 0;\n border-radius: 0;\n background: #fff;\n padding: 0 17px 28px;\n color: #303136;\n box-shadow: none;\n font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\n}\n\n.solidgate-checkout-dialog.is-preparing {\n position: absolute;\n opacity: 0;\n pointer-events: none;\n}\n\n.solidgate-checkout-loader {\n display: grid;\n place-items: center;\n}\n\n.solidgate-checkout-spinner {\n box-sizing: border-box;\n width: 44px;\n height: 44px;\n border: 4px solid var(--color-border, #d1d5db);\n border-top-color: var(--color-primary, #22c55e);\n border-radius: 50%;\n animation: solidgate-checkout-spin 720ms linear infinite;\n}\n\n.solidgate-checkout-visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n}\n\n@keyframes solidgate-checkout-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .solidgate-checkout-spinner {\n animation-duration: 1.6s;\n }\n}\n\n.solidgate-checkout-header {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 16px;\n margin-bottom: 16px;\n}\n\n.solidgate-checkout-dialog.is-branded .solidgate-checkout-header {\n min-height: 70px;\n margin: 0 -17px;\n padding: 0 56px;\n}\n\n.solidgate-checkout-title {\n margin: 0;\n color: var(--color-text, #111827);\n font-size: 18px;\n font-weight: 600;\n line-height: 1.3;\n}\n\n.solidgate-checkout-dialog.is-branded .solidgate-checkout-title {\n color: #020203;\n font-size: 24px;\n font-weight: 900;\n line-height: 1.15;\n text-align: center;\n}\n\n.solidgate-checkout-close {\n position: absolute;\n left: 0;\n top: 50%;\n width: 36px;\n height: 36px;\n flex: none;\n border: 1px solid var(--color-border, #d1d5db);\n border-radius: 8px;\n background: var(--color-bg, #f9fafb);\n color: var(--color-text, #111827);\n font-size: 22px;\n transform: translateY(-50%);\n cursor: pointer;\n}\n\n.solidgate-checkout-dialog.is-branded .solidgate-checkout-close {\n left: 16px;\n width: 40px;\n height: 40px;\n border: 0;\n border-radius: 999px;\n background: #f2f2f3;\n color: #aaa;\n}\n\n.solidgate-checkout-close span,\n.solidgate-checkout-close span::after {\n position: absolute;\n left: 50%;\n top: 50%;\n width: 22px;\n height: 3px;\n border-radius: 999px;\n background: currentColor;\n content: '';\n}\n\n.solidgate-checkout-close span {\n transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.solidgate-checkout-close span::after {\n transform: translate(-50%, -50%) rotate(90deg);\n}\n\n.solidgate-checkout-close:hover {\n background: var(--color-accent-soft, #eef2ff);\n}\n\n.solidgate-checkout-summary {\n color: #303136;\n}\n\n.solidgate-checkout-countdown {\n min-height: 37px;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0;\n border-radius: 12px;\n background: color-mix(in srgb, var(--solidgate-checkout-theme-color) 10%, #fff);\n color: var(--solidgate-checkout-theme-color);\n font-size: 16px;\n font-weight: 900;\n text-align: center;\n}\n\n.solidgate-checkout-satisfaction {\n margin: 17px 0 21px;\n color: #2f3034;\n font-size: 19px;\n font-weight: 800;\n line-height: 1.15;\n text-align: center;\n}\n\n.solidgate-checkout-satisfaction strong {\n color: var(--solidgate-checkout-theme-color);\n}\n\n.solidgate-checkout-price-stack {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.solidgate-checkout-price-row,\n.solidgate-checkout-promo,\n.solidgate-checkout-total {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n\n.solidgate-checkout-price-row {\n font-size: 17px;\n}\n\n.solidgate-checkout-price-row.is-muted {\n color: #9d9d9f;\n font-weight: 500;\n}\n\n.solidgate-checkout-strike {\n text-decoration: line-through 2px;\n}\n\n.solidgate-checkout-price-row.is-discount {\n color: #040508;\n font-weight: 900;\n}\n\n.solidgate-checkout-price-row.is-discount strong:last-child {\n color: #ff2544;\n}\n\n.solidgate-checkout-promo {\n min-height: 42px;\n border-radius: 13px;\n background: #f0f0f0;\n padding: 0 14px;\n color: #8d8d90;\n font-size: 16px;\n}\n\n.solidgate-checkout-promo strong {\n color: #050609;\n font-weight: 900;\n}\n\n.solidgate-checkout-total {\n min-height: 76px;\n margin-top: 20px;\n border-top: 1px solid #dedede;\n font-size: 23px;\n font-weight: 800;\n}\n\n.solidgate-checkout-total.is-plain {\n margin-top: 0;\n}\n\n.solidgate-checkout-total strong {\n font-size: 25px;\n font-weight: 900;\n}\n\n.solidgate-checkout-total strong {\n display: inline-flex;\n align-items: center;\n gap: 7px;\n}\n.solidgate-checkout-total svg {\n width: 25px;\n height: 25px;\n fill: none;\n stroke: currentColor;\n stroke-width: 2;\n stroke-linejoin: round;\n}\n.solidgate-checkout-saved {\n width: fit-content;\n min-height: 36px;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin: -8px 0 9px auto;\n border-radius: 12px;\n background: #ffdce3;\n padding: 0 14px;\n color: #ff2544;\n font-size: 14px;\n font-weight: 900;\n line-height: 1.1;\n}\n\n.solidgate-checkout-email-form,\n.solidgate-checkout-email-label,\n.solidgate-checkout-wallets {\n display: grid;\n}\n\n.solidgate-checkout-email-form {\n gap: 16px;\n}\n\n.solidgate-checkout-email-label {\n gap: 8px;\n color: var(--color-text, #111827);\n font-size: 14px;\n font-weight: 500;\n}\n\n.solidgate-checkout-email-input {\n box-sizing: border-box;\n width: 100%;\n min-height: 44px;\n border: 1px solid var(--color-border, #d1d5db);\n border-radius: 8px;\n background: var(--color-bg, #fff);\n padding: 8px 12px;\n color: var(--color-text, #111827);\n font: inherit;\n}\n\n.solidgate-checkout-email-input::placeholder,\n.solidgate-checkout-status,\n.solidgate-checkout-status-text {\n color: var(--color-text-muted, #6b7280);\n}\n\n.solidgate-checkout-email-input:focus-visible,\n.solidgate-checkout-close:focus-visible,\n.solidgate-checkout-action:focus-visible {\n outline: 2px solid var(--color-accent, #3f51b5);\n outline-offset: 2px;\n}\n\n.solidgate-checkout-alert {\n margin: 0;\n color: var(--color-danger, #b91c1c);\n font-size: 14px;\n}\n\n.solidgate-checkout-action {\n display: block;\n box-sizing: border-box;\n text-align: center;\n text-decoration: none;\n width: 100%;\n min-height: 44px;\n border: 1px solid var(--color-accent, #3f51b5);\n border-radius: 8px;\n background: var(--color-accent, #3f51b5);\n padding: 8px 16px;\n color: var(--color-primary-text, #fff);\n font: inherit;\n font-weight: 600;\n cursor: pointer;\n}\n\n.solidgate-checkout-action:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n}\n\n.solidgate-checkout-action--spaced {\n margin-top: 16px;\n}\n\n.solidgate-checkout-wallets {\n gap: 12px;\n}\n.solidgate-checkout-wallets[data-empty],\n.solidgate-checkout-wallets > div:empty { display: none; }\n.solidgate-checkout-wallets > div:not(:empty) {\n width: 100%;\n height: 54px;\n}\n.solidgate-checkout-wallets apple-pay-button {\n --apple-pay-button-width: 100%;\n --apple-pay-button-height: 54px;\n --apple-pay-button-border-radius: 0;\n width: 100%;\n height: 54px;\n}\n.solidgate-checkout-payment.is-branded {\n display: flex;\n flex-direction: column;\n gap: 12px;\n margin: 0 -17px;\n padding: 9px 17px 32px;\n background: #f2f2f3;\n}\n.solidgate-checkout-methods {\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n gap: 42px;\n}\n.solidgate-checkout-method {\n min-height: 74px;\n border: 2px solid #e6e7eb;\n border-radius: 13px;\n background: #fff;\n color: #303136;\n padding: 9px 8px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 6px;\n font: inherit;\n cursor: pointer;\n}\n.solidgate-checkout-method[aria-selected='true'] { border: 3px solid #050609; }\n.solidgate-checkout-method:focus-visible { outline: 2px solid var(--solidgate-checkout-theme-color, #3f51b5); outline-offset: 2px; }\n.solidgate-checkout-method strong { font-size: 20px; font-weight: 800; line-height: 1.1; }\n.solidgate-checkout-tab-wallet { width: 58px; height: 36px; }\n.solidgate-checkout-tab-brands { display: flex; align-items: center; gap: 4px; }\n.solidgate-checkout-tab-brand { width: 24px; height: 15px; }\n.solidgate-checkout-tab-wallet svg, .solidgate-checkout-tab-brand svg { width: 100%; height: 100%; }\n.solidgate-checkout-secure {\n min-height: 47px;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 9px;\n margin: 0;\n border-radius: 12px;\n background: #dcffd0;\n color: #207733;\n font-size: 18px;\n font-weight: 800;\n}\n.solidgate-checkout-secure svg { width: 23px; height: 23px; }\n.solidgate-checkout-payment.is-branded .solidgate-checkout-card { padding: 10px 14px 0; }\n.solidgate-checkout-secure.is-card { width: fit-content; margin: 14px auto 0; padding: 0 14px; }\n.solidgate-sdk-card-container iframe { border: 0; }\n.solidgate-checkout-payment[hidden],\n.solidgate-checkout-wallets[hidden],\n.solidgate-checkout-card[hidden] { display: none; }\n.solidgate-inline-wallet { width: 100%; }\n.solidgate-inline-wallet .solidgate-checkout-wallets { margin-bottom: 12px; }\n\n.solidgate-checkout-status {\n margin-top: 12px;\n border: 1px solid var(--color-border, #d1d5db);\n border-radius: 12px;\n background: var(--color-bg, #f9fafb);\n padding: 16px;\n font-size: 14px;\n}\n\n.solidgate-checkout-status p,\n.solidgate-checkout-status-text {\n margin: 0;\n}\n";
|
|
@@ -378,8 +378,8 @@ export const solidgateCheckoutDialogStyles = `
|
|
|
378
378
|
.solidgate-checkout-wallets {
|
|
379
379
|
gap: 12px;
|
|
380
380
|
}
|
|
381
|
-
.solidgate-checkout-wallets
|
|
382
|
-
.solidgate-checkout-wallets
|
|
381
|
+
.solidgate-checkout-wallets[data-empty],
|
|
382
|
+
.solidgate-checkout-wallets > div:empty { display: none; }
|
|
383
383
|
.solidgate-checkout-wallets > div:not(:empty) {
|
|
384
384
|
width: 100%;
|
|
385
385
|
height: 54px;
|
|
@@ -447,7 +447,7 @@ export const solidgateCheckoutDialogStyles = `
|
|
|
447
447
|
.solidgate-checkout-wallets[hidden],
|
|
448
448
|
.solidgate-checkout-card[hidden] { display: none; }
|
|
449
449
|
.solidgate-inline-wallet { width: 100%; }
|
|
450
|
-
.solidgate-inline-wallet .solidgate-checkout-wallets
|
|
450
|
+
.solidgate-inline-wallet .solidgate-checkout-wallets { margin-bottom: 12px; }
|
|
451
451
|
|
|
452
452
|
.solidgate-checkout-status {
|
|
453
453
|
margin-top: 12px;
|
|
@@ -45,6 +45,12 @@ export type SolidgateCheckoutDialogPresentation = {
|
|
|
45
45
|
totalLabel: string;
|
|
46
46
|
totalValue: string;
|
|
47
47
|
};
|
|
48
|
+
/** Method the customer submitted in the Solidgate form; `other` covers alternative payment methods. */
|
|
49
|
+
export type SolidgatePaymentMethod = 'apple_pay' | 'google_pay' | 'card' | 'other';
|
|
50
|
+
export type SolidgateCheckoutSuccess = {
|
|
51
|
+
/** Null when this page did not observe the submission, for example after a reload during verification. */
|
|
52
|
+
paymentMethod: SolidgatePaymentMethod | null;
|
|
53
|
+
};
|
|
48
54
|
export type SolidgateCheckoutDialogProps = {
|
|
49
55
|
open: boolean;
|
|
50
56
|
/** Wallet-only paywall placement; mount only one Solidgate surface at a time. */
|
|
@@ -56,7 +62,7 @@ export type SolidgateCheckoutDialogProps = {
|
|
|
56
62
|
presentation?: SolidgateCheckoutDialogPresentation;
|
|
57
63
|
onClose: () => void;
|
|
58
64
|
onCustomerEmailCommit?: (email: string) => Promise<string>;
|
|
59
|
-
onSuccess?: (checkout: SolidgateCheckoutPreparation) => void | Promise<void>;
|
|
65
|
+
onSuccess?: (checkout: SolidgateCheckoutPreparation, result: SolidgateCheckoutSuccess) => void | Promise<void>;
|
|
60
66
|
onRetry?: () => void;
|
|
61
67
|
onError?: (message: string, code?: 'already_subscribed_to_product') => void;
|
|
62
68
|
onPreparationStart?: () => void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { SolidgateCheckoutPreparation } from '../services/solidgate.service.js';
|
|
2
|
-
|
|
2
|
+
import type { SolidgateWalletPaymentMethod } from './useSolidgateWalletReadiness.js';
|
|
3
|
+
import type { SolidgatePaymentMethod } from './SolidgateCheckoutDialog.types.js';
|
|
4
|
+
export declare function SolidgatePaymentForm({ buttonColor, walletOnly, cardSubmitLabel, secureLabel, cardLabel, paymentMethodLabel, checkout, hidden, challengeActive, paymentPending, onError, onMounted, onSubmit, onVerify, onPaymentResult, onWalletsChange, }: {
|
|
3
5
|
buttonColor: string;
|
|
4
6
|
walletOnly?: boolean;
|
|
5
7
|
cardSubmitLabel: string;
|
|
@@ -13,7 +15,8 @@ export declare function SolidgatePaymentForm({ buttonColor, walletOnly, cardSubm
|
|
|
13
15
|
loadingLabel: string;
|
|
14
16
|
onError: (error?: unknown) => void;
|
|
15
17
|
onMounted: () => void;
|
|
16
|
-
onSubmit: () => void;
|
|
18
|
+
onSubmit: (paymentMethod: SolidgatePaymentMethod) => void;
|
|
17
19
|
onVerify: () => void;
|
|
18
20
|
onPaymentResult: () => void;
|
|
21
|
+
onWalletsChange?: (methods: readonly SolidgateWalletPaymentMethod[]) => void;
|
|
19
22
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,7 +3,18 @@ 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
|
-
|
|
6
|
+
/** Solidgate reports the submitted surface as `entity` on its submit event. */
|
|
7
|
+
const toSolidgatePaymentMethod = (event) => {
|
|
8
|
+
const entity = typeof event === 'object' && event !== null && 'entity' in event ? event.entity : null;
|
|
9
|
+
if (entity === 'applebtn')
|
|
10
|
+
return 'apple_pay';
|
|
11
|
+
if (entity === 'googlebtn')
|
|
12
|
+
return 'google_pay';
|
|
13
|
+
if (entity === 'form' || entity === 'resign')
|
|
14
|
+
return 'card';
|
|
15
|
+
return 'other';
|
|
16
|
+
};
|
|
17
|
+
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
18
|
const panelId = useId();
|
|
8
19
|
const [wallets, setWallets] = useState([]);
|
|
9
20
|
const [selectedMethod, setSelectedMethod] = useState('wallet');
|
|
@@ -19,6 +30,9 @@ export function SolidgatePaymentForm({ buttonColor, walletOnly = false, cardSubm
|
|
|
19
30
|
useEffect(() => {
|
|
20
31
|
onMountedRef.current = onMounted;
|
|
21
32
|
}, [onMounted]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
onWalletsChange === null || onWalletsChange === void 0 ? void 0 : onWalletsChange(wallets.map((label) => label === 'Apple Pay' ? 'apple_pay' : 'google_pay'));
|
|
35
|
+
}, [onWalletsChange, wallets]);
|
|
22
36
|
useEffect(() => {
|
|
23
37
|
mountedReportedRef.current = false;
|
|
24
38
|
const boundary = paymentBoundaryRef.current;
|
|
@@ -44,7 +58,9 @@ export function SolidgatePaymentForm({ buttonColor, walletOnly = false, cardSubm
|
|
|
44
58
|
return () => observer.disconnect();
|
|
45
59
|
}, [checkout.attemptId]);
|
|
46
60
|
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,
|
|
61
|
+
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, "data-empty": wallets.length === 0 || 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,
|
|
62
|
+
// Wallet buttons wait for this iframe; iOS Safari throttles it under display:none. The SDK keeps a disabled form invisible.
|
|
63
|
+
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
64
|
form_body: {
|
|
49
65
|
'font-family': 'Inter, Arial, sans-serif',
|
|
50
66
|
},
|
|
@@ -71,9 +87,9 @@ export function SolidgatePaymentForm({ buttonColor, walletOnly = false, cardSubm
|
|
|
71
87
|
mountedReportedRef.current = true;
|
|
72
88
|
onMountedRef.current();
|
|
73
89
|
}
|
|
74
|
-
}, onSubmit: () => {
|
|
90
|
+
}, onSubmit: (event) => {
|
|
75
91
|
submittedRef.current = true;
|
|
76
|
-
onSubmit();
|
|
92
|
+
onSubmit(toSolidgatePaymentMethod(event));
|
|
77
93
|
}, onVerify: onVerify, onSuccess: onPaymentResult, onFail: onPaymentResult, onError: (error) => {
|
|
78
94
|
if (submittedRef.current) {
|
|
79
95
|
onPaymentResult();
|
|
@@ -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;
|