@solvapay/react 2.1.1 → 2.2.0-preview-e3e546693c002c32f128d83bf6c5fe76ac182a79

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/dist/index.d.cts CHANGED
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
- import { S as SolvaPayProviderProps, P as PaymentFormProps, a as PrefillCustomer, T as TopupFormProps, C as CheckoutResult, b as Plan, A as ActivationResult, c as SaveAutoRechargeResponse, d as PurchaseStatus, e as SolvaPayContextValue, U as UsePlansOptions, f as UsePlansReturn, g as UsePlanOptions, h as UsePlanReturn, i as UseProductReturn, j as UseMerchantReturn, k as SolvaPayCopy, l as PurchaseStatusReturn, m as CancelResult, R as ReactivateResult, n as ActivatePlanResult, o as UseTopupOptions, p as UseTopupReturn, B as BalanceStatus, q as UseTopupAmountSelectorOptions, r as UseTopupAmountSelectorReturn, s as UsePaymentMethodReturn, t as AutoRechargeConfig, u as SaveAutoRechargeInput, v as SolvaPayTransport, w as PartialSolvaPayCopy, x as PurchaseInfo, y as Product, z as SolvaPayConfig } from './shared-D0hmT1qU.cjs';
3
- export { D as BootstrapPlanLike, E as CheckoutStep, F as CustomerPurchaseData, M as MandateContext, G as MandateTemplate, H as Merchant, I as PaymentError, J as PaymentIntentResult, K as PaymentMethodInfo, L as PaymentResult, N as PurchaseStatusValue, O as SuccessMeta, Q as TopupPaymentResult, V as TransportBalanceResult, W as TransportCheckoutSessionResult, X as TransportCustomerSessionResult, Y as TransportLimitsResult, Z as UnsupportedTransportMethodError } from './shared-D0hmT1qU.cjs';
4
- import { P as PaymentFormSummary, a as PaymentFormCustomerFields, b as PaymentFormPaymentElement, c as PaymentFormCardElement, d as PaymentFormMandateText, e as PaymentFormTermsCheckbox, f as PaymentFormSubmitButton, g as PaymentFormLoading, h as PaymentFormError, i as PaymentFormLegalFooter, j as PaymentFormBusinessDetails, k as PaymentFormTaxSummary, A as AutoRechargeInputPayload, l as PaywallStructuredContent, C as CheckoutVariant } from './index-SylJb9Rh.cjs';
5
- export { m as ActivationFlowStep, B as BalanceBadge, n as CancelPlanButton, o as CheckoutErrorPhase, p as CheckoutStatus, q as CheckoutSteps, r as CheckoutSummary, s as CheckoutSummaryProps, M as MandateText, t as MandateTextProps, u as PlanBadge, v as ProductBadge, w as PurchaseGate, U as UsageSnapshot, x as UseCheckoutFlowOptions, y as UseCheckoutFlowReturn, z as UseUsageReturn, D as configToAutoRechargeInput, E as deriveVariant, F as useCheckoutFlow, G as useCheckoutStepsContext, H as useUsage } from './index-SylJb9Rh.cjs';
2
+ import { S as SolvaPayProviderProps, P as PaymentFormProps, a as PrefillCustomer, T as TopupFormProps, C as CheckoutResult, b as Plan, A as ActivationResult, B as BootstrapPlanLike, c as SaveAutoRechargeResponse, d as PurchaseStatus, e as SolvaPayContextValue, U as UsePlansOptions, f as UsePlansReturn, g as UsePlanOptions, h as UsePlanReturn, i as UseProductReturn, j as UseMerchantReturn, k as SolvaPayCopy, l as PurchaseStatusReturn, m as CancelResult, R as ReactivateResult, n as ActivatePlanResult, o as UseTopupOptions, p as UseTopupReturn, q as BalanceStatus, r as UseTopupAmountSelectorOptions, s as UseTopupAmountSelectorReturn, t as UsePaymentMethodReturn, u as AutoRechargeConfig, v as SaveAutoRechargeInput, w as SolvaPayTransport, x as PartialSolvaPayCopy, y as PurchaseInfo, z as Product, D as SolvaPayConfig } from './useUsage-CTgRBvFK.cjs';
3
+ export { E as CheckoutStep, F as CustomerPurchaseData, M as MandateContext, G as MandateTemplate, H as Merchant, I as PaymentError, J as PaymentIntentResult, K as PaymentMethodInfo, L as PaymentResult, N as PurchaseStatusValue, O as SuccessMeta, Q as TopupPaymentResult, V as TransportBalanceResult, W as TransportCheckoutSessionResult, X as TransportCustomerSessionResult, Y as TransportLimitsResult, Z as UnsupportedTransportMethodError, _ as UsageSnapshot, $ as UseUsageReturn, a0 as useUsage } from './useUsage-CTgRBvFK.cjs';
4
+ import { P as PaymentFormSummary, a as PaymentFormCustomerFields, b as PaymentFormPaymentElement, c as PaymentFormCardElement, d as PaymentFormMandateText, e as PaymentFormTermsCheckbox, f as PaymentFormSubmitButton, g as PaymentFormLoading, h as PaymentFormError, i as PaymentFormLegalFooter, j as PaymentFormBusinessDetails, k as PaymentFormTaxSummary, A as AutoRechargeInputPayload, l as PaywallStructuredContent, C as CheckoutVariant } from './index-BJGjKUtC.cjs';
5
+ export { m as ActivationFlowStep, B as BalanceBadge, n as CancelPlanButton, o as CheckoutErrorPhase, p as CheckoutStatus, q as CheckoutSteps, r as CheckoutSummary, s as CheckoutSummaryProps, M as MandateText, t as MandateTextProps, u as PlanBadge, v as ProductBadge, w as PurchaseGate, U as UseCheckoutFlowOptions, x as UseCheckoutFlowReturn, y as configToAutoRechargeInput, z as deriveVariant, D as useCheckoutFlow, E as useCheckoutStepsContext } from './index-BJGjKUtC.cjs';
6
6
  import { PaymentIntent, Stripe, StripeElements } from '@stripe/stripe-js';
