@funnelsgrove/payments 0.1.56 → 0.1.57

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 CHANGED
@@ -13,13 +13,17 @@ Read this file before editing checkout code. Deeper implementation docs:
13
13
 
14
14
  ## Current Checkout Path
15
15
 
16
+ Render every visible wallet placement with `StripeSubscriptionWalletSurface`. It is the normal current path for Apple Pay and Google Pay:
17
+
18
+ - Each surface owns one private Checkout Session per simultaneously visible wallet placement, isolated by its own `surfaceId`.
19
+ - Simultaneously visible placements may use the same plan and coupon; nothing is shared because each surface keeps its own session.
20
+ - When the selected plan changes, the surface updates the existing Checkout Session in place without changing `surfaceId`, React `key`, `clientSecret`, `CheckoutProvider`, or the Express Checkout iframe.
21
+
16
22
  Use these for new subscription paywalls:
17
23
 
24
+ - `StripeSubscriptionWalletSurface`
18
25
  - `useStripeSubscriptionCheckoutSession`
19
26
  - `SharedStripeCheckoutV2Dialog`
20
- - `ApplePaySubscriptionCheckoutSlot`
21
- - `GooglePaySubscriptionCheckoutSlot`
22
- - `WalletSubscriptionCheckoutSlot`
23
27
  - `trackPaidStripeSubscriptionCheckoutCompleted`
24
28
 
25
29
  Use these for new one-time paywall plans:
@@ -29,6 +33,10 @@ Use these for new one-time paywall plans:
29
33
 
30
34
  Use `chargeStripeOneClickPayment` for post-checkout one-click upsells when the shared client helper fits the funnel. It delegates to `funnelSdkService.chargeOneClickPayment`.
31
35
 
36
+ ## Advanced Wallet Primitives
37
+
38
+ `ApplePaySubscriptionCheckoutSlot`, `GooglePaySubscriptionCheckoutSlot`, and `WalletSubscriptionCheckoutSlot` stay exported and runtime-compatible. They are backward-compatible advanced low-level primitives: reach for them only when a placement needs wiring `StripeSubscriptionWalletSurface` does not cover. Never share one `useStripeSubscriptionCheckoutSession` result across placements; give each visible placement its own session.
39
+
32
40
  ## Compatibility-Only Surfaces
33
41
 
34
42
  Keep these exports available for saved drafts, old published artifacts, and controlled migrations. Do not use them for new subscription checkout work:
@@ -70,7 +78,7 @@ When a live funnel still uses one of these, migrate the funnel deliberately with
70
78
  - `services/runtimeBillingPlanCatalog.service`: test/live runtime catalog selection.
71
79
  - `services/paywallOffer.service`: timed discount and display-plan helpers.
72
80
  - `services/stripe.service`: Stripe loader, Checkout Session, hosted checkout, one-click, one-time Checkout Session clients, and deprecated PaymentIntent compatibility clients.
73
- - `providers/*`: provider-neutral checkout state and Stripe subscription checkout slots.
81
+ - `providers/*`: provider-neutral checkout state, the Stripe subscription wallet surface, and Stripe subscription checkout slots.
74
82
  - `components/shared/*`: plan selector, checkout dialogs, Express Checkout wrappers, wallet placeholders, and trust assets.
75
83
  - `testing/walletCheckoutSmoke`: wallet checkout smoke assertions.
76
84
 
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export * from './providers/stripe/useStripeOneTimeCheckoutSession.js';
14
14
  export * from './providers/stripe/WalletSubscriptionCheckoutSlot.js';
15
15
  export * from './providers/stripe/ApplePaySubscriptionCheckoutSlot.js';
16
16
  export * from './providers/stripe/GooglePaySubscriptionCheckoutSlot.js';
17
+ export * from './providers/stripe/StripeSubscriptionWalletSurface.js';
17
18
  export { ManageSubscriptionScreen, type ManageSubscriptionContent, type ManageSubscriptionScreenProps, } from './components/ManageSubscriptionScreen.js';
18
19
  export * from './components/shared/SharedStripeCheckoutV2Dialog.js';
