@funnelsgrove/payments 0.42.0 → 0.44.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 CHANGED
@@ -95,6 +95,20 @@ hooks; wallet surfaces accept it through their `checkout` input. Stripe clients
95
95
  cached by publishable key and locale so changing language cannot reuse another
96
96
  language's client. Locale does not change a plan, currency or billing interval.
97
97
 
98
+ For Solidgate, pass `language: 'es'` to `prepareSolidgateCheckout`, or inside
99
+ `SolidgateCheckoutDialog.request`, to use Spanish for the provider form:
100
+
101
+ ```ts
102
+ const checkout = await prepareSolidgateCheckout({ ...checkoutRequest, language: 'es' });
103
+ ```
104
+
105
+ Use a [supported Solidgate language tag](https://docs.solidgate.com/payments/integrate/payment-form/form-insights/implementation-tips/#supported-translations).
106
+ Map regional funnel locales explicitly (for example, `es-ES` to `es`); the API rejects
107
+ unsupported tags. Omitted/null language preserves browser selection. The dialog
108
+ captures language when preparing the attempt; close and reopen it to adopt a change.
109
+ Funnel-owned dialog text still comes from `content` and `presentation`.
110
+ See the [checkout language contract](../../docs/product-specs/billing.md#solidgate-checkout-language).
111
+
98
112
  `ManageSubscriptionContent` exported by this package extends the runtime content
99
113
  with optional `labels: ManageSubscriptionLabels`. A localized funnel should make
100
114
  `labels` required in its own content type and provide the complete English and
@@ -1 +1 @@
1
- export declare const PAYMENTS_PACKAGE_VERSION = "0.42.0";
1
+ export declare const PAYMENTS_PACKAGE_VERSION = "0.44.0";
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/generate-package-version.mjs.
2
- export const PAYMENTS_PACKAGE_VERSION = "0.42.0";
2
+ export const PAYMENTS_PACKAGE_VERSION = "0.44.0";
@@ -106,7 +106,7 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
106
106
  setCommittedEmail(normalizedCustomerEmail);
107
107
  setEmailError(null);
108
108
  }, [customerEmail, normalizedCustomerEmail]);
109
- const { discountKeyOrProviderId, failUrl, funnelPlanKey, paymentProfileId, providerPlanId, checkoutType, environment, funnelEndUserId, funnelId, idempotencyKey, offerSetId, returnUrl, runtimeConfig, successUrl, } = request;
109
+ const { discountKeyOrProviderId, failUrl, funnelPlanKey, paymentProfileId, providerPlanId, checkoutType, environment, language, funnelEndUserId, funnelId, idempotencyKey, offerSetId, returnUrl, runtimeConfig, successUrl, } = request;
110
110
  const checkoutKey = (retryRequest === null || retryRequest === void 0 ? void 0 : retryRequest.originalKey) === idempotencyKey
111
111
  ? retryRequest.key : idempotencyKey;
112
112
  const retryAttemptId = (retryRequest === null || retryRequest === void 0 ? void 0 : retryRequest.originalKey) === idempotencyKey ? retryRequest.attemptId : request.retryAttemptId;
@@ -121,6 +121,7 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
121
121
  providerPlanId: (providerPlanId === null || providerPlanId === void 0 ? void 0 : providerPlanId.trim()) || null,
122
122
  checkoutType: checkoutType || null,
123
123
  environment: environment || null,
124
+ language,
124
125
  idempotencyKey: checkoutKey.trim(),
125
126
  retryAttemptId,
126
127
  discountKeyOrProviderId: (discountKeyOrProviderId === null || discountKeyOrProviderId === void 0 ? void 0 : discountKeyOrProviderId.trim()) || null,
