@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.
Files changed (35) hide show
  1. package/README.md +31 -14
  2. package/dist/components/CheckoutErrorOverlay.d.ts +37 -0
  3. package/dist/components/CheckoutErrorOverlay.js +67 -0
  4. package/dist/generated/package-version.d.ts +1 -1
  5. package/dist/generated/package-version.js +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/providers/stripe/components/SharedStripeCheckoutV2Dialog.d.ts +13 -4
  8. package/dist/providers/stripe/components/SharedStripeCheckoutV2Dialog.js +93 -88
  9. package/dist/providers/stripe/components/StripeCheckoutDialog.d.ts +31 -0
  10. package/dist/providers/stripe/components/StripeCheckoutDialog.js +179 -0
  11. package/dist/providers/stripe/components/StripeWalletFirstCheckout.d.ts +81 -7
  12. package/dist/providers/stripe/components/StripeWalletFirstCheckout.js +204 -56
  13. package/dist/providers/stripe/components/StripeWalletFirstCheckout.options.d.ts +10 -2
  14. package/dist/providers/stripe/components/StripeWalletFirstCheckout.options.js +4 -6
  15. package/dist/providers/stripe/components/StripeWalletFirstCheckout.styles.d.ts +1 -1
  16. package/dist/providers/stripe/components/StripeWalletFirstCheckout.styles.js +11 -1
  17. package/dist/providers/stripe/components/WalletButton.d.ts +3 -1
  18. package/dist/providers/stripe/components/WalletButton.js +3 -3
  19. package/dist/providers/stripe/components/checkout-v2.content.d.ts +3 -0
  20. package/dist/providers/stripe/components/index.d.ts +1 -0
  21. package/dist/providers/stripe/components/index.js +1 -0
  22. package/dist/providers/stripe/components/useCheckoutEmail.internal.d.ts +3 -1
  23. package/dist/providers/stripe/components/useCheckoutEmail.internal.js +8 -3
  24. package/dist/providers/stripe/hooks/checkoutPageAttention.d.ts +3 -0
  25. package/dist/providers/stripe/hooks/checkoutPageAttention.js +54 -0
  26. package/dist/providers/stripe/hooks/checkoutPreparationBackoff.d.ts +1 -0
  27. package/dist/providers/stripe/hooks/checkoutPreparationBackoff.js +5 -7
  28. package/dist/providers/stripe/hooks/useStripeSubscriptionCheckoutSession.js +39 -2
  29. package/package.json +1 -1
  30. package/dist/providers/stripe/components/SharedCheckoutPaymentMethods.internal.d.ts +0 -18
  31. package/dist/providers/stripe/components/SharedCheckoutPaymentMethods.internal.js +0 -15
  32. package/dist/providers/stripe/components/SharedStripeCheckoutV2Form.internal.d.ts +0 -7
  33. package/dist/providers/stripe/components/SharedStripeCheckoutV2Form.internal.js +0 -328
  34. package/dist/providers/stripe/components/SharedStripeCheckoutV2Summary.internal.d.ts +0 -7
  35. package/dist/providers/stripe/components/SharedStripeCheckoutV2Summary.internal.js +0 -19
package/README.md CHANGED
@@ -24,7 +24,7 @@ Use these for new subscription paywalls:
24
24
 
25
25
  - `StripeSubscriptionWalletSurface`
26
26
  - `useStripeSubscriptionCheckoutSession`
27
- - `SharedStripeCheckoutV2Dialog`
27
+ - `StripeCheckoutDialog`
28
28
  - `trackPaidStripeSubscriptionCheckoutCompleted`
29
29
  - `trackStripeSubscriptionPaymentInfoSubmitted`
30
30
 
@@ -75,6 +75,12 @@ method the offer supports (Pix, Klarna, …) as one block; and the card form.
75
75
  `'other'` block when it is listed, else they are not offered. `initialMethod` may name any
76
76
  block, including `'other'` or a method inside it. `copy.methodLabels` names the methods
77
77
  (`{ pix: 'Pix' }`); a missing type shows its capitalized name.
78
+ - A failed payment shows over the blocks, not under them, so nothing below moves and the
79
+ visitor's input stays: a title per failure category, the bank's reason for a decline, a
80
+ retry button that closes it, and after a decline a button to the wallet (or to the card when
81
+ the wallet failed). A field the form can mark keeps its error inline. `copy.errors` overrides
82
+ the English `titles`, `bodies`, `retryLabel`, `dismissLabel`, `switchLabel` (`{method}`) and
83
+ `closeLabel`.
78
84
  - `WalletButton` is the wallet block's slot on its own: progress bar at the button's height,
79
85
  then Stripe's Apple Pay or Google Pay button, or the unavailable note. Inside an existing
80
86
  `CheckoutProvider` omit `session`; for a standalone placement pass
@@ -92,22 +98,33 @@ Use these for new one-time paywall plans:
92
98
  - `StripeOneTimeWalletSurface`
93
99
  - `useStripeOneTimeCheckoutSession`
94
100
  - `createStripeOneTimeCheckout`
