@funnelsgrove/payments 0.1.38 → 0.1.39
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 +2 -1
- package/dist/components/shared/StripeCheckoutExpressCheckoutButton.d.ts +2 -1
- package/dist/components/shared/StripeCheckoutExpressCheckoutButton.js +3 -2
- package/dist/components/shared/StripeExpressCheckoutButton.d.ts +2 -1
- package/dist/components/shared/StripeExpressCheckoutButton.js +2 -2
- package/dist/providers/stripe/WalletSubscriptionCheckoutSlot.d.ts +2 -1
- package/dist/providers/stripe/WalletSubscriptionCheckoutSlot.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ Detailed implementation docs:
|
|
|
47
47
|
- `src/providers/stripe/useStripeSubscriptionCheckoutSession.ts` for Stripe SDK initialization, publishable-key resolution, subscription client-secret preparation, card/wallet loading state, and friendly checkout errors
|
|
48
48
|
- `src/providers/stripe/ApplePaySubscriptionCheckoutSlot.tsx` and `src/providers/stripe/GooglePaySubscriptionCheckoutSlot.tsx` for wallet shells that prepare Stripe Express Checkout on load, keep the loading placeholder clickable, and let Stripe's real wallet controls sit above the placeholder as soon as they mount
|
|
49
49
|
- Stripe subscription checkout sessions reuse the active client secret across card checkout and paywall wallet checkout for the same intent key, so opening the embedded checkout after a paywall wallet button is ready does not create a second subscription session.
|
|
50
|
+
- `trackPaidStripeSubscriptionCheckoutCompleted` verifies a Stripe custom Checkout Session is paid before delegating to `@funnelsgrove/analytics` for the canonical `checkout_completed` purchase event.
|
|
50
51
|
- Stripe Express Checkout elements must stay mounted and measurable until Stripe reports availability; only hide the container after `onReady` or `onLoadError` reports that the requested wallet method is unavailable.
|
|
51
52
|
- Shared checkout dialogs must switch to card checkout when Stripe reports no requested wallet availability, so an unavailable Apple Pay or Google Pay shell never leaves a fake wallet tab blocking the card form.
|
|
52
53
|
- Wallet slots should not leave disabled grey placeholder shells blocking the paywall. While availability is unknown, the placeholder can sit behind Stripe's real wallet element; after Stripe reports unavailable or preparation cannot create a client secret, the placeholder must disappear instead of opening a card checkout under wallet branding.
|
|
@@ -62,7 +63,7 @@ Detailed implementation docs:
|
|
|
62
63
|
## What Does Not Belong Here
|
|
63
64
|
|
|
64
65
|
- funnel routing
|
|
65
|
-
- funnel analytics
|
|
66
|
+
- funnel-owned analytics event definitions outside the shared checkout completion handoff
|
|
66
67
|
- funnel-owned step layout outside the shared checkout shell
|
|
67
68
|
- funnel-owned billing catalog entries
|
|
68
69
|
- funnel-specific decisions about when to activate or upgrade an offer
|
|
@@ -15,7 +15,8 @@ export type StripeCheckoutExpressCheckoutButtonProps = {
|
|
|
15
15
|
serverUpdateKey?: string | null;
|
|
16
16
|
onServerUpdate?: () => Promise<boolean>;
|
|
17
17
|
onAvailabilityChange?: (available: boolean) => void;
|
|
18
|
+
onCancel?: () => void;
|
|
18
19
|
onError?: (message: string | null) => void;
|
|
19
20
|
onSuccess?: () => void | Promise<void>;
|
|
20
21
|
};
|
|
21
|
-
export declare function StripeCheckoutExpressCheckoutButton({ beforeConfirm, returnUrl, confirmEmail, customerEmail, className, options, availabilityPaymentMethods, initialAvailable, keepInitialAvailableOnReady, serverUpdateKey, onServerUpdate, onAvailabilityChange, onError, onSuccess, }: StripeCheckoutExpressCheckoutButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function StripeCheckoutExpressCheckoutButton({ beforeConfirm, returnUrl, confirmEmail, customerEmail, className, options, availabilityPaymentMethods, initialAvailable, keepInitialAvailableOnReady, serverUpdateKey, onServerUpdate, onAvailabilityChange, onCancel, onError, onSuccess, }: StripeCheckoutExpressCheckoutButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { ExpressCheckoutElement, useCheckout, } from '@stripe/react-stripe-js/checkout';
|
|
5
|
+
const ExpressCheckoutElementWithCancel = ExpressCheckoutElement;
|
|
5
6
|
const buildDefaultOptions = () => ({
|
|
6
7
|
buttonHeight: 55,
|
|
7
8
|
buttonTheme: {
|
|
@@ -25,7 +26,7 @@ const buildDefaultOptions = () => ({
|
|
|
25
26
|
paypal: 'never',
|
|
26
27
|
},
|
|
27
28
|
});
|
|
28
|
-
export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, returnUrl, confirmEmail = true, customerEmail, className, options, availabilityPaymentMethods = ['applePay'], initialAvailable, keepInitialAvailableOnReady = false, serverUpdateKey, onServerUpdate, onAvailabilityChange, onError, onSuccess, }) {
|
|
29
|
+
export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, returnUrl, confirmEmail = true, customerEmail, className, options, availabilityPaymentMethods = ['applePay'], initialAvailable, keepInitialAvailableOnReady = false, serverUpdateKey, onServerUpdate, onAvailabilityChange, onCancel, onError, onSuccess, }) {
|
|
29
30
|
const checkoutState = useCheckout();
|
|
30
31
|
const appliedServerUpdateKeyRef = useRef('');
|
|
31
32
|
const serverUpdatePromiseRef = useRef(null);
|
|
@@ -143,7 +144,7 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, returnUrl,
|
|
|
143
144
|
effectiveWalletAvailable === false ? 'is-hidden' : '',
|
|
144
145
|
]
|
|
145
146
|
.filter(Boolean)
|
|
146
|
-
.join(' '), children: _jsx(
|
|
147
|
+
.join(' '), children: _jsx(ExpressCheckoutElementWithCancel, { options: resolvedOptions, onCancel: onCancel, onConfirm: (event) => void handleConfirm(event), onLoadError: ({ error }) => {
|
|
147
148
|
setWalletAvailable(false);
|
|
148
149
|
onAvailabilityChange === null || onAvailabilityChange === void 0 ? void 0 : onAvailabilityChange(false);
|
|
149
150
|
onError === null || onError === void 0 ? void 0 : onError(error.message || 'Unable to load wallet checkout.');
|
|
@@ -12,7 +12,8 @@ export type StripeExpressCheckoutButtonProps = {
|
|
|
12
12
|
initialAvailable?: boolean | null;
|
|
13
13
|
keepInitialAvailableOnReady?: boolean;
|
|
14
14
|
onAvailabilityChange?: (available: boolean) => void;
|
|
15
|
+
onCancel?: () => void;
|
|
15
16
|
onError?: (message: string | null) => void;
|
|
16
17
|
onSuccess?: () => void | Promise<void>;
|
|
17
18
|
};
|
|
18
|
-
export declare function StripeExpressCheckoutButton({ amountCents, beforeConfirm, summaryLabel, returnUrl, customerEmail, customerName, className, options, availabilityPaymentMethods, initialAvailable, keepInitialAvailableOnReady, onAvailabilityChange, onError, onSuccess, }: StripeExpressCheckoutButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function StripeExpressCheckoutButton({ amountCents, beforeConfirm, summaryLabel, returnUrl, customerEmail, customerName, className, options, availabilityPaymentMethods, initialAvailable, keepInitialAvailableOnReady, onAvailabilityChange, onCancel, onError, onSuccess, }: StripeExpressCheckoutButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -53,7 +53,7 @@ const buildDefaultOptions = (input) => {
|
|
|
53
53
|
const isSuccessfulIntentStatus = (status) => {
|
|
54
54
|
return status === 'succeeded' || status === 'processing' || status === 'requires_capture';
|
|
55
55
|
};
|
|
56
|
-
export function StripeExpressCheckoutButton({ amountCents, beforeConfirm, summaryLabel, returnUrl, customerEmail, customerName, className, options, availabilityPaymentMethods = ['applePay'], initialAvailable, keepInitialAvailableOnReady = false, onAvailabilityChange, onError, onSuccess, }) {
|
|
56
|
+
export function StripeExpressCheckoutButton({ amountCents, beforeConfirm, summaryLabel, returnUrl, customerEmail, customerName, className, options, availabilityPaymentMethods = ['applePay'], initialAvailable, keepInitialAvailableOnReady = false, onAvailabilityChange, onCancel, onError, onSuccess, }) {
|
|
57
57
|
const stripe = useStripe();
|
|
58
58
|
const elements = useElements();
|
|
59
59
|
const [walletAvailable, setWalletAvailable] = useState(initialAvailable !== null && initialAvailable !== void 0 ? initialAvailable : null);
|
|
@@ -139,7 +139,7 @@ export function StripeExpressCheckoutButton({ amountCents, beforeConfirm, summar
|
|
|
139
139
|
effectiveWalletAvailable === false ? 'is-hidden' : '',
|
|
140
140
|
]
|
|
141
141
|
.filter(Boolean)
|
|
142
|
-
.join(' '), children: _jsx(ExpressCheckoutElement, { options: resolvedOptions, onConfirm: (event) => void handleConfirm(event), onLoadError: ({ error }) => {
|
|
142
|
+
.join(' '), children: _jsx(ExpressCheckoutElement, { options: resolvedOptions, onCancel: onCancel, onConfirm: (event) => void handleConfirm(event), onLoadError: ({ error }) => {
|
|
143
143
|
setWalletAvailable(false);
|
|
144
144
|
onAvailabilityChange === null || onAvailabilityChange === void 0 ? void 0 : onAvailabilityChange(false);
|
|
145
145
|
onError === null || onError === void 0 ? void 0 : onError(error.message || 'Unable to load wallet checkout.');
|
|
@@ -31,6 +31,7 @@ export type WalletSubscriptionCheckoutSlotProps = {
|
|
|
31
31
|
disabled?: boolean;
|
|
32
32
|
expressCheckoutAllowed?: boolean;
|
|
33
33
|
onAvailabilityChange?: (available: boolean) => void;
|
|
34
|
+
onCancel?: () => void;
|
|
34
35
|
onError?: (message: string | null) => void;
|
|
35
36
|
onSuccess?: () => void | Promise<void>;
|
|
36
37
|
onUnavailableClick?: () => Promise<void> | void;
|
|
@@ -44,5 +45,5 @@ export type WalletSubscriptionCheckoutSlotProps = {
|
|
|
44
45
|
suspended?: boolean;
|
|
45
46
|
};
|
|
46
47
|
export declare function WalletSubscriptionCheckoutLoadingPlaceholder({ className, label, }: Pick<WalletPlaceholderButtonProps, 'className' | 'label'>): import("react/jsx-runtime").JSX.Element;
|
|
47
|
-
export declare function WalletSubscriptionCheckoutSlot({ amountCents, availabilityPaymentMethod, beforeConfirm, className, customerEmail, customerName, disabled, expressCheckoutAllowed, onAvailabilityChange, onError, onSuccess, onUnavailableClick, options, placeholderLabel, renderPreparingPlaceholder, renderPlaceholder, returnUrl, session, summaryLabel, suspended, }: WalletSubscriptionCheckoutSlotProps): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export declare function WalletSubscriptionCheckoutSlot({ amountCents, availabilityPaymentMethod, beforeConfirm, className, customerEmail, customerName, disabled, expressCheckoutAllowed, onAvailabilityChange, onCancel, onError, onSuccess, onUnavailableClick, options, placeholderLabel, renderPreparingPlaceholder, renderPlaceholder, returnUrl, session, summaryLabel, suspended, }: WalletSubscriptionCheckoutSlotProps): import("react/jsx-runtime").JSX.Element;
|
|
48
49
|
export {};
|
|
@@ -27,7 +27,7 @@ export function WalletSubscriptionCheckoutLoadingPlaceholder({ className, label,
|
|
|
27
27
|
.filter(Boolean)
|
|
28
28
|
.join(' '), "aria-label": label, role: 'status', children: [_jsx("span", { className: 'wallet-subscription-checkout-slot__loading-bar' }), _jsx("style", { children: walletSubscriptionCheckoutLoadingPlaceholderStyles })] }));
|
|
29
29
|
}
|
|
30
|
-
export function WalletSubscriptionCheckoutSlot({ amountCents, availabilityPaymentMethod, beforeConfirm, className, customerEmail, customerName, disabled = false, expressCheckoutAllowed = true, onAvailabilityChange, onError, onSuccess, onUnavailableClick, options, placeholderLabel, renderPreparingPlaceholder, renderPlaceholder, returnUrl, session, summaryLabel, suspended = false, }) {
|
|
30
|
+
export function WalletSubscriptionCheckoutSlot({ amountCents, availabilityPaymentMethod, beforeConfirm, className, customerEmail, customerName, disabled = false, expressCheckoutAllowed = true, onAvailabilityChange, onCancel, onError, onSuccess, onUnavailableClick, options, placeholderLabel, renderPreparingPlaceholder, renderPlaceholder, returnUrl, session, summaryLabel, suspended = false, }) {
|
|
31
31
|
const [walletAvailability, setWalletAvailability] = useState({
|
|
32
32
|
available: null,
|
|
33
33
|
intentKey: session.intentKey,
|
|
@@ -131,7 +131,7 @@ export function WalletSubscriptionCheckoutSlot({ amountCents, availabilityPaymen
|
|
|
131
131
|
.filter(Boolean)
|
|
132
132
|
.join(' '), "aria-busy": placeholderIsPreparing || undefined, children: [shouldRenderExpressCheckout &&
|
|
133
133
|
session.activeClientSecret &&
|
|
134
|
-
session.stripePromise ? (_jsx(StripeExpressCheckoutElement, { amountCents: amountCents, availabilityPaymentMethods: [availabilityPaymentMethod], beforeConfirm: beforeConfirm, className: className, clientSecret: session.activeClientSecret, customerEmail: customerEmail, customerName: customerName, onAvailabilityChange: handleAvailabilityChange, onError: handleError, onSuccess: onSuccess, options: options, returnUrl: returnUrl, serverUpdateKey: serverUpdateKey, stripePromise: session.stripePromise, summaryLabel: summaryLabel, onServerUpdate: session.updateCheckoutSessionPlan })) : null, shouldRenderPlaceholder ? (_jsx("div", { className: 'wallet-subscription-checkout-slot__placeholder', children: placeholderRenderer({
|
|
134
|
+
session.stripePromise ? (_jsx(StripeExpressCheckoutElement, { amountCents: amountCents, availabilityPaymentMethods: [availabilityPaymentMethod], beforeConfirm: beforeConfirm, className: className, clientSecret: session.activeClientSecret, customerEmail: customerEmail, customerName: customerName, onAvailabilityChange: handleAvailabilityChange, onCancel: onCancel, onError: handleError, onSuccess: onSuccess, options: options, returnUrl: returnUrl, serverUpdateKey: serverUpdateKey, stripePromise: session.stripePromise, summaryLabel: summaryLabel, onServerUpdate: session.updateCheckoutSessionPlan })) : null, shouldRenderPlaceholder ? (_jsx("div", { className: 'wallet-subscription-checkout-slot__placeholder', children: placeholderRenderer({
|
|
135
135
|
className,
|
|
136
136
|
disabled: slotDisabled,
|
|
137
137
|
label: placeholderLabel,
|