@funnelsgrove/payments 0.64.0 → 0.65.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/components/CheckoutSheet.d.ts +44 -0
- package/dist/components/CheckoutSheet.js +96 -0
- package/dist/components/CheckoutSheet.styles.d.ts +2 -0
- package/dist/components/CheckoutSheet.styles.js +241 -0
- package/dist/components/walletFirstParts.d.ts +16 -0
- package/dist/components/walletFirstParts.js +22 -0
- package/dist/generated/package-version.d.ts +1 -1
- package/dist/generated/package-version.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.d.ts +1 -1
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.js +26 -12
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.styles.d.ts +1 -1
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.styles.js +4 -0
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.types.d.ts +21 -2
- package/dist/providers/solidgate/components/SolidgateCheckoutSheetLayout.d.ts +17 -0
- package/dist/providers/solidgate/components/SolidgateCheckoutSheetLayout.js +36 -0
- package/dist/providers/solidgate/components/SolidgatePaymentForm.d.ts +14 -1
- package/dist/providers/solidgate/components/SolidgatePaymentForm.js +62 -39
- package/dist/providers/stripe/components/SharedCheckoutPaymentMethods.internal.d.ts +3 -1
- package/dist/providers/stripe/components/SharedCheckoutPaymentMethods.internal.js +3 -3
- package/dist/providers/stripe/components/SharedStripeCheckoutV2.styles.d.ts +1 -1
- package/dist/providers/stripe/components/SharedStripeCheckoutV2.styles.js +25 -0
- package/dist/providers/stripe/components/SharedStripeCheckoutV2Dialog.js +9 -0
- package/dist/providers/stripe/components/SharedStripeCheckoutV2Form.internal.js +53 -19
- package/dist/providers/stripe/components/StripeCheckoutSheet.d.ts +16 -0
- package/dist/providers/stripe/components/StripeCheckoutSheet.js +27 -0
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.d.ts +1 -1
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.js +2 -19
- package/dist/providers/stripe/components/index.d.ts +1 -0
- package/dist/providers/stripe/components/index.js +1 -0
- package/dist/providers/stripe/hooks/useStripeSubscriptionCheckoutSession.js +8 -6
- package/dist/providers/stripe/services/checkout/types.d.ts +1 -0
- package/dist/providers/stripe/services/checkoutSessionPaymentMethods.d.ts +2 -0
- package/dist/providers/stripe/services/checkoutSessionPaymentMethods.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-neutral bottom-sheet checkout shell: order summary on top, the payment
|
|
3
|
+
* methods (`children`) below and a guarantee line at the end.
|
|
4
|
+
*
|
|
5
|
+
* `visible={false}` keeps the sheet and its payment form mounted but hidden, so a
|
|
6
|
+
* checkout can be prepared in the background and open with its wallet button ready.
|
|
7
|
+
* A hidden sheet stays rendered (not `display:none`): iOS Safari throttles hidden
|
|
8
|
+
* payment iframes, which would delay wallet buttons.
|
|
9
|
+
*/
|
|
10
|
+
import { type ReactNode } from 'react';
|
|
11
|
+
export type CheckoutSheetSummary = {
|
|
12
|
+
promoActive: boolean;
|
|
13
|
+
/** Shown above the summary while a promo is active; `{percent}` is the discount. */
|
|
14
|
+
countdownLabelTemplate: string;
|
|
15
|
+
discountPercent: number;
|
|
16
|
+
remainingSeconds: number;
|
|
17
|
+
satisfactionPercent: string;
|
|
18
|
+
satisfactionLabel: string;
|
|
19
|
+
regularPriceLabel: string;
|
|
20
|
+
originalPriceValue: string;
|
|
21
|
+
discountLabel: string;
|
|
22
|
+
discountAmountLabel: string;
|
|
23
|
+
promoCodeLabel: string;
|
|
24
|
+
promoCode: string;
|
|
25
|
+
totalLabel: string;
|
|
26
|
+
totalValue: string;
|
|
27
|
+
savedLabel: string;
|
|
28
|
+
};
|
|
29
|
+
export type CheckoutSheetProps = {
|
|
30
|
+
visible: boolean;
|
|
31
|
+
title: string;
|
|
32
|
+
closeAriaLabel: string;
|
|
33
|
+
/** Payment pending: closing would abandon an unresolved payment. */
|
|
34
|
+
closeDisabled?: boolean;
|
|
35
|
+
onClose: () => void;
|
|
36
|
+
summary?: CheckoutSheetSummary;
|
|
37
|
+
guaranteeLabel?: string;
|
|
38
|
+
/** Radio, timer and summary accent. */
|
|
39
|
+
accentColor?: string;
|
|
40
|
+
/** Border of the selected payment method. */
|
|
41
|
+
selectedColor?: string;
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
};
|
|
44
|
+
export declare function CheckoutSheet({ visible, title, closeAriaLabel, closeDisabled, onClose, summary, guaranteeLabel, accentColor, selectedColor, children, }: CheckoutSheetProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Provider-neutral bottom-sheet checkout shell: order summary on top, the payment
|
|
5
|
+
* methods (`children`) below and a guarantee line at the end.
|
|
6
|
+
*
|
|
7
|
+
* `visible={false}` keeps the sheet and its payment form mounted but hidden, so a
|
|
8
|
+
* checkout can be prepared in the background and open with its wallet button ready.
|
|
9
|
+
* A hidden sheet stays rendered (not `display:none`): iOS Safari throttles hidden
|
|
10
|
+
* payment iframes, which would delay wallet buttons.
|
|
11
|
+
*/
|
|
12
|
+
import { useEffect, useRef } from 'react';
|
|
13
|
+
import { checkoutSheetStyles } from './CheckoutSheet.styles.js';
|
|
14
|
+
// Covers a slow card form load after the card method is selected.
|
|
15
|
+
const CARD_FOLLOW_MS = 10000;
|
|
16
|
+
const formatTimer = (remainingSeconds) => {
|
|
17
|
+
const seconds = Number.isFinite(remainingSeconds) ? Math.max(0, Math.floor(remainingSeconds)) : 0;
|
|
18
|
+
return `${String(Math.floor(seconds / 60)).padStart(2, '0')}:${String(seconds % 60).padStart(2, '0')}`;
|
|
19
|
+
};
|
|
20
|
+
export function CheckoutSheet({ visible, title, closeAriaLabel, closeDisabled = false, onClose, summary, guaranteeLabel, accentColor = '#3f51b5', selectedColor = '#4db53f', children, }) {
|
|
21
|
+
const sheetRef = useRef(null);
|
|
22
|
+
const onCloseRef = useRef(onClose);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
onCloseRef.current = onClose;
|
|
25
|
+
}, [onClose]);
|
|
26
|
+
const close = () => {
|
|
27
|
+
if (!closeDisabled)
|
|
28
|
+
onCloseRef.current();
|
|
29
|
+
};
|
|
30
|
+
// Keeps the opened card form in view while it expands and while the provider sizes its fields.
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
var _a;
|
|
33
|
+
const sheet = sheetRef.current;
|
|
34
|
+
if (!sheet || !visible)
|
|
35
|
+
return undefined;
|
|
36
|
+
let followUntil = 0;
|
|
37
|
+
const cardMethod = () => {
|
|
38
|
+
const methods = sheet.querySelectorAll('.wfc-method');
|
|
39
|
+
const card = methods[methods.length - 1];
|
|
40
|
+
return (card === null || card === void 0 ? void 0 : card.dataset.checked) === 'true' ? card : null;
|
|
41
|
+
};
|
|
42
|
+
const revealCard = () => {
|
|
43
|
+
const card = cardMethod();
|
|
44
|
+
if (!card || Date.now() > followUntil)
|
|
45
|
+
return;
|
|
46
|
+
const hiddenBelow = card.getBoundingClientRect().bottom + 16 - sheet.getBoundingClientRect().bottom;
|
|
47
|
+
if (hiddenBelow > 0)
|
|
48
|
+
sheet.scrollTop += hiddenBelow;
|
|
49
|
+
};
|
|
50
|
+
const selectionObserver = new MutationObserver(() => {
|
|
51
|
+
if (!cardMethod())
|
|
52
|
+
return;
|
|
53
|
+
followUntil = Date.now() + CARD_FOLLOW_MS;
|
|
54
|
+
revealCard();
|
|
55
|
+
});
|
|
56
|
+
const sizeObserver = new ResizeObserver(revealCard);
|
|
57
|
+
// A manual scroll takes over, so a late-loading card form never fights the user.
|
|
58
|
+
const stopFollowing = () => {
|
|
59
|
+
followUntil = 0;
|
|
60
|
+
};
|
|
61
|
+
selectionObserver.observe(sheet, { attributeFilter: ['data-checked'], subtree: true });
|
|
62
|
+
sizeObserver.observe((_a = sheet.firstElementChild) !== null && _a !== void 0 ? _a : sheet);
|
|
63
|
+
sheet.addEventListener('wheel', stopFollowing, { passive: true });
|
|
64
|
+
sheet.addEventListener('touchmove', stopFollowing, { passive: true });
|
|
65
|
+
return () => {
|
|
66
|
+
selectionObserver.disconnect();
|
|
67
|
+
sizeObserver.disconnect();
|
|
68
|
+
sheet.removeEventListener('wheel', stopFollowing);
|
|
69
|
+
sheet.removeEventListener('touchmove', stopFollowing);
|
|
70
|
+
};
|
|
71
|
+
}, [visible]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!visible)
|
|
74
|
+
return undefined;
|
|
75
|
+
const closeOnEscape = (event) => {
|
|
76
|
+
if (event.key === 'Escape' && !closeDisabled)
|
|
77
|
+
onCloseRef.current();
|
|
78
|
+
};
|
|
79
|
+
window.addEventListener('keydown', closeOnEscape);
|
|
80
|
+
return () => window.removeEventListener('keydown', closeOnEscape);
|
|
81
|
+
}, [closeDisabled, visible]);
|
|
82
|
+
const style = { '--fg-sheet-accent': accentColor, '--fg-sheet-selected': selectedColor };
|
|
83
|
+
return (_jsxs("div", { className: 'fg-sheet-overlay', "data-visible": visible, "aria-hidden": !visible || undefined, inert: !visible, style: style, onClick: (event) => {
|
|
84
|
+
if (event.target === event.currentTarget)
|
|
85
|
+
close();
|
|
86
|
+
}, children: [_jsx("section", { ref: sheetRef, className: 'fg-sheet', role: 'dialog', "aria-modal": 'true', "aria-labelledby": 'fg-sheet-title', children: _jsxs("div", { className: 'fg-sheet-content', children: [_jsx("span", { className: 'fg-sheet-grabber', "aria-hidden": 'true' }), _jsxs("header", { className: 'fg-sheet-head', children: [_jsx("button", { type: 'button', className: 'fg-sheet-close', "aria-label": closeAriaLabel, disabled: closeDisabled, onClick: close, children: _jsx("svg", { viewBox: '0 0 16 16', "aria-hidden": 'true', children: _jsx("path", { d: 'M3.5 3.5 12.5 12.5M12.5 3.5 3.5 12.5' }) }) }), _jsx("h2", { id: 'fg-sheet-title', children: title })] }), (summary === null || summary === void 0 ? void 0 : summary.promoActive) ? (_jsxs("p", { className: 'fg-sheet-timer', children: [_jsx("span", { "aria-hidden": 'true', children: "\u23F0" }), summary.countdownLabelTemplate.replace('{percent}', String(summary.discountPercent)), _jsx("span", { className: 'fg-sheet-timer-value', children: formatTimer(summary.remainingSeconds) })] })) : null, summary ? (_jsxs(_Fragment, { children: [_jsx("p", { className: 'fg-sheet-proof', children: _jsxs("strong", { children: [summary.satisfactionPercent, " ", summary.satisfactionLabel] }) }), _jsxs("div", { className: 'fg-sheet-summary', children: [summary.promoActive ? (_jsxs(_Fragment, { children: [_jsxs("p", { className: 'fg-sheet-row fg-sheet-row--muted', children: [_jsx("span", { children: summary.regularPriceLabel }), _jsx("s", { children: summary.originalPriceValue })] }), _jsxs("p", { className: 'fg-sheet-row fg-sheet-row--discount', children: [_jsx("span", { children: summary.discountLabel }), _jsx("strong", { children: summary.discountAmountLabel })] }), summary.promoCode.trim() ? (_jsxs("p", { className: 'fg-sheet-promo', children: [_jsx("span", { children: summary.promoCodeLabel }), _jsxs("strong", { children: [_jsx(CheckIcon, {}), summary.promoCode.trim()] })] })) : null, _jsx("hr", {})] })) : null, _jsxs("p", { className: 'fg-sheet-total', children: [_jsx("span", { children: summary.totalLabel }), _jsxs("strong", { children: [_jsx(TagIcon, {}), summary.totalValue] })] }), summary.promoActive && summary.savedLabel ? (_jsxs("p", { className: 'fg-sheet-saved', children: [_jsx("span", { "aria-hidden": 'true', children: "\uD83D\uDD25" }), summary.savedLabel] })) : null] })] })) : null, _jsx("div", { className: 'fg-sheet-methods', children: children }), guaranteeLabel ? _jsxs("p", { className: 'fg-sheet-guarantee', children: [_jsx(LockIcon, {}), guaranteeLabel] }) : null] }) }), _jsx("style", { children: checkoutSheetStyles })] }));
|
|
87
|
+
}
|
|
88
|
+
function CheckIcon() {
|
|
89
|
+
return (_jsxs("svg", { className: 'fg-sheet-check', viewBox: '0 0 13 13', "aria-hidden": 'true', children: [_jsx("circle", { cx: '6.5', cy: '6.5', r: '5.7', fill: '#1e7019' }), _jsx("path", { d: 'M3.9 6.66 5.6 8.37 9.1 4.63', fill: 'none', stroke: '#fff', strokeWidth: '1.46', strokeLinecap: 'round', strokeLinejoin: 'round' })] }));
|
|
90
|
+
}
|
|
91
|
+
function TagIcon() {
|
|
92
|
+
return (_jsxs("svg", { className: 'fg-sheet-tag', viewBox: '0 0 20 20', "aria-hidden": 'true', children: [_jsx("path", { d: 'M2.5 10V3.33c0-.46.37-.83.83-.83H10l7.5 7.5-7.5 7.5L2.5 10Z', fill: 'none', stroke: 'currentColor', strokeWidth: '1.67', strokeLinejoin: 'round' }), _jsx("circle", { cx: '6.67', cy: '6.67', r: '1.33', fill: 'currentColor' })] }));
|
|
93
|
+
}
|
|
94
|
+
function LockIcon() {
|
|
95
|
+
return (_jsxs("svg", { className: 'fg-sheet-lock', viewBox: '0 0 18 18', "aria-hidden": 'true', children: [_jsx("path", { d: 'M5.63 7.88V5.85a3.38 3.38 0 0 1 6.75 0v2.03', fill: 'none', stroke: '#2e8b2a', strokeWidth: '1.9', strokeLinecap: 'round' }), _jsx("rect", { x: '2.81', y: '7.65', width: '12.38', height: '9', rx: '2.47', fill: '#2e8b2a' })] }));
|
|
96
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Styles for CheckoutSheet; accents come from its `accentColor` and `selectedColor` props. */
|
|
2
|
+
export declare const checkoutSheetStyles = "\n.fg-sheet-overlay {\n position: fixed;\n inset: 0;\n z-index: 80;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n background: rgb(20 26 61 / 50%);\n animation: fg-sheet-fade-in .2s ease-out;\n}\n\n.fg-sheet {\n width: min(100%, var(--shell-width, 430px));\n max-height: calc(100dvh - 24px);\n overflow-y: auto;\n overscroll-behavior: contain;\n border-radius: 28px 28px 0 0;\n background: #eef3fb;\n box-sizing: border-box;\n font-family: Inter, var(--font-family-base), sans-serif;\n color: #1c1f33;\n animation: fg-sheet-up .32s cubic-bezier(.25, .8, .25, 1);\n}\n\n.fg-sheet-content {\n display: flex;\n flex-direction: column;\n gap: 14px;\n padding: 12px 24px calc(34px + env(safe-area-inset-bottom, 0px));\n}\n\n@keyframes fg-sheet-up { from { transform: translateY(100%); } }\n@keyframes fg-sheet-fade-in { from { opacity: 0; } }\n@media (prefers-reduced-motion: reduce) {\n .fg-sheet, .fg-sheet-overlay { animation: none; }\n}\n\n.fg-sheet-grabber {\n align-self: center;\n width: 40px;\n height: 5px;\n border-radius: 3px;\n background: #c9d3e6;\n}\n\n.fg-sheet-head {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 40px;\n}\n\n.fg-sheet-head h2 {\n margin: 0;\n font-size: 20px;\n font-weight: 800;\n line-height: 1.2;\n}\n\n.fg-sheet-close {\n position: absolute;\n left: 0;\n top: 0;\n display: grid;\n place-items: center;\n width: 40px;\n height: 40px;\n padding: 0;\n border: 0;\n border-radius: 12px;\n background: #fff;\n cursor: pointer;\n}\n\n.fg-sheet-close svg {\n width: 16px;\n height: 16px;\n fill: none;\n stroke: #4a5068;\n stroke-width: 1.8;\n stroke-linecap: round;\n}\n\n.fg-sheet-close:focus-visible { outline: 3px solid var(--fg-sheet-accent); outline-offset: 2px; }\n\n.fg-sheet-timer {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 10px;\n margin: 0;\n padding: 10px 14px;\n border: 1px solid #dce6f5;\n border-radius: 14px;\n background: #fff;\n box-shadow: 0 4px 12px rgb(31 41 107 / 6%);\n font-size: 15px;\n font-weight: 700;\n}\n\n.fg-sheet-timer > span:first-child { font-size: 18px; }\n\n.fg-sheet-timer-value {\n padding: 3px 8px;\n border-radius: 8px;\n background: #eef3fb;\n color: #1f2a6b;\n font-size: 16px;\n font-weight: 800;\n letter-spacing: .32px;\n font-variant-numeric: tabular-nums;\n}\n\n.fg-sheet-proof {\n margin: 0;\n font-size: 15px;\n font-weight: 700;\n line-height: 21px;\n text-align: center;\n}\n\n.fg-sheet-proof strong { color: var(--fg-sheet-accent); }\n\n.fg-sheet-summary {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 14px 16px;\n border-radius: 16px;\n background: #fff;\n}\n\n.fg-sheet-summary hr {\n width: 100%;\n margin: 0;\n border: 0;\n border-top: 1px solid #dce6f5;\n}\n\n.fg-sheet-row,\n.fg-sheet-promo,\n.fg-sheet-total {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n margin: 0;\n}\n\n.fg-sheet-row--muted { color: #646b82; font-size: 14px; }\n.fg-sheet-row--discount { font-size: 15px; font-weight: 700; }\n.fg-sheet-row--discount strong { color: #cc2b31; font-weight: 800; }\n\n.fg-sheet-promo {\n padding: 9px 12px;\n border-radius: 10px;\n background: #eef3fb;\n color: #646b82;\n font-size: 13px;\n}\n\n.fg-sheet-promo strong,\n.fg-sheet-total strong {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n color: #1c1f33;\n font-weight: 800;\n}\n\n.fg-sheet-promo strong { font-size: 14px; letter-spacing: .42px; text-transform: uppercase; }\n.fg-sheet-check { width: 13px; height: 13px; }\n.fg-sheet-total span { font-size: 20px; font-weight: 800; }\n.fg-sheet-total strong { font-size: 24px; }\n.fg-sheet-tag { width: 20px; height: 20px; }\n\n.fg-sheet-saved {\n display: inline-flex;\n align-self: flex-end;\n align-items: center;\n gap: 6px;\n margin: 0;\n padding: 6px 12px;\n border-radius: 99px;\n background: #fde3e4;\n color: #b4232a;\n font-size: 13px;\n font-weight: 700;\n}\n\n/* Wallet-first payment methods, restyled for the sheet. */\n.fg-sheet .wfc { gap: 10px; }\n.fg-sheet .wfc-method { border-radius: 18px; box-shadow: 0 0 0 1px #dce6f5; transition: box-shadow .2s ease; }\n.fg-sheet .wfc-method[data-checked='true'] { box-shadow: 0 0 0 2px var(--fg-sheet-selected); }\n.fg-sheet .wfc-method-head { min-height: 58px; padding: 16px; gap: 12px; border-radius: 18px; }\n.fg-sheet .wfc-radio { border-color: #b9bfcc; }\n.fg-sheet .wfc-method[data-checked='true'] .wfc-radio { border-color: var(--fg-sheet-selected); }\n.fg-sheet .wfc-mark { height: 26px; }\n.fg-sheet .wfc-brand { width: 42px; height: 28px; border-radius: 5px; }\n.fg-sheet .wfc-benefits:empty { display: none; }\n.fg-sheet .wfc-wallet-button,\n.fg-sheet .wfc-progress { border-radius: 14px; }\n.fg-sheet .wfc-secure { margin-top: 10px; color: #646b82; font-size: 13px; }\n.fg-sheet .wfc-card-form .wfc-secure { display: none; }\n.fg-sheet .wfc-submit {\n min-height: 56px;\n border-radius: 14px;\n font: 700 18px/1.2 Inter, var(--font-family-base), sans-serif;\n}\n\n.fg-sheet-error {\n margin: 0;\n color: #c62828;\n font-size: 14px;\n text-align: center;\n}\n\n.fg-sheet-guarantee {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin: 0;\n font-size: 15px;\n font-weight: 700;\n}\n\n.fg-sheet-lock { width: 18px; height: 18px; flex: none; }\n\n/* Prepared in the background: rendered for the payment provider, invisible and inert for the visitor. */\n.fg-sheet-overlay[data-visible='false'] {\n visibility: hidden;\n pointer-events: none;\n animation: none;\n}\n.fg-sheet-overlay[data-visible='false'] .fg-sheet { animation: none; }\n.fg-sheet-close:disabled { cursor: default; opacity: .5; }\n";
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/** Styles for CheckoutSheet; accents come from its `accentColor` and `selectedColor` props. */
|
|
2
|
+
export const checkoutSheetStyles = `
|
|
3
|
+
.fg-sheet-overlay {
|
|
4
|
+
position: fixed;
|
|
5
|
+
inset: 0;
|
|
6
|
+
z-index: 80;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: flex-end;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
background: rgb(20 26 61 / 50%);
|
|
11
|
+
animation: fg-sheet-fade-in .2s ease-out;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.fg-sheet {
|
|
15
|
+
width: min(100%, var(--shell-width, 430px));
|
|
16
|
+
max-height: calc(100dvh - 24px);
|
|
17
|
+
overflow-y: auto;
|
|
18
|
+
overscroll-behavior: contain;
|
|
19
|
+
border-radius: 28px 28px 0 0;
|
|
20
|
+
background: #eef3fb;
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
font-family: Inter, var(--font-family-base), sans-serif;
|
|
23
|
+
color: #1c1f33;
|
|
24
|
+
animation: fg-sheet-up .32s cubic-bezier(.25, .8, .25, 1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.fg-sheet-content {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
gap: 14px;
|
|
31
|
+
padding: 12px 24px calc(34px + env(safe-area-inset-bottom, 0px));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@keyframes fg-sheet-up { from { transform: translateY(100%); } }
|
|
35
|
+
@keyframes fg-sheet-fade-in { from { opacity: 0; } }
|
|
36
|
+
@media (prefers-reduced-motion: reduce) {
|
|
37
|
+
.fg-sheet, .fg-sheet-overlay { animation: none; }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.fg-sheet-grabber {
|
|
41
|
+
align-self: center;
|
|
42
|
+
width: 40px;
|
|
43
|
+
height: 5px;
|
|
44
|
+
border-radius: 3px;
|
|
45
|
+
background: #c9d3e6;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.fg-sheet-head {
|
|
49
|
+
position: relative;
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
min-height: 40px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.fg-sheet-head h2 {
|
|
57
|
+
margin: 0;
|
|
58
|
+
font-size: 20px;
|
|
59
|
+
font-weight: 800;
|
|
60
|
+
line-height: 1.2;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.fg-sheet-close {
|
|
64
|
+
position: absolute;
|
|
65
|
+
left: 0;
|
|
66
|
+
top: 0;
|
|
67
|
+
display: grid;
|
|
68
|
+
place-items: center;
|
|
69
|
+
width: 40px;
|
|
70
|
+
height: 40px;
|
|
71
|
+
padding: 0;
|
|
72
|
+
border: 0;
|
|
73
|
+
border-radius: 12px;
|
|
74
|
+
background: #fff;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.fg-sheet-close svg {
|
|
79
|
+
width: 16px;
|
|
80
|
+
height: 16px;
|
|
81
|
+
fill: none;
|
|
82
|
+
stroke: #4a5068;
|
|
83
|
+
stroke-width: 1.8;
|
|
84
|
+
stroke-linecap: round;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.fg-sheet-close:focus-visible { outline: 3px solid var(--fg-sheet-accent); outline-offset: 2px; }
|
|
88
|
+
|
|
89
|
+
.fg-sheet-timer {
|
|
90
|
+
display: flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
justify-content: center;
|
|
93
|
+
gap: 10px;
|
|
94
|
+
margin: 0;
|
|
95
|
+
padding: 10px 14px;
|
|
96
|
+
border: 1px solid #dce6f5;
|
|
97
|
+
border-radius: 14px;
|
|
98
|
+
background: #fff;
|
|
99
|
+
box-shadow: 0 4px 12px rgb(31 41 107 / 6%);
|
|
100
|
+
font-size: 15px;
|
|
101
|
+
font-weight: 700;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.fg-sheet-timer > span:first-child { font-size: 18px; }
|
|
105
|
+
|
|
106
|
+
.fg-sheet-timer-value {
|
|
107
|
+
padding: 3px 8px;
|
|
108
|
+
border-radius: 8px;
|
|
109
|
+
background: #eef3fb;
|
|
110
|
+
color: #1f2a6b;
|
|
111
|
+
font-size: 16px;
|
|
112
|
+
font-weight: 800;
|
|
113
|
+
letter-spacing: .32px;
|
|
114
|
+
font-variant-numeric: tabular-nums;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.fg-sheet-proof {
|
|
118
|
+
margin: 0;
|
|
119
|
+
font-size: 15px;
|
|
120
|
+
font-weight: 700;
|
|
121
|
+
line-height: 21px;
|
|
122
|
+
text-align: center;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.fg-sheet-proof strong { color: var(--fg-sheet-accent); }
|
|
126
|
+
|
|
127
|
+
.fg-sheet-summary {
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
gap: 10px;
|
|
131
|
+
padding: 14px 16px;
|
|
132
|
+
border-radius: 16px;
|
|
133
|
+
background: #fff;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.fg-sheet-summary hr {
|
|
137
|
+
width: 100%;
|
|
138
|
+
margin: 0;
|
|
139
|
+
border: 0;
|
|
140
|
+
border-top: 1px solid #dce6f5;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.fg-sheet-row,
|
|
144
|
+
.fg-sheet-promo,
|
|
145
|
+
.fg-sheet-total {
|
|
146
|
+
display: flex;
|
|
147
|
+
align-items: center;
|
|
148
|
+
justify-content: space-between;
|
|
149
|
+
gap: 12px;
|
|
150
|
+
margin: 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.fg-sheet-row--muted { color: #646b82; font-size: 14px; }
|
|
154
|
+
.fg-sheet-row--discount { font-size: 15px; font-weight: 700; }
|
|
155
|
+
.fg-sheet-row--discount strong { color: #cc2b31; font-weight: 800; }
|
|
156
|
+
|
|
157
|
+
.fg-sheet-promo {
|
|
158
|
+
padding: 9px 12px;
|
|
159
|
+
border-radius: 10px;
|
|
160
|
+
background: #eef3fb;
|
|
161
|
+
color: #646b82;
|
|
162
|
+
font-size: 13px;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.fg-sheet-promo strong,
|
|
166
|
+
.fg-sheet-total strong {
|
|
167
|
+
display: inline-flex;
|
|
168
|
+
align-items: center;
|
|
169
|
+
gap: 6px;
|
|
170
|
+
color: #1c1f33;
|
|
171
|
+
font-weight: 800;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.fg-sheet-promo strong { font-size: 14px; letter-spacing: .42px; text-transform: uppercase; }
|
|
175
|
+
.fg-sheet-check { width: 13px; height: 13px; }
|
|
176
|
+
.fg-sheet-total span { font-size: 20px; font-weight: 800; }
|
|
177
|
+
.fg-sheet-total strong { font-size: 24px; }
|
|
178
|
+
.fg-sheet-tag { width: 20px; height: 20px; }
|
|
179
|
+
|
|
180
|
+
.fg-sheet-saved {
|
|
181
|
+
display: inline-flex;
|
|
182
|
+
align-self: flex-end;
|
|
183
|
+
align-items: center;
|
|
184
|
+
gap: 6px;
|
|
185
|
+
margin: 0;
|
|
186
|
+
padding: 6px 12px;
|
|
187
|
+
border-radius: 99px;
|
|
188
|
+
background: #fde3e4;
|
|
189
|
+
color: #b4232a;
|
|
190
|
+
font-size: 13px;
|
|
191
|
+
font-weight: 700;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* Wallet-first payment methods, restyled for the sheet. */
|
|
195
|
+
.fg-sheet .wfc { gap: 10px; }
|
|
196
|
+
.fg-sheet .wfc-method { border-radius: 18px; box-shadow: 0 0 0 1px #dce6f5; transition: box-shadow .2s ease; }
|
|
197
|
+
.fg-sheet .wfc-method[data-checked='true'] { box-shadow: 0 0 0 2px var(--fg-sheet-selected); }
|
|
198
|
+
.fg-sheet .wfc-method-head { min-height: 58px; padding: 16px; gap: 12px; border-radius: 18px; }
|
|
199
|
+
.fg-sheet .wfc-radio { border-color: #b9bfcc; }
|
|
200
|
+
.fg-sheet .wfc-method[data-checked='true'] .wfc-radio { border-color: var(--fg-sheet-selected); }
|
|
201
|
+
.fg-sheet .wfc-mark { height: 26px; }
|
|
202
|
+
.fg-sheet .wfc-brand { width: 42px; height: 28px; border-radius: 5px; }
|
|
203
|
+
.fg-sheet .wfc-benefits:empty { display: none; }
|
|
204
|
+
.fg-sheet .wfc-wallet-button,
|
|
205
|
+
.fg-sheet .wfc-progress { border-radius: 14px; }
|
|
206
|
+
.fg-sheet .wfc-secure { margin-top: 10px; color: #646b82; font-size: 13px; }
|
|
207
|
+
.fg-sheet .wfc-card-form .wfc-secure { display: none; }
|
|
208
|
+
.fg-sheet .wfc-submit {
|
|
209
|
+
min-height: 56px;
|
|
210
|
+
border-radius: 14px;
|
|
211
|
+
font: 700 18px/1.2 Inter, var(--font-family-base), sans-serif;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.fg-sheet-error {
|
|
215
|
+
margin: 0;
|
|
216
|
+
color: #c62828;
|
|
217
|
+
font-size: 14px;
|
|
218
|
+
text-align: center;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.fg-sheet-guarantee {
|
|
222
|
+
display: flex;
|
|
223
|
+
align-items: center;
|
|
224
|
+
justify-content: center;
|
|
225
|
+
gap: 8px;
|
|
226
|
+
margin: 0;
|
|
227
|
+
font-size: 15px;
|
|
228
|
+
font-weight: 700;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.fg-sheet-lock { width: 18px; height: 18px; flex: none; }
|
|
232
|
+
|
|
233
|
+
/* Prepared in the background: rendered for the payment provider, invisible and inert for the visitor. */
|
|
234
|
+
.fg-sheet-overlay[data-visible='false'] {
|
|
235
|
+
visibility: hidden;
|
|
236
|
+
pointer-events: none;
|
|
237
|
+
animation: none;
|
|
238
|
+
}
|
|
239
|
+
.fg-sheet-overlay[data-visible='false'] .fg-sheet { animation: none; }
|
|
240
|
+
.fg-sheet-close:disabled { cursor: default; opacity: .5; }
|
|
241
|
+
`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Building blocks shared by the wallet-first Stripe and Solidgate checkouts. Internal to the package. */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { type PlatformWalletPaymentMethod } from '../providers/stripe/components/walletPlatform.js';
|
|
4
|
+
export declare function MethodCard({ checked, children, disabled, header, label, onSelect }: {
|
|
5
|
+
checked: boolean;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
header: ReactNode;
|
|
9
|
+
label: string;
|
|
10
|
+
onSelect: () => void;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function ApplePayMark(): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function GooglePayMark(): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function CardBrandMarks(): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
/** Google Pay on Android, Apple Pay everywhere else — read synchronously from the browser. */
|
|
16
|
+
export declare function usePlatformWallet(): PlatformWalletPaymentMethod;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/** Building blocks shared by the wallet-first Stripe and Solidgate checkouts. Internal to the package. */
|
|
4
|
+
import { useSyncExternalStore } from 'react';
|
|
5
|
+
import { resolveWalletPlatform } from '../providers/stripe/components/walletPlatform.js';
|
|
6
|
+
export function MethodCard({ checked, children, disabled, header, label, onSelect }) {
|
|
7
|
+
return (_jsxs("section", { className: 'wfc-method', "data-checked": checked, children: [_jsxs("button", { type: 'button', role: 'radio', "aria-checked": checked, "aria-label": label, className: 'wfc-method-head', disabled: disabled, onClick: onSelect, children: [_jsx("span", { className: 'wfc-radio', "aria-hidden": 'true' }), header] }), _jsx("div", { className: 'wfc-method-body', "data-open": checked, inert: !checked, "aria-hidden": !checked, children: _jsx("div", { className: 'wfc-method-clip', children: _jsx("div", { className: 'wfc-method-content', children: children }) }) })] }));
|
|
8
|
+
}
|
|
9
|
+
export function ApplePayMark() {
|
|
10
|
+
return (_jsxs("svg", { className: 'wfc-mark wfc-mark--apple', viewBox: '0 0 64 26', role: 'img', "aria-label": 'Apple Pay', children: [_jsx("path", { d: 'M14.6 13.6c0-2.6 2.1-3.8 2.2-3.9-1.2-1.8-3.1-2-3.7-2-1.6-.2-3.1.9-3.9.9-.8 0-2-.9-3.4-.9-1.7 0-3.3 1-4.2 2.6-1.8 3.1-.5 7.7 1.3 10.2.9 1.2 1.9 2.6 3.2 2.6 1.3-.1 1.8-.8 3.3-.8 1.6 0 2 .8 3.4.8s2.3-1.3 3.1-2.5c1-1.4 1.4-2.8 1.4-2.9 0 0-2.7-1-2.7-4.1ZM12.1 6c.7-.9 1.2-2 1-3.2-1 0-2.3.7-3 1.6-.7.8-1.3 2-1.1 3.1 1.1.1 2.3-.6 3.1-1.5Z', fill: 'currentColor' }), _jsx("text", { x: '22', y: '20', fontSize: '17', fontWeight: '600', fill: 'currentColor', fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', children: "Pay" })] }));
|
|
11
|
+
}
|
|
12
|
+
export function GooglePayMark() {
|
|
13
|
+
return (_jsxs("svg", { className: 'wfc-mark wfc-mark--google', viewBox: '0 0 64 26', role: 'img', "aria-label": 'Google Pay', children: [_jsx("path", { d: 'M19.6 13.2c0-.6-.1-1.2-.2-1.8h-8.6v3.4h4.9a4.2 4.2 0 0 1-1.8 2.8v2.3h2.9c1.7-1.6 2.8-3.9 2.8-6.7Z', fill: '#4285F4' }), _jsx("path", { d: 'M10.8 22c2.4 0 4.5-.8 6-2.2l-2.9-2.3c-.8.6-1.9.9-3.1.9-2.4 0-4.4-1.6-5.1-3.7h-3v2.3A9 9 0 0 0 10.8 22Z', fill: '#34A853' }), _jsx("path", { d: 'M5.7 14.7a5.4 5.4 0 0 1 0-3.4V9H2.7a9 9 0 0 0 0 8l3-2.3Z', fill: '#FBBC04' }), _jsx("path", { d: 'M10.8 7.6c1.3 0 2.5.5 3.5 1.4l2.6-2.6A9 9 0 0 0 2.7 9l3 2.3c.7-2.1 2.7-3.7 5.1-3.7Z', fill: '#EA4335' }), _jsx("text", { x: '23', y: '20', fontSize: '17', fontWeight: '500', fill: '#3c4043', fontFamily: '"Google Sans", Roboto, -apple-system, sans-serif', children: "Pay" })] }));
|
|
14
|
+
}
|
|
15
|
+
export function CardBrandMarks() {
|
|
16
|
+
return (_jsxs("span", { className: 'wfc-card-marks', "aria-hidden": 'true', children: [_jsx("svg", { viewBox: '0 0 48 30', className: 'wfc-brand', children: _jsx("text", { x: '24', y: '21', textAnchor: 'middle', fontSize: '17', fontWeight: '800', fontStyle: 'italic', fill: '#1a1f71', fontFamily: 'Arial, sans-serif', children: "VISA" }) }), _jsxs("svg", { viewBox: '0 0 48 30', className: 'wfc-brand', children: [_jsx("circle", { cx: '19', cy: '15', r: '10', fill: '#eb001b' }), _jsx("circle", { cx: '29', cy: '15', r: '10', fill: '#f79e1b', fillOpacity: '.9' })] }), _jsxs("svg", { viewBox: '0 0 48 30', className: 'wfc-brand wfc-brand--box', style: { background: '#1b4fa0' }, children: [_jsx("circle", { cx: '19', cy: '15', r: '9', fill: '#0099df' }), _jsx("circle", { cx: '29', cy: '15', r: '9', fill: '#e60014', fillOpacity: '.85' })] }), _jsx("svg", { viewBox: '0 0 48 30', className: 'wfc-brand wfc-brand--box', style: { background: '#2e77bc' }, children: _jsx("text", { x: '24', y: '19', textAnchor: 'middle', fontSize: '10', fontWeight: '800', fill: '#fff', fontFamily: 'Arial, sans-serif', children: "AMEX" }) })] }));
|
|
17
|
+
}
|
|
18
|
+
/** Google Pay on Android, Apple Pay everywhere else — read synchronously from the browser. */
|
|
19
|
+
export function usePlatformWallet() {
|
|
20
|
+
const platform = useSyncExternalStore(() => () => undefined, () => resolveWalletPlatform({ maxTouchPoints: navigator.maxTouchPoints, userAgent: navigator.userAgent }), () => 'ios');
|
|
21
|
+
return platform === 'android' ? 'googlePay' : 'applePay';
|
|
22
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PAYMENTS_PACKAGE_VERSION = "0.
|
|
1
|
+
export declare const PAYMENTS_PACKAGE_VERSION = "0.65.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.65.0";
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './providers/paymentProvider.types.js';
|
|
|
15
15
|
export * from './providers/stripe/index.js';
|
|
16
16
|
export * from './providers/solidgate/index.js';
|
|
17
17
|
export { ManageSubscriptionScreen, type ManageSubscriptionContent, type ManageSubscriptionScreenProps, type ManageSubscriptionLabels, } from './components/ManageSubscriptionScreen.js';
|
|
18
|
+
export { CheckoutSheet, type CheckoutSheetProps, type CheckoutSheetSummary } from './components/CheckoutSheet.js';
|
|
18
19
|
export { isCheckoutEmailError, isValidCheckoutEmail } from './services/checkoutEmail.js';
|
|
19
20
|
export * from './components/CheckoutEmailDialog.js';
|
|
20
21
|
export * from './components/CreatorDealBanner.js';
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export * from './providers/stripe/index.js';
|
|
|
17
17
|
export * from './providers/solidgate/index.js';
|
|
18
18
|
// Provider-neutral subscription management UI.
|
|
19
19
|
export { ManageSubscriptionScreen, } from './components/ManageSubscriptionScreen.js';
|
|
20
|
+
export { CheckoutSheet } from './components/CheckoutSheet.js';
|
|
20
21
|
export { isCheckoutEmailError, isValidCheckoutEmail } from './services/checkoutEmail.js';
|
|
21
22
|
export * from './components/CheckoutEmailDialog.js';
|
|
22
23
|
export * from './components/CreatorDealBanner.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SolidgateCheckoutDialogProps } from './SolidgateCheckoutDialog.types.js';
|
|
2
2
|
export type { SolidgateCheckoutDialogState, SolidgateCheckoutDialogContent, SolidgateCheckoutDialogPresentation, SolidgateCheckoutDialogProps, SolidgateCheckoutAnalyticsContext, SolidgateCheckoutSuccess, SolidgatePaymentMethod, } from './SolidgateCheckoutDialog.types.js';
|
|
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;
|
|
3
|
+
export declare function SolidgateCheckoutDialog({ open, layout, visible, request, customerEmail, checkoutAnalytics, content, presentation, onClose, onCustomerEmailCommit, onSuccess, onRetry, onError, onPreparationStart, onStateChange, onPaymentPendingChange, }: SolidgateCheckoutDialogProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -8,6 +8,7 @@ import { trackCheckoutCanceled, trackCheckoutFailureShown, } from '../../../serv
|
|
|
8
8
|
import { isSolidgateCustomerDecline, solidgateDeclineMessage } from '../services/solidgateDeclineMessage.js';
|
|
9
9
|
import { solidgateFailureDetails } from '../services/solidgateFailureDetails.js';
|
|
10
10
|
import { SolidgateCheckoutSummary } from './SolidgateCheckoutSummary.js';
|
|
11
|
+
import { SolidgateCheckoutSheetLayout } from './SolidgateCheckoutSheetLayout.js';
|
|
11
12
|
import { SolidgatePaymentForm } from './SolidgatePaymentForm.js';
|
|
12
13
|
import { useSolidgateWalletReadiness } from './useSolidgateWalletReadiness.js';
|
|
13
14
|
import { solidgateCheckoutDialogStyles } from './SolidgateCheckoutDialog.styles.js';
|
|
@@ -42,8 +43,8 @@ const initialView = {
|
|
|
42
43
|
canResumeVerification: false,
|
|
43
44
|
};
|
|
44
45
|
const isAbortError = (error) => (error instanceof DOMException && error.name === 'AbortError');
|
|
45
|
-
export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, customerEmail, checkoutAnalytics, content, presentation, onClose, onCustomerEmailCommit, onSuccess, onRetry, onError, onPreparationStart, onStateChange, onPaymentPendingChange, }) {
|
|
46
|
-
var _a;
|
|
46
|
+
export function SolidgateCheckoutDialog({ open, layout = 'dialog', visible = true, request, customerEmail, checkoutAnalytics, content, presentation, onClose, onCustomerEmailCommit, onSuccess, onRetry, onError, onPreparationStart, onStateChange, onPaymentPendingChange, }) {
|
|
47
|
+
var _a, _b, _c, _d;
|
|
47
48
|
const copy = useMemo(() => (Object.assign(Object.assign({}, defaultContent), content)), [content]);
|
|
48
49
|
const [view, setView] = useState(initialView);
|
|
49
50
|
const [retryRequest, setRetryRequest] = useState(null);
|
|
@@ -152,7 +153,7 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
152
153
|
}, []);
|
|
153
154
|
const requiresEmailCommit = Boolean(onCustomerEmailCommit);
|
|
154
155
|
const startedAttemptRef = useRef(null);
|
|
155
|
-
const walletReadiness = useSolidgateWalletReadiness(checkoutAnalyticsRef, layout
|
|
156
|
+
const walletReadiness = useSolidgateWalletReadiness(checkoutAnalyticsRef, layout !== 'dialog' && view.state === 'ready' ? (_a = view.checkout) === null || _a === void 0 ? void 0 : _a.attemptId : undefined);
|
|
156
157
|
const { startPreparation: startWalletPreparation, finishPreparation: finishWalletPreparation } = walletReadiness;
|
|
157
158
|
const active = open && (layout !== 'wallet' || Boolean(normalizedCustomerEmail));
|
|
158
159
|
useEffect(() => {
|
|
@@ -187,7 +188,7 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
187
188
|
setState(initialView);
|
|
188
189
|
}
|
|
189
190
|
});
|
|
190
|
-
const walletPreparation = layout
|
|
191
|
+
const walletPreparation = layout !== 'dialog' ? startWalletPreparation() : null;
|
|
191
192
|
void prepareSolidgateCheckout(Object.assign(Object.assign({}, preparedRequest), { signal: controller.signal }))
|
|
192
193
|
.then((checkout) => {
|
|
193
194
|
if (!controller.signal.aborted) {
|
|
@@ -195,7 +196,7 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
195
196
|
if (walletPreparation)
|
|
196
197
|
finishWalletPreparation(walletPreparation, checkout.attemptId);
|
|
197
198
|
setState({ state: 'ready', checkout, canResumeVerification: false });
|
|
198
|
-
if (layout
|
|
199
|
+
if (layout === 'dialog') {
|
|
199
200
|
void trackSolidgateCheckoutEvent('checkout_started', checkout.attemptId, checkoutAnalyticsRef.current);
|
|
200
201
|
}
|
|
201
202
|
}
|
|
@@ -225,7 +226,8 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
225
226
|
|| view.state === 'success' || view.canResumeVerification;
|
|
226
227
|
useEffect(() => {
|
|
227
228
|
var _a;
|
|
228
|
-
|
|
229
|
+
// The sheet handles Escape and focus itself.
|
|
230
|
+
if (!open || layout === 'sheet' || (layout === 'wallet' && !hasExistingSubscription)) {
|
|
229
231
|
return;
|
|
230
232
|
}
|
|
231
233
|
const previouslyFocused = document.activeElement instanceof HTMLElement
|
|
@@ -288,10 +290,13 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
288
290
|
beforeNotify: () => trackSolidgateCheckoutEvent('checkout_completed', checkout.attemptId, checkoutAnalyticsRef.current),
|
|
289
291
|
});
|
|
290
292
|
const submitted = submittedMethodRef.current;
|
|
291
|
-
if (!embedded)
|
|
293
|
+
if (!embedded) {
|
|
294
|
+
// An embedded paywall reports completion before notifying its parent; a funnel page reports it here.
|
|
295
|
+
await trackSolidgateCheckoutEvent('checkout_completed', checkout.attemptId, checkoutAnalyticsRef.current);
|
|
292
296
|
await ((_b = onSuccessRef.current) === null || _b === void 0 ? void 0 : _b.call(onSuccessRef, checkout, {
|
|
293
297
|
paymentMethod: (submitted === null || submitted === void 0 ? void 0 : submitted.attemptId) === checkout.attemptId ? submitted.paymentMethod : null,
|
|
294
298
|
}));
|
|
299
|
+
}
|
|
295
300
|
successAttemptRef.current = checkout.attemptId;
|
|
296
301
|
}
|
|
297
302
|
setState({ state: 'success', checkout, canResumeVerification: false });
|
|
@@ -417,12 +422,24 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
417
422
|
void trackSolidgateCheckoutEvent('add_payment_info', ((_c = view.checkout) === null || _c === void 0 ? void 0 : _c.attemptId) || '', checkoutAnalyticsRef.current);
|
|
418
423
|
}
|
|
419
424
|
setState(Object.assign(Object.assign({}, view), { state: 'submitting' }));
|
|
420
|
-
}, onVerify: () => void verifyCanonicalStatus(true), onPaymentResult: () => void verifyCanonicalStatus(false), onWalletsChange: layout
|
|
425
|
+
}, onVerify: () => void verifyCanonicalStatus(true), onPaymentResult: () => void verifyCanonicalStatus(false), onWalletsChange: layout !== 'dialog' ? walletReadiness.reportWalletsReady : undefined, walletFirst: layout === 'sheet' ? {
|
|
426
|
+
walletLabels: (_b = presentation === null || presentation === void 0 ? void 0 : presentation.walletLabels) !== null && _b !== void 0 ? _b : { applePay: 'Apple Pay', googlePay: 'Google Pay' },
|
|
427
|
+
walletUnavailableNote: (_c = presentation === null || presentation === void 0 ? void 0 : presentation.walletUnavailableNote) !== null && _c !== void 0 ? _c : '{wallet} isn’t available in this browser. Pay with a card below.',
|
|
428
|
+
secureNote: (presentation === null || presentation === void 0 ? void 0 : presentation.secureLabel) || '',
|
|
429
|
+
themeColor: (presentation === null || presentation === void 0 ? void 0 : presentation.selectedColor) || '#4db53f',
|
|
430
|
+
} : undefined, onError: (error) => {
|
|
421
431
|
var _a, _b;
|
|
422
432
|
setState(Object.assign(Object.assign({}, view), { state: 'recoverable_error', canResumeVerification: false }));
|
|
423
433
|
trackFailure(copyRef.current.error, 'payment_form', (_a = view.checkout) === null || _a === void 0 ? void 0 : _a.attemptId, solidgateFailureDetails(error));
|
|
424
434
|
(_b = onErrorRef.current) === null || _b === void 0 ? void 0 : _b.call(onErrorRef, copyRef.current.error);
|
|
425
435
|
} }, view.checkout.attemptId)) : null;
|
|
436
|
+
const emailForm = (_jsxs("form", { className: 'solidgate-checkout-email-form', onSubmit: (event) => void commitCustomerEmail(event), children: [_jsxs("label", { className: 'solidgate-checkout-email-label', children: [copy.customerEmailLabel, _jsx("input", { type: 'email', autoComplete: 'email', inputMode: 'email', maxLength: 320, required: true, value: emailInput, onChange: (event) => {
|
|
437
|
+
setEmailInput(event.target.value);
|
|
438
|
+
setEmailError(null);
|
|
439
|
+
}, placeholder: copy.customerEmailPlaceholder, "aria-invalid": Boolean(emailError), className: 'solidgate-checkout-email-input' })] }), emailError ? (_jsx("p", { role: 'alert', className: 'solidgate-checkout-alert', children: emailError })) : null, _jsx("button", { type: 'submit', disabled: emailSubmitting, className: 'solidgate-checkout-action', children: copy.customerEmailContinue })] }));
|
|
440
|
+
if (layout === 'sheet') {
|
|
441
|
+
return (_jsxs(SolidgateCheckoutSheetLayout, { visible: visible, attemptId: view.state === 'ready' ? (_d = view.checkout) === null || _d === void 0 ? void 0 : _d.attemptId : undefined, checkoutAnalyticsRef: checkoutAnalyticsRef, title: hasExistingSubscription ? copy.existingSubscriptionTitle : (presentation === null || presentation === void 0 ? void 0 : presentation.title) || copy.title, closeAriaLabel: copy.closeAriaLabel, closeDisabled: paymentPending, onClose: handleClose, presentation: hasExistingSubscription ? undefined : presentation, children: [view.state === 'collecting_email' ? emailForm : null, view.state === 'loading' && !view.checkout ? (_jsx("span", { className: 'wfc-progress wfc-progress--form', role: 'status', "aria-label": copy.loading })) : null, paymentForm, statusMessage && view.state !== 'ready' && view.state !== 'loading' ? (_jsx("div", { className: 'solidgate-checkout-status', children: _jsx("p", { role: 'status', "aria-live": 'polite', children: statusMessage }) })) : null, recoveryActions, _jsx("style", { children: solidgateCheckoutDialogStyles })] }));
|
|
442
|
+
}
|
|
426
443
|
if (layout === 'wallet' && !hasExistingSubscription) {
|
|
427
444
|
return (_jsxs("div", { className: 'solidgate-inline-wallet', onClick: (event) => {
|
|
428
445
|
var _a;
|
|
@@ -438,8 +455,5 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
|
|
|
438
455
|
'solidgate-checkout-dialog',
|
|
439
456
|
showPreparingLoader ? 'is-preparing' : '',
|
|
440
457
|
presentation && !hasExistingSubscription ? 'is-branded' : '',
|
|
441
|
-
].filter(Boolean).join(' '), children: [_jsxs("div", { className: 'solidgate-checkout-header', children: [_jsx("button", { ref: closeButtonRef, type: 'button', onClick: handleClose, disabled: paymentPending, "aria-label": copy.closeAriaLabel, className: 'solidgate-checkout-close', children: _jsx("span", { "aria-hidden": 'true' }) }), _jsx("h2", { id: 'solidgate-checkout-title', className: 'solidgate-checkout-title', children: hasExistingSubscription ? copy.existingSubscriptionTitle : (presentation === null || presentation === void 0 ? void 0 : presentation.title) || copy.title })] }), presentation && !hasExistingSubscription ? _jsx(SolidgateCheckoutSummary, { presentation: presentation }) : null, view.state === 'collecting_email' ?
|
|
442
|
-
setEmailInput(event.target.value);
|
|
443
|
-
setEmailError(null);
|
|
444
|
-
}, placeholder: copy.customerEmailPlaceholder, "aria-invalid": Boolean(emailError), className: 'solidgate-checkout-email-input' })] }), emailError ? (_jsx("p", { role: 'alert', className: 'solidgate-checkout-alert', children: emailError })) : null, _jsx("button", { type: 'submit', disabled: emailSubmitting, className: 'solidgate-checkout-action', children: copy.customerEmailContinue })] })) : null, paymentForm, statusMessage && view.state !== 'ready' ? (_jsx("div", { className: 'solidgate-checkout-status', children: _jsx("p", { role: 'status', "aria-live": 'polite', children: statusMessage }) })) : null, recoveryActions] })) : null] }), _jsx("style", { children: solidgateCheckoutDialogStyles })] }));
|
|
458
|
+
].filter(Boolean).join(' '), children: [_jsxs("div", { className: 'solidgate-checkout-header', children: [_jsx("button", { ref: closeButtonRef, type: 'button', onClick: handleClose, disabled: paymentPending, "aria-label": copy.closeAriaLabel, className: 'solidgate-checkout-close', children: _jsx("span", { "aria-hidden": 'true' }) }), _jsx("h2", { id: 'solidgate-checkout-title', className: 'solidgate-checkout-title', children: hasExistingSubscription ? copy.existingSubscriptionTitle : (presentation === null || presentation === void 0 ? void 0 : presentation.title) || copy.title })] }), presentation && !hasExistingSubscription ? _jsx(SolidgateCheckoutSummary, { presentation: presentation }) : null, view.state === 'collecting_email' ? emailForm : null, paymentForm, statusMessage && view.state !== 'ready' ? (_jsx("div", { className: 'solidgate-checkout-status', children: _jsx("p", { role: 'status', "aria-live": 'polite', children: statusMessage }) })) : null, recoveryActions] })) : null] }), _jsx("style", { children: solidgateCheckoutDialogStyles })] }));
|
|
445
459
|
}
|