95
- - `SharedStripeCheckoutV2Dialog`
96
-
97
- `SharedStripeCheckoutV2Dialog` defaults to the existing full-screen `standard` surface. Pass
98
- `variant='compact'` for a centered desktop modal with the same Stripe-owned wallet/card flow;
99
- mobile remains full-screen and all checkout analytics and verified-success behavior are unchanged.
100
-
101
- Pass `presentation='inline'` to embed a card-only form in the paywall. The host owns the offer summary and renewal disclosure. Inline checkout has no modal semantics, close button, Escape dismissal, or shared wallet session; analytics and verified-success callbacks are unchanged.
101
+ - `StripeCheckoutDialog`
102
+
103
+ `StripeCheckoutDialog` is the checkout dialog (ClaimBee paywall-v3 layout): order summary with
104
+ the discount timer and satisfaction line, the `StripeWalletFirstCheckout` blocks and a guarantee
105
+ line. It is a bottom sheet on phones and a centred modal from 640px wide. It takes every
106
+ `StripeWalletFirstCheckout` prop plus `title`, `closeAriaLabel`, `onClose`, `summary` and
107
+ `guaranteeLabel`. Mount it while open: one mount reports `checkout_shown` (surface `dialog`) and
108
+ queues `checkout_started`; closing reports `checkout_canceled`.
109
+
110
+ `SharedStripeCheckoutV2Dialog` keeps its props for existing funnels and renders the same
111
+ components: a dialog renders `StripeCheckoutDialog` (both `variant`s; `compact` only drops the
112
+ satisfaction line) and `presentation='inline'` renders `StripeWalletFirstCheckout` in the page.
113
+ Its email field, PayPal slot, billing countries, wallet availability, card brands and
114
+ expired-session handler map onto the wallet-first props below. The old `.shared-checkout-v2-*`
115
+ classes of the dialog are gone; funnels that styled or queried them need the new markup.
116
+
117
+ `StripeWalletFirstCheckout` also accepts `email` (an email field in the card form; wallets show
118
+ only while the visitor keeps the session's email), `supportedCountries` and
119
+ `unsupportedCountryMessage`, `initialWalletAvailable`, `hideUnavailableWallet`, `cardBrandLabels`,
120
+ `onInactiveCheckoutSession` and `onPaymentInfoSubmitted`.
102
121
 
103
122
  For a mixed Stripe/PayPal Offer Set, pass the selected binding's `PayPalCheckout`
104
- as `paypalCheckout` to `SharedStripeCheckoutV2Dialog`. It appears in the checkout
105
- wallet group alongside Apple Pay and Google Pay, with card as a separate tab.
123
+ as `paypalCheckout`. It is its own block after the wallet.
106
124
  Set `showSummary={false}` on `PayPalCheckout` to omit its repeated plan caption.
107
- The mixed wallet group omits the Stripe-only price/discount summary; native approval
108
- sheets retain each provider’s actual terms. Forward `onPendingChange`
109
- to `paypalPending` so an unresolved PayPal purchase keeps its selected method.
110
- This slot applies only to dialog presentation. A PayPal-only Offer Set
125
+ Forward `onPendingChange` to `paypalPending` so an unresolved PayPal purchase keeps
126
+ the PayPal block selected and locks the others. The V2 dialog passes it only for the
127
+ dialog presentation. A PayPal-only Offer Set
111
128
  uses `PayPalCheckoutDialog` around the same native checkout, without creating a
112
129
  Stripe session. The funnel owns opening the dialog and post-success navigation.
113
130
 
@@ -0,0 +1,37 @@
1
+ import type { CheckoutFailureCategory } from '../services/checkoutObservability.service.js';
2
+ export type CheckoutErrorOverlayCopy = {
3
+ /** Title per failure category; the provider's message is the body. */
4
+ titles?: Partial<Record<CheckoutFailureCategory, string>>;
5
+ /** Body per category instead of the provider's message; a network failure has an English default. */
6
+ bodies?: Partial<Record<CheckoutFailureCategory, string>>;
7
+ retryLabel?: string;
8
+ /** Primary action for an existing subscription, where retrying makes no sense. */
9
+ dismissLabel?: string;
10
+ /** Primary action after a confirmed payment whose result is not known yet. */
11
+ checkStatusLabel?: string;
12
+ /** `{method}` is the other payment method's label. */
13
+ switchLabel?: string;
14
+ closeLabel?: string;
15
+ };
16
+ export type CheckoutErrorOverlayProps = {
17
+ category: CheckoutFailureCategory;
18
+ message: string;
19
+ copy?: CheckoutErrorOverlayCopy;
20
+ onDismiss: () => void;
21
+ /** Another payment method to offer after a decline. */
22
+ alternative?: {
23
+ label: string;
24
+ onSelect: () => void;
25
+ } | null;
26
+ /** Replaces the category title, e.g. while a confirmed payment is verified. */
27
+ title?: string;
28
+ /** Replaces the primary action, which otherwise closes the overlay. */
29
+ primary?: {
30
+ label: string;
31
+ onClick: () => void;
32
+ };
33
+ /** False while only the primary action may continue, e.g. a confirmed payment awaiting verification. */
34
+ dismissible?: boolean;
35
+ };
36
+ export declare function CheckoutErrorOverlay({ alternative, category, copy, dismissible, message, onDismiss, primary, title: titleOverride }: CheckoutErrorOverlayProps): import("react/jsx-runtime").JSX.Element;
37
+ export declare const checkoutErrorOverlayStyles = "\n.cfo { position:absolute; inset:-6px; z-index:5; display:grid; place-items:center; padding:6px; overflow:auto; border-radius:20px;\n background:rgba(246,247,251,.66); -webkit-backdrop-filter:blur(3px); backdrop-filter:blur(3px); animation:cfo-in .18s ease both; }\n.cfo-card { position:relative; width:min(100%, 420px); padding:20px 18px 10px; border-radius:20px; background:#fff; text-align:center;\n box-shadow:0 14px 34px rgba(20,22,31,.16), 0 0 0 1px rgba(20,22,31,.05); animation:cfo-card-in .26s cubic-bezier(.2,.9,.3,1.2) both; }\n.cfo-close { position:absolute; top:10px; right:10px; width:30px; height:30px; border:0; border-radius:8px; background:#f3f4f8; color:#666; font-size:13px; cursor:pointer; }\n.cfo-badge { display:grid; place-items:center; width:46px; height:46px; margin:0 auto 10px; border-radius:50%; font-size:20px; font-weight:800; }\n.cfo[data-tone='error'] .cfo-badge { background:#fdeeee; color:#c62828; }\n.cfo[data-tone='warning'] .cfo-badge { background:#fff6e0; color:#c98a00; }\n.cfo[data-tone='info'] .cfo-badge { background:#eaf1ff; color:#1f4fb8; }\n.cfo-title { margin:0; padding:0 24px; font-size:18px; font-weight:700; line-height:1.3; color:#14161f; }\n.cfo-message { margin:6px 4px 0; font-size:14px; line-height:1.45; color:#6b7183; }\n.cfo-primary { display:block; width:100%; min-height:48px; margin-top:16px; border:0; border-radius:12px; background:var(--wfc-button, #14161f); color:#fff; font-family:inherit; font-size:16px; font-weight:600; line-height:1.2; cursor:pointer; }\n.cfo-secondary { display:block; width:100%; min-height:42px; margin-top:2px; border:0; background:transparent; color:var(--wfc-theme, #14161f); font-family:inherit; font-size:15px; font-weight:600; line-height:1.2; cursor:pointer; }\n.cfo-primary:focus-visible, .cfo-secondary:focus-visible, .cfo-close:focus-visible { outline:3px solid var(--wfc-theme, #14161f); outline-offset:2px; }\n@keyframes cfo-in { from { opacity:0; } }\n@keyframes cfo-card-in { from { opacity:0; transform:translateY(10px) scale(.97); } }\n@media (prefers-reduced-motion: reduce) { .cfo, .cfo-card { animation:none; } }\n";
@@ -0,0 +1,67 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * A checkout failure laid over the payment methods instead of replacing them,
5
+ * so the layout underneath keeps its size and the visitor's input. The parent
6
+ * must be `position: relative`. Validation failures are not shown here: the
7
+ * payment form marks the field itself.
8
+ */
9
+ import { useEffect, useRef } from 'react';
10
+ const DEFAULT_TITLES = {
11
+ payment_rejection: 'Payment declined',
12
+ validation_failure: 'Check your payment details',
13
+ network_failure: 'You seem to be offline',
14
+ session_failure: 'This checkout expired',
15
+ platform_failure: 'We couldn’t start the payment',
16
+ existing_subscription: 'You already have this plan',
17
+ };
18
+ // A network message is technical ("Failed to fetch"); other categories keep the provider's reason.
19
+ const DEFAULT_BODIES = {
20
+ network_failure: 'We couldn’t reach the payment server. Check your connection and try again; your details are kept.',
21
+ };
22
+ const TONES = {
23
+ payment_rejection: 'error',
24
+ validation_failure: 'error',
25
+ network_failure: 'warning',
26
+ session_failure: 'warning',
27
+ platform_failure: 'error',
28
+ existing_subscription: 'info',
29
+ };
30
+ const ICONS = { error: '!', warning: '↻', info: '✓' };
31
+ export function CheckoutErrorOverlay({ alternative, category, copy, dismissible = true, message, onDismiss, primary, title: titleOverride }) {
32
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
33
+ const tone = TONES[category];
34
+ const primaryRef = useRef(null);
35
+ useEffect(() => { var _a; (_a = primaryRef.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); }, []);
36
+ const title = (_b = titleOverride !== null && titleOverride !== void 0 ? titleOverride : (_a = copy === null || copy === void 0 ? void 0 : copy.titles) === null || _a === void 0 ? void 0 : _a[category]) !== null && _b !== void 0 ? _b : DEFAULT_TITLES[category];
37
+ const body = (_e = (_d = (_c = copy === null || copy === void 0 ? void 0 : copy.bodies) === null || _c === void 0 ? void 0 : _c[category]) !== null && _d !== void 0 ? _d : DEFAULT_BODIES[category]) !== null && _e !== void 0 ? _e : message;
38
+ const primaryLabel = (_f = primary === null || primary === void 0 ? void 0 : primary.label) !== null && _f !== void 0 ? _f : (category === 'existing_subscription' ? (_g = copy === null || copy === void 0 ? void 0 : copy.dismissLabel) !== null && _g !== void 0 ? _g : 'OK' : (_h = copy === null || copy === void 0 ? void 0 : copy.retryLabel) !== null && _h !== void 0 ? _h : 'Try again');
39
+ return (_jsxs("div", { className: 'cfo', "data-tone": tone, onKeyDown: (event) => {
40
+ if (event.key !== 'Escape')
41
+ return;
42
+ // Escape belongs to the overlay; a surrounding dialog must not close as well.
43
+ event.preventDefault();
44
+ event.stopPropagation();
45
+ if (dismissible)
46
+ onDismiss();
47
+ }, children: [_jsxs("div", { className: 'cfo-card', role: 'alertdialog', "aria-labelledby": 'cfo-title', "aria-describedby": 'cfo-message', children: [dismissible ? _jsx("button", { type: 'button', className: 'cfo-close', "aria-label": (_j = copy === null || copy === void 0 ? void 0 : copy.closeLabel) !== null && _j !== void 0 ? _j : 'Close', onClick: onDismiss, children: "\u2715" }) : null, _jsx("span", { className: 'cfo-badge', "aria-hidden": 'true', children: ICONS[tone] }), _jsx("h3", { id: 'cfo-title', className: 'cfo-title', role: 'alert', children: title }), _jsx("p", { id: 'cfo-message', className: 'cfo-message', children: body }), _jsx("button", { ref: primaryRef, type: 'button', className: 'cfo-primary', onClick: (_k = primary === null || primary === void 0 ? void 0 : primary.onClick) !== null && _k !== void 0 ? _k : onDismiss, children: primaryLabel }), alternative ? (_jsx("button", { type: 'button', className: 'cfo-secondary', onClick: alternative.onSelect, children: ((_l = copy === null || copy === void 0 ? void 0 : copy.switchLabel) !== null && _l !== void 0 ? _l : 'Pay with {method}').replace('{method}', alternative.label) })) : null] }), _jsx("style", { children: checkoutErrorOverlayStyles })] }));
48
+ }
49
+ export const checkoutErrorOverlayStyles = `
50
+ .cfo { position:absolute; inset:-6px; z-index:5; display:grid; place-items:center; padding:6px; overflow:auto; border-radius:20px;
51
+ background:rgba(246,247,251,.66); -webkit-backdrop-filter:blur(3px); backdrop-filter:blur(3px); animation:cfo-in .18s ease both; }
52
+ .cfo-card { position:relative; width:min(100%, 420px); padding:20px 18px 10px; border-radius:20px; background:#fff; text-align:center;
53
+ box-shadow:0 14px 34px rgba(20,22,31,.16), 0 0 0 1px rgba(20,22,31,.05); animation:cfo-card-in .26s cubic-bezier(.2,.9,.3,1.2) both; }
54
+ .cfo-close { position:absolute; top:10px; right:10px; width:30px; height:30px; border:0; border-radius:8px; background:#f3f4f8; color:#666; font-size:13px; cursor:pointer; }
55
+ .cfo-badge { display:grid; place-items:center; width:46px; height:46px; margin:0 auto 10px; border-radius:50%; font-size:20px; font-weight:800; }
56
+ .cfo[data-tone='error'] .cfo-badge { background:#fdeeee; color:#c62828; }
57
+ .cfo[data-tone='warning'] .cfo-badge { background:#fff6e0; color:#c98a00; }
58
+ .cfo[data-tone='info'] .cfo-badge { background:#eaf1ff; color:#1f4fb8; }
59
+ .cfo-title { margin:0; padding:0 24px; font-size:18px; font-weight:700; line-height:1.3; color:#14161f; }
60
+ .cfo-message { margin:6px 4px 0; font-size:14px; line-height:1.45; color:#6b7183; }
61
+ .cfo-primary { display:block; width:100%; min-height:48px; margin-top:16px; border:0; border-radius:12px; background:var(--wfc-button, #14161f); color:#fff; font-family:inherit; font-size:16px; font-weight:600; line-height:1.2; cursor:pointer; }
62
+ .cfo-secondary { display:block; width:100%; min-height:42px; margin-top:2px; border:0; background:transparent; color:var(--wfc-theme, #14161f); font-family:inherit; font-size:15px; font-weight:600; line-height:1.2; cursor:pointer; }
63
+ .cfo-primary:focus-visible, .cfo-secondary:focus-visible, .cfo-close:focus-visible { outline:3px solid var(--wfc-theme, #14161f); outline-offset:2px; }
64
+ @keyframes cfo-in { from { opacity:0; } }
65
+ @keyframes cfo-card-in { from { opacity:0; transform:translateY(10px) scale(.97); } }
66
+ @media (prefers-reduced-motion: reduce) { .cfo, .cfo-card { animation:none; } }
67
+ `;
@@ -1 +1 @@
1
- export declare const PAYMENTS_PACKAGE_VERSION = "0.68.0";
1
+ export declare const PAYMENTS_PACKAGE_VERSION = "0.70.0";
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/generate-package-version.mjs.
2
- export const PAYMENTS_PACKAGE_VERSION = "0.68.0";
2
+ export const PAYMENTS_PACKAGE_VERSION = "0.70.0";
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ 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
18
  export { CheckoutSheet, type CheckoutSheetProps, type CheckoutSheetSummary } from './components/CheckoutSheet.js';
19
+ export type { CheckoutErrorOverlayCopy } from './components/CheckoutErrorOverlay.js';
19
20
  export { isCheckoutEmailError, isValidCheckoutEmail } from './services/checkoutEmail.js';
20
21
  export * from './components/CheckoutEmailDialog.js';
21
22
  export * from './components/CreatorDealBanner.js';
@@ -1,8 +1,8 @@
1
1
  import { type CSSProperties, type ReactNode } from 'react';
2
- import type { StripeCheckoutErrorDetails } from '../services/stripeCheckoutError.js';
3
2
  import type { Stripe } from '@stripe/stripe-js';
3
+ import type { StripeCheckoutErrorDetails } from '../services/stripeCheckoutError.js';
4
4
  import { type StripeSubscriptionCheckoutAnalyticsContext } from '../services/checkoutCompletionAnalytics.service.js';
5
- import type { SharedStripeCheckoutV2Copy } from './checkout-v2.content.js';
5
+ import { type SharedStripeCheckoutV2Copy } from './checkout-v2.content.js';
6
6
  export type { SharedStripeCheckoutV2Copy } from './checkout-v2.content.js';
7
7
  export type SharedCheckoutV2CssVars = CSSProperties & {
8
8
  '--shared-checkout-v2-theme-color': string;
@@ -65,8 +65,9 @@ export type SharedStripeCheckoutV2DialogProps = {
65
65
  walletButtonLabel: string;
66
66
  originalPriceLabel: string;
67
67
  originalPriceValue: string;
68
+ /** Legacy: both variants render the same dialog; `compact` only drops the satisfaction line. */
68
69
  variant?: 'standard' | 'compact';
69
- /** Embed a card-only form in the host page; the host owns offer presentation. */
70
+ /** `inline` embeds the wallet-first checkout in the host page; the host owns offer presentation. */
70
71
  presentation?: 'dialog' | 'inline';
71
72
  };
72
73
  export type SharedCheckoutSpecialOfferDialogProps = {
@@ -80,5 +81,13 @@ export type SharedCheckoutSpecialOfferDialogProps = {
80
81
  themeColor: string;
81
82
  title: string;
82
83
  };
83
- export declare function SharedStripeCheckoutV2Dialog({ checkoutAnalytics, checkoutSessionId, clientSecret, onClose, onWalletCancel, stripePromise, supportedCountries, variant, presentation, ...props }: SharedStripeCheckoutV2DialogProps): import("react/jsx-runtime").JSX.Element;
84
+ /**
85
+ * The V2 checkout, kept for funnels that import it: a dialog renders
86
+ * `StripeCheckoutDialog` (ClaimBee paywall-v3 layout, `variant` no longer
87
+ * changes the look) and `presentation: 'inline'` renders
88
+ * `StripeWalletFirstCheckout` in the page. Every V2 prop keeps its meaning:
89
+ * the email field, PayPal, billing countries, wallet availability, card brands
90
+ * and the expired-session handler map onto the wallet-first checkout.
91
+ */
92
+ export declare function SharedStripeCheckoutV2Dialog({ copy, checkoutAnalytics, checkoutSessionId, onClose, onWalletCancel, presentation, variant, ...props }: SharedStripeCheckoutV2DialogProps): import("react/jsx-runtime").JSX.Element;
84
93
  export declare function SharedCheckoutSpecialOfferDialog({ buttonColor, buttonLabel, description, discountLabel, imageAlt, imageSrc, onAccept, themeColor, title, }: SharedCheckoutSpecialOfferDialogProps): import("react/jsx-runtime").JSX.Element;
@@ -10,102 +10,107 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  }
11
11
  return t;
12
12
  };
13
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { useCallback, useEffect, useMemo } from 'react';
15
- import { CheckoutProvider } from '@stripe/react-stripe-js/checkout';
16
- import { normalizeSupportedCheckoutCountries } from './checkoutCountries.js';
17
- import { queueStripeSubscriptionCheckoutStarted, trackStripeCheckoutShown } from '../services/checkoutCompletionAnalytics.service.js';
18
- import { trackCheckoutCanceled } from '../../../services/checkoutObservability.service.js';
19
- import { useCheckoutShownOnce } from '../hooks/useCheckoutShownOnce.js';
20
- import { SharedStripeCheckoutV2CheckoutSessionForm, getFixedSupportedBillingCountry } from './SharedStripeCheckoutV2Form.internal.js';
13
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
+ import { useEffect } from 'react';
15
+ import { queueStripeSubscriptionCheckoutStarted } from '../services/checkoutCompletionAnalytics.service.js';
16
+ import { StripeCheckoutDialog } from './StripeCheckoutDialog.js';
17
+ import { StripeWalletFirstCheckout } from './StripeWalletFirstCheckout.js';
21
18
  import { sharedStripeCheckoutV2Styles } from './SharedStripeCheckoutV2.styles.js';
22
- const stripeCheckoutV2Appearance = {
23
- labels: 'above',
24
- inputs: 'spaced',
25
- variables: {
26
- borderRadius: '0px',
27
- colorBackground: '#fff',
28
- colorText: '#303136',
29
- colorTextPlaceholder: '#8c909a',
30
- gridColumnSpacing: '12px',
31
- gridRowSpacing: '14px',
32
- spacingUnit: '5px',
33
- },
34
- rules: {
35
- '.Label': {
36
- paddingLeft: '14px',
37
- paddingRight: '14px',
38
- marginBottom: '6px',
39
- },
40
- // CHECKOUT-BR-010: accordion items match the wallet option above them.
41
- '.AccordionItem': {
42
- border: '2px solid #e6e7eb',
43
- borderRadius: '13px',
44
- boxShadow: 'none',
19
+ import { defaultCheckoutV2Copy } from './checkout-v2.content.js';
20
+ const defaultPaymentMethodLabels = ['Visa', 'Mastercard', 'Maestro', 'Discover'];
21
+ /**
22
+ * The V2 checkout, kept for funnels that import it: a dialog renders
23
+ * `StripeCheckoutDialog` (ClaimBee paywall-v3 layout, `variant` no longer
24
+ * changes the look) and `presentation: 'inline'` renders
25
+ * `StripeWalletFirstCheckout` in the page. Every V2 prop keeps its meaning:
26
+ * the email field, PayPal, billing countries, wallet availability, card brands
27
+ * and the expired-session handler map onto the wallet-first checkout.
28
+ */
29
+ export function SharedStripeCheckoutV2Dialog(_a) {
30
+ var _b, _c, _d, _e, _f, _g;
31
+ var { copy = defaultCheckoutV2Copy, checkoutAnalytics = null, checkoutSessionId = null, onClose, onWalletCancel, presentation = 'dialog', variant = 'standard' } = _a, props = __rest(_a, ["copy", "checkoutAnalytics", "checkoutSessionId", "onClose", "onWalletCancel", "presentation", "variant"]);
32
+ const walletFirst = {
33
+ amountCents: props.amountCents,
34
+ buttonColor: props.buttonColor,
35
+ checkoutAnalytics,
36
+ checkoutSessionId,
37
+ clientSecret: props.clientSecret,
38
+ copy: {
39
+ walletBenefits: { applePay: [], googlePay: [] },
40
+ walletLabels: { applePay: props.walletButtonLabel, googlePay: 'Google Pay' },
41
+ cardLabel: copy.cardLabel,
42
+ cardSubmitLabel: props.cardSubmitLabel,
43
+ processingLabel: props.processingLabel,
44
+ // The dialog shows the secure label once, under the methods.
45
+ secureNote: presentation === 'inline' ? props.secureLabel : '',
46
+ walletUnavailableNote: '',
47
+ verifyingPayment: copy.verifyingPayment,
48
+ paymentConfirmed: copy.paymentConfirmed,
49
+ paymentFailed: copy.paymentFailed,
50
+ formNotReady: copy.formNotReady,
51
+ errors: Object.assign({ checkStatusLabel: copy.checkPaymentStatus }, copy.errors),
45
52
  },
46
- '.AccordionItem--selected': {
47
- border: '3px solid #050505',
53
+ customerEmail: (_c = (_b = props.customerEmail) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '',
54
+ customerName: props.customerName,
55
+ email: {
56
+ editable: props.customerEmailEditable,
57
+ label: props.customerEmailLabel,
58
+ placeholder: props.customerEmailPlaceholder,
59
+ invalidMessage: props.customerEmailInvalidMessage,
60
+ onChange: props.onCustomerEmailChange,
61
+ onCommit: props.onCustomerEmailCommit,
48
62
  },
49
- },
50
- };
51
- const compactStripeCheckoutV2Appearance = Object.assign(Object.assign({}, stripeCheckoutV2Appearance), { variables: Object.assign(Object.assign({}, stripeCheckoutV2Appearance.variables), { borderRadius: '14px', colorPrimary: '#1687f8' }) });
52
- function CheckoutSessionProvider({ children, clientSecret, fixedBillingCountry, stripePromise, variant, }) {
53
- const providerChildren = children;
54
- const checkoutProviderOptions = useMemo(() => (Object.assign(Object.assign({ clientSecret }, (fixedBillingCountry
55
- ? {
56
- defaultValues: {
57
- billingAddress: {
58
- address: {
59
- country: fixedBillingCountry,
60
- },
61
- },
62
- },
63
- }
64
- : {})), { elementsOptions: {
65
- appearance: variant === 'compact'
66
- ? compactStripeCheckoutV2Appearance
67
- : stripeCheckoutV2Appearance,
68
- } })), [clientSecret, fixedBillingCountry, variant]);
69
- return (_jsx(CheckoutProvider, { stripe: stripePromise, options: checkoutProviderOptions, children: providerChildren }, clientSecret));
63
+ cardBrandLabels: ((_d = props.paymentMethodLabels) === null || _d === void 0 ? void 0 : _d.length) ? props.paymentMethodLabels : defaultPaymentMethodLabels,
64
+ // V2 never showed Stripe's stale-session error, with or without a handler.
65
+ onInactiveCheckoutSession: (_e = props.onInactiveCheckoutSession) !== null && _e !== void 0 ? _e : (() => undefined),
66
+ // The inline form has no dialog to close: only an explicit wallet handler runs there.
67
+ onCancel: presentation === 'inline' ? onWalletCancel : onWalletCancel !== null && onWalletCancel !== void 0 ? onWalletCancel : onClose,
68
+ onError: props.onError,
69
+ onPaymentInfoSubmitted: props.onPaymentInfoSubmitted,
70
+ onSuccess: props.onSuccess,
71
+ initialWalletAvailable: props.initialWalletAvailable,
72
+ // V2 fell back to the card quietly where the wallet cannot pay.
73
+ hideUnavailableWallet: true,
74
+ paypalCheckout: presentation === 'dialog' ? props.paypalCheckout : undefined,
75
+ paypalLabel: props.paypalLabel,
76
+ paypalPending: props.paypalPending,
77
+ returnUrl: props.returnUrl,
78
+ stripePromise: props.stripePromise,
79
+ summaryLabel: ((_f = props.summaryLabel) === null || _f === void 0 ? void 0 : _f.trim()) || props.discountLabel || props.title,
80
+ supportedCountries: props.supportedCountries,
81
+ themeColor: props.themeColor,
82
+ unsupportedCountryMessage: props.unsupportedCountryMessage,
83
+ };
84
+ if (presentation === 'inline')
85
+ return _jsx(InlineCheckout, { title: props.title, checkout: walletFirst });
86
+ const promoActive = (_g = props.promoActive) !== null && _g !== void 0 ? _g : (props.discountPercent > 0 && props.promoCode.trim().length > 0);
87
+ return (_jsx(StripeCheckoutDialog, Object.assign({}, walletFirst, { title: props.title, closeAriaLabel: props.closeAriaLabel, onClose: onClose, guaranteeLabel: props.secureLabel, summary: {
88
+ promoActive,
89
+ countdownLabel: `${props.discountPercent}% ${props.countdownLabel}`.trim(),
90
+ remainingSeconds: props.remainingSeconds,
91
+ // The compact variant never showed the satisfaction line.
92
+ satisfactionPercent: variant === 'standard' ? props.satisfactionPercent : undefined,
93
+ satisfactionLabel: variant === 'standard' ? props.satisfactionLabel : undefined,
94
+ originalPriceLabel: props.originalPriceLabel,
95
+ originalPriceValue: props.originalPriceValue,
96
+ discountLabel: props.discountLabel,
97
+ discountAmountLabel: props.discountAmountLabel,
98
+ promoCodeLabel: props.promoCodeLabel,
99
+ promoCode: props.promoCode,
100
+ totalLabel: props.totalLabel,
101
+ totalValue: props.totalValue,
102
+ savedLabel: props.savedLabel,
103
+ } })));
70
104
  }
71
- export function SharedStripeCheckoutV2Dialog(_a) {
72
- var { checkoutAnalytics, checkoutSessionId, clientSecret, onClose, onWalletCancel, stripePromise, supportedCountries, variant = 'standard', presentation = 'dialog' } = _a, props = __rest(_a, ["checkoutAnalytics", "checkoutSessionId", "clientSecret", "onClose", "onWalletCancel", "stripePromise", "supportedCountries", "variant", "presentation"]);
73
- const normalizedSupportedCountries = useMemo(() => normalizeSupportedCheckoutCountries(supportedCountries), [supportedCountries]);
74
- const fixedBillingCountry = getFixedSupportedBillingCountry(normalizedSupportedCountries);
75
- const handleClose = useCallback(() => {
76
- if (checkoutAnalytics) {
77
- trackCheckoutCanceled({
78
- analytics: checkoutAnalytics,
79
- checkoutSessionId,
80
- failureStage: 'checkout_dialog',
81
- provider: 'stripe',
82
- });
83
- }
84
- onClose();
85
- }, [checkoutAnalytics, checkoutSessionId, onClose]);
86
- // The dialog is mounted while open, so one mount is one show.
87
- useCheckoutShownOnce(Boolean(checkoutAnalytics), () => {
88
- if (checkoutAnalytics)
89
- trackStripeCheckoutShown(Object.assign(Object.assign({}, checkoutAnalytics), { checkoutSessionId, checkoutSurface: presentation }));
90
- });
105
+ /** The inline V2 form started the checkout when it rendered; the wallet-first block keeps that. */
106
+ function InlineCheckout({ checkout, title }) {
107
+ const { checkoutAnalytics, checkoutSessionId } = checkout;
91
108
  useEffect(() => {
92
- if (!checkoutAnalytics) {
109
+ if (!checkoutAnalytics)
93
110
  return;
94
- }
95
111
  queueStripeSubscriptionCheckoutStarted(Object.assign(Object.assign({}, checkoutAnalytics), { checkoutSessionId, checkoutStartSource: 'card_form_open', paymentMethod: 'card' }));
96
112
  }, [checkoutAnalytics, checkoutSessionId]);
97
- useEffect(() => {
98
- if (presentation === 'inline')
99
- return;
100
- const handleKeyDown = (event) => {
101
- if (event.key === 'Escape') {
102
- handleClose();
103
- }
104
- };
105
- window.addEventListener('keydown', handleKeyDown);
106
- return () => window.removeEventListener('keydown', handleKeyDown);
107
- }, [handleClose, presentation]);
108
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: presentation === 'inline' ? 'shared-checkout-v2-inline' : 'shared-checkout-v2-overlay', children: _jsx("div", { className: presentation === 'inline' ? undefined : 'shared-checkout-v2-dialog', "data-variant": variant, role: presentation === 'dialog' ? 'dialog' : 'region', "aria-modal": presentation === 'dialog' ? true : undefined, "aria-labelledby": presentation === 'dialog' ? 'shared-checkout-v2-title' : undefined, "aria-label": presentation === 'inline' ? props.title : undefined, children: _jsx(CheckoutSessionProvider, { clientSecret: clientSecret, fixedBillingCountry: fixedBillingCountry, stripePromise: stripePromise, variant: variant, children: _jsx(SharedStripeCheckoutV2CheckoutSessionForm, Object.assign({}, props, { presentation: presentation, checkoutAnalytics: checkoutAnalytics, checkoutSessionId: checkoutSessionId, clientSecret: clientSecret, onClose: handleClose, onWalletCancel: onWalletCancel !== null && onWalletCancel !== void 0 ? onWalletCancel : onClose, supportedCountries: normalizedSupportedCountries, variant: variant })) }) }) }), _jsx("style", { children: sharedStripeCheckoutV2Styles })] }));
113
+ return (_jsx("div", { className: 'shared-checkout-v2-inline', role: 'region', "aria-label": title, children: _jsx(StripeWalletFirstCheckout, Object.assign({}, checkout, { checkoutSurface: 'inline' })) }));
109
114
  }