7
7
  import { BusinessDetailsInput, TaxBreakdown } from '@solvapay/core';
8
+ import * as react_jsx_runtime from 'react/jsx-runtime';
8
9
  export { AuthAdapter, createAnonymousAuthAdapter, defaultAuthAdapter, getOrCreateAnonymousCustomerRef, resetAnonymousCustomerRef } from './adapters/auth.cjs';
9
10
  export { SessionAuthAdapterOptions, createSessionAuthAdapter } from './adapters/session-auth.cjs';
10
11
  import '@stripe/react-stripe-js';
11
- import 'react/jsx-runtime';
12
12
 
13
13
  /**
14
14
  * SolvaPay Provider - Headless Context Provider for React.
@@ -58,8 +58,8 @@ declare const SolvaPayProvider: React.FC<SolvaPayProviderProps>;
58
58
  *
59
59
  * Consumers who just want a drop-in payment form use this component. It
60
60
  * renders the primitive's Root with a golden-path default tree composed of
61
- * `PaymentForm.Summary`, `CustomerFields`, `PaymentElement`, `MandateText`,
62
- * an optional `TermsCheckbox`, and `SubmitButton`. Free-plan activation
61
+ * `PaymentForm.Summary`, `CustomerFields`, `PaymentElement`, an optional
62
+ * `TermsCheckbox`, `SubmitButton`, and `MandateText`. Free-plan activation
63
63
  * flows through the same composition — `FreeInner` in the primitive swaps
64
64
  * the submit handler so the default tree works identically for paid and
65
65
  * free plans.
@@ -305,6 +305,8 @@ interface CurrentPlanCardClassNames {
305
305
  usageMeter?: string;
306
306
  paymentMethod?: string;
307
307
  actions?: string;
308
+ /** Small muted caption above a value when `showFieldLabels` is set. */
309
+ fieldLabel?: string;
308
310
  /** Embedded pending-cancellation notice + reactivate CTA. */
309
311
  cancelledNotice?: string;
310
312
  }
@@ -351,6 +353,17 @@ interface CurrentPlanCardProps {
351
353
  * Hosted-page parity for the MCP account surface.
352
354
  */
353
355
  showReference?: boolean;
356
+ /**
357
+ * Caption the price/rate and balance values with a field label
358
+ * ("Rate", "Balance"). Default: `false`. Those lines are bare
359
+ * numbers otherwise, which read alike on a surface that shows both.
360
+ */
361
+ showFieldLabels?: boolean;
362
+ /**
363
+ * Live catalog plans. Used to format a PAYG usage rate when the
364
+ * frozen snapshot has no `options[]`.
365
+ */
366
+ plans?: readonly CatalogPlanLike[];
354
367
  /** Per-element classNames. */
355
368
  classNames?: CurrentPlanCardClassNames;
356
369
  /**
@@ -359,6 +372,20 @@ interface CurrentPlanCardProps {
359
372
  */
360
373
  className?: string;
361
374
  }
375
+ /**
376
+ * Structural catalog / snapshot subset `formatPaygRate` can read.
377
+ * Wider than `BootstrapPlanLike` so MCP `PlanLike` (which allows `null`
378
+ * on optional fields) is assignable without a cast.
379
+ */
380
+ interface CatalogPlanLike {
381
+ reference?: string | null;
382
+ name?: string;
383
+ options?: BootstrapPlanLike['options'] | null;
384
+ price?: number | null;
385
+ currency?: string | null;
386
+ requiresPayment?: boolean | null;
387
+ isMetered?: boolean | null;
388
+ }
362
389
  declare const CurrentPlanCard: React.FC<CurrentPlanCardProps>;
363
390
 