19
20
  export * from './components/shared/StripeExpressCheckoutElement.js';
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ export * from './providers/stripe/useStripeOneTimeCheckoutSession.js';
17
17
  export * from './providers/stripe/WalletSubscriptionCheckoutSlot.js';
18
18
  export * from './providers/stripe/ApplePaySubscriptionCheckoutSlot.js';
19
19
  export * from './providers/stripe/GooglePaySubscriptionCheckoutSlot.js';
20
+ export * from './providers/stripe/StripeSubscriptionWalletSurface.js';
20
21
  // Shared checkout and subscription-management UI.
21
22
  export { ManageSubscriptionScreen, } from './components/ManageSubscriptionScreen.js';
22
23
  export * from './components/shared/SharedStripeCheckoutV2Dialog.js';
@@ -4,4 +4,9 @@ export type ApplePaySubscriptionCheckoutSlotProps = Omit<WalletSubscriptionCheck
4
4
  options?: Partial<StripeCheckoutExpressCheckoutElementOptions>;
5
5
  placeholderLabel?: string;
6
6
  };
7
+ /**
8
+ * @deprecated Prefer StripeSubscriptionWalletSurface for visible wallet placements. This slot stays
9
+ * exported and runtime-compatible as an advanced low-level primitive; its checkout session must
10
+ * never be shared across placements.
11
+ */
7
12
  export declare function ApplePaySubscriptionCheckoutSlot({ options, placeholderLabel, ...slotProps }: ApplePaySubscriptionCheckoutSlotProps): import("react/jsx-runtime").JSX.Element;
@@ -36,6 +36,11 @@ const applePayExpressCheckoutOptions = {
36
36
  paypal: 'never',
37
37
  },
38
38
  };
39
+ /**
40
+ * @deprecated Prefer StripeSubscriptionWalletSurface for visible wallet placements. This slot stays
41
+ * exported and runtime-compatible as an advanced low-level primitive; its checkout session must
42
+ * never be shared across placements.
43
+ */
39
44
  export function ApplePaySubscriptionCheckoutSlot(_a) {
40
45
  var _b, _c, _d, _e, _f, _g, _h, _j, _k;
41
46
  var { options, placeholderLabel = 'Subscribe with Apple Pay' } = _a, slotProps = __rest(_a, ["options", "placeholderLabel"]);
@@ -4,4 +4,9 @@ export type GooglePaySubscriptionCheckoutSlotProps = Omit<WalletSubscriptionChec
4
4
  options?: Partial<StripeCheckoutExpressCheckoutElementOptions>;
5
5
  placeholderLabel?: string;
6
6
  };
7
+ /**
8
+ * @deprecated Prefer StripeSubscriptionWalletSurface for visible wallet placements. This slot stays
9
+ * exported and runtime-compatible as an advanced low-level primitive; its checkout session must
10
+ * never be shared across placements.
11
+ */
7
12
  export declare function GooglePaySubscriptionCheckoutSlot({ options, placeholderLabel, ...slotProps }: GooglePaySubscriptionCheckoutSlotProps): import("react/jsx-runtime").JSX.Element;
@@ -36,6 +36,11 @@ const googlePayExpressCheckoutOptions = {
36
36
  paypal: 'never',
37
37
  },
38
38
  };