110
115
  function SharedCheckoutSpecialOfferGift({ discountLabel, imageAlt, imageSrc, }) {
111
116
  if (imageSrc) {
@@ -0,0 +1,31 @@
1
+ import { type StripeWalletFirstCheckoutProps } from './StripeWalletFirstCheckout.js';
2
+ export type StripeCheckoutDialogSummary = {
3
+ totalLabel: string;
4
+ totalValue: string;
5
+ /** A discount is running: shows the timer, the regular price, the discount, the promo code and the saving. */
6
+ promoActive?: boolean;
7
+ /** Text before the timer, e.g. "50% discount ends in". */
8
+ countdownLabel?: string;
9
+ remainingSeconds?: number;
10
+ satisfactionPercent?: string;
11
+ satisfactionLabel?: string;
12
+ originalPriceLabel?: string;
13
+ originalPriceValue?: string;
14
+ discountLabel?: string;
15
+ discountAmountLabel?: string;
16
+ promoCodeLabel?: string;
17
+ promoCode?: string;
18
+ savedLabel?: string;
19
+ };
20
+ export type StripeCheckoutDialogProps = Omit<StripeWalletFirstCheckoutProps, 'checkoutSurface'> & {
21
+ title: string;
22
+ closeAriaLabel: string;
23
+ onClose: () => void;
24
+ summary: StripeCheckoutDialogSummary;
25
+ /** Line under the payment methods, e.g. a money-back guarantee. */
26
+ guaranteeLabel?: string;
27
+ /** A failure outside the payment form, e.g. the Checkout Session could not be created. */
28
+ error?: string | null;
29
+ };
30
+ export declare function StripeCheckoutDialog({ title, closeAriaLabel, onClose, summary, guaranteeLabel, error, ...checkout }: StripeCheckoutDialogProps): import("react/jsx-runtime").JSX.Element;
31
+ export declare const stripeCheckoutDialogStyles = "\n.fgcd-overlay {\n --fgcd-soft: color-mix(in srgb, var(--fgcd-theme) 10%, #fff);\n --fgcd-bg: color-mix(in srgb, var(--fgcd-theme) 4%, #f6f6f9);\n --fgcd-border: color-mix(in srgb, var(--fgcd-theme) 12%, #e4e4ea);\n --fgcd-text: #101010;\n --fgcd-muted: #66646e;\n position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center;\n background: rgb(16 12 30 / 50%); animation: fgcd-fade-in .2s ease-out;\n}\n.fgcd-sheet {\n width: min(100%, 480px); max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain;\n border-radius: 28px 28px 0 0; background: var(--fgcd-bg); box-sizing: border-box; color: var(--fgcd-text);\n animation: fgcd-sheet-up .32s cubic-bezier(.25, .8, .25, 1);\n}\n.fgcd-sheet *, .fgcd-sheet *::before, .fgcd-sheet *::after { box-sizing: border-box; }\n.fgcd-content { display: flex; flex-direction: column; gap: 14px; padding: 12px 24px calc(34px + env(safe-area-inset-bottom, 0px)); }\n@media (min-width: 640px) {\n .fgcd-overlay { align-items: center; padding: 24px; }\n .fgcd-sheet { max-height: calc(100dvh - 48px); border-radius: 28px; animation: fgcd-pop .24s cubic-bezier(.2, .9, .3, 1.1); }\n .fgcd-content { padding: 20px 28px 28px; }\n .fgcd-grabber { display: none; }\n}\n@keyframes fgcd-sheet-up { from { transform: translateY(100%); } }\n@keyframes fgcd-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }\n@keyframes fgcd-fade-in { from { opacity: 0; } }\n@media (prefers-reduced-motion: reduce) { .fgcd-sheet, .fgcd-overlay { animation: none; } }\n.fgcd-grabber { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--fgcd-theme) 18%, #ddd); }\n.fgcd-head { position: relative; display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 44px; }\n.fgcd-head h2 { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.2; text-align: center; }\n.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; }\n.fgcd-close svg { width: 16px; height: 16px; fill: none; stroke: #4a4660; stroke-width: 1.8; stroke-linecap: round; }\n.fgcd-close:focus-visible { outline: 3px solid var(--fgcd-theme); outline-offset: 2px; }\n.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; }\n.fgcd-timer > span:first-child { font-size: 18px; }\n.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; }\n.fgcd-proof { margin: 0; font-size: 15px; font-weight: 700; line-height: 21px; text-align: center; }\n.fgcd-proof strong { color: var(--fgcd-theme); }\n.fgcd-summary { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 16px; background: #fff; }\n.fgcd-summary hr { width: 100%; margin: 0; border: 0; border-top: 1px solid var(--fgcd-border); }\n.fgcd-row, .fgcd-promo, .fgcd-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; }\n.fgcd-row--muted { color: var(--fgcd-muted); font-size: 14px; }\n.fgcd-row--discount { font-size: 15px; font-weight: 700; }\n.fgcd-row--discount strong { color: #cc2b31; font-weight: 800; }\n.fgcd-promo { padding: 9px 12px; border-radius: 10px; background: var(--fgcd-soft); color: var(--fgcd-muted); font-size: 13px; }\n.fgcd-promo strong, .fgcd-total strong { display: inline-flex; align-items: center; gap: 6px; color: var(--fgcd-text); font-weight: 800; }\n.fgcd-promo strong { font-size: 14px; letter-spacing: .42px; text-transform: uppercase; }\n.fgcd-check { width: 13px; height: 13px; }\n.fgcd-total span { font-size: 20px; font-weight: 800; }\n.fgcd-total strong { font-size: 24px; }\n.fgcd-tag { width: 20px; height: 20px; }\n.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; }\n.fgcd-sheet .wfc { gap: 10px; }\n.fgcd-sheet .wfc-method { border-radius: 18px; box-shadow: 0 0 0 1px var(--fgcd-border); transition: box-shadow .2s ease; }\n.fgcd-sheet .wfc-method[data-checked='true'] { box-shadow: 0 0 0 2px var(--fgcd-theme); }\n.fgcd-sheet .wfc-method-head { min-height: 58px; padding: 16px; gap: 12px; border-radius: 18px; }\n.fgcd-sheet .wfc-mark { height: 26px; }\n.fgcd-sheet .wfc-brand { width: 42px; height: 28px; border-radius: 5px; }\n.fgcd-sheet .wfc-benefits:empty { display: none; }\n.fgcd-sheet .wfc-wallet-button, .fgcd-sheet .wfc-progress { border-radius: 14px; }\n.fgcd-sheet .wfc-secure { margin-top: 10px; color: var(--fgcd-muted); font-size: 13px; }\n.fgcd-sheet .wfc-card-form .wfc-secure { display: none; }\n.fgcd-sheet .wfc-submit { min-height: 56px; border-radius: 14px; font-size: 18px; font-weight: 700; }\n.fgcd-error { margin: 0; color: #c62828; font-size: 14px; text-align: center; }\n.fgcd-guarantee { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 700; }\n.fgcd-guarantee svg { width: 18px; height: 18px; flex: none; }\n";