@solvapay/react 1.0.6 → 1.0.9-preview.1

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.ts CHANGED
@@ -1,17 +1,16 @@
1
1
  import React$1 from 'react';
2
+ import * as _stripe_stripe_js from '@stripe/stripe-js';
2
3
  import { PaymentIntent, Stripe } from '@stripe/stripe-js';
3
- import { ProcessPaymentResult } from '@solvapay/server';
4
+ import { ProcessPaymentResult, ActivatePlanResult } from '@solvapay/server';
5
+ export { ActivatePlanResult } from '@solvapay/server';
4
6
  import { AuthAdapter } from './adapters/auth.js';
5
7
  export { defaultAuthAdapter } from './adapters/auth.js';
6
-
7
- /**
8
- * TypeScript type definitions for @solvapay/react
9
- */
8
+ import * as react_jsx_runtime from 'react/jsx-runtime';
10
9
 
11
10
  interface PurchaseInfo {
12
11
  reference: string;
13
12
  productName: string;
14
- productReference?: string;
13
+ productRef?: string;
15
14
  status: string;
16
15
  startDate: string;
17
16
  endDate?: string;
@@ -23,13 +22,14 @@ interface PurchaseInfo {
23
22
  isRecurring?: boolean;
24
23
  nextBillingDate?: string;
25
24
  billingCycle?: string;
26
- transactionId?: string;
25
+ planRef?: string;
27
26
  planSnapshot?: {
28
27
  reference?: string;
29
- meterId?: string;
28
+ price?: number;
29
+ meterRef?: string;
30
30
  limit?: number;
31
31
  freeUnits?: number;
32
- pricePerUnit?: number;
32
+ creditsPerUnit?: number;
33
33
  planType?: string;
34
34
  billingCycle?: string | null;
35
35
  features?: Record<string, unknown> | null;
@@ -54,8 +54,40 @@ interface PaymentIntentResult {
54
54
  accountId?: string;
55
55
  customerRef?: string;
56
56
  }
57
+ interface TopupPaymentResult {
58
+ clientSecret: string;
59
+ publishableKey: string;
60
+ accountId?: string;
61
+ customerRef?: string;
62
+ }
63
+ interface UseTopupOptions {
64
+ amount: number;
65
+ currency?: string;
66
+ }
67
+ interface UseTopupReturn {
68
+ loading: boolean;
69
+ error: Error | null;
70
+ stripePromise: Promise<_stripe_stripe_js.Stripe | null> | null;
71
+ clientSecret: string | null;
72
+ startTopup: () => Promise<void>;
73
+ reset: () => void;
74
+ }
75
+ interface TopupFormProps {
76
+ amount: number;
77
+ currency?: string;
78
+ onSuccess?: (paymentIntent: PaymentIntent) => void;
79
+ onError?: (error: Error) => void;
80
+ returnUrl?: string;
81
+ submitButtonText?: string;
82
+ className?: string;
83
+ buttonClassName?: string;
84
+ }
57
85
  interface PurchaseStatus {
58
86
  loading: boolean;
87
+ /** True when data already exists but a background refetch is in progress */
88
+ isRefetching: boolean;
89
+ /** Last fetch error, or null if the most recent fetch succeeded */
90
+ error: Error | null;
59
91
  customerRef?: string;
60
92
  email?: string;
61
93
  name?: string;
@@ -86,6 +118,15 @@ interface PurchaseStatus {
86
118
  * SolvaPay Provider Configuration
87
119
  * Sensible defaults for minimal code, but fully customizable
88
120
  */
121
+ interface BalanceStatus {
122
+ loading: boolean;
123
+ credits: number | null;
124
+ displayCurrency: string | null;
125
+ creditsPerMinorUnit: number | null;
126
+ displayExchangeRate: number | null;
127
+ refetch: () => Promise<void>;
128
+ adjustBalance: (credits: number) => void;
129
+ }
89
130
  interface SolvaPayConfig {
90
131
  /**
91
132
  * API route configuration
@@ -95,6 +136,12 @@ interface SolvaPayConfig {
95
136
  checkPurchase?: string;
96
137
  createPayment?: string;
97
138
  processPayment?: string;
139
+ createTopupPayment?: string;
140
+ customerBalance?: string;
141
+ cancelRenewal?: string;
142
+ reactivateRenewal?: string;
143
+ activatePlan?: string;
144
+ listPlans?: string;
98
145
  };
99
146
  /**
100
147
  * Authentication configuration
@@ -149,11 +196,23 @@ interface SolvaPayConfig {
149
196
  */
150
197
  onError?: (error: Error, context: string) => void;
151
198
  }
199
+ interface CancelResult {
200
+ reference?: string;
201
+ status?: string;
202
+ cancelledAt?: string;
203
+ [key: string]: unknown;
204
+ }
205
+ interface ReactivateResult {
206
+ reference?: string;
207
+ status?: string;
208
+ [key: string]: unknown;
209
+ }
210
+
152
211
  interface SolvaPayContextValue {
153
212
  purchase: PurchaseStatus;
154
213
  refetchPurchase: () => Promise<void>;
155
214
  createPayment: (params: {
156
- planRef: string;
215
+ planRef?: string;
157
216
  productRef?: string;
158
217
  }) => Promise<PaymentIntentResult>;
159
218
  processPayment?: (params: {
@@ -161,8 +220,26 @@ interface SolvaPayContextValue {
161
220
  productRef: string;
162
221
  planRef?: string;
163
222
  }) => Promise<ProcessPaymentResult>;
223
+ createTopupPayment: (params: {
224
+ amount: number;
225
+ currency?: string;
226
+ }) => Promise<TopupPaymentResult>;
227
+ cancelRenewal: (params: {
228
+ purchaseRef: string;
229
+ reason?: string;
230
+ }) => Promise<CancelResult>;
231
+ reactivateRenewal: (params: {
232
+ purchaseRef: string;
233
+ }) => Promise<ReactivateResult>;
234
+ activatePlan: (params: {
235
+ productRef: string;
236
+ planRef: string;
237
+ }) => Promise<ActivatePlanResult>;
164
238
  customerRef?: string;
165
239
  updateCustomerRef?: (newCustomerRef: string) => void;
240
+ balance: BalanceStatus;
241
+ /** @internal Provider config — used by SDK hooks, not part of public API */
242
+ _config?: SolvaPayConfig;
166
243
  }
167
244
  interface SolvaPayProviderProps {
168
245
  /**
@@ -175,7 +252,7 @@ interface SolvaPayProviderProps {
175
252
  * Use only if you need custom logic beyond standard API routes
176
253
  */
177
254
  createPayment?: (params: {
178
- planRef: string;
255
+ planRef?: string;
179
256
  productRef?: string;
180
257
  }) => Promise<PaymentIntentResult>;
181
258
  checkPurchase?: () => Promise<CustomerPurchaseData>;
@@ -184,6 +261,10 @@ interface SolvaPayProviderProps {
184
261
  productRef: string;
185
262
  planRef?: string;
186
263
  }) => Promise<ProcessPaymentResult>;
264
+ createTopupPayment?: (params: {
265
+ amount: number;
266
+ currency?: string;
267
+ }) => Promise<TopupPaymentResult>;
187
268
  children: React.ReactNode;
188
269
  }
189
270
  interface ProductBadgeProps {
@@ -218,15 +299,39 @@ interface PaymentError extends Error {
218
299
  type?: string;
219
300
  }
220
301
  /**
221
- * Plan interface for plans
302
+ * Plan returned by the SolvaPay API.
303
+ *
304
+ * All fields are optional except `reference` so the type stays compatible
305
+ * with partial JSON responses from custom fetcher functions.
222
306
  */
223
307
  interface Plan {
308
+ type?: 'recurring' | 'one-time' | 'usage-based';
224
309
  reference: string;
310
+ name?: string;
311
+ description?: string;
225
312
  price?: number;
226
313
  currency?: string;
314
+ currencySymbol?: string;
315
+ freeUnits?: number;
316
+ setupFee?: number;
317
+ trialDays?: number;
318
+ billingCycle?: string;
319
+ billingModel?: 'pre-paid' | 'post-paid';
320
+ creditsPerUnit?: number;
321
+ measures?: string;
322
+ limit?: number;
323
+ rolloverUnusedUnits?: boolean;
324
+ limits?: Record<string, unknown>;
325
+ features?: Record<string, unknown> | string[];
326
+ requiresPayment?: boolean;
327
+ default?: boolean;
328
+ isActive?: boolean;
329
+ maxActiveUsers?: number;
330
+ accessExpiryDays?: number;
331
+ status?: string;
332
+ createdAt?: string;
333
+ updatedAt?: string;
227
334
  interval?: string;
228
- features?: string[];
229
- isFreeTier?: boolean;
230
335
  metadata?: Record<string, unknown>;
231
336
  }
232
337
  /**
@@ -242,9 +347,10 @@ interface UsePlansOptions {
242
347
  */
243
348
  productRef?: string;
244
349
  /**
245
- * Optional filter function to filter plans
350
+ * Optional filter function to filter plans.
351
+ * Receives plan and its index (after sorting, if sortBy is provided).
246
352
  */
247
- filter?: (plan: Plan) => boolean;
353
+ filter?: (plan: Plan, index: number) => boolean;
248
354
  /**
249
355
  * Optional sort function to sort plans
250
356
  */
@@ -253,6 +359,18 @@ interface UsePlansOptions {
253
359
  * Auto-select first paid plan on load
254
360
  */
255
361
  autoSelectFirstPaid?: boolean;
362
+ /**
363
+ * Plan reference to select initially when plans load.
364
+ * Applied at most once when selectionReady is true.
365
+ * Takes priority over autoSelectFirstPaid.
366
+ */
367
+ initialPlanRef?: string;
368
+ /**
369
+ * When false, plans still fetch but auto-selection is deferred.
370
+ * When it transitions to true, one-shot initial selection fires.
371
+ * Defaults to true.
372
+ */
373
+ selectionReady?: boolean;
256
374
  }
257
375
  /**
258
376
  * Return type for usePlans hook
@@ -266,6 +384,8 @@ interface UsePlansReturn {
266
384
  setSelectedPlanIndex: (index: number) => void;
267
385
  selectPlan: (planRef: string) => void;
268
386
  refetch: () => Promise<void>;
387
+ /** True after the one-shot initial selection has been applied */
388
+ isSelectionReady: boolean;
269
389
  }
270
390
  /**
271
391
  * Props for headless PricingSelector component
@@ -282,7 +402,7 @@ interface PricingSelectorProps {
282
402
  /**
283
403
  * Optional filter function
284
404
  */
285
- filter?: (plan: Plan) => boolean;
405
+ filter?: (plan: Plan, index: number) => boolean;
286
406
  /**
287
407
  * Optional sort function
288
408
  */
@@ -336,12 +456,14 @@ interface PurchaseStatusReturn {
336
456
  */
337
457
  interface PaymentFormProps {
338
458
  /**
339
- * Plan reference to checkout. PaymentForm handles the entire checkout flow internally
340
- * including Stripe initialization and payment intent creation.
459
+ * Plan reference to checkout. When omitted, the SDK auto-resolves the plan from
460
+ * productRef (requires exactly one active plan or a default plan). Pass explicitly
461
+ * when the product has multiple plans without a default.
341
462
  */
342
- planRef: string;
463
+ planRef?: string;
343
464
  /**
344
- * Product reference. Required for processing payment after confirmation.
465
+ * Product reference. Required when planRef is omitted (for plan resolution)
466
+ * and for processing payment after confirmation.
345
467
  */
346
468
  productRef?: string;
347
469
  /**
@@ -369,6 +491,33 @@ interface PaymentFormProps {
369
491
  */
370
492
  buttonClassName?: string;
371
493
  }
494
+ interface BalanceBadgeProps {
495
+ className?: string;
496
+ numberOnly?: boolean;
497
+ children?: (props: {
498
+ credits: number | null;
499
+ loading: boolean;
500
+ displayCurrency: string | null;
501
+ creditsPerMinorUnit: number | null;
502
+ }) => React.ReactNode;
503
+ }
504
+ interface UseTopupAmountSelectorOptions {
505
+ currency: string;
506
+ minAmount?: number;
507
+ maxAmount?: number;
508
+ }
509
+ interface UseTopupAmountSelectorReturn {
510
+ quickAmounts: number[];
511
+ selectedAmount: number | null;
512
+ customAmount: string;
513
+ resolvedAmount: number | null;
514
+ selectQuickAmount: (amount: number) => void;
515
+ setCustomAmount: (value: string) => void;
516
+ error: string | null;
517
+ validate: () => boolean;
518
+ reset: () => void;
519
+ currencySymbol: string;
520
+ }
372
521
  type PurchaseStatusValue = 'pending' | 'active' | 'trialing' | 'past_due' | 'cancelled' | 'expired' | 'suspended' | 'refunded';
373
522
 
374
523
  /**
@@ -459,16 +608,13 @@ declare const SolvaPayProvider: React$1.FC<SolvaPayProviderProps>;
459
608
  * including card input, plan selection, and payment processing. It handles
460
609
  * the entire checkout flow including payment intent creation and confirmation.
461
610
  *
462
- * Features:
463
- * - Automatic Stripe Elements initialization
464
- * - Payment intent creation on mount
465
- * - Card input and validation
466
- * - Payment processing with error handling
467
- * - Automatic purchase refresh after payment
611
+ * When `planRef` is omitted but `productRef` is provided, the component
612
+ * auto-resolves the plan by fetching the product's plans and selecting the
613
+ * single active plan or the one marked as default.
468
614
  *
469
615
  * @param props - Payment form configuration
470
- * @param props.planRef - Plan reference to purchase (required)
471
- * @param props.productRef - Product reference for usage tracking
616
+ * @param props.planRef - Plan reference (optional if product has single/default plan)
617
+ * @param props.productRef - Product reference (required when planRef is omitted)
472
618
  * @param props.onSuccess - Callback when payment succeeds
473
619
  * @param props.onError - Callback when payment fails
474
620
  * @param props.returnUrl - Optional return URL after payment (for redirects)
@@ -478,34 +624,25 @@ declare const SolvaPayProvider: React$1.FC<SolvaPayProviderProps>;
478
624
  *
479
625
  * @example
480
626
  * ```tsx
481
- * import { PaymentForm } from '@solvapay/react';
482
- * import { useRouter } from 'next/navigation';
483
- *
484
- * function CheckoutPage() {
485
- * const router = useRouter();
627
+ * // Explicit plan
628
+ * <PaymentForm planRef="pln_premium" productRef="prd_myapi" onSuccess={...} />
486
629
  *
487
- * return (
488
- * <PaymentForm
489
- * planRef="pln_premium"
490
- * productRef="prd_myapi"
491
- * onSuccess={() => {
492
- * console.log('Payment successful!');
493
- * router.push('/dashboard');
494
- * }}
495
- * onError={(error) => {
496
- * console.error('Payment failed:', error);
497
- * }}
498
- * />
499
- * );
500
- * }
630
+ * // Auto-resolve plan (product must have exactly one plan or a default)
631
+ * <PaymentForm productRef="prd_myapi" onSuccess={...} />
501
632
  * ```
502
- *
503
- * @see {@link useCheckout} for programmatic checkout handling
504
- * @see {@link SolvaPayProvider} for required context provider
505
- * @since 1.0.0
506
633
  */
507
634
  declare const PaymentForm: React$1.FC<PaymentFormProps>;
508
635
 
636
+ /**
637
+ * Credit top-up form with Stripe Elements.
638
+ *
639
+ * Unlike `PaymentForm`, this component does **not** call `processPayment`
640
+ * after Stripe confirmation. Credits are recorded via the backend webhook
641
+ * handler (`CreditService.recordCredit`), so `onSuccess` is called
642
+ * immediately after `stripe.confirmCardPayment` succeeds.
643
+ */
644
+ declare const TopupForm: React$1.FC<TopupFormProps>;
645
+
509
646
  /**
510
647
  * Headless Product Badge Component
511
648
  *
@@ -626,6 +763,8 @@ interface StripePaymentFormWrapperProps {
626
763
  */
627
764
  declare const StripePaymentFormWrapper: React$1.FC<StripePaymentFormWrapperProps>;
628
765
 
766
+ declare function BalanceBadge({ className, numberOnly, children }: BalanceBadgeProps): react_jsx_runtime.JSX.Element | null;
767
+
629
768
  /**
630
769
  * Hook to get current purchase status and information.
631
770
  *
@@ -719,60 +858,33 @@ interface UseCheckoutReturn {
719
858
  error: Error | null;
720
859
  stripePromise: Promise<Stripe | null> | null;
721
860
  clientSecret: string | null;
861
+ resolvedPlanRef: string | null;
722
862
  startCheckout: () => Promise<void>;
723
863
  reset: () => void;
724
864
  }
725
865
  /**
726
866
  * Hook to manage checkout flow for payment processing.
727
867
  *
728
- * Handles payment intent creation and Stripe initialization. This hook
729
- * manages the checkout state including loading, errors, Stripe instance,
730
- * and client secret. Use this for programmatic checkout flows.
868
+ * Handles payment intent creation and Stripe initialization. When `planRef`
869
+ * is omitted but `productRef` is provided, the hook auto-resolves the plan
870
+ * by fetching the product's plans and selecting the single/default one.
731
871
  *
732
872
  * @param options - Checkout options
733
- * @param options.planRef - Plan reference to purchase (required)
734
- * @param options.productRef - Optional product reference for usage tracking
873
+ * @param options.planRef - Plan reference (optional if product has single/default plan)
874
+ * @param options.productRef - Product reference (required when planRef is omitted)
735
875
  * @returns Checkout state and methods
736
- * @returns loading - Whether checkout is in progress
737
- * @returns error - Error state if checkout fails
738
- * @returns stripePromise - Promise resolving to Stripe instance
739
- * @returns clientSecret - Stripe payment intent client secret
740
- * @returns startCheckout - Function to start the checkout process
741
- * @returns reset - Function to reset checkout state
742
876
  *
743
877
  * @example
744
878
  * ```tsx
745
- * import { useCheckout } from '@solvapay/react';
746
- * import { PaymentElement } from '@stripe/react-stripe-js';
747
- *
748
- * function CustomCheckout() {
749
- * const { loading, error, stripePromise, clientSecret, startCheckout } = useCheckout({
750
- * planRef: 'pln_premium',
751
- * productRef: 'prd_myapi',
752
- * });
753
- *
754
- * useEffect(() => {
755
- * startCheckout();
756
- * }, []);
757
- *
758
- * if (loading) return <Spinner />;
759
- * if (error) return <div>Error: {error.message}</div>;
760
- * if (!clientSecret || !stripePromise) return null;
879
+ * // Explicit planRef (no resolution needed)
880
+ * const checkout = useCheckout({ planRef: 'pln_premium', productRef: 'prd_myapi' })
761
881
  *
762
- * return (
763
- * <Elements stripe={await stripePromise} options={{ clientSecret }}>
764
- * <PaymentElement />
765
- * </Elements>
766
- * );
767
- * }
882
+ * // Auto-resolve plan from product (single plan or default plan)
883
+ * const checkout = useCheckout({ productRef: 'prd_myapi' })
768
884
  * ```
769
- *
770
- * @see {@link PaymentForm} for a complete payment form component
771
- * @see {@link SolvaPayProvider} for required context provider
772
- * @since 1.0.0
773
885
  */
774
886
  declare function useCheckout(options: {
775
- planRef: string;
887
+ planRef?: string;
776
888
  productRef?: string;
777
889
  }): UseCheckoutReturn;
778
890
 
@@ -820,29 +932,13 @@ declare function useCheckout(options: {
820
932
  declare function useSolvaPay(): SolvaPayContextValue;
821
933
 
822
934
  /**
823
- * Hook to manage plan fetching and selection
935
+ * Hook to manage plan fetching and selection.
824
936
  *
825
- * Provides a reusable way to fetch, filter, sort and select plans.
826
- * Handles loading and error states automatically.
827
- * Uses a global cache to prevent duplicate fetches when multiple components use the same productRef.
828
- *
829
- * @example
830
- * ```tsx
831
- * const plans = usePlans({
832
- * productRef: 'prd_123',
833
- * fetcher: async (productRef) => {
834
- * const res = await fetch(`/api/list-plans?productRef=${productRef}`);
835
- * const data = await res.json();
836
- * return data.plans;
837
- * },
838
- * sortBy: (a, b) => (a.price || 0) - (b.price || 0),
839
- * autoSelectFirstPaid: true,
840
- * });
841
- *
842
- * // Use in component
843
- * if (plans.loading) return <div>Loading...</div>;
844
- * if (plans.error) return <div>Error: {plans.error.message}</div>;
845
- * ```
937
+ * Selection lifecycle:
938
+ * 1. While `selectionReady` is false, plans fetch but no auto-selection fires.
939
+ * 2. When `selectionReady` becomes true AND plans are loaded, one-shot initial
940
+ * selection is applied (initialPlanRef > autoSelectFirstPaid > index 0).
941
+ * 3. After initial selection, user picks always win — the hook never overrides.
846
942
  */
847
943
  declare function usePlans(options: UsePlansOptions): UsePlansReturn;
848
944
 
@@ -864,6 +960,113 @@ declare function usePlans(options: UsePlansOptions): UsePlansReturn;
864
960
  */
865
961
  declare function usePurchaseStatus(): PurchaseStatusReturn;
866
962
 
963
+ interface PurchaseActions {
964
+ cancelRenewal: (params: {
965
+ purchaseRef: string;
966
+ reason?: string;
967
+ }) => Promise<CancelResult>;
968
+ reactivateRenewal: (params: {
969
+ purchaseRef: string;
970
+ }) => Promise<ReactivateResult>;
971
+ activatePlan: (params: {
972
+ productRef: string;
973
+ planRef: string;
974
+ }) => Promise<ActivatePlanResult>;
975
+ isCancelling: boolean;
976
+ isReactivating: boolean;
977
+ isActivating: boolean;
978
+ }
979
+ /**
980
+ * Hook for purchase lifecycle mutations: cancel, reactivate, and activate.
981
+ *
982
+ * Wraps the context methods with per-operation loading states.
983
+ * Auto-refetches purchase data on success (handled by the context methods).
984
+ *
985
+ * @example
986
+ * ```tsx
987
+ * const { cancelRenewal, reactivateRenewal, isCancelling } = usePurchaseActions()
988
+ *
989
+ * await cancelRenewal({ purchaseRef: purchase.reference, reason: 'User requested' })
990
+ * ```
991
+ */
992
+ declare function usePurchaseActions(): PurchaseActions;
993
+
994
+ type ActivationState = 'idle' | 'activating' | 'activated' | 'topup_required' | 'payment_required' | 'error';
995
+ interface UseActivationReturn {
996
+ activate: (params: {
997
+ productRef: string;
998
+ planRef: string;
999
+ }) => Promise<void>;
1000
+ state: ActivationState;
1001
+ error: string | null;
1002
+ result: ActivatePlanResult | null;
1003
+ reset: () => void;
1004
+ }
1005
+ /**
1006
+ * State-machine hook for the plan activation flow.
1007
+ *
1008
+ * Wraps `activatePlan` from context and maps API response statuses
1009
+ * to discrete UI states: idle → activating → activated | topup_required | payment_required | error.
1010
+ *
1011
+ * Auto-refetches purchase data on successful activation (handled by context).
1012
+ *
1013
+ * @example
1014
+ * ```tsx
1015
+ * const { activate, state, error, reset } = useActivation()
1016
+ *
1017
+ * if (state === 'topup_required') return <TopupPrompt />
1018
+ * if (state === 'activated') return <SuccessMessage />
1019
+ *
1020
+ * <button onClick={() => activate({ productRef, planRef })} disabled={state === 'activating'}>
1021
+ * Activate
1022
+ * </button>
1023
+ * ```
1024
+ */
1025
+ declare function useActivation(): UseActivationReturn;
1026
+
1027
+ /**
1028
+ * Hook to manage credit top-up flow.
1029
+ *
1030
+ * Handles payment intent creation (with `purpose: 'credit_topup'`) and
1031
+ * Stripe initialization. Unlike `useCheckout`, there is no plan resolution
1032
+ * and no `processPayment` step — credits are recorded via webhook.
1033
+ *
1034
+ * @param options.amount - Amount in smallest currency unit (e.g. cents)
1035
+ * @param options.currency - ISO 4217 currency code (default: 'usd')
1036
+ */
1037
+ declare function useTopup(options: UseTopupOptions): UseTopupReturn;
1038
+
1039
+ /**
1040
+ * Hook to get the current customer's credits.
1041
+ *
1042
+ * Automatically fetches on mount and re-fetches when
1043
+ * authentication state changes (ensures credits load
1044
+ * even when auth resolves after initial render).
1045
+ *
1046
+ * @example
1047
+ * ```tsx
1048
+ * const { credits, displayCurrency, loading, refetch } = useBalance()
1049
+ * ```
1050
+ */
1051
+ declare function useBalance(): BalanceStatus;
1052
+
1053
+ /**
1054
+ * Headless hook for top-up amount selection.
1055
+ *
1056
+ * Manages quick-pick presets, custom input, mutual exclusivity, and validation.
1057
+ * Currency-aware: presets and symbol adjust based on the ISO 4217 code.
1058
+ *
1059
+ * @example
1060
+ * ```tsx
1061
+ * const {
1062
+ * quickAmounts, selectedAmount, customAmount,
1063
+ * resolvedAmount, selectQuickAmount, setCustomAmount,
1064
+ * error, validate, reset, currencySymbol,
1065
+ * } = useTopupAmountSelector({ currency: 'usd' })
1066
+ * ```
1067
+ */
1068
+ declare function useTopupAmountSelector(options: UseTopupAmountSelectorOptions): UseTopupAmountSelectorReturn;
1069
+
867
1070
  /**
868
1071
  * Purchase utility functions
869
1072
  *
@@ -921,4 +1124,4 @@ declare function getPrimaryPurchase(purchases: PurchaseInfo[]): PurchaseInfo | n
921
1124
  */
922
1125
  declare function isPaidPurchase(purchase: PurchaseInfo): boolean;
923
1126
 
924
- export { AuthAdapter, type CustomerInfo, type CustomerPurchaseData, type PaymentError, PaymentForm, type PaymentFormProps, type PaymentIntentResult, type Plan, PlanBadge, type PlanBadgeProps, PlanSelector, type PlanSelectorProps, PricingSelector, type PricingSelectorProps, ProductBadge, type ProductBadgeProps, PurchaseGate, type PurchaseGateProps, type PurchaseInfo, type PurchaseStatus, type PurchaseStatusReturn, type PurchaseStatusValue, type SolvaPayConfig, type SolvaPayContextValue, SolvaPayProvider, type SolvaPayProviderProps, Spinner, StripePaymentFormWrapper, type UsePlansOptions, type UsePlansReturn, filterPurchases, getActivePurchases, getCancelledPurchasesWithEndDate, getMostRecentPurchase, getPrimaryPurchase, isPaidPurchase, useCheckout, useCustomer, usePlans, usePurchase, usePurchaseStatus, useSolvaPay };
1127
+ export { type ActivationState, AuthAdapter, BalanceBadge, type BalanceBadgeProps, type BalanceStatus, type CancelResult, type CustomerInfo, type CustomerPurchaseData, type PaymentError, PaymentForm, type PaymentFormProps, type PaymentIntentResult, type Plan, PlanBadge, type PlanBadgeProps, PlanSelector, type PlanSelectorProps, PricingSelector, type PricingSelectorProps, ProductBadge, type ProductBadgeProps, type PurchaseActions, PurchaseGate, type PurchaseGateProps, type PurchaseInfo, type PurchaseStatus, type PurchaseStatusReturn, type PurchaseStatusValue, type ReactivateResult, type SolvaPayConfig, type SolvaPayContextValue, SolvaPayProvider, type SolvaPayProviderProps, Spinner, StripePaymentFormWrapper, TopupForm, type TopupFormProps, type TopupPaymentResult, type UseActivationReturn, type UsePlansOptions, type UsePlansReturn, type UseTopupAmountSelectorOptions, type UseTopupAmountSelectorReturn, type UseTopupOptions, type UseTopupReturn, filterPurchases, getActivePurchases, getCancelledPurchasesWithEndDate, getMostRecentPurchase, getPrimaryPurchase, isPaidPurchase, useActivation, useBalance, useCheckout, useCustomer, usePlans, usePurchase, usePurchaseActions, usePurchaseStatus, useSolvaPay, useTopup, useTopupAmountSelector };