39
+ /**
40
+ * @deprecated Prefer StripeSubscriptionWalletSurface for visible wallet placements. This slot stays
41
+ * exported and runtime-compatible as an advanced low-level primitive; its checkout session must
42
+ * never be shared across placements.
43
+ */
39
44
  export function GooglePaySubscriptionCheckoutSlot(_a) {
40
45
  var _b, _c, _d, _e, _f, _g, _h, _j, _k;
41
46
  var { options, placeholderLabel = 'Subscribe with Google Pay' } = _a, slotProps = __rest(_a, ["options", "placeholderLabel"]);
@@ -0,0 +1,82 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { Appearance, StripeCheckoutExpressCheckoutElementOptions } from '@stripe/stripe-js';
3
+ import { type PlatformWalletPaymentMethod } from '../../components/shared/walletPlatform.js';
4
+ import type { StripeSubscriptionCheckoutAnalyticsContext } from '../../services/checkoutCompletionAnalytics.service.js';
5
+ import { type StripeSubscriptionCheckoutSessionInput } from './useStripeSubscriptionCheckoutSession.js';
6
+ export type StripeSubscriptionWalletSurfaceCheckoutInput = Omit<StripeSubscriptionCheckoutSessionInput, 'onError'> & {
7
+ customerName?: string | null;
8
+ };
9
+ export type StripeSubscriptionWalletSurfaceAvailability = {
10
+ anyAvailable: boolean;
11
+ methods: Partial<Record<PlatformWalletPaymentMethod, boolean>>;
12
+ resolved: boolean;
13
+ };
14
+ export type StripeSubscriptionWalletSurfaceAvailabilityState = {
15
+ intentKey: string;
16
+ methods: Partial<Record<PlatformWalletPaymentMethod, boolean>>;
17
+ };
18
+ export type StripeSubscriptionWalletSurfaceErrorContext = {
19
+ paymentMethod?: PlatformWalletPaymentMethod;
20
+ surfaceId: string;
21
+ };
22
+ export type StripeSubscriptionWalletSurfaceErrorEmission = {
23
+ context: StripeSubscriptionWalletSurfaceErrorContext;
24
+ errorState: StripeSubscriptionWalletSurfaceErrorState;
25
+ message: string | null;
26
+ };
27
+ export type StripeSubscriptionWalletSurfaceErrorState = {
28
+ methodMessages: Partial<Record<PlatformWalletPaymentMethod, string>>;
29
+ surfaceMessage: string | null;
30
+ };
31
+ export type StripeSubscriptionWalletSurfaceRenderStateInput = {
32
+ anyAvailable: boolean;
33
+ configured: boolean;
34
+ paymentMethodCount: number;
35
+ resolved: boolean;
36
+ suspended: boolean;
37
+ };
38
+ export declare function buildStripeSubscriptionWalletSurfaceAnalyticsMetadata(analyticsMetadata: Record<string, unknown> | null | undefined, surfaceId: string): Record<string, unknown>;
39
+ export declare function buildStripeSubscriptionWalletSurfaceCheckoutAnalytics(checkoutAnalytics: StripeSubscriptionCheckoutAnalyticsContext | null | undefined, surfaceId: string): StripeSubscriptionCheckoutAnalyticsContext | null;
40
+ export declare function normalizeStripeSubscriptionWalletSurfaceMethods(paymentMethods: readonly PlatformWalletPaymentMethod[]): PlatformWalletPaymentMethod[];
41
+ export declare function getStripeSubscriptionWalletSurfaceVisibleMethods(paymentMethods: readonly PlatformWalletPaymentMethod[], methods: Partial<Record<PlatformWalletPaymentMethod, boolean>>): PlatformWalletPaymentMethod[];
42
+ export declare function getStripeSubscriptionWalletSurfaceMethodAvailability(state: StripeSubscriptionWalletSurfaceAvailabilityState, intentKey: string): Partial<Record<PlatformWalletPaymentMethod, boolean>>;
43
+ export declare function applyStripeSubscriptionWalletSurfaceMethodAvailability(state: StripeSubscriptionWalletSurfaceAvailabilityState, intentKey: string, method: PlatformWalletPaymentMethod, available: boolean): StripeSubscriptionWalletSurfaceAvailabilityState;
44
+ export declare function buildStripeSubscriptionWalletSurfaceAvailability(paymentMethods: readonly PlatformWalletPaymentMethod[], methods: Partial<Record<PlatformWalletPaymentMethod, boolean>>): StripeSubscriptionWalletSurfaceAvailability;
45
+ export declare function shouldRenderStripeSubscriptionWalletSurface({ anyAvailable, configured, paymentMethodCount, resolved, suspended, }: StripeSubscriptionWalletSurfaceRenderStateInput): boolean;
46
+ export declare function resolveStripeSubscriptionWalletSurfaceError({ errorState, message, paymentMethod, surfaceId, }: {
47
+ errorState: StripeSubscriptionWalletSurfaceErrorState;
48
+ message: string | null;
49
+ paymentMethod?: PlatformWalletPaymentMethod;
50
+ surfaceId: string;
51
+ }): StripeSubscriptionWalletSurfaceErrorEmission | null;
52
+ export type StripeSubscriptionWalletSurfaceProps = {
53
+ amountCents: number;
54
+ appearance?: Appearance;
55
+ applePayOptions?: Partial<StripeCheckoutExpressCheckoutElementOptions>;
56
+ applePayPlaceholderLabel?: string;
57
+ beforeConfirm?: () => Promise<string | null>;
58
+ checkout: StripeSubscriptionWalletSurfaceCheckoutInput;
59
+ checkoutAnalytics?: StripeSubscriptionCheckoutAnalyticsContext | null;
60
+ className?: string;
61
+ containerClassName?: string;
62
+ disabled?: boolean;
63
+ googlePayOptions?: Partial<StripeCheckoutExpressCheckoutElementOptions>;
64
+ googlePayPlaceholderLabel?: string;
65
+ onAvailabilityChange?: (availability: StripeSubscriptionWalletSurfaceAvailability) => void;
66
+ onCancel?: () => void;
67
+ onError?: (message: string | null, context: StripeSubscriptionWalletSurfaceErrorContext) => void;
68
+ onPaymentInfoSubmitted?: () => void | Promise<void>;
69
+ onSuccess?: () => void | Promise<void>;
70
+ onUnavailableClick?: () => Promise<void> | void;
71
+ paymentMethods?: readonly PlatformWalletPaymentMethod[];
72
+ renderHeader?: (props: {
73
+ availability: StripeSubscriptionWalletSurfaceAvailability;
74
+ }) => ReactNode;
75
+ resolveMethodClassName?: (method: PlatformWalletPaymentMethod) => string | undefined;
76
+ resolveMethodWrapperClassName?: (method: PlatformWalletPaymentMethod) => string | undefined;
77
+ slotClassName?: string;
78
+ summaryLabel: string;
79
+ surfaceId: string;
80
+ suspended?: boolean;
81
+ };
82
+ export declare function StripeSubscriptionWalletSurface({ amountCents, appearance, applePayOptions, applePayPlaceholderLabel, beforeConfirm, checkout, checkoutAnalytics, className, containerClassName, disabled, googlePayOptions, googlePayPlaceholderLabel, onAvailabilityChange, onCancel, onError, onPaymentInfoSubmitted, onSuccess, onUnavailableClick, paymentMethods, renderHeader, resolveMethodClassName, resolveMethodWrapperClassName, slotClassName, summaryLabel, surfaceId, suspended, }: StripeSubscriptionWalletSurfaceProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,188 @@
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 } from "react/jsx-runtime";
14
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
15
+ import { usePlatformWalletPaymentMethods, } from '../../components/shared/walletPlatform.js';
16
+ import { ApplePaySubscriptionCheckoutSlot } from './ApplePaySubscriptionCheckoutSlot.js';
17
+ import { GooglePaySubscriptionCheckoutSlot } from './GooglePaySubscriptionCheckoutSlot.js';
18
+ import { useStripeSubscriptionCheckoutSession, } from './useStripeSubscriptionCheckoutSession.js';
19
+ export function buildStripeSubscriptionWalletSurfaceAnalyticsMetadata(analyticsMetadata, surfaceId) {
20
+ return Object.assign(Object.assign({}, (analyticsMetadata !== null && analyticsMetadata !== void 0 ? analyticsMetadata : {})), { checkoutSurfaceId: surfaceId });
21
+ }
22
+ export function buildStripeSubscriptionWalletSurfaceCheckoutAnalytics(checkoutAnalytics, surfaceId) {
23
+ if (!checkoutAnalytics) {
24
+ return null;
25
+ }
26
+ return Object.assign(Object.assign({}, checkoutAnalytics), { metadata: buildStripeSubscriptionWalletSurfaceAnalyticsMetadata(checkoutAnalytics.metadata, surfaceId) });
27
+ }
28
+ export function normalizeStripeSubscriptionWalletSurfaceMethods(paymentMethods) {
29
+ return paymentMethods.filter((method, index) => paymentMethods.indexOf(method) === index);
30
+ }
31
+ export function getStripeSubscriptionWalletSurfaceVisibleMethods(paymentMethods, methods) {
32
+ return paymentMethods.filter((method) => methods[method] !== false);
33
+ }
34
+ export function getStripeSubscriptionWalletSurfaceMethodAvailability(state, intentKey) {
35
+ return state.intentKey === intentKey ? state.methods : {};
36
+ }
37
+ export function applyStripeSubscriptionWalletSurfaceMethodAvailability(state, intentKey, method, available) {
38
+ return {
39
+ intentKey,
40
+ methods: Object.assign(Object.assign({}, getStripeSubscriptionWalletSurfaceMethodAvailability(state, intentKey)), { [method]: available }),
41
+ };
42
+ }
43
+ export function buildStripeSubscriptionWalletSurfaceAvailability(paymentMethods, methods) {
44
+ const reportedMethods = paymentMethods.filter((method) => typeof methods[method] === 'boolean');
45
+ return {
46
+ anyAvailable: reportedMethods.some((method) => methods[method] === true),
47
+ methods: reportedMethods.reduce((current, method) => (Object.assign(Object.assign({}, current), { [method]: methods[method] === true })), {}),
48
+ resolved: reportedMethods.length === paymentMethods.length,
49
+ };
50
+ }
51
+ export function shouldRenderStripeSubscriptionWalletSurface({ anyAvailable, configured, paymentMethodCount, resolved, suspended, }) {
52
+ return configured && !suspended && paymentMethodCount > 0 && (!resolved || anyAvailable);
53
+ }
54
+ export function resolveStripeSubscriptionWalletSurfaceError({ errorState, message, paymentMethod, surfaceId, }) {
55
+ if (paymentMethod && errorState.methodMessages[paymentMethod] === message) {
56
+ return null;
57
+ }
58
+ if (!paymentMethod) {
59
+ const methodMessages = Object.values(errorState.methodMessages);
60
+ if (message === null) {
61
+ if (errorState.surfaceMessage === null && methodMessages.length === 0) {
62
+ return null;
63
+ }
64
+ }
65
+ else if (errorState.surfaceMessage === message || methodMessages.includes(message)) {
66
+ return null;
67
+ }
68
+ }
69
+ const nextErrorState = message === null
70
+ ? { methodMessages: {}, surfaceMessage: null }
71
+ : paymentMethod
72
+ ? Object.assign(Object.assign({}, errorState), { methodMessages: Object.assign(Object.assign({}, errorState.methodMessages), { [paymentMethod]: message }) }) : Object.assign(Object.assign({}, errorState), { surfaceMessage: message });
73
+ return {
74
+ context: Object.assign(Object.assign({}, (paymentMethod ? { paymentMethod } : {})), { surfaceId }),
75
+ errorState: nextErrorState,
76
+ message,
77
+ };
78
+ }
79
+ // Availability identity used to notify consumers only when the aggregate actually changed.
80
+ function buildAvailabilitySignature(availability) {
81
+ return [
82
+ availability.resolved ? 'resolved' : 'unresolved',
83
+ availability.anyAvailable ? 'available' : 'unavailable',
84
+ Object.entries(availability.methods)
85
+ .map(([method, available]) => `${method}:${available ? '1' : '0'}`)
86
+ .sort()
87
+ .join(','),
88
+ ].join('|');
89
+ }
90
+ export function StripeSubscriptionWalletSurface({ amountCents, appearance, applePayOptions, applePayPlaceholderLabel, beforeConfirm, checkout, checkoutAnalytics, className, containerClassName, disabled, googlePayOptions, googlePayPlaceholderLabel, onAvailabilityChange, onCancel, onError, onPaymentInfoSubmitted, onSuccess, onUnavailableClick, paymentMethods, renderHeader, resolveMethodClassName, resolveMethodWrapperClassName, slotClassName, summaryLabel, surfaceId, suspended = false, }) {
91
+ var _a;
92
+ const platformWalletPaymentMethods = usePlatformWalletPaymentMethods();
93
+ const walletPaymentMethods = normalizeStripeSubscriptionWalletSurfaceMethods(paymentMethods !== null && paymentMethods !== void 0 ? paymentMethods : platformWalletPaymentMethods);
94
+ const normalizedSurfaceId = surfaceId.trim();
95
+ const { customerName } = checkout, checkoutSessionInput = __rest(checkout, ["customerName"]);
96
+ const surfaceAnalyticsMetadata = useMemo(() => buildStripeSubscriptionWalletSurfaceAnalyticsMetadata(checkout.analyticsMetadata, normalizedSurfaceId), [checkout.analyticsMetadata, normalizedSurfaceId]);
97
+ const session = useStripeSubscriptionCheckoutSession(Object.assign(Object.assign({}, checkoutSessionInput), { analyticsMetadata: surfaceAnalyticsMetadata }));
98
+ const surfaceCheckoutAnalytics = useMemo(() => buildStripeSubscriptionWalletSurfaceCheckoutAnalytics(checkoutAnalytics, normalizedSurfaceId), [checkoutAnalytics, normalizedSurfaceId]);
99
+ const [availabilityState, setAvailabilityState] = useState({
100
+ intentKey: session.intentKey,
101
+ methods: {},
102
+ });
103
+ const availability = buildStripeSubscriptionWalletSurfaceAvailability(walletPaymentMethods, getStripeSubscriptionWalletSurfaceMethodAvailability(availabilityState, session.intentKey));
104
+ const availabilitySignature = buildAvailabilitySignature(availability);
105
+ const reportedAvailabilitySignatureRef = useRef(null);
106
+ const errorStateRef = useRef({
107
+ methodMessages: {},
108
+ surfaceMessage: null,
109
+ });
110
+ const emitError = useCallback((message, paymentMethod) => {
111
+ const emission = resolveStripeSubscriptionWalletSurfaceError({
112
+ errorState: errorStateRef.current,
113
+ message,
114
+ paymentMethod,
115
+ surfaceId: normalizedSurfaceId,
116
+ });
117
+ if (!emission) {
118
+ return;
119
+ }
120
+ errorStateRef.current = emission.errorState;
121
+ onError === null || onError === void 0 ? void 0 : onError(emission.message, emission.context);
122
+ }, [normalizedSurfaceId, onError]);
123
+ useEffect(() => {
124
+ if (reportedAvailabilitySignatureRef.current === availabilitySignature) {
125
+ return;
126
+ }
127
+ reportedAvailabilitySignatureRef.current = availabilitySignature;
128
+ onAvailabilityChange === null || onAvailabilityChange === void 0 ? void 0 : onAvailabilityChange(availability);
129
+ }, [availability, availabilitySignature, onAvailabilityChange]);
130
+ useEffect(() => {
131
+ emitError(session.error);
132
+ }, [emitError, session.error]);
133
+ const renderWalletMethod = (method) => {
134
+ var _a;
135
+ const slotProps = {
136
+ amountCents,
137
+ appearance,
138
+ beforeConfirm,
139
+ checkoutAnalytics: surfaceCheckoutAnalytics,
140
+ className: (_a = resolveMethodClassName === null || resolveMethodClassName === void 0 ? void 0 : resolveMethodClassName(method)) !== null && _a !== void 0 ? _a : className,
141
+ customerEmail: checkout.customerEmail,
142
+ customerName,
143
+ disabled,
144
+ onAvailabilityChange: (available) => setAvailabilityState((current) => applyStripeSubscriptionWalletSurfaceMethodAvailability(current, session.intentKey, method, available)),
145
+ onCancel,
146
+ onError: (message) => emitError(message, method),
147
+ onPaymentInfoSubmitted,
148
+ onSuccess,
149
+ onUnavailableClick,
150
+ returnUrl: checkout.returnUrl,
151
+ session,
152
+ slotClassName,
153
+ summaryLabel,
154
+ };
155
+ if (method === 'applePay') {
156
+ return (_jsx(ApplePaySubscriptionCheckoutSlot, Object.assign({}, slotProps, { options: applePayOptions, placeholderLabel: applePayPlaceholderLabel })));
157
+ }
158
+ if (method === 'googlePay') {
159
+ return (_jsx(GooglePaySubscriptionCheckoutSlot, Object.assign({}, slotProps, { options: googlePayOptions, placeholderLabel: googlePayPlaceholderLabel })));
160
+ }
161
+ return null;
162
+ };
163
+ const visibleWalletPaymentMethods = getStripeSubscriptionWalletSurfaceVisibleMethods(walletPaymentMethods, availability.methods);
164
+ const shouldRenderSurface = shouldRenderStripeSubscriptionWalletSurface({
165
+ anyAvailable: availability.anyAvailable,
166
+ configured: session.configured,
167
+ paymentMethodCount: walletPaymentMethods.length,
168
+ resolved: availability.resolved,
169
+ suspended,
170
+ });
171
+ if (!shouldRenderSurface) {
172
+ return null;
173
+ }
174
+ return (_jsxs("div", { className: [
175
+ 'stripe-subscription-wallet-surface',
176
+ containerClassName !== null && containerClassName !== void 0 ? containerClassName : '',
177
+ ]
178
+ .filter(Boolean)
179
+ .join(' '), "data-wallet-surface-id": normalizedSurfaceId, children: [(_a = renderHeader === null || renderHeader === void 0 ? void 0 : renderHeader({ availability })) !== null && _a !== void 0 ? _a : null, visibleWalletPaymentMethods.map((method) => {
180
+ var _a;
181
+ return (_jsx("div", { className: [
182
+ 'stripe-subscription-wallet-surface__method',
183
+ (_a = resolveMethodWrapperClassName === null || resolveMethodWrapperClassName === void 0 ? void 0 : resolveMethodWrapperClassName(method)) !== null && _a !== void 0 ? _a : '',
184
+ ]
185
+ .filter(Boolean)
186
+ .join(' '), "data-wallet-payment-method": method, children: renderWalletMethod(method) }, method));
187
+ })] }));
188
+ }
@@ -50,5 +50,10 @@ export type WalletSubscriptionCheckoutSlotProps = {
50
50
  suspended?: boolean;
51
51
  };
52
52
  export declare function WalletSubscriptionCheckoutLoadingPlaceholder({ className, label, }: Pick<WalletPlaceholderButtonProps, 'className' | 'label'>): import("react/jsx-runtime").JSX.Element;
53
+ /**
54
+ * @deprecated Prefer StripeSubscriptionWalletSurface for visible wallet placements. This slot stays
55
+ * exported and runtime-compatible as an advanced low-level primitive; its checkout session must
56
+ * never be shared across placements.
57
+ */
53
58
  export declare function WalletSubscriptionCheckoutSlot({ amountCents, appearance, availabilityPaymentMethod, beforeConfirm, checkoutAnalytics, className, customerEmail, customerName, disabled, expressCheckoutAllowed, onAvailabilityChange, onCancel, onError, onPaymentInfoSubmitted, onSuccess, onUnavailableClick, options, placeholderLabel, renderPreparingPlaceholder, renderPlaceholder, returnUrl, session, slotClassName, summaryLabel, suspended, }: WalletSubscriptionCheckoutSlotProps): import("react/jsx-runtime").JSX.Element;
54
59
  export {};
@@ -29,6 +29,11 @@ export function WalletSubscriptionCheckoutLoadingPlaceholder({ className, label,
29
29
  .filter(Boolean)
30
30
  .join(' '), "aria-label": label, role: 'status', children: [_jsx("span", { className: 'wallet-subscription-checkout-slot__loading-bar' }), _jsx("style", { children: walletSubscriptionCheckoutLoadingPlaceholderStyles })] }));
31
31
  }
32
+ /**
33
+ * @deprecated Prefer StripeSubscriptionWalletSurface for visible wallet placements. This slot stays
34
+ * exported and runtime-compatible as an advanced low-level primitive; its checkout session must
35
+ * never be shared across placements.
36
+ */
32
37
  export function WalletSubscriptionCheckoutSlot({ amountCents, appearance, availabilityPaymentMethod, beforeConfirm, checkoutAnalytics, className, customerEmail, customerName, disabled = false, expressCheckoutAllowed = true, onAvailabilityChange, onCancel, onError, onPaymentInfoSubmitted, onSuccess, onUnavailableClick, options, placeholderLabel, renderPreparingPlaceholder, renderPlaceholder, returnUrl, session, slotClassName, summaryLabel, suspended = false, }) {
33
38
  const [walletAvailability, setWalletAvailability] = useState({
34
39
  available: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/payments",
3
- "version": "0.1.56",
3
+ "version": "0.1.57",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",