@funnelsgrove/payments 0.68.0 → 0.70.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 +31 -14
- package/dist/components/CheckoutErrorOverlay.d.ts +37 -0
- package/dist/components/CheckoutErrorOverlay.js +67 -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/providers/stripe/components/SharedStripeCheckoutV2Dialog.d.ts +13 -4
- package/dist/providers/stripe/components/SharedStripeCheckoutV2Dialog.js +93 -88
- package/dist/providers/stripe/components/StripeCheckoutDialog.d.ts +31 -0
- package/dist/providers/stripe/components/StripeCheckoutDialog.js +179 -0
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.d.ts +81 -7
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.js +204 -56
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.options.d.ts +10 -2
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.options.js +4 -6
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.styles.d.ts +1 -1
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.styles.js +11 -1
- package/dist/providers/stripe/components/WalletButton.d.ts +3 -1
- package/dist/providers/stripe/components/WalletButton.js +3 -3
- package/dist/providers/stripe/components/checkout-v2.content.d.ts +3 -0
- package/dist/providers/stripe/components/index.d.ts +1 -0
- package/dist/providers/stripe/components/index.js +1 -0
- package/dist/providers/stripe/components/useCheckoutEmail.internal.d.ts +3 -1
- package/dist/providers/stripe/components/useCheckoutEmail.internal.js +8 -3
- package/dist/providers/stripe/hooks/checkoutPageAttention.d.ts +3 -0
- package/dist/providers/stripe/hooks/checkoutPageAttention.js +54 -0
- package/dist/providers/stripe/hooks/checkoutPreparationBackoff.d.ts +1 -0
- package/dist/providers/stripe/hooks/checkoutPreparationBackoff.js +5 -7
- package/dist/providers/stripe/hooks/useStripeSubscriptionCheckoutSession.js +39 -2
- package/package.json +1 -1
- package/dist/providers/stripe/components/SharedCheckoutPaymentMethods.internal.d.ts +0 -18
- package/dist/providers/stripe/components/SharedCheckoutPaymentMethods.internal.js +0 -15
- package/dist/providers/stripe/components/SharedStripeCheckoutV2Form.internal.d.ts +0 -7
- package/dist/providers/stripe/components/SharedStripeCheckoutV2Form.internal.js +0 -328
- package/dist/providers/stripe/components/SharedStripeCheckoutV2Summary.internal.d.ts +0 -7
- package/dist/providers/stripe/components/SharedStripeCheckoutV2Summary.internal.js +0 -19
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
/**
|
|
15
|
+
* Checkout dialog (ClaimBee paywall-v3 layout): order summary with the
|
|
16
|
+
* discount timer and satisfaction line, the wallet-first payment blocks and a
|
|
17
|
+
* guarantee line. A bottom sheet on phones, a centred modal from 640px wide.
|
|
18
|
+
* Mount it while open: one mount is one `checkout_shown` (surface `dialog`) and
|
|
19
|
+
* queues `checkout_started`; closing reports `checkout_canceled`.
|
|
20
|
+
*
|
|
21
|
+
* The caller owns the Checkout Session, as for `StripeWalletFirstCheckout`;
|
|
22
|
+
* pass its `clientSecret` as soon as it exists (it may be prepared before the
|
|
23
|
+
* dialog opens) so the wallet button is ready on open.
|
|
24
|
+
*/
|
|
25
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
26
|
+
import { StripeWalletFirstCheckout } from './StripeWalletFirstCheckout.js';
|
|
27
|
+
import { queueStripeSubscriptionCheckoutStarted } from '../services/checkoutCompletionAnalytics.service.js';
|
|
28
|
+
import { trackCheckoutCanceled } from '../../../services/checkoutObservability.service.js';
|
|
29
|
+
// Keeps the open card form in view while it expands and while Stripe sizes its fields,
|
|
30
|
+
// including a slow Stripe card form load after the card method is selected.
|
|
31
|
+
const CARD_FOLLOW_MS = 10000;
|
|
32
|
+
const formatCountdown = (remainingSeconds = 0) => {
|
|
33
|
+
const seconds = Number.isFinite(remainingSeconds) ? Math.max(0, Math.floor(remainingSeconds)) : 0;
|
|
34
|
+
return `${String(Math.floor(seconds / 60)).padStart(2, '0')}:${String(seconds % 60).padStart(2, '0')}`;
|
|
35
|
+
};
|
|
36
|
+
export function StripeCheckoutDialog(_a) {
|
|
37
|
+
var _b, _c;
|
|
38
|
+
var { title, closeAriaLabel, onClose, summary, guaranteeLabel, error } = _a, checkout = __rest(_a, ["title", "closeAriaLabel", "onClose", "summary", "guaranteeLabel", "error"]);
|
|
39
|
+
const sheetRef = useRef(null);
|
|
40
|
+
const { checkoutAnalytics, checkoutSessionId } = checkout;
|
|
41
|
+
const close = useCallback(() => {
|
|
42
|
+
if (checkoutAnalytics) {
|
|
43
|
+
trackCheckoutCanceled({ analytics: checkoutAnalytics, checkoutSessionId, failureStage: 'checkout_dialog', provider: 'stripe' });
|
|
44
|
+
}
|
|
45
|
+
onClose();
|
|
46
|
+
}, [checkoutAnalytics, checkoutSessionId, onClose]);
|
|
47
|
+
// Opening the dialog starts the checkout, as it always has for the dialog.
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!checkoutAnalytics)
|
|
50
|
+
return;
|
|
51
|
+
queueStripeSubscriptionCheckoutStarted(Object.assign(Object.assign({}, checkoutAnalytics), { checkoutSessionId, checkoutStartSource: 'card_form_open', paymentMethod: 'card' }));
|
|
52
|
+
}, [checkoutAnalytics, checkoutSessionId]);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const closeOnEscape = (event) => { if (event.key === 'Escape' && !event.defaultPrevented)
|
|
55
|
+
close(); };
|
|
56
|
+
window.addEventListener('keydown', closeOnEscape);
|
|
57
|
+
return () => window.removeEventListener('keydown', closeOnEscape);
|
|
58
|
+
}, [close]);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
var _a;
|
|
61
|
+
const sheet = sheetRef.current;
|
|
62
|
+
if (!sheet || typeof ResizeObserver === 'undefined')
|
|
63
|
+
return undefined;
|
|
64
|
+
let followUntil = 0;
|
|
65
|
+
const cardMethod = () => {
|
|
66
|
+
const methods = sheet.querySelectorAll('.wfc-method');
|
|
67
|
+
const card = methods[methods.length - 1];
|
|
68
|
+
return (card === null || card === void 0 ? void 0 : card.dataset.checked) === 'true' ? card : null;
|
|
69
|
+
};
|
|
70
|
+
const revealCard = () => {
|
|
71
|
+
const card = cardMethod();
|
|
72
|
+
if (!card || Date.now() > followUntil)
|
|
73
|
+
return;
|
|
74
|
+
const hiddenBelow = card.getBoundingClientRect().bottom + 16 - sheet.getBoundingClientRect().bottom;
|
|
75
|
+
if (hiddenBelow > 0)
|
|
76
|
+
sheet.scrollTop += hiddenBelow;
|
|
77
|
+
};
|
|
78
|
+
const selectionObserver = new MutationObserver(() => {
|
|
79
|
+
if (!cardMethod())
|
|
80
|
+
return;
|
|
81
|
+
followUntil = Date.now() + CARD_FOLLOW_MS;
|
|
82
|
+
revealCard();
|
|
83
|
+
});
|
|
84
|
+
const sizeObserver = new ResizeObserver(revealCard);
|
|
85
|
+
// A manual scroll takes over, so a late-loading card form never fights the visitor.
|
|
86
|
+
const stopFollowing = () => { followUntil = 0; };
|
|
87
|
+
selectionObserver.observe(sheet, { attributeFilter: ['data-checked'], subtree: true });
|
|
88
|
+
sizeObserver.observe((_a = sheet.firstElementChild) !== null && _a !== void 0 ? _a : sheet);
|
|
89
|
+
sheet.addEventListener('wheel', stopFollowing, { passive: true });
|
|
90
|
+
sheet.addEventListener('touchmove', stopFollowing, { passive: true });
|
|
91
|
+
return () => {
|
|
92
|
+
selectionObserver.disconnect();
|
|
93
|
+
sizeObserver.disconnect();
|
|
94
|
+
sheet.removeEventListener('wheel', stopFollowing);
|
|
95
|
+
sheet.removeEventListener('touchmove', stopFollowing);
|
|
96
|
+
};
|
|
97
|
+
}, []);
|
|
98
|
+
const promoActive = Boolean(summary.promoActive);
|
|
99
|
+
const promoCode = (_c = (_b = summary.promoCode) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
100
|
+
const style = { '--fgcd-theme': checkout.themeColor };
|
|
101
|
+
return (_jsxs("div", { className: 'fgcd-overlay', style: style, onClick: (event) => { if (event.target === event.currentTarget)
|
|
102
|
+
close(); }, children: [_jsx("section", { ref: sheetRef, className: 'fgcd-sheet', role: 'dialog', "aria-modal": 'true', "aria-labelledby": 'fgcd-title', children: _jsxs("div", { className: 'fgcd-content', children: [_jsx("span", { className: 'fgcd-grabber', "aria-hidden": 'true' }), _jsxs("header", { className: 'fgcd-head', children: [_jsx("button", { type: 'button', className: 'fgcd-close', "aria-label": closeAriaLabel, 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: 'fgcd-title', children: title })] }), promoActive && summary.countdownLabel ? (_jsxs("p", { className: 'fgcd-timer', children: [_jsx("span", { "aria-hidden": 'true', children: "\u23F0" }), summary.countdownLabel, _jsx("span", { className: 'fgcd-timer-value', children: formatCountdown(summary.remainingSeconds) })] })) : null, summary.satisfactionPercent || summary.satisfactionLabel ? (_jsxs("p", { className: 'fgcd-proof', children: [_jsx("strong", { children: summary.satisfactionPercent }), " ", summary.satisfactionLabel] })) : null, _jsxs("div", { className: 'fgcd-summary', children: [promoActive ? (_jsxs(_Fragment, { children: [summary.originalPriceValue ? (_jsxs("p", { className: 'fgcd-row fgcd-row--muted', children: [_jsx("span", { children: summary.originalPriceLabel }), _jsx("s", { children: summary.originalPriceValue })] })) : null, summary.discountAmountLabel ? (_jsxs("p", { className: 'fgcd-row fgcd-row--discount', children: [_jsx("span", { children: summary.discountLabel }), _jsx("strong", { children: summary.discountAmountLabel })] })) : null, promoCode ? (_jsxs("p", { className: 'fgcd-promo', children: [_jsx("span", { children: summary.promoCodeLabel }), _jsxs("strong", { children: [_jsx(CheckIcon, {}), promoCode] })] })) : null, _jsx("hr", {})] })) : null, _jsxs("p", { className: 'fgcd-total', children: [_jsx("span", { children: summary.totalLabel }), _jsxs("strong", { children: [_jsx(TagIcon, {}), summary.totalValue] })] }), promoActive && summary.savedLabel ? _jsxs("p", { className: 'fgcd-saved', children: [_jsx("span", { "aria-hidden": 'true', children: "\uD83D\uDD25" }), summary.savedLabel] }) : null] }), _jsx("div", { className: 'fgcd-methods', children: _jsx(StripeWalletFirstCheckout, Object.assign({}, checkout, { checkoutSurface: 'dialog' })) }), error ? _jsx("p", { className: 'fgcd-error', role: 'alert', children: error }) : null, guaranteeLabel ? _jsxs("p", { className: 'fgcd-guarantee', children: [_jsx(LockIcon, {}), guaranteeLabel] }) : null] }) }), _jsx("style", { children: stripeCheckoutDialogStyles })] }));
|
|
103
|
+
}
|
|
104
|
+
function CheckIcon() {
|
|
105
|
+
return (_jsxs("svg", { className: 'fgcd-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' })] }));
|
|
106
|
+
}
|
|
107
|
+
function TagIcon() {
|
|
108
|
+
return (_jsxs("svg", { className: 'fgcd-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' })] }));
|
|
109
|
+
}
|
|
110
|
+
function LockIcon() {
|
|
111
|
+
return (_jsxs("svg", { viewBox: '0 0 20 20', "aria-hidden": 'true', children: [_jsx("rect", { x: '3.5', y: '8.5', width: '13', height: '9', rx: '2.2', fill: 'none', stroke: 'currentColor', strokeWidth: '1.7' }), _jsx("path", { d: 'M6.5 8.5V6.3a3.5 3.5 0 0 1 7 0v2.2', fill: 'none', stroke: 'currentColor', strokeWidth: '1.7', strokeLinecap: 'round' })] }));
|
|
112
|
+
}
|
|
113
|
+
export const stripeCheckoutDialogStyles = `
|
|
114
|
+
.fgcd-overlay {
|
|
115
|
+
--fgcd-soft: color-mix(in srgb, var(--fgcd-theme) 10%, #fff);
|
|
116
|
+
--fgcd-bg: color-mix(in srgb, var(--fgcd-theme) 4%, #f6f6f9);
|
|
117
|
+
--fgcd-border: color-mix(in srgb, var(--fgcd-theme) 12%, #e4e4ea);
|
|
118
|
+
--fgcd-text: #101010;
|
|
119
|
+
--fgcd-muted: #66646e;
|
|
120
|
+
position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center;
|
|
121
|
+
background: rgb(16 12 30 / 50%); animation: fgcd-fade-in .2s ease-out;
|
|
122
|
+
}
|
|
123
|
+
.fgcd-sheet {
|
|
124
|
+
width: min(100%, 480px); max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain;
|
|
125
|
+
border-radius: 28px 28px 0 0; background: var(--fgcd-bg); box-sizing: border-box; color: var(--fgcd-text);
|
|
126
|
+
animation: fgcd-sheet-up .32s cubic-bezier(.25, .8, .25, 1);
|
|
127
|
+
}
|
|
128
|
+
.fgcd-sheet *, .fgcd-sheet *::before, .fgcd-sheet *::after { box-sizing: border-box; }
|
|
129
|
+
.fgcd-content { display: flex; flex-direction: column; gap: 14px; padding: 12px 24px calc(34px + env(safe-area-inset-bottom, 0px)); }
|
|
130
|
+
@media (min-width: 640px) {
|
|
131
|
+
.fgcd-overlay { align-items: center; padding: 24px; }
|
|
132
|
+
.fgcd-sheet { max-height: calc(100dvh - 48px); border-radius: 28px; animation: fgcd-pop .24s cubic-bezier(.2, .9, .3, 1.1); }
|
|
133
|
+
.fgcd-content { padding: 20px 28px 28px; }
|
|
134
|
+
.fgcd-grabber { display: none; }
|
|
135
|
+
}
|
|
136
|
+
@keyframes fgcd-sheet-up { from { transform: translateY(100%); } }
|
|
137
|
+
@keyframes fgcd-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
|
|
138
|
+
@keyframes fgcd-fade-in { from { opacity: 0; } }
|
|
139
|
+
@media (prefers-reduced-motion: reduce) { .fgcd-sheet, .fgcd-overlay { animation: none; } }
|
|
140
|
+
.fgcd-grabber { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--fgcd-theme) 18%, #ddd); }
|
|
141
|
+
.fgcd-head { position: relative; display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 44px; }
|
|
142
|
+
.fgcd-head h2 { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.2; text-align: center; }
|
|
143
|
+
.fgcd-close { position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 12px; background: #fff; cursor: pointer; }
|
|
144
|
+
.fgcd-close svg { width: 16px; height: 16px; fill: none; stroke: #4a4660; stroke-width: 1.8; stroke-linecap: round; }
|
|
145
|
+
.fgcd-close:focus-visible { outline: 3px solid var(--fgcd-theme); outline-offset: 2px; }
|
|
146
|
+
.fgcd-timer { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; padding: 10px 14px; border: 1px solid var(--fgcd-border); border-radius: 14px; background: #fff; box-shadow: 0 4px 12px rgb(16 12 30 / 6%); font-size: 15px; font-weight: 700; }
|
|
147
|
+
.fgcd-timer > span:first-child { font-size: 18px; }
|
|
148
|
+
.fgcd-timer-value { padding: 3px 8px; border-radius: 8px; background: var(--fgcd-soft); color: var(--fgcd-theme); font-size: 16px; font-weight: 800; letter-spacing: .32px; font-variant-numeric: tabular-nums; }
|
|
149
|
+
.fgcd-proof { margin: 0; font-size: 15px; font-weight: 700; line-height: 21px; text-align: center; }
|
|
150
|
+
.fgcd-proof strong { color: var(--fgcd-theme); }
|
|
151
|
+
.fgcd-summary { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 16px; background: #fff; }
|
|
152
|
+
.fgcd-summary hr { width: 100%; margin: 0; border: 0; border-top: 1px solid var(--fgcd-border); }
|
|
153
|
+
.fgcd-row, .fgcd-promo, .fgcd-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; }
|
|
154
|
+
.fgcd-row--muted { color: var(--fgcd-muted); font-size: 14px; }
|
|
155
|
+
.fgcd-row--discount { font-size: 15px; font-weight: 700; }
|
|
156
|
+
.fgcd-row--discount strong { color: #cc2b31; font-weight: 800; }
|
|
157
|
+
.fgcd-promo { padding: 9px 12px; border-radius: 10px; background: var(--fgcd-soft); color: var(--fgcd-muted); font-size: 13px; }
|
|
158
|
+
.fgcd-promo strong, .fgcd-total strong { display: inline-flex; align-items: center; gap: 6px; color: var(--fgcd-text); font-weight: 800; }
|
|
159
|
+
.fgcd-promo strong { font-size: 14px; letter-spacing: .42px; text-transform: uppercase; }
|
|
160
|
+
.fgcd-check { width: 13px; height: 13px; }
|
|
161
|
+
.fgcd-total span { font-size: 20px; font-weight: 800; }
|
|
162
|
+
.fgcd-total strong { font-size: 24px; }
|
|
163
|
+
.fgcd-tag { width: 20px; height: 20px; }
|
|
164
|
+
.fgcd-saved { display: inline-flex; align-self: flex-end; align-items: center; gap: 6px; margin: 0; padding: 6px 12px; border-radius: 99px; background: #fde3e4; color: #b4232a; font-size: 13px; font-weight: 700; }
|
|
165
|
+
.fgcd-sheet .wfc { gap: 10px; }
|
|
166
|
+
.fgcd-sheet .wfc-method { border-radius: 18px; box-shadow: 0 0 0 1px var(--fgcd-border); transition: box-shadow .2s ease; }
|
|
167
|
+
.fgcd-sheet .wfc-method[data-checked='true'] { box-shadow: 0 0 0 2px var(--fgcd-theme); }
|
|
168
|
+
.fgcd-sheet .wfc-method-head { min-height: 58px; padding: 16px; gap: 12px; border-radius: 18px; }
|
|
169
|
+
.fgcd-sheet .wfc-mark { height: 26px; }
|
|
170
|
+
.fgcd-sheet .wfc-brand { width: 42px; height: 28px; border-radius: 5px; }
|
|
171
|
+
.fgcd-sheet .wfc-benefits:empty { display: none; }
|
|
172
|
+
.fgcd-sheet .wfc-wallet-button, .fgcd-sheet .wfc-progress { border-radius: 14px; }
|
|
173
|
+
.fgcd-sheet .wfc-secure { margin-top: 10px; color: var(--fgcd-muted); font-size: 13px; }
|
|
174
|
+
.fgcd-sheet .wfc-card-form .wfc-secure { display: none; }
|
|
175
|
+
.fgcd-sheet .wfc-submit { min-height: 56px; border-radius: 14px; font-size: 18px; font-weight: 700; }
|
|
176
|
+
.fgcd-error { margin: 0; color: #c62828; font-size: 14px; text-align: center; }
|
|
177
|
+
.fgcd-guarantee { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 700; }
|
|
178
|
+
.fgcd-guarantee svg { width: 18px; height: 18px; flex: none; }
|
|
179
|
+
`;
|
|
@@ -1,5 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet-first inline Stripe checkout (Checkout Sessions), one block per
|
|
3
|
+
* payment method (CHECKOUT-BR-010).
|
|
4
|
+
*
|
|
5
|
+
* One platform wallet is the first, preselected method: Google Pay on Android,
|
|
6
|
+
* Apple Pay everywhere else, shown with Stripe's own wallet button. Card
|
|
7
|
+
* payment is the last method. Between them, every other method the offer
|
|
8
|
+
* supports (Pix, Klarna, …) forms one block, or its own block when `methods`
|
|
9
|
+
* names it; a native PayPal checkout passed as `paypalCheckout` follows the
|
|
10
|
+
* wallet. The wallet and the card share the caller's Checkout Session; every
|
|
11
|
+
* other Stripe block owns a Checkout Session restricted to its methods, created
|
|
12
|
+
* when the block is selected. The whole layout renders immediately, even before
|
|
13
|
+
* the checkout session exists; the wallet slot holds a progress bar at the
|
|
14
|
+
* exact button height until Stripe's button replaces it, so nothing moves.
|
|
15
|
+
* Where the wallet cannot pay, the same slot explains that (or the block hides
|
|
16
|
+
* with `hideUnavailableWallet`). The card form has no email or terms text: the
|
|
17
|
+
* session carries the email, unless `email` asks the visitor for it. Stripe
|
|
18
|
+
* asks for the postal code only for card countries that use it (US, CA, UK).
|
|
19
|
+
* `paymentElementOptions` overrides these card form defaults. `initialMethod`
|
|
20
|
+
* opens another block first, e.g. `'card'` for a bottom-of-page "complete your
|
|
21
|
+
* order" block; the wallet stays one tap away. A failed payment lies over the
|
|
22
|
+
* blocks (CheckoutErrorOverlay), so nothing below moves.
|
|
23
|
+
*
|
|
24
|
+
* The caller owns the card Checkout Session (`clientSecret`, created with
|
|
25
|
+
* `paymentMethodTypes: ['card']` so its form never shows another method), the
|
|
26
|
+
* copy and what happens after `onSuccess`.
|
|
27
|
+
*/
|
|
28
|
+
import { type ReactNode } from 'react';
|
|
1
29
|
import type { Stripe, StripeCheckoutPaymentElementOptions } from '@stripe/stripe-js';
|
|
2
30
|
import type { PlatformWalletPaymentMethod } from './walletPlatform.js';
|
|
31
|
+
import { type CheckoutErrorOverlayCopy } from '../../../components/CheckoutErrorOverlay.js';
|
|
3
32
|
import { type StripeSubscriptionCheckoutAnalyticsContext } from '../services/checkoutCompletionAnalytics.service.js';
|
|
4
33
|
import { type StripeSubscriptionCheckoutSessionInput } from '../hooks/useStripeSubscriptionCheckoutSession.js';
|
|
5
34
|
import { type StripeCheckoutErrorDetails } from '../services/stripeCheckoutError.js';
|
|
@@ -19,12 +48,34 @@ export type StripeWalletFirstCheckoutCopy = {
|
|
|
19
48
|
formNotReady: string;
|
|
20
49
|
/** Labels of other Stripe methods by type, e.g. `{ pix: 'Pix' }`; a missing type shows its capitalized name. */
|
|
21
50
|
methodLabels?: Partial<Record<string, string>>;
|
|
51
|
+
/** Titles and actions of the failure shown over the blocks; English defaults. The provider's message is the body. */
|
|
52
|
+
errors?: CheckoutErrorOverlayCopy;
|
|
53
|
+
};
|
|
54
|
+
/** The visitor confirms or corrects the email before paying; a saved change may replace the Checkout Session. */
|
|
55
|
+
export type StripeWalletFirstCheckoutEmail = {
|
|
56
|
+
/** Show the email field even when the session's email is valid. */
|
|
57
|
+
editable?: boolean;
|
|
58
|
+
label?: string;
|
|
59
|
+
placeholder?: string;
|
|
60
|
+
invalidMessage?: string;
|
|
61
|
+
onChange?: (email: string) => void;
|
|
62
|
+
/** Saves a changed email; resolves the saved address. Saving may switch the Funnel User and replace the session. */
|
|
63
|
+
onCommit?: (email: string) => Promise<string | null | void>;
|
|
22
64
|
};
|
|
23
65
|
/**
|
|
24
|
-
* A payment method block: the platform wallet, the card form, one block with every
|
|
25
|
-
*
|
|
66
|
+
* A payment method block: the platform wallet, the card form, PayPal, one block with every other
|
|
67
|
+
* method the offer supports (`'other'`), or one Stripe method type such as `'pix'`.
|
|
26
68
|
*/
|
|
27
|
-
export type StripeWalletFirstMethod = 'wallet' | 'card' | 'other' | (string & {});
|
|
69
|
+
export type StripeWalletFirstMethod = 'wallet' | 'card' | 'other' | 'paypal' | (string & {});
|
|
70
|
+
/**
|
|
71
|
+
* The paid Checkout Session and how it was paid (CHECKOUT-SC-031). A method block pays in its own
|
|
72
|
+
* session, so this may differ from the card session. `paymentMethod` is a Stripe method type such as
|
|
73
|
+
* `'card'`, `'apple_pay'`, `'google_pay'` or `'pix'`; null when Stripe did not report it.
|
|
74
|
+
*/
|
|
75
|
+
export type StripeWalletFirstPayment = {
|
|
76
|
+
checkoutSessionId: string | null;
|
|
77
|
+
paymentMethod: string | null;
|
|
78
|
+
};
|
|
28
79
|
export type StripeWalletFirstCheckoutProps = {
|
|
29
80
|
amountCents: number;
|
|
30
81
|
buttonColor: string;
|
|
@@ -39,10 +90,11 @@ export type StripeWalletFirstCheckoutProps = {
|
|
|
39
90
|
onCancel?: () => void;
|
|
40
91
|
onError?: (message: string | null, details?: StripeCheckoutErrorDetails) => void;
|
|
41
92
|
/**
|
|
42
|
-
* Called after a paid checkout
|
|
43
|
-
*
|
|
93
|
+
* Called after a paid checkout with the paid session and method, e.g. to offer a one-click upsell
|
|
94
|
+
* only after a method that can be charged again. Return `true` when the caller has already moved the
|
|
95
|
+
* visitor on (e.g. client-side navigation to the next step); a card payment then skips the `returnUrl` reload.
|
|
44
96
|
*/
|
|
45
|
-
onSuccess?: () => void | boolean | Promise<void | boolean>;
|
|
97
|
+
onSuccess?: (payment: StripeWalletFirstPayment) => void | boolean | Promise<void | boolean>;
|
|
46
98
|
returnUrl: string;
|
|
47
99
|
stripePromise: Promise<Stripe | null> | null;
|
|
48
100
|
summaryLabel: string;
|
|
@@ -52,7 +104,7 @@ export type StripeWalletFirstCheckoutProps = {
|
|
|
52
104
|
/**
|
|
53
105
|
* The blocks and their order; defaults to the wallet, every other method the offer supports as one
|
|
54
106
|
* block, then the card. A method named here gets its own block; other methods not named go into the
|
|
55
|
-
* `'other'` block when it is listed, else they are not offered.
|
|
107
|
+
* `'other'` block when it is listed, else they are not offered. PayPal follows the wallet unless named.
|
|
56
108
|
*/
|
|
57
109
|
methods?: readonly StripeWalletFirstMethod[];
|
|
58
110
|
/**
|
|
@@ -71,5 +123,27 @@ export type StripeWalletFirstCheckoutProps = {
|
|
|
71
123
|
* e.g. `{ fields: { billingDetails: { address: { country: 'auto', postalCode: 'never' } } } }`.
|
|
72
124
|
*/
|
|
73
125
|
paymentElementOptions?: StripeCheckoutPaymentElementOptions;
|
|
126
|
+
/** Where the checkout shows, for `checkout_shown`; a dialog passes `'dialog'`. */
|
|
127
|
+
checkoutSurface?: 'inline' | 'dialog';
|
|
128
|
+
/** Ask for the email in the card form; without it the session's email is used as is. */
|
|
129
|
+
email?: StripeWalletFirstCheckoutEmail;
|
|
130
|
+
/** Card brands in the card header, e.g. `['Visa', 'Mastercard']`; defaults to Visa, Mastercard, Maestro and Amex. */
|
|
131
|
+
cardBrandLabels?: readonly string[];
|
|
132
|
+
/** Billing countries the offer accepts (ISO codes); a single country is filled in and its field hidden. */
|
|
133
|
+
supportedCountries?: readonly string[];
|
|
134
|
+
unsupportedCountryMessage?: string;
|
|
135
|
+
/** Wallet availability known from an earlier render, so the wallet button shows without the progress bar. */
|
|
136
|
+
initialWalletAvailable?: boolean | null;
|
|
137
|
+
/** Hide the wallet block where this browser cannot pay with it, instead of explaining that in the slot. */
|
|
138
|
+
hideUnavailableWallet?: boolean;
|
|
139
|
+
/** A native PayPal checkout, shown as its own block after the wallet. */
|
|
140
|
+
paypalCheckout?: ReactNode;
|
|
141
|
+
paypalLabel?: string;
|
|
142
|
+
/** A PayPal payment is in flight: the PayPal block stays selected and every other block is locked. */
|
|
143
|
+
paypalPending?: boolean;
|
|
144
|
+
/** The Checkout Session expired; the caller replaces it instead of the visitor seeing Stripe's error. */
|
|
145
|
+
onInactiveCheckoutSession?: () => void;
|
|
146
|
+
/** Called after `add_payment_info`, before a card or wallet confirmation. */
|
|
147
|
+
onPaymentInfoSubmitted?: () => void | Promise<void>;
|
|
74
148
|
};
|
|
75
149
|
export declare function StripeWalletFirstCheckout(props: StripeWalletFirstCheckoutProps): import("react/jsx-runtime").JSX.Element;
|