364
391
  type AutoRechargeProps = {
@@ -381,17 +408,18 @@ declare function AutoRecharge({ currency, defaultThresholdAmountMajor, defaultTo
381
408
  * Render-eager: the button is enabled and labelled from the first paint
382
409
  * regardless of session state. The portal session URL is fetched in the
383
410
  * background through `useCustomerSessionUrl()` (a single in-flight call
384
- * shared across every instance under the same transport). When the URL
385
- * is ready, click is a synchronous `<a target="_blank">` navigation —
386
- * which MCP host sandboxes permit even though scripted `window.open`
387
- * after an async round-trip is blocked.
388
- *
389
- * If the user clicks before the URL has resolved, the click handler
390
- * awaits the in-flight fetch and falls back to `window.open` (works on
391
- * hosts that don't sandbox scripted opens, e.g. ChatGPT). On Claude the
392
- * sandbox silently drops the open in that race; the cache-hit path
393
- * remains the optimal one and is the steady state for any user that
394
- * doesn't click within a few hundred ms of opening the surface.
411
+ * shared across every instance under the same transport).
412
+ *
413
+ * Opening the portal always goes through `useExternalLink`, which
414
+ * prefers the host's `ui/open-link` when one is mounted and otherwise
415
+ * lets the browser navigate. That distinction matters inside MCP hosts:
416
+ * Claude's iframe sandbox omits `allow-popups`, so both a bare
417
+ * `<a target="_blank">` and `window.open()` are dropped without an
418
+ * error — the button looks alive and does nothing.
419
+ *
420
+ * If the user clicks before the URL has resolved, the handler awaits
421
+ * the in-flight fetch and then opens the resolved URL through the same
422
+ * path, flipping to the error state if the open is refused.
395
423
  */
396
424
 
397
425
  interface LaunchCustomerPortalButtonProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'rel' | 'onError'> {
@@ -761,7 +789,7 @@ interface UseActivationReturn {
761
789
  activate: (params: {
762
790
  productRef: string;
763
791
  planRef: string;
764
- }) => Promise<void>;
792
+ }) => Promise<ActivationState>;
765
793
  state: ActivationState;
766
794
  error: string | null;
767
795
  result: ActivatePlanResult | null;
@@ -942,6 +970,16 @@ interface UseLimitsReturn {
942
970
  needsUpgrade: boolean | null;
943
971
  /** The customer was auto-upgraded and access was restored. `null` while loading. */
944
972
  upgraded: boolean | null;
973
+ /**
974
+ * Consumed units this period. `null` while loading, when disabled, or
975
+ * when the backend did not measure a finite cap.
976
+ */
977
+ used: number | null;
978
+ /**
979
+ * The effective finite cap for this meter. `null` while loading, when
980
+ * disabled, or when the backend did not measure a finite cap.
981
+ */
982
+ limit: number | null;
945
983
  loading: boolean;
946
984
  error: Error | null;
947
985
  refetch: () => Promise<void>;
@@ -1001,6 +1039,43 @@ interface UsePaywallResolverReturn {
1001
1039
  }
1002
1040
  declare function usePaywallResolver(content: PaywallStructuredContent): UsePaywallResolverReturn;
1003
1041
 
1042
+ interface ExternalLinkOpener {
1043
+ /**
1044
+ * Whether the host can open links right now. Read synchronously from
1045
+ * the click handler, because suppressing native navigation on a host
1046
+ * that *cannot* open links would turn a working link into a dead one
1047
+ * — so `preventDefault()` is gated on this returning `true`.
1048
+ */
1049
+ canOpen: () => boolean;
1050
+ /**
1051
+ * Hand `url` to the host. Resolves `false` when the host refused
1052
+ * (blocked domain, user cancelled) or the request failed, so callers
1053
+ * can surface the dead end instead of leaving the user guessing.
1054
+ */
1055
+ open: (url: string) => Promise<boolean>;
1056
+ }
1057
+ interface ExternalLinkProviderProps {
1058
+ opener: ExternalLinkOpener;
1059
+ children: React.ReactNode;
1060
+ }
1061
+ declare function ExternalLinkProvider({ opener, children }: ExternalLinkProviderProps): react_jsx_runtime.JSX.Element;
1062
+ /**
1063
+ * Imperative opener for flows that only learn the URL after an `await`,
1064
+ * where there is no anchor left to click (the portal button's
1065
+ * cache-miss path). Prefers the host, otherwise asks the browser.
1066
+ *
1067
+ * Resolves `false` only when a host-mediated open was attempted and
1068
+ * refused. The browser path reports `true` because it cannot be
1069
+ * verified: `window.open` with `noopener` returns `null` on success by
1070
+ * spec, so a null handle says nothing about whether the tab opened.
1071
+ */
1072
+ declare function useOpenExternal(): (url: string) => Promise<boolean>;
1073
+ /**
1074
+ * `onClick` for any `<a href target="_blank">` the SDK renders. A no-op
1075
+ * when no host opener is mounted, which leaves the browser to navigate.
1076
+ */
1077
+ declare function useExternalLinkClick(): (event: React.MouseEvent<HTMLAnchorElement>) => void;
1078
+
1004
1079
  type CopyContextValue = {
1005
1080
  locale?: string;
1006
1081
  copy: SolvaPayCopy;
@@ -1164,6 +1239,18 @@ declare function resolveCta(input: ResolveCtaInput): string;
1164
1239
  * Use `'payment-element'` with `PaymentForm.PaymentElement`.
1165
1240
  */
1166
1241
  type ConfirmPaymentMode = 'payment-element' | 'card-element';
1242
+ type ConfirmBillingDetails = {
1243
+ email?: string;
1244
+ name?: string;
1245
+ address?: {
1246
+ line1?: string;
1247
+ line2?: string;
1248
+ city?: string;
1249
+ state?: string;
1250
+ postal_code?: string;
1251
+ country?: string;
1252
+ };
1253
+ };
1167
1254
  type ConfirmPaymentInput = {
1168
1255
  stripe: Stripe;
1169
1256
  elements: StripeElements;
@@ -1174,11 +1261,8 @@ type ConfirmPaymentInput = {
1174
1261
  */
1175
1262
  mode?: ConfirmPaymentMode;
1176
1263
  returnUrl: string;
1177
- /** Billing details from `useCustomer()` (echoed from backend). */
1178
- billingDetails?: {
1179
- email?: string;
1180
- name?: string;
1181
- };
1264
+ /** Billing details from `useCustomer()` plus the SolvaPay-owned address. */
1265
+ billingDetails?: ConfirmBillingDetails;
1182
1266
  /**
1183
1267
  * When true, skip the browser redirect during PaymentElement confirmation
1184
1268
  * and resolve only if the intent finishes synchronously. This is what
@@ -1255,7 +1339,8 @@ declare const DEFAULT_ROUTES: {
1255
1339
  readonly autoRecharge: "/api/auto-recharge";
1256
1340
  readonly getUsage: "/api/usage";
1257
1341
  readonly getLimits: "/api/limits";
1342
+ readonly getHistory: "/api/history";
1258
1343
  };
1259
1344
  declare function createHttpTransport(config: SolvaPayConfig | undefined): SolvaPayTransport;
1260
1345
 
1261
- export { ActivatePlanResult, ActivationFlow, type ActivationFlowProps, ActivationResult, type ActivationState, AmountPicker, type AmountPickerProps, AutoRecharge, type AutoRechargeProps, BalanceStatus, CancelResult, CancelledPlanNotice, type CancelledPlanNoticeProps, CheckoutLayout, type CheckoutLayoutPlanSelectorOptions, type CheckoutLayoutProps, type CheckoutLayoutSize, CheckoutResult, CheckoutVariant, type ConfirmPaymentInput, type ConfirmPaymentMode, type ConfirmPaymentResult, CopyContext, CopyProvider, CreditGate, type CreditGateProps, CurrentPlanCard, type CurrentPlanCardClassNames, type CurrentPlanCardProps, type CustomerInfo, DEFAULT_ROUTES, type FormatPriceOptions, LaunchCustomerPortalButton, type LaunchCustomerPortalButtonProps, PartialSolvaPayCopy, type PaymentElementKind, PaymentForm, PaymentFormContext, type PaymentFormContextValue, PaymentFormProps, PaymentFormProvider, Plan, PlanSelector, type PlanSelectorProps, PrefillCustomer, Product, type PurchaseActions, PurchaseInfo, PurchaseStatus, PurchaseStatusReturn, ReactivateResult, SolvaPayConfig, SolvaPayContextValue, SolvaPayCopy, SolvaPayProvider, SolvaPayProviderProps, SolvaPayTransport, Spinner, StripePaymentFormWrapper, type StripePaymentFormWrapperProps, TopupForm, TopupFormProps, UpdatePaymentMethodButton, type UpdatePaymentMethodButtonMode, type UpdatePaymentMethodButtonProps, type UseActivationReturn, type UseAutoActivateFreePlanOptions, type UseAutoActivateFreePlanReturn, type UseLimitsOptions, type UseLimitsReturn, UseMerchantReturn, UsePaymentMethodReturn, type UsePaywallResolverReturn, UsePlanOptions, UsePlanReturn, UsePlansOptions, UsePlansReturn, UseProductReturn, UseTopupAmountSelectorOptions, UseTopupAmountSelectorReturn, UseTopupOptions, UseTopupReturn, confirmPayment, createHttpTransport, enCopy, filterPurchases, formatPrice, getActivePurchases, getCancelledPurchasesWithEndDate, getMinorUnitsPerMajor, getMostRecentPurchase, getPrimaryPurchase, interpolate, isPaidPurchase, isPlanPurchase, isTopupPurchase, isUnlimited, mergeCopy, readPaymentIntentClientSecret, resolveCta, stripPaymentIntentParams, toMajorUnits, useActivation, useAutoActivateFreePlan, useAutoRecharge, useBalance, useCheckout, useCopy, useCustomer, useLimits, useLocale, useMerchant, usePaymentForm, usePaymentMethod, usePaywallResolver, usePlan, usePlans, useProduct, usePurchase, usePurchaseActions, usePurchaseStatus, useSolvaPay, useTopup, useTopupAmountSelector, useTransport };
1346
+ export { ActivatePlanResult, ActivationFlow, type ActivationFlowProps, ActivationResult, type ActivationState, AmountPicker, type AmountPickerProps, AutoRecharge, type AutoRechargeProps, BalanceStatus, BootstrapPlanLike, CancelResult, CancelledPlanNotice, type CancelledPlanNoticeProps, CheckoutLayout, type CheckoutLayoutPlanSelectorOptions, type CheckoutLayoutProps, type CheckoutLayoutSize, CheckoutResult, CheckoutVariant, type ConfirmPaymentInput, type ConfirmPaymentMode, type ConfirmPaymentResult, CopyContext, CopyProvider, CreditGate, type CreditGateProps, CurrentPlanCard, type CurrentPlanCardClassNames, type CurrentPlanCardProps, type CustomerInfo, DEFAULT_ROUTES, type ExternalLinkOpener, ExternalLinkProvider, type ExternalLinkProviderProps, type FormatPriceOptions, LaunchCustomerPortalButton, type LaunchCustomerPortalButtonProps, PartialSolvaPayCopy, type PaymentElementKind, PaymentForm, PaymentFormContext, type PaymentFormContextValue, PaymentFormProps, PaymentFormProvider, Plan, PlanSelector, type PlanSelectorProps, PrefillCustomer, Product, type PurchaseActions, PurchaseInfo, PurchaseStatus, PurchaseStatusReturn, ReactivateResult, SolvaPayConfig, SolvaPayContextValue, SolvaPayCopy, SolvaPayProvider, SolvaPayProviderProps, SolvaPayTransport, Spinner, StripePaymentFormWrapper, type StripePaymentFormWrapperProps, TopupForm, TopupFormProps, UpdatePaymentMethodButton, type UpdatePaymentMethodButtonMode, type UpdatePaymentMethodButtonProps, type UseActivationReturn, type UseAutoActivateFreePlanOptions, type UseAutoActivateFreePlanReturn, type UseLimitsOptions, type UseLimitsReturn, UseMerchantReturn, UsePaymentMethodReturn, type UsePaywallResolverReturn, UsePlanOptions, UsePlanReturn, UsePlansOptions, UsePlansReturn, UseProductReturn, UseTopupAmountSelectorOptions, UseTopupAmountSelectorReturn, UseTopupOptions, UseTopupReturn, confirmPayment, createHttpTransport, enCopy, filterPurchases, formatPrice, getActivePurchases, getCancelledPurchasesWithEndDate, getMinorUnitsPerMajor, getMostRecentPurchase, getPrimaryPurchase, interpolate, isPaidPurchase, isPlanPurchase, isTopupPurchase, isUnlimited, mergeCopy, readPaymentIntentClientSecret, resolveCta, stripPaymentIntentParams, toMajorUnits, useActivation, useAutoActivateFreePlan, useAutoRecharge, useBalance, useCheckout, useCopy, useCustomer, useExternalLinkClick, useLimits, useLocale, useMerchant, useOpenExternal, usePaymentForm, usePaymentMethod, usePaywallResolver, usePlan, usePlans, useProduct, usePurchase, usePurchaseActions, usePurchaseStatus, useSolvaPay, useTopup, useTopupAmountSelector, useTransport };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
- import { S as SolvaPayProviderProps, P as PaymentFormProps, a as PrefillCustomer, T as TopupFormProps, C as CheckoutResult, b as Plan, A as ActivationResult, c as SaveAutoRechargeResponse, d as PurchaseStatus, e as SolvaPayContextValue, U as UsePlansOptions, f as UsePlansReturn, g as UsePlanOptions, h as UsePlanReturn, i as UseProductReturn, j as UseMerchantReturn, k as SolvaPayCopy, l as PurchaseStatusReturn, m as CancelResult, R as ReactivateResult, n as ActivatePlanResult, o as UseTopupOptions, p as UseTopupReturn, B as BalanceStatus, q as UseTopupAmountSelectorOptions, r as UseTopupAmountSelectorReturn, s as UsePaymentMethodReturn, t as AutoRechargeConfig, u as SaveAutoRechargeInput, v as SolvaPayTransport, w as PartialSolvaPayCopy, x as PurchaseInfo, y as Product, z as SolvaPayConfig } from './shared-CUl6mTC1.js';
3
- export { D as BootstrapPlanLike, E as CheckoutStep, F as CustomerPurchaseData, M as MandateContext, G as MandateTemplate, H as Merchant, I as PaymentError, J as PaymentIntentResult, K as PaymentMethodInfo, L as PaymentResult, N as PurchaseStatusValue, O as SuccessMeta, Q as TopupPaymentResult, V as TransportBalanceResult, W as TransportCheckoutSessionResult, X as TransportCustomerSessionResult, Y as TransportLimitsResult, Z as UnsupportedTransportMethodError } from './shared-CUl6mTC1.js';
4
- import { P as PaymentFormSummary, a as PaymentFormCustomerFields, b as PaymentFormPaymentElement, c as PaymentFormCardElement, d as PaymentFormMandateText, e as PaymentFormTermsCheckbox, f as PaymentFormSubmitButton, g as PaymentFormLoading, h as PaymentFormError, i as PaymentFormLegalFooter, j as PaymentFormBusinessDetails, k as PaymentFormTaxSummary, A as AutoRechargeInputPayload, l as PaywallStructuredContent, C as CheckoutVariant } from './index-CBWGkBqF.js';
5
- export { m as ActivationFlowStep, B as BalanceBadge, n as CancelPlanButton, o as CheckoutErrorPhase, p as CheckoutStatus, q as CheckoutSteps, r as CheckoutSummary, s as CheckoutSummaryProps, M as MandateText, t as MandateTextProps, u as PlanBadge, v as ProductBadge, w as PurchaseGate, U as UsageSnapshot, x as UseCheckoutFlowOptions, y as UseCheckoutFlowReturn, z as UseUsageReturn, D as configToAutoRechargeInput, E as deriveVariant, F as useCheckoutFlow, G as useCheckoutStepsContext, H as useUsage } from './index-CBWGkBqF.js';
2
+ import { S as SolvaPayProviderProps, P as PaymentFormProps, a as PrefillCustomer, T as TopupFormProps, C as CheckoutResult, b as Plan, A as ActivationResult, B as BootstrapPlanLike, c as SaveAutoRechargeResponse, d as PurchaseStatus, e as SolvaPayContextValue, U as UsePlansOptions, f as UsePlansReturn, g as UsePlanOptions, h as UsePlanReturn, i as UseProductReturn, j as UseMerchantReturn, k as SolvaPayCopy, l as PurchaseStatusReturn, m as CancelResult, R as ReactivateResult, n as ActivatePlanResult, o as UseTopupOptions, p as UseTopupReturn, q as BalanceStatus, r as UseTopupAmountSelectorOptions, s as UseTopupAmountSelectorReturn, t as UsePaymentMethodReturn, u as AutoRechargeConfig, v as SaveAutoRechargeInput, w as SolvaPayTransport, x as PartialSolvaPayCopy, y as PurchaseInfo, z as Product, D as SolvaPayConfig } from './useUsage-CMqxEF9d.js';
3
+ export { E as CheckoutStep, F as CustomerPurchaseData, M as MandateContext, G as MandateTemplate, H as Merchant, I as PaymentError, J as PaymentIntentResult, K as PaymentMethodInfo, L as PaymentResult, N as PurchaseStatusValue, O as SuccessMeta, Q as TopupPaymentResult, V as TransportBalanceResult, W as TransportCheckoutSessionResult, X as TransportCustomerSessionResult, Y as TransportLimitsResult, Z as UnsupportedTransportMethodError, _ as UsageSnapshot, $ as UseUsageReturn, a0 as useUsage } from './useUsage-CMqxEF9d.js';
4
+ import { P as PaymentFormSummary, a as PaymentFormCustomerFields, b as PaymentFormPaymentElement, c as PaymentFormCardElement, d as PaymentFormMandateText, e as PaymentFormTermsCheckbox, f as PaymentFormSubmitButton, g as PaymentFormLoading, h as PaymentFormError, i as PaymentFormLegalFooter, j as PaymentFormBusinessDetails, k as PaymentFormTaxSummary, A as AutoRechargeInputPayload, l as PaywallStructuredContent, C as CheckoutVariant } from './index-PsjS_d7V.js';
5
+ export { m as ActivationFlowStep, B as BalanceBadge, n as CancelPlanButton, o as CheckoutErrorPhase, p as CheckoutStatus, q as CheckoutSteps, r as CheckoutSummary, s as CheckoutSummaryProps, M as MandateText, t as MandateTextProps, u as PlanBadge, v as ProductBadge, w as PurchaseGate, U as UseCheckoutFlowOptions, x as UseCheckoutFlowReturn, y as configToAutoRechargeInput, z as deriveVariant, D as useCheckoutFlow, E as useCheckoutStepsContext } from './index-PsjS_d7V.js';
6
6
  import { PaymentIntent, Stripe, StripeElements } from '@stripe/stripe-js';
7
7
  import { BusinessDetailsInput, TaxBreakdown } from '@solvapay/core';
8
+ import * as react_jsx_runtime from 'react/jsx-runtime';
8
9
  export { AuthAdapter, createAnonymousAuthAdapter, defaultAuthAdapter, getOrCreateAnonymousCustomerRef, resetAnonymousCustomerRef } from './adapters/auth.js';
9
10
  export { SessionAuthAdapterOptions, createSessionAuthAdapter } from './adapters/session-auth.js';
10
11
  import '@stripe/react-stripe-js';
11
- import 'react/jsx-runtime';
12
12
 
13
13
  /**
14
14
  * SolvaPay Provider - Headless Context Provider for React.
@@ -58,8 +58,8 @@ declare const SolvaPayProvider: React.FC<SolvaPayProviderProps>;
58
58
  *
59
59
  * Consumers who just want a drop-in payment form use this component. It
60
60
  * renders the primitive's Root with a golden-path default tree composed of
61
- * `PaymentForm.Summary`, `CustomerFields`, `PaymentElement`, `MandateText`,
62
- * an optional `TermsCheckbox`, and `SubmitButton`. Free-plan activation
61
+ * `PaymentForm.Summary`, `CustomerFields`, `PaymentElement`, an optional
62
+ * `TermsCheckbox`, `SubmitButton`, and `MandateText`. Free-plan activation
63
63
  * flows through the same composition — `FreeInner` in the primitive swaps
64
64
  * the submit handler so the default tree works identically for paid and
65
65
  * free plans.
@@ -305,6 +305,8 @@ interface CurrentPlanCardClassNames {
305
305
  usageMeter?: string;
306
306
  paymentMethod?: string;
307
307
  actions?: string;
308
+ /** Small muted caption above a value when `showFieldLabels` is set. */
309
+ fieldLabel?: string;
308
310
  /** Embedded pending-cancellation notice + reactivate CTA. */
309
311
  cancelledNotice?: string;
310
312
  }
@@ -351,6 +353,17 @@ interface CurrentPlanCardProps {
351
353
  * Hosted-page parity for the MCP account surface.
352
354
  */
353
355
  showReference?: boolean;
356
+ /**
357
+ * Caption the price/rate and balance values with a field label
358
+ * ("Rate", "Balance"). Default: `false`. Those lines are bare
359
+ * numbers otherwise, which read alike on a surface that shows both.
360
+ */
361
+ showFieldLabels?: boolean;
362
+ /**
363
+ * Live catalog plans. Used to format a PAYG usage rate when the
364
+ * frozen snapshot has no `options[]`.
365
+ */
366
+ plans?: readonly CatalogPlanLike[];
354
367
  /** Per-element classNames. */
355
368
  classNames?: CurrentPlanCardClassNames;
356
369
  /**
@@ -359,6 +372,20 @@ interface CurrentPlanCardProps {
359
372
  */
360
373
  className?: string;
361
374
  }
375
+ /**
376
+ * Structural catalog / snapshot subset `formatPaygRate` can read.
377
+ * Wider than `BootstrapPlanLike` so MCP `PlanLike` (which allows `null`
378
+ * on optional fields) is assignable without a cast.
379
+ */
380
+ interface CatalogPlanLike {
381
+ reference?: string | null;
382
+ name?: string;
383
+ options?: BootstrapPlanLike['options'] | null;
384
+ price?: number | null;
385
+ currency?: string | null;
386
+ requiresPayment?: boolean | null;
387
+ isMetered?: boolean | null;
388
+ }
362
389
  declare const CurrentPlanCard: React.FC<CurrentPlanCardProps>;
363
390
 
364
391
  type AutoRechargeProps = {
@@ -381,17 +408,18 @@ declare function AutoRecharge({ currency, defaultThresholdAmountMajor, defaultTo
381
408
  * Render-eager: the button is enabled and labelled from the first paint
382
409
  * regardless of session state. The portal session URL is fetched in the
383
410
  * background through `useCustomerSessionUrl()` (a single in-flight call
384
- * shared across every instance under the same transport). When the URL
385
- * is ready, click is a synchronous `<a target="_blank">` navigation —
386
- * which MCP host sandboxes permit even though scripted `window.open`
387
- * after an async round-trip is blocked.
388
- *
389
- * If the user clicks before the URL has resolved, the click handler
390
- * awaits the in-flight fetch and falls back to `window.open` (works on
391
- * hosts that don't sandbox scripted opens, e.g. ChatGPT). On Claude the
392
- * sandbox silently drops the open in that race; the cache-hit path
393
- * remains the optimal one and is the steady state for any user that
394
- * doesn't click within a few hundred ms of opening the surface.
411
+ * shared across every instance under the same transport).
412
+ *
413
+ * Opening the portal always goes through `useExternalLink`, which
414
+ * prefers the host's `ui/open-link` when one is mounted and otherwise
415
+ * lets the browser navigate. That distinction matters inside MCP hosts:
416
+ * Claude's iframe sandbox omits `allow-popups`, so both a bare
417
+ * `<a target="_blank">` and `window.open()` are dropped without an
418
+ * error — the button looks alive and does nothing.
419
+ *
420
+ * If the user clicks before the URL has resolved, the handler awaits
421
+ * the in-flight fetch and then opens the resolved URL through the same
422
+ * path, flipping to the error state if the open is refused.
395
423
  */
396
424
 
397
425
  interface LaunchCustomerPortalButtonProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'rel' | 'onError'> {
@@ -761,7 +789,7 @@ interface UseActivationReturn {
761
789
  activate: (params: {
762
790
  productRef: string;
763
791
  planRef: string;
764
- }) => Promise<void>;
792
+ }) => Promise<ActivationState>;
765
793
  state: ActivationState;
766
794
  error: string | null;
767
795
  result: ActivatePlanResult | null;
@@ -942,6 +970,16 @@ interface UseLimitsReturn {
942
970
  needsUpgrade: boolean | null;
943
971
  /** The customer was auto-upgraded and access was restored. `null` while loading. */
944
972
  upgraded: boolean | null;
973
+ /**
974
+ * Consumed units this period. `null` while loading, when disabled, or
975
+ * when the backend did not measure a finite cap.
976
+ */
977
+ used: number | null;
978
+ /**
979
+ * The effective finite cap for this meter. `null` while loading, when
980
+ * disabled, or when the backend did not measure a finite cap.
981
+ */
982
+ limit: number | null;
945
983
  loading: boolean;
946
984
  error: Error | null;
947
985
  refetch: () => Promise<void>;
@@ -1001,6 +1039,43 @@ interface UsePaywallResolverReturn {
1001
1039
  }
1002
1040
  declare function usePaywallResolver(content: PaywallStructuredContent): UsePaywallResolverReturn;
1003
1041
 
1042
+ interface ExternalLinkOpener {
1043
+ /**
1044
+ * Whether the host can open links right now. Read synchronously from
1045
+ * the click handler, because suppressing native navigation on a host
1046
+ * that *cannot* open links would turn a working link into a dead one
1047
+ * — so `preventDefault()` is gated on this returning `true`.
1048
+ */
1049
+ canOpen: () => boolean;
1050
+ /**
1051
+ * Hand `url` to the host. Resolves `false` when the host refused
1052
+ * (blocked domain, user cancelled) or the request failed, so callers
1053
+ * can surface the dead end instead of leaving the user guessing.
1054
+ */
1055
+ open: (url: string) => Promise<boolean>;
1056
+ }
1057
+ interface ExternalLinkProviderProps {
1058
+ opener: ExternalLinkOpener;
1059
+ children: React.ReactNode;
1060
+ }
1061
+ declare function ExternalLinkProvider({ opener, children }: ExternalLinkProviderProps): react_jsx_runtime.JSX.Element;
1062
+ /**
1063
+ * Imperative opener for flows that only learn the URL after an `await`,
1064
+ * where there is no anchor left to click (the portal button's
1065
+ * cache-miss path). Prefers the host, otherwise asks the browser.
1066
+ *
1067
+ * Resolves `false` only when a host-mediated open was attempted and
1068
+ * refused. The browser path reports `true` because it cannot be
1069
+ * verified: `window.open` with `noopener` returns `null` on success by
1070
+ * spec, so a null handle says nothing about whether the tab opened.
1071
+ */
1072
+ declare function useOpenExternal(): (url: string) => Promise<boolean>;
1073
+ /**
1074
+ * `onClick` for any `<a href target="_blank">` the SDK renders. A no-op
1075
+ * when no host opener is mounted, which leaves the browser to navigate.
1076
+ */
1077
+ declare function useExternalLinkClick(): (event: React.MouseEvent<HTMLAnchorElement>) => void;
1078
+
1004
1079
  type CopyContextValue = {
1005
1080
  locale?: string;
1006
1081
  copy: SolvaPayCopy;
@@ -1164,6 +1239,18 @@ declare function resolveCta(input: ResolveCtaInput): string;
1164
1239
  * Use `'payment-element'` with `PaymentForm.PaymentElement`.
1165
1240
  */
1166
1241
  type ConfirmPaymentMode = 'payment-element' | 'card-element';
1242
+ type ConfirmBillingDetails = {
1243
+ email?: string;
1244
+ name?: string;
1245
+ address?: {
1246
+ line1?: string;
1247
+ line2?: string;
1248
+ city?: string;
1249
+ state?: string;
1250
+ postal_code?: string;
1251
+ country?: string;
1252
+ };
1253
+ };
1167
1254
  type ConfirmPaymentInput = {
1168
1255
  stripe: Stripe;
1169
1256
  elements: StripeElements;
@@ -1174,11 +1261,8 @@ type ConfirmPaymentInput = {
1174
1261
  */
1175
1262
  mode?: ConfirmPaymentMode;
1176
1263
  returnUrl: string;
1177
- /** Billing details from `useCustomer()` (echoed from backend). */
1178
- billingDetails?: {
1179
- email?: string;
1180
- name?: string;
1181
- };
1264
+ /** Billing details from `useCustomer()` plus the SolvaPay-owned address. */
1265
+ billingDetails?: ConfirmBillingDetails;
1182
1266
  /**
1183
1267
  * When true, skip the browser redirect during PaymentElement confirmation
1184
1268
  * and resolve only if the intent finishes synchronously. This is what
@@ -1255,7 +1339,8 @@ declare const DEFAULT_ROUTES: {
1255
1339
  readonly autoRecharge: "/api/auto-recharge";
1256
1340
  readonly getUsage: "/api/usage";
1257
1341
  readonly getLimits: "/api/limits";
1342
+ readonly getHistory: "/api/history";
1258
1343
  };
1259
1344
  declare function createHttpTransport(config: SolvaPayConfig | undefined): SolvaPayTransport;
1260
1345
 
1261
- export { ActivatePlanResult, ActivationFlow, type ActivationFlowProps, ActivationResult, type ActivationState, AmountPicker, type AmountPickerProps, AutoRecharge, type AutoRechargeProps, BalanceStatus, CancelResult, CancelledPlanNotice, type CancelledPlanNoticeProps, CheckoutLayout, type CheckoutLayoutPlanSelectorOptions, type CheckoutLayoutProps, type CheckoutLayoutSize, CheckoutResult, CheckoutVariant, type ConfirmPaymentInput, type ConfirmPaymentMode, type ConfirmPaymentResult, CopyContext, CopyProvider, CreditGate, type CreditGateProps, CurrentPlanCard, type CurrentPlanCardClassNames, type CurrentPlanCardProps, type CustomerInfo, DEFAULT_ROUTES, type FormatPriceOptions, LaunchCustomerPortalButton, type LaunchCustomerPortalButtonProps, PartialSolvaPayCopy, type PaymentElementKind, PaymentForm, PaymentFormContext, type PaymentFormContextValue, PaymentFormProps, PaymentFormProvider, Plan, PlanSelector, type PlanSelectorProps, PrefillCustomer, Product, type PurchaseActions, PurchaseInfo, PurchaseStatus, PurchaseStatusReturn, ReactivateResult, SolvaPayConfig, SolvaPayContextValue, SolvaPayCopy, SolvaPayProvider, SolvaPayProviderProps, SolvaPayTransport, Spinner, StripePaymentFormWrapper, type StripePaymentFormWrapperProps, TopupForm, TopupFormProps, UpdatePaymentMethodButton, type UpdatePaymentMethodButtonMode, type UpdatePaymentMethodButtonProps, type UseActivationReturn, type UseAutoActivateFreePlanOptions, type UseAutoActivateFreePlanReturn, type UseLimitsOptions, type UseLimitsReturn, UseMerchantReturn, UsePaymentMethodReturn, type UsePaywallResolverReturn, UsePlanOptions, UsePlanReturn, UsePlansOptions, UsePlansReturn, UseProductReturn, UseTopupAmountSelectorOptions, UseTopupAmountSelectorReturn, UseTopupOptions, UseTopupReturn, confirmPayment, createHttpTransport, enCopy, filterPurchases, formatPrice, getActivePurchases, getCancelledPurchasesWithEndDate, getMinorUnitsPerMajor, getMostRecentPurchase, getPrimaryPurchase, interpolate, isPaidPurchase, isPlanPurchase, isTopupPurchase, isUnlimited, mergeCopy, readPaymentIntentClientSecret, resolveCta, stripPaymentIntentParams, toMajorUnits, useActivation, useAutoActivateFreePlan, useAutoRecharge, useBalance, useCheckout, useCopy, useCustomer, useLimits, useLocale, useMerchant, usePaymentForm, usePaymentMethod, usePaywallResolver, usePlan, usePlans, useProduct, usePurchase, usePurchaseActions, usePurchaseStatus, useSolvaPay, useTopup, useTopupAmountSelector, useTransport };
1346
+ export { ActivatePlanResult, ActivationFlow, type ActivationFlowProps, ActivationResult, type ActivationState, AmountPicker, type AmountPickerProps, AutoRecharge, type AutoRechargeProps, BalanceStatus, BootstrapPlanLike, CancelResult, CancelledPlanNotice, type CancelledPlanNoticeProps, CheckoutLayout, type CheckoutLayoutPlanSelectorOptions, type CheckoutLayoutProps, type CheckoutLayoutSize, CheckoutResult, CheckoutVariant, type ConfirmPaymentInput, type ConfirmPaymentMode, type ConfirmPaymentResult, CopyContext, CopyProvider, CreditGate, type CreditGateProps, CurrentPlanCard, type CurrentPlanCardClassNames, type CurrentPlanCardProps, type CustomerInfo, DEFAULT_ROUTES, type ExternalLinkOpener, ExternalLinkProvider, type ExternalLinkProviderProps, type FormatPriceOptions, LaunchCustomerPortalButton, type LaunchCustomerPortalButtonProps, PartialSolvaPayCopy, type PaymentElementKind, PaymentForm, PaymentFormContext, type PaymentFormContextValue, PaymentFormProps, PaymentFormProvider, Plan, PlanSelector, type PlanSelectorProps, PrefillCustomer, Product, type PurchaseActions, PurchaseInfo, PurchaseStatus, PurchaseStatusReturn, ReactivateResult, SolvaPayConfig, SolvaPayContextValue, SolvaPayCopy, SolvaPayProvider, SolvaPayProviderProps, SolvaPayTransport, Spinner, StripePaymentFormWrapper, type StripePaymentFormWrapperProps, TopupForm, TopupFormProps, UpdatePaymentMethodButton, type UpdatePaymentMethodButtonMode, type UpdatePaymentMethodButtonProps, type UseActivationReturn, type UseAutoActivateFreePlanOptions, type UseAutoActivateFreePlanReturn, type UseLimitsOptions, type UseLimitsReturn, UseMerchantReturn, UsePaymentMethodReturn, type UsePaywallResolverReturn, UsePlanOptions, UsePlanReturn, UsePlansOptions, UsePlansReturn, UseProductReturn, UseTopupAmountSelectorOptions, UseTopupAmountSelectorReturn, UseTopupOptions, UseTopupReturn, confirmPayment, createHttpTransport, enCopy, filterPurchases, formatPrice, getActivePurchases, getCancelledPurchasesWithEndDate, getMinorUnitsPerMajor, getMostRecentPurchase, getPrimaryPurchase, interpolate, isPaidPurchase, isPlanPurchase, isTopupPurchase, isUnlimited, mergeCopy, readPaymentIntentClientSecret, resolveCta, stripPaymentIntentParams, toMajorUnits, useActivation, useAutoActivateFreePlan, useAutoRecharge, useBalance, useCheckout, useCopy, useCustomer, useExternalLinkClick, useLimits, useLocale, useMerchant, useOpenExternal, usePaymentForm, usePaymentMethod, usePaywallResolver, usePlan, usePlans, useProduct, usePurchase, usePurchaseActions, usePurchaseStatus, useSolvaPay, useTopup, useTopupAmountSelector, useTransport };