@@ -143,6 +144,7 @@ export function SolidgateCheckoutDialog({ open, layout = 'dialog', request, cust
143
144
  providerPlanId,
144
145
  checkoutType,
145
146
  environment,
147
+ language,
146
148
  funnelEndUserId,
147
149
  funnelId,
148
150
  funnelSdkPublishableKey,
@@ -34,6 +34,8 @@ export type PrepareSolidgateCheckoutInput = {
34
34
  providerPlanId?: string | null;
35
35
  checkoutType?: 'subscription' | 'one_time' | null;
36
36
  environment?: 'test' | 'live' | null;
37
+ /** Solidgate form language tag (for example, 'es'); omitted/null uses browser language. */
38
+ language?: string | null;
37
39
  idempotencyKey: string;
38
40
  retryAttemptId?: string | null;
39
41
  discountKeyOrProviderId?: string | null;
@@ -129,8 +129,8 @@ export const prepareSolidgateCheckout = async (input) => {
129
129
  if (!paymentProfileId || !providerPlanId || !checkoutType || !environment) {
130
130
  throw new Error('Solidgate V2 checkout selection is incomplete');
131
131
  }
132
- const result = parsePreparation(await postJson('/sdk/public/v2/payments/checkout-sessions', Object.assign(Object.assign({ checkoutType, uiMode: 'custom', environment,
133
- paymentProfileId, provider: 'solidgate', providerPlanId, planKey: requiredString(input.funnelPlanKey, 'funnelPlanKey'), funnelId: resolveFunnelId(input.funnelId, input.runtimeConfig), funnelEndUserId: requiredString(input.funnelEndUserId, 'funnelEndUserId'), offerSetId: requiredString(input.offerSetId, 'offerSetId'), idempotencyKey: requiredString(input.idempotencyKey, 'idempotencyKey') }, (input.retryAttemptId ? { retryAttemptId: input.retryAttemptId } : {})), { couponId: ((_c = input.discountKeyOrProviderId) === null || _c === void 0 ? void 0 : _c.trim()) || null, returnUrl: paywallCheckoutReturnUrl(requiredString(input.returnUrl, 'returnUrl'), 'solidgate'), successUrl: paywallCheckoutReturnUrl(requiredString(input.successUrl, 'successUrl'), 'solidgate'), failUrl: paywallCheckoutReturnUrl(requiredString(input.failUrl, 'failUrl'), 'solidgate', true) }), input.runtimeConfig, input.signal));
132
+ const result = parsePreparation(await postJson('/sdk/public/v2/payments/checkout-sessions', Object.assign(Object.assign(Object.assign({ checkoutType, uiMode: 'custom', environment,
133
+ paymentProfileId, provider: 'solidgate', providerPlanId, planKey: requiredString(input.funnelPlanKey, 'funnelPlanKey'), funnelId: resolveFunnelId(input.funnelId, input.runtimeConfig), funnelEndUserId: requiredString(input.funnelEndUserId, 'funnelEndUserId'), offerSetId: requiredString(input.offerSetId, 'offerSetId'), idempotencyKey: requiredString(input.idempotencyKey, 'idempotencyKey') }, (input.language != null ? { language: input.language } : {})), (input.retryAttemptId ? { retryAttemptId: input.retryAttemptId } : {})), { couponId: ((_c = input.discountKeyOrProviderId) === null || _c === void 0 ? void 0 : _c.trim()) || null, returnUrl: paywallCheckoutReturnUrl(requiredString(input.returnUrl, 'returnUrl'), 'solidgate'), successUrl: paywallCheckoutReturnUrl(requiredString(input.successUrl, 'successUrl'), 'solidgate'), failUrl: paywallCheckoutReturnUrl(requiredString(input.failUrl, 'failUrl'), 'solidgate', true) }), input.runtimeConfig, input.signal));
134
134
  retainPaywallCheckout('solidgate', result.attemptId);
135
135
  return result;
136
136
  };
@@ -34,5 +34,7 @@ export type StripeWalletFirstCheckoutProps = {
34
34
  stripePromise: Promise<Stripe | null> | null;
35
35
  summaryLabel: string;
36
36
  themeColor: string;
37
+ /** The method selected on mount; defaults to the platform wallet. */
38
+ initialMethod?: 'wallet' | 'card';
37
39
  };
38
40
  export declare function StripeWalletFirstCheckout(props: StripeWalletFirstCheckoutProps): import("react/jsx-runtime").JSX.Element;
@@ -10,6 +10,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
10
10
  * bar at the exact button height until Stripe's button replaces it, so nothing
11
11
  * moves. Where the wallet cannot pay, the same slot explains that. The card
12
12
  * form has no email, ZIP or terms text: the session carries the email.
13
+ * `initialMethod: 'card'` opens the card form first, e.g. for a bottom-of-page
14
+ * "complete your order" block; the wallet stays one tap away.
13
15
  *
14
16
  * The caller owns the subscription Checkout Session (`clientSecret`), the copy
15
17
  * and what happens after `onSuccess`.
@@ -34,9 +36,17 @@ const appearance = {
34
36
  },
35
37
  };
36
38
  export function StripeWalletFirstCheckout(props) {
37
- const { buttonColor, checkoutAnalytics, checkoutSessionId, clientSecret, copy, stripePromise, themeColor } = props;
39
+ const { buttonColor, checkoutAnalytics, checkoutSessionId, clientSecret, copy, initialMethod = 'wallet', stripePromise, themeColor } = props;
38
40
  const wallet = usePlatformWallet();
39
- const [selected, setSelected] = useState('wallet');
41
+ const [selected, setSelected] = useState(initialMethod);
42
+ // A card form that is open on mount has not been opened by the visitor yet.
43
+ const [cardEngaged, setCardEngaged] = useState(initialMethod !== 'card');
44
+ const select = (method) => {
45
+ if (method === 'card')
46
+ setCardEngaged(true);
47
+ setSelected(method);
48
+ };
49
+ const engageCard = () => setCardEngaged(true);
40
50
  const style = { '--wfc-theme': themeColor, '--wfc-button': buttonColor };
41
51
  const options = useMemo(() => clientSecret ? {
42
52
  clientSecret,
@@ -47,15 +57,16 @@ export function StripeWalletFirstCheckout(props) {
47
57
  if (checkoutAnalytics)
48
58
  trackStripeCheckoutShown(Object.assign(Object.assign({}, checkoutAnalytics), { checkoutSessionId, checkoutSurface: 'inline' }));
49
59
  });
50
- // Session creation is preparation; the card checkout starts when the visitor opens the card form.
60
+ // Session creation is preparation; the card checkout starts when the visitor opens the card form,
61
+ // or, when it opens preselected, on their first input into it.
51
62
  useEffect(() => {
52
- if (!checkoutAnalytics || !clientSecret || selected !== 'card')
63
+ if (!checkoutAnalytics || !clientSecret || selected !== 'card' || !cardEngaged)
53
64
  return;
54
65
  queueStripeSubscriptionCheckoutStarted(Object.assign(Object.assign({}, checkoutAnalytics), { checkoutSessionId, checkoutStartSource: 'card_form_open', paymentMethod: 'card' }));
55
- }, [checkoutAnalytics, checkoutSessionId, clientSecret, selected]);
56
- return (_jsxs(_Fragment, { children: [options && stripePromise ? (_jsx(CheckoutProvider, { stripe: stripePromise, options: options, children: _jsx(StripeWalletFirstCheckoutForm, Object.assign({}, props, { wallet: wallet, selected: selected, onSelect: setSelected, style: style })) }, options.clientSecret)) : (_jsx(CheckoutLayout, { copy: copy, wallet: wallet, selected: selected, onSelect: setSelected, disabled: false, style: style, walletSlot: _jsx("span", { className: 'wfc-progress', role: 'status', "aria-label": copy.processingLabel }), cardBody: _jsx("span", { className: 'wfc-progress wfc-progress--form', "aria-hidden": 'true' }) })), _jsx("style", { children: stripeWalletFirstCheckoutStyles })] }));
66
+ }, [checkoutAnalytics, checkoutSessionId, clientSecret, selected, cardEngaged]);
67
+ return (_jsxs(_Fragment, { children: [options && stripePromise ? (_jsx(CheckoutProvider, { stripe: stripePromise, options: options, children: _jsx(StripeWalletFirstCheckoutForm, Object.assign({}, props, { wallet: wallet, selected: selected, onSelect: select, onCardEngaged: engageCard, style: style })) }, options.clientSecret)) : (_jsx(CheckoutLayout, { copy: copy, wallet: wallet, selected: selected, onSelect: select, disabled: false, style: style, walletSlot: _jsx("span", { className: 'wfc-progress', role: 'status', "aria-label": copy.processingLabel }), cardBody: _jsx("span", { className: 'wfc-progress wfc-progress--form', "aria-hidden": 'true' }) })), _jsx("style", { children: stripeWalletFirstCheckoutStyles })] }));
57
68
  }
58
- function StripeWalletFirstCheckoutForm({ amountCents, checkoutAnalytics, checkoutSessionId, copy, customerEmail, customerName, onCancel, onError, onSuccess, returnUrl, summaryLabel, wallet, selected, onSelect, style, }) {
69
+ function StripeWalletFirstCheckoutForm({ amountCents, checkoutAnalytics, checkoutSessionId, copy, customerEmail, customerName, onCancel, onError, onSuccess, returnUrl, summaryLabel, wallet, selected, onSelect, onCardEngaged, style, }) {
59
70
  const checkoutState = useCheckout();
60
71
  // null until Stripe answers; the slot shows progress at the button's height meanwhile.
61
72
  const [walletAvailable, setWalletAvailable] = useState(null);
@@ -167,7 +178,8 @@ function StripeWalletFirstCheckoutForm({ amountCents, checkoutAnalytics, checkou
167
178
  // where the customer paid, until the success screen takes over.
168
179
  const paymentStatus = completed ? copy.paymentConfirmed : providerConfirmed ? copy.verifyingPayment : null;
169
180
  const locked = Boolean(paymentStatus) && !error;
170
- return (_jsx(CheckoutLayout, { copy: copy, wallet: wallet, selected: selected, onSelect: onSelect, disabled: submitting || walletConfirming || locked, style: style, walletNote: selected === 'wallet' ? paymentStatus : null, walletSlot: _jsxs(_Fragment, { children: [_jsx("div", { className: 'wfc-wallet-button', "data-ready": walletAvailable === true, children: _jsx(StripeCheckoutExpressCheckoutButton, { amountCents: amountCents, availabilityPaymentMethods: [wallet], beforeConfirm: async () => { setWalletConfirming(true); return customerEmail || null; }, checkoutAnalytics: checkoutAnalytics, checkoutSessionId: checkoutSessionId, confirmEmail: false, customerEmail: customerEmail, customerName: customerName, onAvailabilityChange: setWalletAvailable, onCancel: () => { setWalletConfirming(false); onCancel === null || onCancel === void 0 ? void 0 : onCancel(); }, onEmbeddedComplete: () => setCompleted(true), onError: message => { setWalletConfirming(false); showError(message, undefined, true); }, onPaymentRejected: () => { setWalletConfirming(false); onSelect('card'); }, onSuccess: () => trackSuccess(), onVerificationPending: () => setProviderConfirmed(true), options: expressOptions, returnUrl: returnUrl, summaryLabel: summaryLabel }) }), walletAvailable === null ? _jsx("span", { className: 'wfc-progress wfc-progress--overlay', role: 'status', "aria-label": copy.processingLabel }) : null, walletAvailable === false ? _jsx("p", { className: 'wfc-wallet-unavailable', role: 'status', children: copy.walletUnavailableNote.replace('{wallet}', copy.walletLabels[wallet]) }) : null] }), cardBody: _jsxs("form", { className: 'wfc-card-form', onSubmit: event => void submitCard(event), children: [_jsx(PaymentElement, { options: paymentElementOptions, onChange: event => setPaymentElementComplete(event.complete), onReady: () => setPaymentElementReady(true) }), _jsx("button", { type: 'submit', className: 'wfc-submit', disabled: locked || submitting || !paymentElementReady, "aria-live": 'polite', children: locked && paymentStatus ? paymentStatus : submitting ? copy.processingLabel : copy.cardSubmitLabel }), _jsx("p", { className: 'wfc-secure', children: copy.secureNote })] }), footer: error ? _jsx("p", { className: 'wfc-error', role: 'alert', children: error }) : null }));
181
+ return (_jsx(CheckoutLayout, { copy: copy, wallet: wallet, selected: selected, onSelect: onSelect, disabled: submitting || walletConfirming || locked, style: style, walletNote: selected === 'wallet' ? paymentStatus : null, walletSlot: _jsxs(_Fragment, { children: [_jsx("div", { className: 'wfc-wallet-button', "data-ready": walletAvailable === true, children: _jsx(StripeCheckoutExpressCheckoutButton, { amountCents: amountCents, availabilityPaymentMethods: [wallet], beforeConfirm: async () => { setWalletConfirming(true); return customerEmail || null; }, checkoutAnalytics: checkoutAnalytics, checkoutSessionId: checkoutSessionId, confirmEmail: false, customerEmail: customerEmail, customerName: customerName, onAvailabilityChange: setWalletAvailable, onCancel: () => { setWalletConfirming(false); onCancel === null || onCancel === void 0 ? void 0 : onCancel(); }, onEmbeddedComplete: () => setCompleted(true), onError: message => { setWalletConfirming(false); showError(message, undefined, true); }, onPaymentRejected: () => { setWalletConfirming(false); onSelect('card'); }, onSuccess: () => trackSuccess(), onVerificationPending: () => setProviderConfirmed(true), options: expressOptions, returnUrl: returnUrl, summaryLabel: summaryLabel }) }), walletAvailable === null ? _jsx("span", { className: 'wfc-progress wfc-progress--overlay', role: 'status', "aria-label": copy.processingLabel }) : null, walletAvailable === false ? _jsx("p", { className: 'wfc-wallet-unavailable', role: 'status', children: copy.walletUnavailableNote.replace('{wallet}', copy.walletLabels[wallet]) }) : null] }), cardBody: _jsxs("form", { className: 'wfc-card-form', onSubmit: event => void submitCard(event), children: [_jsx(PaymentElement, { options: paymentElementOptions, onChange: event => { setPaymentElementComplete(event.complete); if (!event.empty)
182
+ onCardEngaged(); }, onReady: () => setPaymentElementReady(true) }), _jsx("button", { type: 'submit', className: 'wfc-submit', disabled: locked || submitting || !paymentElementReady, "aria-live": 'polite', children: locked && paymentStatus ? paymentStatus : submitting ? copy.processingLabel : copy.cardSubmitLabel }), _jsx("p", { className: 'wfc-secure', children: copy.secureNote })] }), footer: error ? _jsx("p", { className: 'wfc-error', role: 'alert', children: error }) : null }));
171
183
  }
172
184
  /** Shared by the loading and live states so switching between them moves nothing. */
173
185
  function CheckoutLayout({ cardBody, copy, disabled, footer, onSelect, selected, style, wallet, walletNote, walletSlot }) {
@@ -63,7 +63,9 @@ export declare const buildDiscountedPaywallPlans: (input: {
63
63
  }) => PaywallDisplayPlan[];
64
64
  export declare const getPaywallPromoDisplayName: (referenceMs: number) => string;
65
65
  export declare const buildPaywallRenewalDisclaimer: (input: {
66
- plan: Pick<PaywallPlan, "priceLabel" | "billingInterval" | "billingIntervalCount">;
66
+ plan: Pick<PaywallPlan, "priceLabel" | "billingInterval" | "billingIntervalCount" | "followUpPriceLabel" | "followUpBillingInterval" | "followUpBillingIntervalCount">;
67
67
  hasActiveDiscount: boolean;
68
68
  productName?: string;
69
69
  }) => string;
70
+ /** A plan with a follow-up price renews at that price, not at its intro price. */
71
+ export declare const getPaywallRenewalTerms: (plan: Pick<PaywallPlan, "priceLabel" | "billingInterval" | "billingIntervalCount" | "followUpPriceLabel" | "followUpBillingInterval" | "followUpBillingIntervalCount">) => Pick<PaywallPlan, "priceLabel" | "billingInterval" | "billingIntervalCount">;
@@ -314,5 +314,14 @@ export const buildPaywallRenewalDisclaimer = (input) => {
314
314
  var _a;
315
315
  const introLabel = input.hasActiveDiscount ? 'discounted intro plan' : 'selected plan';
316
316
  const productPrefix = ((_a = input.productName) === null || _a === void 0 ? void 0 : _a.trim()) ? `${input.productName.trim()} ` : '';
317
- return `Without cancellation, before the ${introLabel} ends, I accept that ${productPrefix}will automatically charge ${input.plan.priceLabel} ${formatRecurringCadence(input.plan)} until I cancel. Cancel online via the profile on the website or app.`;
317
+ const renewal = getPaywallRenewalTerms(input.plan);
318
+ return `Without cancellation, before the ${introLabel} ends, I accept that ${productPrefix}will automatically charge ${renewal.priceLabel} ${formatRecurringCadence(renewal)} until I cancel. Cancel online via the profile on the website or app.`;
318
319
  };
320
+ /** A plan with a follow-up price renews at that price, not at its intro price. */
321
+ export const getPaywallRenewalTerms = (plan) => (plan.followUpPriceLabel
322
+ ? {
323
+ priceLabel: plan.followUpPriceLabel,
324
+ billingInterval: plan.followUpBillingInterval,
325
+ billingIntervalCount: plan.followUpBillingIntervalCount,
326
+ }
327
+ : plan);
@@ -27,6 +27,8 @@ export type PaywallPlan = {
27
27
  followUpPlanTitle?: string;
28
28
  followUpBillingInterval?: BillingPlanInterval;
29
29
  followUpBillingIntervalCount?: number;
30
+ /** Renewal amount of the follow-up price, shown in the auto-renewal disclaimer. */
31
+ followUpPriceLabel?: string;
30
32
  introIterations?: number;
31
33
  source: 'stripe' | 'config';
32
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/payments",
3
- "version": "0.42.0",
3
+ "version": "0.44.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",
@@ -46,11 +46,11 @@
46
46
  "jsdom": "20.0.3",
47
47
  "typescript": "^5",
48
48
  "vitest": "^3.2.4",
49
- "@funnelsgrove/runtime": "0.33.0",
50
- "@funnelsgrove/analytics": "0.15.0"
49
+ "@funnelsgrove/runtime": "0.34.0",
50
+ "@funnelsgrove/analytics": "0.16.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@funnelsgrove/runtime": "^0.33.0",
54
- "@funnelsgrove/analytics": "^0.15.0"
53
+ "@funnelsgrove/runtime": "^0.34.0",
54
+ "@funnelsgrove/analytics": "^0.16.0"
55
55
  }
56
56
  }