@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.
@@ -1,4 +1,4 @@
1
- import { $ as components, b as Plan, P as PaymentFormProps, a as PrefillCustomer, A as ActivationResult, r as UseTopupAmountSelectorReturn, a0 as AutoRechargeInput, t as AutoRechargeConfig, a1 as AutoRechargeDisplayBlock, E as CheckoutStep, O as SuccessMeta } from './shared-CUl6mTC1.js';
1
+ import { a4 as components, b as Plan, P as PaymentFormProps, a as PrefillCustomer, A as ActivationResult, s as UseTopupAmountSelectorReturn, a5 as AutoRechargeInput, u as AutoRechargeConfig, a6 as AutoRechargeDisplayBlock, E as CheckoutStep, O as SuccessMeta } from './useUsage-CTgRBvFK.cjs';
2
2
  import React from 'react';
3
3
  import { PaymentElement, CardElement } from '@stripe/react-stripe-js';
4
4
  import { TaxBreakdown } from '@solvapay/core';
@@ -17,7 +17,36 @@ type LimitActivationProduct = components['schemas']['LimitProductBriefDto'];
17
17
  /**
18
18
  * Structured content for paywall errors (MCP structuredContent and manual handling).
19
19
  */
20
- type PaywallStructuredContent = {
20
+ /**
21
+ * Fields shared by every `PaywallStructuredContent` kind so a text-only
22
+ * host can recover from a gate without a second tool call. Every field
23
+ * other than `kind` / `product` / `checkoutUrl` / `message` is omitted
24
+ * when the backend did not send it — never defaulted.
25
+ */
26
+ type PaywallGateRecoveryFields = {
27
+ /** Active plan reference from `limits.plan`. */
28
+ planRef?: string;
29
+ /** Product plans from `checkLimits` (activation already had this). */
30
+ plans?: LimitPlanSummary[];
31
+ /** Meter the gated call was charged against. */
32
+ meterName?: string;
33
+ /** Per-unit charge of the active plan, in minor currency units. */
34
+ unitPriceMinor?: number;
35
+ /** ISO 4217 currency for `unitPriceMinor`. */
36
+ currency?: string;
37
+ /**
38
+ * Included-usage counters. Omitted when `freeUnits` is absent or `0`
39
+ * (the unlimited sentinel) so we never emit misleading zeros.
40
+ */
41
+ included?: {
42
+ total: number;
43
+ used: number;
44
+ remaining: number;
45
+ };
46
+ /** Prepaid credit balance, coalesced from nested or top-level fields. */
47
+ creditBalance?: number;
48
+ };
49
+ type PaywallStructuredContent = ({
21
50
  kind: 'payment_required';
22
51
  /** Product ref from paywall metadata (or env default) */
23
52
  product: string;
@@ -32,7 +61,7 @@ type PaywallStructuredContent = {
32
61
  balance?: LimitActivationBalance;
33
62
  /** Rich product context from checkLimits (name, ref, provider slug/id) */
34
63
  productDetails?: LimitActivationProduct;
35
- } | {
64
+ } & PaywallGateRecoveryFields) | ({
36
65
  kind: 'activation_required';
37
66
  /** Product ref from paywall metadata (or env default) */
38
67
  product: string;
@@ -42,11 +71,10 @@ type PaywallStructuredContent = {
42
71
  */
43
72
  checkoutUrl: string;
44
73
  confirmationUrl?: string;
45
- plans?: LimitPlanSummary[];
46
74
  balance?: LimitActivationBalance;
47
75
  /** Rich product context from checkLimits (name, ref, provider slug/id) */
48
76
  productDetails?: LimitActivationProduct;
49
- };
77
+ } & PaywallGateRecoveryFields);
50
78
 
51
79
  /**
52
80
  * Default-tree shim over the `CheckoutSummary` primitive.
@@ -203,6 +231,12 @@ declare const PaymentFormBusinessDetails: {
203
231
  readonly Country: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & {
204
232
  asChild?: boolean;
205
233
  } & React.RefAttributes<HTMLSelectElement>>;
234
+ readonly State: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
235
+ asChild?: boolean;
236
+ } & React.RefAttributes<HTMLInputElement>>;
237
+ readonly PostalCode: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
238
+ asChild?: boolean;
239
+ } & React.RefAttributes<HTMLInputElement>>;
206
240
  readonly TaxId: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
207
241
  asChild?: boolean;
208
242
  } & React.RefAttributes<HTMLInputElement>>;
@@ -260,6 +294,12 @@ declare const PaymentForm: {
260
294
  readonly Country: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & {
261
295
  asChild?: boolean;
262
296
  } & React.RefAttributes<HTMLSelectElement>>;
297
+ readonly State: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
298
+ asChild?: boolean;
299
+ } & React.RefAttributes<HTMLInputElement>>;
300
+ readonly PostalCode: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
301
+ asChild?: boolean;
302
+ } & React.RefAttributes<HTMLInputElement>>;
263
303
  readonly TaxId: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
264
304
  asChild?: boolean;
265
305
  } & React.RefAttributes<HTMLInputElement>>;
@@ -568,39 +608,6 @@ declare function configToAutoRechargeInput(config: AutoRechargeConfig, options?:
568
608
  };
569
609
  }): AutoRechargeInput | null;
570
610
 
571
- interface UseUsageReturn {
572
- /** Raw usage snapshot (`null` when no usage-based plan is active). */
573
- usage: UsageSnapshot | null;
574
- loading: boolean;
575
- error: Error | null;
576
- refetch: () => Promise<void>;
577
- /** 0-100, rounded to 2dp. `null` when total is unknown (unlimited/empty). */
578
- percentUsed: number | null;
579
- /** Plan is usage-based, `percentUsed >= 80`. */
580
- isApproachingLimit: boolean;
581
- /** Plan is usage-based, `percentUsed >= 100`. */
582
- isAtLimit: boolean;
583
- /**
584
- * True when the backend reports no finite cap on this meter. Sourced
585
- * from `useLimits().unlimited`, never inferred from a missing `total`
586
- * — an unknown cap is not an absent one.
587
- */
588
- isUnlimited: boolean;
589
- /** The meter reference (e.g. `'tokens'`). `null` when not usage-based. */
590
- meterRef: string | null;
591
- }
592
- interface UsageSnapshot {
593
- meterRef: string | null;
594
- total: number | null;
595
- used: number;
596
- remaining: number | null;
597
- percentUsed: number | null;
598
- periodStart?: string;
599
- periodEnd?: string;
600
- purchaseRef?: string;
601
- }
602
- declare function useUsage(): UseUsageReturn;
603
-
604
611
  type CheckoutStatus = 'idle' | 'activating' | 'paying' | 'error';
605
612
  type CheckoutErrorPhase = 'activate' | 'pay';
606
613
  interface UseCheckoutFlowOptions {
@@ -832,4 +839,4 @@ declare const CheckoutStepsBackLink: React.ForwardRefExoticComponent<Omit<React.
832
839
  } & React.RefAttributes<HTMLButtonElement>>;
833
840
  declare const CheckoutStepsSuccess: typeof Success;
834
841
 
835
- export { CheckoutStepsPayment as $, type AutoRechargeInputPayload as A, BalanceBadge as B, type CheckoutVariant as C, configToAutoRechargeInput as D, deriveVariant as E, useCheckoutFlow as F, useCheckoutSteps as G, useUsage as H, type AmountInputUnit as I, type AutoRechargeFormState as J, ActivationFlow as K, ActivationFlowActivateButton as L, MandateText as M, ActivationFlowActivated as N, ActivationFlowAmountPicker as O, PaymentFormSummary as P, ActivationFlowContinueButton as Q, ActivationFlowError as R, ActivationFlowLoading as S, ActivationFlowRetrying as T, type UsageSnapshot as U, ActivationFlowRoot as V, ActivationFlowSummary as W, CheckoutStepsAmountContinueButton as X, CheckoutStepsAmountPicker as Y, CheckoutStepsBackLink as Z, CheckoutStepsIfStep as _, PaymentFormCustomerFields as a, CheckoutStepsPlanContinueButton as a0, CheckoutStepsPlanGrid as a1, CheckoutStepsRoot as a2, CheckoutStepsStepHeading as a3, CheckoutStepsStepMessage as a4, CheckoutStepsSuccess as a5, PaymentForm as a6, PaymentFormRoot as a7, PurchaseGateAllowed as a8, PurchaseGateBlocked as a9, PurchaseGateError as aa, PurchaseGateLoading as ab, PurchaseGateRoot as ac, useActivationFlow as ad, usePurchaseGate as ae, PaymentFormPaymentElement as b, PaymentFormCardElement as c, PaymentFormMandateText as d, PaymentFormTermsCheckbox as e, PaymentFormSubmitButton as f, PaymentFormLoading as g, PaymentFormError as h, PaymentFormLegalFooter as i, PaymentFormBusinessDetails as j, PaymentFormTaxSummary as k, type PaywallStructuredContent as l, type ActivationFlowStep as m, CancelPlanButton as n, type CheckoutErrorPhase as o, type CheckoutStatus as p, CheckoutSteps as q, CheckoutSummary as r, type CheckoutSummaryProps as s, type MandateTextProps as t, PlanBadge as u, ProductBadge as v, PurchaseGate as w, type UseCheckoutFlowOptions as x, type UseCheckoutFlowReturn as y, type UseUsageReturn as z };
842
+ export { CheckoutStepsRoot as $, type AutoRechargeInputPayload as A, BalanceBadge as B, type CheckoutVariant as C, useCheckoutFlow as D, useCheckoutSteps as E, type AmountInputUnit as F, type AutoRechargeFormState as G, ActivationFlow as H, ActivationFlowActivateButton as I, ActivationFlowActivated as J, ActivationFlowAmountPicker as K, ActivationFlowContinueButton as L, MandateText as M, ActivationFlowError as N, ActivationFlowLoading as O, PaymentFormSummary as P, ActivationFlowRetrying as Q, ActivationFlowRoot as R, ActivationFlowSummary as S, CheckoutStepsAmountContinueButton as T, type UseCheckoutFlowOptions as U, CheckoutStepsAmountPicker as V, CheckoutStepsBackLink as W, CheckoutStepsIfStep as X, CheckoutStepsPayment as Y, CheckoutStepsPlanContinueButton as Z, CheckoutStepsPlanGrid as _, PaymentFormCustomerFields as a, CheckoutStepsStepHeading as a0, CheckoutStepsStepMessage as a1, CheckoutStepsSuccess as a2, PaymentForm as a3, PaymentFormRoot as a4, PurchaseGateAllowed as a5, PurchaseGateBlocked as a6, PurchaseGateError as a7, PurchaseGateLoading as a8, PurchaseGateRoot as a9, useActivationFlow as aa, usePurchaseGate as ab, PaymentFormPaymentElement as b, PaymentFormCardElement as c, PaymentFormMandateText as d, PaymentFormTermsCheckbox as e, PaymentFormSubmitButton as f, PaymentFormLoading as g, PaymentFormError as h, PaymentFormLegalFooter as i, PaymentFormBusinessDetails as j, PaymentFormTaxSummary as k, type PaywallStructuredContent as l, type ActivationFlowStep as m, CancelPlanButton as n, type CheckoutErrorPhase as o, type CheckoutStatus as p, CheckoutSteps as q, CheckoutSummary as r, type CheckoutSummaryProps as s, type MandateTextProps as t, PlanBadge as u, ProductBadge as v, PurchaseGate as w, type UseCheckoutFlowReturn as x, configToAutoRechargeInput as y, deriveVariant as z };
@@ -1,4 +1,4 @@
1
- import { $ as components, b as Plan, P as PaymentFormProps, a as PrefillCustomer, A as ActivationResult, r as UseTopupAmountSelectorReturn, a0 as AutoRechargeInput, t as AutoRechargeConfig, a1 as AutoRechargeDisplayBlock, E as CheckoutStep, O as SuccessMeta } from './shared-D0hmT1qU.cjs';
1
+ import { a4 as components, b as Plan, P as PaymentFormProps, a as PrefillCustomer, A as ActivationResult, s as UseTopupAmountSelectorReturn, a5 as AutoRechargeInput, u as AutoRechargeConfig, a6 as AutoRechargeDisplayBlock, E as CheckoutStep, O as SuccessMeta } from './useUsage-CMqxEF9d.js';
2
2
  import React from 'react';
3
3
  import { PaymentElement, CardElement } from '@stripe/react-stripe-js';
4
4
  import { TaxBreakdown } from '@solvapay/core';
@@ -17,7 +17,36 @@ type LimitActivationProduct = components['schemas']['LimitProductBriefDto'];
17
17
  /**
18
18
  * Structured content for paywall errors (MCP structuredContent and manual handling).
19
19
  */
20
- type PaywallStructuredContent = {
20
+ /**
21
+ * Fields shared by every `PaywallStructuredContent` kind so a text-only
22
+ * host can recover from a gate without a second tool call. Every field
23
+ * other than `kind` / `product` / `checkoutUrl` / `message` is omitted
24
+ * when the backend did not send it — never defaulted.
25
+ */
26
+ type PaywallGateRecoveryFields = {
27
+ /** Active plan reference from `limits.plan`. */
28
+ planRef?: string;
29
+ /** Product plans from `checkLimits` (activation already had this). */
30
+ plans?: LimitPlanSummary[];
31
+ /** Meter the gated call was charged against. */
32
+ meterName?: string;
33
+ /** Per-unit charge of the active plan, in minor currency units. */
34
+ unitPriceMinor?: number;
35
+ /** ISO 4217 currency for `unitPriceMinor`. */
36
+ currency?: string;
37
+ /**
38
+ * Included-usage counters. Omitted when `freeUnits` is absent or `0`
39
+ * (the unlimited sentinel) so we never emit misleading zeros.
40
+ */
41
+ included?: {
42
+ total: number;
43
+ used: number;
44
+ remaining: number;
45
+ };
46
+ /** Prepaid credit balance, coalesced from nested or top-level fields. */
47
+ creditBalance?: number;
48
+ };
49
+ type PaywallStructuredContent = ({
21
50
  kind: 'payment_required';
22
51
  /** Product ref from paywall metadata (or env default) */
23
52
  product: string;
@@ -32,7 +61,7 @@ type PaywallStructuredContent = {
32
61
  balance?: LimitActivationBalance;
33
62
  /** Rich product context from checkLimits (name, ref, provider slug/id) */
34
63
  productDetails?: LimitActivationProduct;
35
- } | {
64
+ } & PaywallGateRecoveryFields) | ({
36
65
  kind: 'activation_required';
37
66
  /** Product ref from paywall metadata (or env default) */
38
67
  product: string;
@@ -42,11 +71,10 @@ type PaywallStructuredContent = {
42
71
  */
43
72
  checkoutUrl: string;
44
73
  confirmationUrl?: string;
45
- plans?: LimitPlanSummary[];
46
74
  balance?: LimitActivationBalance;
47
75
  /** Rich product context from checkLimits (name, ref, provider slug/id) */
48
76
  productDetails?: LimitActivationProduct;
49
- };
77
+ } & PaywallGateRecoveryFields);
50
78
 
51
79
  /**
52
80
  * Default-tree shim over the `CheckoutSummary` primitive.
@@ -203,6 +231,12 @@ declare const PaymentFormBusinessDetails: {
203
231
  readonly Country: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & {
204
232
  asChild?: boolean;
205
233
  } & React.RefAttributes<HTMLSelectElement>>;
234
+ readonly State: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
235
+ asChild?: boolean;
236
+ } & React.RefAttributes<HTMLInputElement>>;
237
+ readonly PostalCode: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
238
+ asChild?: boolean;
239
+ } & React.RefAttributes<HTMLInputElement>>;
206
240
  readonly TaxId: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
207
241
  asChild?: boolean;
208
242
  } & React.RefAttributes<HTMLInputElement>>;
@@ -260,6 +294,12 @@ declare const PaymentForm: {
260
294
  readonly Country: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & {
261
295
  asChild?: boolean;
262
296
  } & React.RefAttributes<HTMLSelectElement>>;
297
+ readonly State: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
298
+ asChild?: boolean;
299
+ } & React.RefAttributes<HTMLInputElement>>;
300
+ readonly PostalCode: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
301
+ asChild?: boolean;
302
+ } & React.RefAttributes<HTMLInputElement>>;
263
303
  readonly TaxId: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
264
304
  asChild?: boolean;
265
305
  } & React.RefAttributes<HTMLInputElement>>;
@@ -568,39 +608,6 @@ declare function configToAutoRechargeInput(config: AutoRechargeConfig, options?:
568
608
  };
569
609
  }): AutoRechargeInput | null;
570
610
 
571
- interface UseUsageReturn {
572
- /** Raw usage snapshot (`null` when no usage-based plan is active). */
573
- usage: UsageSnapshot | null;
574
- loading: boolean;
575
- error: Error | null;
576
- refetch: () => Promise<void>;
577
- /** 0-100, rounded to 2dp. `null` when total is unknown (unlimited/empty). */
578
- percentUsed: number | null;
579
- /** Plan is usage-based, `percentUsed >= 80`. */
580
- isApproachingLimit: boolean;
581
- /** Plan is usage-based, `percentUsed >= 100`. */
582
- isAtLimit: boolean;
583
- /**
584
- * True when the backend reports no finite cap on this meter. Sourced
585
- * from `useLimits().unlimited`, never inferred from a missing `total`
586
- * — an unknown cap is not an absent one.
587
- */
588
- isUnlimited: boolean;
589
- /** The meter reference (e.g. `'tokens'`). `null` when not usage-based. */
590
- meterRef: string | null;
591
- }
592
- interface UsageSnapshot {
593
- meterRef: string | null;
594
- total: number | null;
595
- used: number;
596
- remaining: number | null;
597
- percentUsed: number | null;
598
- periodStart?: string;
599
- periodEnd?: string;
600
- purchaseRef?: string;
601
- }
602
- declare function useUsage(): UseUsageReturn;
603
-
604
611
  type CheckoutStatus = 'idle' | 'activating' | 'paying' | 'error';
605
612
  type CheckoutErrorPhase = 'activate' | 'pay';
606
613
  interface UseCheckoutFlowOptions {
@@ -832,4 +839,4 @@ declare const CheckoutStepsBackLink: React.ForwardRefExoticComponent<Omit<React.
832
839
  } & React.RefAttributes<HTMLButtonElement>>;
833
840
  declare const CheckoutStepsSuccess: typeof Success;
834
841
 
835
- export { CheckoutStepsPayment as $, type AutoRechargeInputPayload as A, BalanceBadge as B, type CheckoutVariant as C, configToAutoRechargeInput as D, deriveVariant as E, useCheckoutFlow as F, useCheckoutSteps as G, useUsage as H, type AmountInputUnit as I, type AutoRechargeFormState as J, ActivationFlow as K, ActivationFlowActivateButton as L, MandateText as M, ActivationFlowActivated as N, ActivationFlowAmountPicker as O, PaymentFormSummary as P, ActivationFlowContinueButton as Q, ActivationFlowError as R, ActivationFlowLoading as S, ActivationFlowRetrying as T, type UsageSnapshot as U, ActivationFlowRoot as V, ActivationFlowSummary as W, CheckoutStepsAmountContinueButton as X, CheckoutStepsAmountPicker as Y, CheckoutStepsBackLink as Z, CheckoutStepsIfStep as _, PaymentFormCustomerFields as a, CheckoutStepsPlanContinueButton as a0, CheckoutStepsPlanGrid as a1, CheckoutStepsRoot as a2, CheckoutStepsStepHeading as a3, CheckoutStepsStepMessage as a4, CheckoutStepsSuccess as a5, PaymentForm as a6, PaymentFormRoot as a7, PurchaseGateAllowed as a8, PurchaseGateBlocked as a9, PurchaseGateError as aa, PurchaseGateLoading as ab, PurchaseGateRoot as ac, useActivationFlow as ad, usePurchaseGate as ae, PaymentFormPaymentElement as b, PaymentFormCardElement as c, PaymentFormMandateText as d, PaymentFormTermsCheckbox as e, PaymentFormSubmitButton as f, PaymentFormLoading as g, PaymentFormError as h, PaymentFormLegalFooter as i, PaymentFormBusinessDetails as j, PaymentFormTaxSummary as k, type PaywallStructuredContent as l, type ActivationFlowStep as m, CancelPlanButton as n, type CheckoutErrorPhase as o, type CheckoutStatus as p, CheckoutSteps as q, CheckoutSummary as r, type CheckoutSummaryProps as s, type MandateTextProps as t, PlanBadge as u, ProductBadge as v, PurchaseGate as w, type UseCheckoutFlowOptions as x, type UseCheckoutFlowReturn as y, type UseUsageReturn as z };
842
+ export { CheckoutStepsRoot as $, type AutoRechargeInputPayload as A, BalanceBadge as B, type CheckoutVariant as C, useCheckoutFlow as D, useCheckoutSteps as E, type AmountInputUnit as F, type AutoRechargeFormState as G, ActivationFlow as H, ActivationFlowActivateButton as I, ActivationFlowActivated as J, ActivationFlowAmountPicker as K, ActivationFlowContinueButton as L, MandateText as M, ActivationFlowError as N, ActivationFlowLoading as O, PaymentFormSummary as P, ActivationFlowRetrying as Q, ActivationFlowRoot as R, ActivationFlowSummary as S, CheckoutStepsAmountContinueButton as T, type UseCheckoutFlowOptions as U, CheckoutStepsAmountPicker as V, CheckoutStepsBackLink as W, CheckoutStepsIfStep as X, CheckoutStepsPayment as Y, CheckoutStepsPlanContinueButton as Z, CheckoutStepsPlanGrid as _, PaymentFormCustomerFields as a, CheckoutStepsStepHeading as a0, CheckoutStepsStepMessage as a1, CheckoutStepsSuccess as a2, PaymentForm as a3, PaymentFormRoot as a4, PurchaseGateAllowed as a5, PurchaseGateBlocked as a6, PurchaseGateError as a7, PurchaseGateLoading as a8, PurchaseGateRoot as a9, useActivationFlow as aa, usePurchaseGate as ab, PaymentFormPaymentElement as b, PaymentFormCardElement as c, PaymentFormMandateText as d, PaymentFormTermsCheckbox as e, PaymentFormSubmitButton as f, PaymentFormLoading as g, PaymentFormError as h, PaymentFormLegalFooter as i, PaymentFormBusinessDetails as j, PaymentFormTaxSummary as k, type PaywallStructuredContent as l, type ActivationFlowStep as m, CancelPlanButton as n, type CheckoutErrorPhase as o, type CheckoutStatus as p, CheckoutSteps as q, CheckoutSummary as r, type CheckoutSummaryProps as s, type MandateTextProps as t, PlanBadge as u, ProductBadge as v, PurchaseGate as w, type UseCheckoutFlowReturn as x, configToAutoRechargeInput as y, deriveVariant as z };