@billingos/sdk 0.1.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.
@@ -0,0 +1,3346 @@
1
+ import { ClassProp } from 'class-variance-authority/types';
2
+ import { ClassValue } from 'clsx';
3
+ import { default as default_2 } from 'react';
4
+ import { FetchStatus } from '@tanstack/react-query';
5
+ import { JSX } from 'react/jsx-runtime';
6
+ import { QueryClient } from '@tanstack/react-query';
7
+ import { QueryObserverResult } from '@tanstack/react-query';
8
+ import * as React_2 from 'react';
9
+ import { RefetchOptions } from '@tanstack/react-query';
10
+ import { useQueryClient as useBillingOSQueryClient } from '@tanstack/react-query';
11
+ import { UseMutationOptions } from '@tanstack/react-query';
12
+ import { UseMutationResult } from '@tanstack/react-query';
13
+ import { UseQueryOptions } from '@tanstack/react-query';
14
+ import { UseQueryResult } from '@tanstack/react-query';
15
+ import { VariantProps } from 'class-variance-authority';
16
+
17
+ /**
18
+ * Add amounts together
19
+ * @param amounts - Array of amounts in cents
20
+ * @returns Sum in cents
21
+ *
22
+ * @example
23
+ * addAmounts([1000, 2000, 3000]) // 6000
24
+ */
25
+ export declare const addAmounts: (...amounts: number[]) => number;
26
+
27
+ /**
28
+ * Input for adding a payment method
29
+ */
30
+ export declare interface AddPaymentMethodInput {
31
+ paymentMethodId: string;
32
+ setAsDefault?: boolean;
33
+ }
34
+
35
+ export declare function AddPaymentMethodModal({ open, onOpenChange, onSuccess, clientSecret, stripePublishableKey, isLoading, }: AddPaymentMethodModalProps): JSX.Element;
36
+
37
+ declare interface AddPaymentMethodModalProps {
38
+ open: boolean;
39
+ onOpenChange: (open: boolean) => void;
40
+ onSuccess: (paymentMethodId: string, setAsDefault: boolean) => void;
41
+ clientSecret?: string;
42
+ stripePublishableKey?: string;
43
+ isLoading?: boolean;
44
+ }
45
+
46
+ /**
47
+ * Response for adding a payment method
48
+ */
49
+ export declare interface AddPaymentMethodResponse {
50
+ paymentMethod: PortalPaymentMethod;
51
+ }
52
+
53
+ export declare const Alert: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & VariantProps<(props?: ({
54
+ variant?: "success" | "default" | "destructive" | "warning" | null | undefined;
55
+ } & ClassProp) | undefined) => string> & React_2.RefAttributes<HTMLDivElement>>;
56
+
57
+ export declare const AlertDescription: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLParagraphElement> & React_2.RefAttributes<HTMLParagraphElement>>;
58
+
59
+ export declare const AlertTitle: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLHeadingElement> & React_2.RefAttributes<HTMLParagraphElement>>;
60
+
61
+ /**
62
+ * API error response
63
+ */
64
+ export declare interface APIErrorResponse {
65
+ error: {
66
+ message: string;
67
+ code?: string;
68
+ details?: unknown;
69
+ };
70
+ }
71
+
72
+ /**
73
+ * Available plan option
74
+ */
75
+ export declare interface AvailablePlan {
76
+ product_id: string;
77
+ product_name: string;
78
+ description: string | null;
79
+ price_id: string;
80
+ amount: number;
81
+ currency: string;
82
+ interval: string;
83
+ is_free: boolean;
84
+ }
85
+
86
+ /**
87
+ * Response from GET /subscriptions/:id/available-plans
88
+ */
89
+ export declare interface AvailablePlansResponse {
90
+ current_plan: {
91
+ product_id: string;
92
+ product_name: string;
93
+ price_id: string;
94
+ amount: number;
95
+ currency: string;
96
+ interval: string;
97
+ } | null;
98
+ available_upgrades: AvailablePlan[];
99
+ available_downgrades: AvailablePlan[];
100
+ restrictions: string[];
101
+ }
102
+
103
+ export declare function Badge({ className, variant, ...props }: BadgeProps): JSX.Element;
104
+
105
+ export declare interface BadgeProps extends React_2.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {
106
+ }
107
+
108
+ export declare const badgeVariants: (props?: ({
109
+ variant?: "success" | "default" | "destructive" | "warning" | "secondary" | "outline" | null | undefined;
110
+ } & ClassProp) | undefined) => string;
111
+
112
+ export declare function BannerNudge({ trigger, onUpgrade, onDismiss, }: BannerNudgeProps): JSX.Element;
113
+
114
+ export declare interface BannerNudgeProps {
115
+ trigger: NudgeTrigger;
116
+ onUpgrade: () => void;
117
+ onDismiss: () => void;
118
+ theme?: 'light' | 'dark';
119
+ }
120
+
121
+ /**
122
+ * Main BillingOS API client
123
+ */
124
+ export declare class BillingOSClient {
125
+ private sessionToken;
126
+ private baseUrl;
127
+ private headers;
128
+ private timeout;
129
+ constructor(sessionToken: string, options?: BillingOSClientOptions);
130
+ /**
131
+ * Internal method to make HTTP requests
132
+ */
133
+ private request;
134
+ /**
135
+ * GET request helper
136
+ */
137
+ get<T>(path: string): Promise<T>;
138
+ /**
139
+ * POST request helper
140
+ */
141
+ post<T>(path: string, body?: unknown): Promise<T>;
142
+ /**
143
+ * PATCH request helper
144
+ */
145
+ patch<T>(path: string, body?: unknown): Promise<T>;
146
+ /**
147
+ * DELETE request helper
148
+ */
149
+ delete<T>(path: string): Promise<T>;
150
+ /**
151
+ * Create a new customer
152
+ */
153
+ createCustomer(input: CreateCustomerInput): Promise<Customer>;
154
+ /**
155
+ * Get a customer by ID
156
+ */
157
+ getCustomer(id: string): Promise<Customer>;
158
+ /**
159
+ * List customers (paginated)
160
+ */
161
+ listCustomers(params?: {
162
+ page?: number;
163
+ page_size?: number;
164
+ }): Promise<PaginatedResponse<Customer>>;
165
+ /**
166
+ * Update a customer
167
+ */
168
+ updateCustomer(id: string, input: UpdateCustomerInput): Promise<Customer>;
169
+ /**
170
+ * Delete a customer
171
+ */
172
+ deleteCustomer(id: string): Promise<void>;
173
+ /**
174
+ * Create a new subscription
175
+ */
176
+ createSubscription(input: CreateSubscriptionInput): Promise<Subscription>;
177
+ /**
178
+ * Get a subscription by ID
179
+ */
180
+ getSubscription(id: string): Promise<Subscription>;
181
+ /**
182
+ * List subscriptions (paginated)
183
+ */
184
+ listSubscriptions(params?: {
185
+ customer_id?: string;
186
+ page?: number;
187
+ page_size?: number;
188
+ }): Promise<PaginatedResponse<Subscription>>;
189
+ /**
190
+ * Update a subscription
191
+ */
192
+ updateSubscription(id: string, input: UpdateSubscriptionInput): Promise<Subscription>;
193
+ /**
194
+ * Cancel a subscription
195
+ */
196
+ cancelSubscription(id: string, immediately?: boolean): Promise<Subscription>;
197
+ /**
198
+ * Reactivate a canceled subscription
199
+ */
200
+ reactivateSubscription(id: string): Promise<Subscription>;
201
+ /**
202
+ * Preview subscription changes
203
+ */
204
+ previewSubscription(id: string, input: UpdateSubscriptionInput): Promise<SubscriptionPreview>;
205
+ /**
206
+ * Get available plans for upgrade/downgrade
207
+ */
208
+ getAvailablePlans(subscriptionId: string): Promise<AvailablePlansResponse>;
209
+ /**
210
+ * Preview a plan change (upgrade/downgrade) with proration details
211
+ */
212
+ previewPlanChange(subscriptionId: string, input: PreviewChangeInput): Promise<PreviewChangeResponse>;
213
+ /**
214
+ * Execute a plan change (upgrade/downgrade)
215
+ */
216
+ changePlan(subscriptionId: string, input: ChangePlanInput): Promise<ChangePlanResponse>;
217
+ /**
218
+ * Check if a customer has access to a feature
219
+ * Customer ID is resolved server-side from session token
220
+ */
221
+ checkEntitlement(input: CheckEntitlementInput): Promise<Entitlement>;
222
+ /**
223
+ * List all entitlements for a customer
224
+ * Customer ID is resolved server-side from session token
225
+ */
226
+ listEntitlements(_customerId?: string): Promise<Entitlement[]>;
227
+ /**
228
+ * Track a usage event
229
+ * Customer ID is resolved server-side from session token
230
+ */
231
+ trackUsage(event: UsageEvent): Promise<void>;
232
+ /**
233
+ * Get usage metrics for a customer and feature
234
+ * Customer ID is resolved server-side from session token
235
+ */
236
+ getUsageMetrics(_customerId?: string, featureKey?: string): Promise<UsageMetrics>;
237
+ /**
238
+ * Get an invoice by ID
239
+ */
240
+ getInvoice(id: string): Promise<Invoice>;
241
+ /**
242
+ * List invoices for a customer
243
+ */
244
+ listInvoices(params?: {
245
+ customer_id?: string;
246
+ page?: number;
247
+ page_size?: number;
248
+ }): Promise<PaginatedResponse<Invoice>>;
249
+ /**
250
+ * List payment methods for a customer
251
+ */
252
+ listPaymentMethods(customerId: string): Promise<PaymentMethod[]>;
253
+ /**
254
+ * Remove a payment method
255
+ */
256
+ removePaymentMethod(id: string): Promise<void>;
257
+ /**
258
+ * Set default payment method
259
+ */
260
+ setDefaultPaymentMethod(id: string): Promise<void>;
261
+ /**
262
+ * Get all portal data for the current customer
263
+ */
264
+ getCustomerPortal(): Promise<CustomerPortalData>;
265
+ /**
266
+ * Update subscription (upgrade/downgrade)
267
+ */
268
+ updatePortalSubscription(subscriptionId: string, input: PortalUpdateSubscriptionInput): Promise<PortalUpdateSubscriptionResponse>;
269
+ /**
270
+ * Cancel subscription with feedback
271
+ */
272
+ cancelPortalSubscription(subscriptionId: string, input: PortalCancelSubscriptionInput): Promise<PortalCancelSubscriptionResponse>;
273
+ /**
274
+ * Reactivate a canceled subscription
275
+ */
276
+ reactivatePortalSubscription(subscriptionId: string): Promise<void>;
277
+ /**
278
+ * Add a payment method
279
+ */
280
+ addPaymentMethod(input: AddPaymentMethodInput): Promise<AddPaymentMethodResponse>;
281
+ /**
282
+ * Get setup intent for adding a new card
283
+ */
284
+ getSetupIntent(): Promise<SetupIntentResponse>;
285
+ /**
286
+ * Retry a failed invoice
287
+ */
288
+ retryInvoice(invoiceId: string, paymentMethodId?: string): Promise<RetryInvoiceResponse>;
289
+ /**
290
+ * Update customer billing information
291
+ */
292
+ updateCustomerBilling(input: UpdateCustomerBillingInput): Promise<CustomerBillingInfo>;
293
+ /**
294
+ * Create a checkout session for purchasing a subscription
295
+ */
296
+ createCheckout(input: CreateCheckoutInput): Promise<CreateCheckoutResponse>;
297
+ /**
298
+ * Confirm a checkout after payment is processed
299
+ */
300
+ confirmCheckout(clientSecret: string, paymentMethodId: string): Promise<ConfirmCheckoutResponse>;
301
+ /**
302
+ * Checkout API methods for iframe-based checkout modal
303
+ */
304
+ checkout: {
305
+ /**
306
+ * Create a checkout session for iframe-based checkout
307
+ */
308
+ createSession: (input: CreateCheckoutSessionInput) => Promise<CreateCheckoutSessionResponse>;
309
+ /**
310
+ * Get checkout session details
311
+ */
312
+ getSession: (sessionId: string) => Promise<CheckoutSessionDetails>;
313
+ /**
314
+ * Cancel a checkout session (not implemented in backend yet)
315
+ */
316
+ cancelSession: (_sessionId: string) => Promise<void>;
317
+ /**
318
+ * Confirm payment for a checkout session
319
+ */
320
+ confirmPayment: (clientSecret: string, paymentMethodId: string) => Promise<ConfirmCheckoutResponse>;
321
+ /**
322
+ * Apply coupon to a checkout session (not implemented in backend yet)
323
+ */
324
+ applyCoupon: (_sessionId: string, _couponCode: string) => Promise<CheckoutSessionDetails>;
325
+ };
326
+ /**
327
+ * Portal API methods for iframe-based customer portal
328
+ */
329
+ portal: {
330
+ /**
331
+ * Create a portal session for customer self-service
332
+ */
333
+ createSession: (input?: {
334
+ customerId?: string;
335
+ metadata?: Record<string, any>;
336
+ }) => Promise<{
337
+ id: string;
338
+ expiresAt: string;
339
+ }>;
340
+ /**
341
+ * Get portal session status
342
+ */
343
+ getSessionStatus: (sessionId: string) => Promise<{
344
+ isValid: boolean;
345
+ expiresAt?: string;
346
+ }>;
347
+ /**
348
+ * Get portal data for a session
349
+ */
350
+ getPortalData: (sessionId: string) => Promise<any>;
351
+ };
352
+ /**
353
+ * Get all products for the pricing table
354
+ * @param planIds - Optional array of plan IDs to filter
355
+ */
356
+ getProducts(planIds?: string[]): Promise<GetProductsResponse>;
357
+ /**
358
+ * Check usage and get nudge trigger if applicable
359
+ * Uses usage-metrics endpoint and computes nudge client-side
360
+ */
361
+ checkUsage(): Promise<UsageCheckResponse>;
362
+ }
363
+
364
+ /**
365
+ * Configuration options for the BillingOS client
366
+ */
367
+ export declare interface BillingOSClientOptions {
368
+ /**
369
+ * Base URL for the API (defaults to production)
370
+ */
371
+ baseUrl?: string;
372
+ /**
373
+ * Environment (production or sandbox)
374
+ */
375
+ environment?: 'production' | 'sandbox';
376
+ /**
377
+ * API version to use
378
+ */
379
+ version?: string;
380
+ /**
381
+ * Custom headers to include in all requests
382
+ */
383
+ headers?: Record<string, string>;
384
+ /**
385
+ * Timeout for requests in milliseconds
386
+ */
387
+ timeout?: number;
388
+ }
389
+
390
+ /**
391
+ * Context value provided by BillingOSProvider
392
+ */
393
+ export declare interface BillingOSContextValue {
394
+ /**
395
+ * The BillingOS API client instance
396
+ */
397
+ client: BillingOSClient;
398
+ /**
399
+ * Optional customer ID for the current user
400
+ */
401
+ customerId?: string;
402
+ /**
403
+ * Optional customer email
404
+ */
405
+ customerEmail?: string;
406
+ /**
407
+ * Optional customer name
408
+ */
409
+ customerName?: string;
410
+ /**
411
+ * Optional organization ID
412
+ */
413
+ organizationId?: string;
414
+ }
415
+
416
+ /**
417
+ * Base error class for all BillingOS SDK errors
418
+ */
419
+ export declare class BillingOSError extends Error {
420
+ status?: number | undefined;
421
+ data?: unknown | undefined;
422
+ constructor(message: string, status?: number | undefined, data?: unknown | undefined);
423
+ }
424
+
425
+ /**
426
+ * Provider component for BillingOS SDK
427
+ *
428
+ * Wraps your app and provides the BillingOS client to all hooks and components.
429
+ *
430
+ * @example
431
+ * Auto-fetch session token from endpoint:
432
+ * ```tsx
433
+ * import { BillingOSProvider } from '@billingos/sdk'
434
+ *
435
+ * function App() {
436
+ * return (
437
+ * <BillingOSProvider
438
+ * sessionTokenUrl="/api/billingos-session"
439
+ * customerId="customer_123"
440
+ * >
441
+ * <YourApp />
442
+ * </BillingOSProvider>
443
+ * )
444
+ * }
445
+ * ```
446
+ *
447
+ * @example
448
+ * Manually provide session token:
449
+ * ```tsx
450
+ * function App() {
451
+ * const [sessionToken, setSessionToken] = useState('bos_session_...')
452
+ *
453
+ * return (
454
+ * <BillingOSProvider sessionToken={sessionToken}>
455
+ * <YourApp />
456
+ * </BillingOSProvider>
457
+ * )
458
+ * }
459
+ * ```
460
+ */
461
+ export declare function BillingOSProvider({ sessionToken: manualSessionToken, sessionTokenUrl, sessionTokenOptions, customerId, customerEmail, customerName, organizationId, options, queryClient, children, }: BillingOSProviderProps): JSX.Element | null;
462
+
463
+ /**
464
+ * Props for BillingOSProvider
465
+ */
466
+ export declare interface BillingOSProviderProps {
467
+ /**
468
+ * Session token - can be provided directly OR fetched automatically from tokenUrl
469
+ * Use this when you already have a session token
470
+ */
471
+ sessionToken?: string;
472
+ /**
473
+ * URL to fetch session token from (e.g., /api/billingos-session)
474
+ * The SDK will automatically fetch and refresh the token
475
+ */
476
+ sessionTokenUrl?: string;
477
+ /**
478
+ * Session token options (auto-refresh settings, error handlers, etc.)
479
+ */
480
+ sessionTokenOptions?: Omit<UseSessionTokenOptions, 'token' | 'tokenUrl'>;
481
+ /**
482
+ * Optional customer ID for the current user
483
+ */
484
+ customerId?: string;
485
+ /**
486
+ * Optional customer email
487
+ */
488
+ customerEmail?: string;
489
+ /**
490
+ * Optional customer name
491
+ */
492
+ customerName?: string;
493
+ /**
494
+ * Optional organization ID
495
+ */
496
+ organizationId?: string;
497
+ /**
498
+ * Client configuration options
499
+ */
500
+ options?: BillingOSClientOptions;
501
+ /**
502
+ * Optional custom QueryClient instance
503
+ * If not provided, a default one will be created
504
+ */
505
+ queryClient?: QueryClient;
506
+ /**
507
+ * Child components
508
+ */
509
+ children: default_2.ReactNode;
510
+ }
511
+
512
+ export declare const Button: React_2.ForwardRefExoticComponent<ButtonProps & React_2.RefAttributes<HTMLButtonElement>>;
513
+
514
+ export declare interface ButtonProps extends React_2.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
515
+ asChild?: boolean;
516
+ }
517
+
518
+ export declare const buttonVariants: (props?: ({
519
+ variant?: "link" | "default" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
520
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
521
+ } & ClassProp) | undefined) => string;
522
+
523
+ /**
524
+ * Calculate percentage of an amount
525
+ * @param cents - Amount in cents
526
+ * @param percentage - Percentage (0-100)
527
+ * @returns Calculated amount in cents
528
+ *
529
+ * @example
530
+ * calculatePercentage(10000, 20) // 2000 (20% of $100)
531
+ */
532
+ export declare const calculatePercentage: (cents: number, percentage: number) => number;
533
+
534
+ export declare function CancelSubscriptionModal({ open, onOpenChange, periodEndDate, onConfirm, isCanceling, }: CancelSubscriptionModalProps): JSX.Element;
535
+
536
+ declare interface CancelSubscriptionModalProps {
537
+ open: boolean;
538
+ onOpenChange: (open: boolean) => void;
539
+ periodEndDate: string;
540
+ onConfirm: (input: PortalCancelSubscriptionInput) => void;
541
+ isCanceling?: boolean;
542
+ }
543
+
544
+ export declare const Card: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & React_2.RefAttributes<HTMLDivElement>>;
545
+
546
+ export declare const CardContent: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & React_2.RefAttributes<HTMLDivElement>>;
547
+
548
+ export declare const CardDescription: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & React_2.RefAttributes<HTMLDivElement>>;
549
+
550
+ export declare const CardFooter: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & React_2.RefAttributes<HTMLDivElement>>;
551
+
552
+ export declare const CardHeader: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & React_2.RefAttributes<HTMLDivElement>>;
553
+
554
+ export declare const CardTitle: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & React_2.RefAttributes<HTMLDivElement>>;
555
+
556
+ /**
557
+ * Effective timing for plan changes
558
+ */
559
+ export declare type ChangeEffectiveTiming = 'immediate' | 'period_end';
560
+
561
+ /**
562
+ * Input for changing a plan
563
+ */
564
+ export declare interface ChangePlanInput {
565
+ new_price_id: string;
566
+ confirm_amount?: number;
567
+ effective_date?: ChangeEffectiveTiming;
568
+ }
569
+
570
+ export declare function ChangePlanModal({ open, onOpenChange, subscriptionId, onSuccess, }: ChangePlanModalProps): JSX.Element;
571
+
572
+ declare interface ChangePlanModalProps {
573
+ open: boolean;
574
+ onOpenChange: (open: boolean) => void;
575
+ subscriptionId: string;
576
+ onSuccess?: () => void;
577
+ }
578
+
579
+ /**
580
+ * Response from POST /subscriptions/:id/change-plan
581
+ */
582
+ export declare interface ChangePlanResponse {
583
+ subscription: {
584
+ id: string;
585
+ status: string;
586
+ price_id: string;
587
+ current_period_end: string;
588
+ };
589
+ change: {
590
+ id: string;
591
+ from_price_id: string;
592
+ to_price_id: string;
593
+ change_type: ChangeType;
594
+ status: string;
595
+ effective_date: string;
596
+ };
597
+ invoice?: {
598
+ id: string;
599
+ amount_due: number;
600
+ status: string;
601
+ };
602
+ message: string;
603
+ }
604
+
605
+ /**
606
+ * Type of plan change
607
+ */
608
+ export declare type ChangeType = 'upgrade' | 'downgrade';
609
+
610
+ export declare const Checkbox: React_2.ForwardRefExoticComponent<CheckboxProps & React_2.RefAttributes<HTMLInputElement>>;
611
+
612
+ declare interface CheckboxProps extends Omit<React_2.InputHTMLAttributes<HTMLInputElement>, 'type'> {
613
+ onCheckedChange?: (checked: boolean) => void;
614
+ }
615
+
616
+ /**
617
+ * Input for checking entitlements
618
+ */
619
+ export declare interface CheckEntitlementInput {
620
+ customer_id: string;
621
+ feature_key: string;
622
+ }
623
+
624
+ /**
625
+ * Programmatic checkout API
626
+ */
627
+ export declare class CheckoutAPI {
628
+ private client?;
629
+ private container?;
630
+ private root?;
631
+ constructor(client?: BillingOSClient);
632
+ /**
633
+ * Open the checkout modal programmatically
634
+ */
635
+ open(options: CheckoutOpenOptions): Promise<{
636
+ success: boolean;
637
+ subscription?: Subscription;
638
+ error?: Error;
639
+ }>;
640
+ /**
641
+ * Close the checkout modal
642
+ */
643
+ close(): void;
644
+ }
645
+
646
+ /**
647
+ * Customer info for checkout
648
+ */
649
+ export declare interface CheckoutCustomer {
650
+ email: string;
651
+ name: string;
652
+ }
653
+
654
+ export declare function CheckoutModal({ open, onOpenChange, priceId, customer, couponCode, collectBillingAddress, existingSubscriptionId, metadata, theme, locale, onSuccess, onError, onCancel, debug }: CheckoutModalProps): JSX.Element;
655
+
656
+ export declare interface CheckoutModalProps {
657
+ /**
658
+ * Whether the modal is open
659
+ */
660
+ open: boolean;
661
+ /**
662
+ * Callback when the modal open state changes
663
+ */
664
+ onOpenChange: (open: boolean) => void;
665
+ /**
666
+ * The price ID to checkout
667
+ */
668
+ priceId: string;
669
+ /**
670
+ * Customer information to pre-populate
671
+ */
672
+ customer?: {
673
+ email?: string;
674
+ name?: string;
675
+ taxId?: string;
676
+ };
677
+ /**
678
+ * Coupon code to apply
679
+ */
680
+ couponCode?: string;
681
+ /**
682
+ * Whether to collect billing address
683
+ */
684
+ collectBillingAddress?: boolean;
685
+ /**
686
+ * Currency for the checkout (defaults to price currency)
687
+ */
688
+ currency?: string;
689
+ /**
690
+ * Existing subscription ID for upgrades/downgrades
691
+ */
692
+ existingSubscriptionId?: string;
693
+ /**
694
+ * Custom metadata to attach to the subscription
695
+ */
696
+ metadata?: Record<string, string>;
697
+ /**
698
+ * Theme for the checkout modal
699
+ */
700
+ theme?: 'light' | 'dark' | 'auto';
701
+ /**
702
+ * Locale for the checkout (e.g., 'en', 'es', 'fr')
703
+ */
704
+ locale?: string;
705
+ /**
706
+ * Success callback with the created subscription
707
+ */
708
+ onSuccess: (subscription: any) => void;
709
+ /**
710
+ * Error callback
711
+ */
712
+ onError?: (error: Error) => void;
713
+ /**
714
+ * Cancel callback when user closes without completing
715
+ */
716
+ onCancel?: () => void;
717
+ /**
718
+ * Debug mode for development
719
+ */
720
+ debug?: boolean;
721
+ }
722
+
723
+ /**
724
+ * Options for opening the checkout modal programmatically
725
+ */
726
+ export declare interface CheckoutOpenOptions {
727
+ /**
728
+ * The price ID to checkout
729
+ */
730
+ priceId: string;
731
+ /**
732
+ * Customer information to pre-populate
733
+ */
734
+ customer?: {
735
+ email?: string;
736
+ name?: string;
737
+ taxId?: string;
738
+ };
739
+ /**
740
+ * Coupon code to apply
741
+ */
742
+ couponCode?: string;
743
+ /**
744
+ * Whether to collect billing address
745
+ */
746
+ collectBillingAddress?: boolean;
747
+ /**
748
+ * Currency for the checkout (defaults to price currency)
749
+ */
750
+ currency?: string;
751
+ /**
752
+ * Existing subscription ID for upgrades/downgrades
753
+ */
754
+ existingSubscriptionId?: string;
755
+ /**
756
+ * Custom metadata to attach to the subscription
757
+ */
758
+ metadata?: Record<string, string>;
759
+ /**
760
+ * Theme for the checkout modal
761
+ */
762
+ theme?: 'light' | 'dark' | 'auto';
763
+ /**
764
+ * Locale for the checkout (e.g., 'en', 'es', 'fr')
765
+ */
766
+ locale?: string;
767
+ /**
768
+ * Success callback with the created subscription
769
+ */
770
+ onSuccess?: (subscription: Subscription) => void;
771
+ /**
772
+ * Error callback
773
+ */
774
+ onError?: (error: Error) => void;
775
+ /**
776
+ * Cancel callback when user closes without completing
777
+ */
778
+ onCancel?: () => void;
779
+ /**
780
+ * Debug mode for development
781
+ */
782
+ debug?: boolean;
783
+ /**
784
+ * Session token for authentication (if not using provider)
785
+ */
786
+ sessionToken?: string;
787
+ /**
788
+ * API base URL (if not using provider)
789
+ */
790
+ apiUrl?: string;
791
+ }
792
+
793
+ /**
794
+ * Product summary for checkout
795
+ */
796
+ export declare interface CheckoutProduct {
797
+ name: string;
798
+ interval: 'day' | 'week' | 'month' | 'year';
799
+ features: string[];
800
+ }
801
+
802
+ /**
803
+ * Proration details for subscription changes
804
+ */
805
+ export declare interface CheckoutProration {
806
+ credited: number;
807
+ charged: number;
808
+ total: number;
809
+ explanation: string;
810
+ }
811
+
812
+ /**
813
+ * Result from opening checkout
814
+ */
815
+ export declare interface CheckoutResult {
816
+ success: boolean;
817
+ subscription?: Subscription;
818
+ error?: Error;
819
+ }
820
+
821
+ /**
822
+ * Checkout session returned by the API
823
+ */
824
+ export declare interface CheckoutSession {
825
+ id: string;
826
+ clientSecret: string;
827
+ amount: number;
828
+ currency: string;
829
+ proration?: CheckoutProration;
830
+ product: CheckoutProduct;
831
+ customer: CheckoutCustomer;
832
+ stripeAccountId?: string;
833
+ }
834
+
835
+ /**
836
+ * Detailed checkout session information
837
+ */
838
+ export declare interface CheckoutSessionDetails {
839
+ id: string;
840
+ clientSecret: string;
841
+ amount: number;
842
+ currency: string;
843
+ priceId: string;
844
+ product: CheckoutProduct;
845
+ customer: CheckoutCustomer;
846
+ couponCode?: string;
847
+ discountAmount?: number;
848
+ taxAmount?: number;
849
+ totalAmount: number;
850
+ proration?: CheckoutProration;
851
+ status: 'pending' | 'processing' | 'completed' | 'failed' | 'expired';
852
+ expiresAt: string;
853
+ stripeAccountId?: string;
854
+ }
855
+
856
+ /**
857
+ * Utility function to merge Tailwind CSS classes
858
+ * Combines clsx for conditional classes with tailwind-merge for deduplication
859
+ */
860
+ export declare function cn(...inputs: ClassValue[]): string;
861
+
862
+ /**
863
+ * Compact upgrade prompt for inline use
864
+ */
865
+ export declare function CompactUpgradePrompt({ feature, onUpgradeClick, className, }: {
866
+ feature?: string;
867
+ onUpgradeClick?: () => void;
868
+ className?: string;
869
+ }): JSX.Element;
870
+
871
+ /**
872
+ * Compact usage display for inline use
873
+ */
874
+ export declare function CompactUsageDisplay({ featureKey, className, }: {
875
+ featureKey: string;
876
+ className?: string;
877
+ }): JSX.Element | null;
878
+
879
+ /**
880
+ * Input for confirming a checkout
881
+ */
882
+ export declare interface ConfirmCheckoutInput {
883
+ paymentMethodId: string;
884
+ }
885
+
886
+ /**
887
+ * Response from confirming a checkout
888
+ */
889
+ export declare interface ConfirmCheckoutResponse {
890
+ success: boolean;
891
+ subscriptionId: string;
892
+ status: 'active' | 'trialing';
893
+ message: string;
894
+ }
895
+
896
+ /**
897
+ * Convert cents to float (dollars)
898
+ * @param cents - Amount in cents
899
+ * @returns Amount in dollars as a float
900
+ *
901
+ * @example
902
+ * convertCentsToFloat(1050) // 10.5
903
+ */
904
+ export declare const convertCentsToFloat: (cents: number) => number;
905
+
906
+ /**
907
+ * Convert float (dollars) to cents
908
+ * @param amount - Amount in dollars
909
+ * @returns Amount in cents as an integer
910
+ *
911
+ * @example
912
+ * convertFloatToCents(10.5) // 1050
913
+ */
914
+ export declare const convertFloatToCents: (amount: number) => number;
915
+
916
+ /**
917
+ * Factory function to create a BillingOS client instance
918
+ */
919
+ export declare function createBillingOSClient(sessionToken: string, options?: BillingOSClientOptions): BillingOSClient;
920
+
921
+ /**
922
+ * Input for creating a checkout session
923
+ */
924
+ export declare interface CreateCheckoutInput {
925
+ priceId: string;
926
+ customerEmail?: string;
927
+ customerName?: string;
928
+ existingSubscriptionId?: string;
929
+ }
930
+
931
+ /**
932
+ * Response from creating a checkout session
933
+ * The API returns the checkout session directly
934
+ */
935
+ export declare type CreateCheckoutResponse = CheckoutSession;
936
+
937
+ /**
938
+ * Input for creating an iframe checkout session
939
+ */
940
+ export declare interface CreateCheckoutSessionInput {
941
+ priceId: string;
942
+ customer?: {
943
+ email?: string;
944
+ name?: string;
945
+ taxId?: string;
946
+ };
947
+ couponCode?: string;
948
+ metadata?: Record<string, string>;
949
+ existingSubscriptionId?: string;
950
+ mode?: 'embedded' | 'redirect';
951
+ successUrl?: string;
952
+ cancelUrl?: string;
953
+ }
954
+
955
+ /**
956
+ * Response from creating a checkout session
957
+ */
958
+ export declare interface CreateCheckoutSessionResponse {
959
+ id: string;
960
+ url?: string;
961
+ expiresAt: string;
962
+ status: 'pending' | 'completed' | 'expired';
963
+ }
964
+
965
+ /**
966
+ * Input for creating a customer
967
+ */
968
+ export declare interface CreateCustomerInput {
969
+ email: string;
970
+ name?: string;
971
+ metadata?: Record<string, string>;
972
+ }
973
+
974
+ /**
975
+ * Input for creating a subscription
976
+ */
977
+ export declare interface CreateSubscriptionInput {
978
+ customer_id: string;
979
+ price_id: string;
980
+ trial_days?: number;
981
+ metadata?: Record<string, string>;
982
+ }
983
+
984
+ /**
985
+ * Customer represents a billing customer
986
+ */
987
+ export declare interface Customer {
988
+ id: string;
989
+ email: string;
990
+ name?: string;
991
+ metadata?: Record<string, string>;
992
+ created_at: string;
993
+ updated_at: string;
994
+ }
995
+
996
+ /**
997
+ * Customer billing info response
998
+ */
999
+ export declare interface CustomerBillingInfo {
1000
+ id: string;
1001
+ email: string;
1002
+ name: string;
1003
+ billingAddress?: PortalAddress;
1004
+ }
1005
+
1006
+ export declare function CustomerPortal({ isOpen, onClose, mode, defaultTab, theme, className, customerId, metadata, onSubscriptionUpdate, onSubscriptionCancel, onPaymentMethodAdd, onPaymentMethodUpdate, debug }: CustomerPortalProps): JSX.Element;
1007
+
1008
+ /**
1009
+ * Complete portal data from API
1010
+ */
1011
+ export declare interface CustomerPortalData {
1012
+ subscription: PortalSubscription | null;
1013
+ invoices: PortalInvoice[];
1014
+ paymentMethods: PortalPaymentMethod[];
1015
+ customer: PortalCustomer;
1016
+ availablePlans: PortalAvailablePlan[];
1017
+ }
1018
+
1019
+ export declare interface CustomerPortalProps {
1020
+ /**
1021
+ * Open/close state (for drawer/modal mode)
1022
+ */
1023
+ isOpen?: boolean;
1024
+ /**
1025
+ * Callback when user closes portal
1026
+ */
1027
+ onClose?: () => void;
1028
+ /**
1029
+ * Display mode
1030
+ * - 'drawer': Slide-in from right (default)
1031
+ * - 'modal': Centered modal
1032
+ * - 'page': Full-page view
1033
+ */
1034
+ mode?: 'drawer' | 'modal' | 'page';
1035
+ /**
1036
+ * Default tab to show
1037
+ */
1038
+ defaultTab?: PortalTab;
1039
+ /**
1040
+ * Optional: Custom theme
1041
+ */
1042
+ theme?: 'light' | 'dark';
1043
+ /**
1044
+ * Optional: Custom class name
1045
+ */
1046
+ className?: string;
1047
+ /**
1048
+ * Optional: Customer ID to load specific customer
1049
+ */
1050
+ customerId?: string;
1051
+ /**
1052
+ * Optional: Custom metadata
1053
+ */
1054
+ metadata?: Record<string, any>;
1055
+ /**
1056
+ * Callback when subscription is updated
1057
+ */
1058
+ onSubscriptionUpdate?: (subscription: any) => void;
1059
+ /**
1060
+ * Callback when subscription is cancelled
1061
+ */
1062
+ onSubscriptionCancel?: () => void;
1063
+ /**
1064
+ * Callback when payment method is added
1065
+ */
1066
+ onPaymentMethodAdd?: () => void;
1067
+ /**
1068
+ * Callback when payment method is updated
1069
+ */
1070
+ onPaymentMethodUpdate?: () => void;
1071
+ /**
1072
+ * Debug mode for development
1073
+ */
1074
+ debug?: boolean;
1075
+ }
1076
+
1077
+ /**
1078
+ * Date utilities namespace
1079
+ */
1080
+ export declare const DateUtils: {
1081
+ format: (date: string | Date, formatStr?: string) => string;
1082
+ formatRelative: (date: string | Date, baseDate?: Date) => string;
1083
+ formatRelativeDate: (date: string | Date, baseDate?: Date) => string;
1084
+ isPast: (date: string | Date) => boolean;
1085
+ isFuture: (date: string | Date) => boolean;
1086
+ parse: (date: string) => Date;
1087
+ };
1088
+
1089
+ export declare function Dialog({ open, onOpenChange, children }: DialogProps): JSX.Element;
1090
+
1091
+ export declare const DialogContent: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & React_2.RefAttributes<HTMLDivElement>>;
1092
+
1093
+ export declare const DialogDescription: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLParagraphElement> & React_2.RefAttributes<HTMLParagraphElement>>;
1094
+
1095
+ export declare const DialogFooter: {
1096
+ ({ className, ...props }: React_2.HTMLAttributes<HTMLDivElement>): JSX.Element;
1097
+ displayName: string;
1098
+ };
1099
+
1100
+ export declare const DialogHeader: {
1101
+ ({ className, ...props }: React_2.HTMLAttributes<HTMLDivElement>): JSX.Element;
1102
+ displayName: string;
1103
+ };
1104
+
1105
+ export declare const DialogOverlay: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & React_2.RefAttributes<HTMLDivElement>>;
1106
+
1107
+ export declare function DialogPortal({ children }: DialogPortalProps): JSX.Element | null;
1108
+
1109
+ declare interface DialogPortalProps {
1110
+ children: React_2.ReactNode;
1111
+ }
1112
+
1113
+ declare interface DialogProps {
1114
+ open?: boolean;
1115
+ onOpenChange?: (open: boolean) => void;
1116
+ children: React_2.ReactNode;
1117
+ }
1118
+
1119
+ export declare const DialogTitle: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLHeadingElement> & React_2.RefAttributes<HTMLHeadingElement>>;
1120
+
1121
+ export declare const DialogTrigger: React_2.ForwardRefExoticComponent<DialogTriggerProps & React_2.RefAttributes<HTMLButtonElement>>;
1122
+
1123
+ declare interface DialogTriggerProps extends React_2.ButtonHTMLAttributes<HTMLButtonElement> {
1124
+ asChild?: boolean;
1125
+ }
1126
+
1127
+ export declare function Drawer({ open, onOpenChange, children }: DrawerProps): JSX.Element;
1128
+
1129
+ export declare const DrawerClose: React_2.ForwardRefExoticComponent<React_2.ButtonHTMLAttributes<HTMLButtonElement> & React_2.RefAttributes<HTMLButtonElement>>;
1130
+
1131
+ export declare const DrawerContent: React_2.ForwardRefExoticComponent<DrawerContentProps & React_2.RefAttributes<HTMLDivElement>>;
1132
+
1133
+ declare interface DrawerContentProps extends React_2.HTMLAttributes<HTMLDivElement> {
1134
+ /**
1135
+ * Whether to prevent closing when clicking outside or pressing ESC
1136
+ */
1137
+ preventClose?: boolean;
1138
+ /**
1139
+ * Callback when user attempts to close but it's prevented
1140
+ */
1141
+ onCloseAttempt?: () => void;
1142
+ }
1143
+
1144
+ export declare const DrawerDescription: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLParagraphElement> & React_2.RefAttributes<HTMLParagraphElement>>;
1145
+
1146
+ export declare const DrawerFooter: {
1147
+ ({ className, ...props }: React_2.HTMLAttributes<HTMLDivElement>): JSX.Element;
1148
+ displayName: string;
1149
+ };
1150
+
1151
+ export declare const DrawerHeader: {
1152
+ ({ className, ...props }: React_2.HTMLAttributes<HTMLDivElement>): JSX.Element;
1153
+ displayName: string;
1154
+ };
1155
+
1156
+ declare interface DrawerProps {
1157
+ open?: boolean;
1158
+ onOpenChange?: (open: boolean) => void;
1159
+ children: React_2.ReactNode;
1160
+ }
1161
+
1162
+ export declare const DrawerTitle: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLHeadingElement> & React_2.RefAttributes<HTMLHeadingElement>>;
1163
+
1164
+ export declare const DrawerTrigger: React_2.ForwardRefExoticComponent<DrawerTriggerProps & React_2.RefAttributes<HTMLButtonElement>>;
1165
+
1166
+ declare interface DrawerTriggerProps extends React_2.ButtonHTMLAttributes<HTMLButtonElement> {
1167
+ asChild?: boolean;
1168
+ }
1169
+
1170
+ /**
1171
+ * Entitlement represents a feature access grant
1172
+ */
1173
+ export declare interface Entitlement {
1174
+ feature_key: string;
1175
+ has_access: boolean;
1176
+ limit?: number;
1177
+ usage?: number;
1178
+ metadata?: Record<string, string>;
1179
+ }
1180
+
1181
+ /**
1182
+ * Query keys for entitlement-related queries
1183
+ */
1184
+ export declare const entitlementKeys: {
1185
+ all: readonly ["entitlements"];
1186
+ lists: () => readonly ["entitlements", "list"];
1187
+ list: (customerId: string) => readonly ["entitlements", "list", string];
1188
+ checks: () => readonly ["entitlements", "check"];
1189
+ check: (customerId: string, featureKey: string) => readonly ["entitlements", "check", string, string];
1190
+ usage: (customerId: string, featureKey: string) => readonly ["entitlements", "usage", string, string];
1191
+ };
1192
+
1193
+ /**
1194
+ * Feature access response
1195
+ */
1196
+ export declare interface FeatureAccess {
1197
+ feature_key: string;
1198
+ has_access: boolean;
1199
+ limit?: number;
1200
+ usage?: number;
1201
+ metadata?: Record<string, any>;
1202
+ }
1203
+
1204
+ /**
1205
+ * Feature entitlement
1206
+ */
1207
+ export declare interface FeatureEntitlement {
1208
+ feature_key: string;
1209
+ feature_title: string;
1210
+ feature_type: 'boolean_flag' | 'usage_quota' | 'numeric_limit';
1211
+ granted_at: string;
1212
+ product_name: string;
1213
+ subscription_status: string;
1214
+ properties?: Record<string, any>;
1215
+ }
1216
+
1217
+ /**
1218
+ * FeatureGate component for conditional rendering based on feature access
1219
+ *
1220
+ * @example
1221
+ * ```tsx
1222
+ * <FeatureGate
1223
+ * feature="advanced_analytics"
1224
+ * fallback={<UpgradePrompt feature="Advanced Analytics" />}
1225
+ * >
1226
+ * <AdvancedAnalyticsDashboard />
1227
+ * </FeatureGate>
1228
+ * ```
1229
+ */
1230
+ export declare function FeatureGate({ feature, children, fallback, loading, onAccessDenied, onQuotaExceeded, showUsageBadge, }: FeatureGateProps): JSX.Element;
1231
+
1232
+ export declare interface FeatureGateProps {
1233
+ /**
1234
+ * The feature key to check access for
1235
+ */
1236
+ feature: string;
1237
+ /**
1238
+ * Content to render when user has access
1239
+ */
1240
+ children: default_2.ReactNode;
1241
+ /**
1242
+ * Content to render when access is denied (optional)
1243
+ */
1244
+ fallback?: default_2.ReactNode;
1245
+ /**
1246
+ * Content to render while loading (optional)
1247
+ */
1248
+ loading?: default_2.ReactNode;
1249
+ /**
1250
+ * Callback when access is denied
1251
+ */
1252
+ onAccessDenied?: () => void;
1253
+ /**
1254
+ * Callback when quota is exceeded
1255
+ */
1256
+ onQuotaExceeded?: (usage: number, limit: number) => void;
1257
+ /**
1258
+ * Whether to show remaining usage in a badge
1259
+ */
1260
+ showUsageBadge?: boolean;
1261
+ }
1262
+
1263
+ export declare function FeatureList({ features, className }: FeatureListProps): JSX.Element | null;
1264
+
1265
+ declare interface FeatureListProps {
1266
+ features: PortalFeatureWithUsage[];
1267
+ className?: string;
1268
+ }
1269
+
1270
+ /**
1271
+ * Format cents as currency with symbol
1272
+ * @param cents - Amount in cents
1273
+ * @param currency - Currency code (e.g., 'USD', 'EUR')
1274
+ * @param minimumFractionDigits - Minimum decimal places
1275
+ * @param notation - Number notation style
1276
+ * @param maximumFractionDigits - Maximum decimal places
1277
+ * @returns Formatted currency string with symbol
1278
+ *
1279
+ * @example
1280
+ * formatCurrencyAndAmount(1050, 'USD') // "$10.50"
1281
+ * formatCurrencyAndAmount(1000000, 'USD', 0, 'compact') // "$10K"
1282
+ * formatCurrencyAndAmount(5000, 'EUR') // "€50.00"
1283
+ */
1284
+ export declare const formatCurrencyAndAmount: (cents: number, currency: string, minimumFractionDigits?: number, notation?: "standard" | "scientific" | "engineering" | "compact", maximumFractionDigits?: number) => string;
1285
+
1286
+ /**
1287
+ * Format currency in compact notation (e.g., $1.2K, $3.5M)
1288
+ * @param cents - Amount in cents
1289
+ * @param currency - Currency code
1290
+ * @returns Compact formatted currency string
1291
+ *
1292
+ * @example
1293
+ * formatCurrencyCompact(1200000, 'USD') // "$12K"
1294
+ * formatCurrencyCompact(3500000000, 'USD') // "$35M"
1295
+ */
1296
+ export declare const formatCurrencyCompact: (cents: number, currency: string) => string;
1297
+
1298
+ /**
1299
+ * Format currency without cents (whole dollars only)
1300
+ * @param cents - Amount in cents
1301
+ * @param currency - Currency code
1302
+ * @returns Formatted currency string without cents
1303
+ *
1304
+ * @example
1305
+ * formatCurrencyWhole(1050, 'USD') // "$10"
1306
+ * formatCurrencyWhole(1099, 'USD') // "$11" (rounds)
1307
+ */
1308
+ export declare const formatCurrencyWhole: (cents: number, currency: string) => string;
1309
+
1310
+ /**
1311
+ * Format a date string or Date object
1312
+ * @param date - Date string (ISO) or Date object
1313
+ * @param formatStr - Format string (date-fns format)
1314
+ * @returns Formatted date string
1315
+ *
1316
+ * @example
1317
+ * formatDate('2024-01-15T10:30:00Z', 'PPP') // "January 15th, 2024"
1318
+ * formatDate(new Date(), 'yyyy-MM-dd') // "2024-01-15"
1319
+ */
1320
+ export declare const formatDate: (date: string | Date, formatStr?: string) => string;
1321
+
1322
+ /**
1323
+ * Format a price range (e.g., "$10 - $50")
1324
+ * @param minCents - Minimum amount in cents
1325
+ * @param maxCents - Maximum amount in cents
1326
+ * @param currency - Currency code
1327
+ * @returns Formatted price range string
1328
+ *
1329
+ * @example
1330
+ * formatPriceRange(1000, 5000, 'USD') // "$10 - $50"
1331
+ */
1332
+ export declare const formatPriceRange: (minCents: number, maxCents: number, currency: string) => string;
1333
+
1334
+ /**
1335
+ * Format a date relative to now (e.g., "today at 10:30 AM")
1336
+ * @param date - Date string (ISO) or Date object
1337
+ * @param baseDate - Base date to compare against (defaults to now)
1338
+ * @returns Relative date string
1339
+ *
1340
+ * @example
1341
+ * formatRelativeDate('2024-01-15T10:30:00Z') // "today at 10:30 AM"
1342
+ */
1343
+ export declare const formatRelativeDate: (date: string | Date, baseDate?: Date) => string;
1344
+
1345
+ /**
1346
+ * Format a date as relative time (e.g., "2 hours ago")
1347
+ * @param date - Date string (ISO) or Date object
1348
+ * @param baseDate - Base date to compare against (defaults to now)
1349
+ * @returns Relative time string
1350
+ *
1351
+ * @example
1352
+ * formatRelativeTime('2024-01-15T08:30:00Z') // "2 hours ago"
1353
+ */
1354
+ export declare const formatRelativeTime: (date: string | Date, baseDate?: Date) => string;
1355
+
1356
+ /**
1357
+ * Convert cents to dollar string
1358
+ * @param cents - Amount in cents
1359
+ * @param showCents - Force showing cents even if amount is whole dollars
1360
+ * @param pretty - Use locale formatting with thousand separators
1361
+ * @returns Formatted dollar string
1362
+ *
1363
+ * @example
1364
+ * getCentsInDollarString(1000) // "10"
1365
+ * getCentsInDollarString(1050, true) // "10.50"
1366
+ * getCentsInDollarString(1000000, false, true) // "10,000"
1367
+ */
1368
+ export declare const getCentsInDollarString: (cents: number, showCents?: boolean, pretty?: boolean) => string;
1369
+
1370
+ /**
1371
+ * Get or create the global checkout API instance
1372
+ */
1373
+ export declare function getCheckoutAPI(client?: BillingOSClient): CheckoutAPI;
1374
+
1375
+ /**
1376
+ * Get currency symbol for a currency code
1377
+ * @param currency - Currency code (e.g., 'USD', 'EUR')
1378
+ * @returns Currency symbol (e.g., '$', '€')
1379
+ *
1380
+ * @example
1381
+ * getCurrencySymbol('USD') // "$"
1382
+ * getCurrencySymbol('EUR') // "€"
1383
+ * getCurrencySymbol('GBP') // "£"
1384
+ */
1385
+ export declare const getCurrencySymbol: (currency: string) => string;
1386
+
1387
+ /**
1388
+ * Response from GET /sdk/products
1389
+ */
1390
+ export declare interface GetProductsResponse {
1391
+ products: PricingProduct[];
1392
+ currentSubscription: PricingCurrentSubscription | null;
1393
+ }
1394
+
1395
+ export declare const Input: React_2.ForwardRefExoticComponent<Omit<React_2.DetailedHTMLProps<React_2.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & React_2.RefAttributes<HTMLInputElement>>;
1396
+
1397
+ /**
1398
+ * Invoice represents a billing invoice
1399
+ */
1400
+ export declare interface Invoice {
1401
+ id: string;
1402
+ customer_id: string;
1403
+ amount_due: number;
1404
+ amount_paid: number;
1405
+ currency: string;
1406
+ status: 'draft' | 'open' | 'paid' | 'uncollectible' | 'void';
1407
+ due_date?: string;
1408
+ paid_at?: string;
1409
+ invoice_pdf?: string;
1410
+ created_at: string;
1411
+ }
1412
+
1413
+ export declare function InvoiceCard({ invoice, onRetry, onDownload, isRetrying, className, }: InvoiceCardProps): JSX.Element;
1414
+
1415
+ declare interface InvoiceCardProps {
1416
+ invoice: PortalInvoice;
1417
+ onRetry?: (invoiceId: string) => void;
1418
+ onDownload?: (pdfUrl: string) => void;
1419
+ isRetrying?: boolean;
1420
+ className?: string;
1421
+ }
1422
+
1423
+ export declare function InvoicesTab({ invoices, onRetryInvoice, onDownloadInvoice, retryingInvoiceId, isLoading, className, }: InvoicesTabProps): JSX.Element;
1424
+
1425
+ declare interface InvoicesTabProps {
1426
+ invoices: PortalInvoice[];
1427
+ onRetryInvoice: (invoiceId: string) => void;
1428
+ onDownloadInvoice: (pdfUrl: string) => void;
1429
+ retryingInvoiceId?: string;
1430
+ isLoading?: boolean;
1431
+ className?: string;
1432
+ }
1433
+
1434
+ /**
1435
+ * Check if a date is in the future
1436
+ * @param date - Date string (ISO) or Date object
1437
+ * @returns True if date is in the future
1438
+ */
1439
+ export declare const isFuture: (date: string | Date) => boolean;
1440
+
1441
+ /**
1442
+ * Check if an amount is negative
1443
+ * @param cents - Amount in cents
1444
+ * @returns True if amount is negative
1445
+ */
1446
+ export declare const isNegativeAmount: (cents: number) => boolean;
1447
+
1448
+ /**
1449
+ * Type guard to check if an error is a not found error
1450
+ */
1451
+ export declare function isNotFoundError(error: unknown): error is NotFoundError;
1452
+
1453
+ /**
1454
+ * Check if a date is in the past
1455
+ * @param date - Date string (ISO) or Date object
1456
+ * @returns True if date is in the past
1457
+ */
1458
+ export declare const isPast: (date: string | Date) => boolean;
1459
+
1460
+ /**
1461
+ * Type guard to check if an error is a rate limit error
1462
+ */
1463
+ export declare function isRateLimitError(error: unknown): error is RateLimitError;
1464
+
1465
+ /**
1466
+ * Type guard to check if an error is an unauthorized error
1467
+ */
1468
+ export declare function isUnauthorizedError(error: unknown): error is UnauthorizedError;
1469
+
1470
+ /**
1471
+ * Type guard to check if an error is a validation error
1472
+ */
1473
+ export declare function isValidationError(error: unknown): error is ValidationError;
1474
+
1475
+ /**
1476
+ * Check if an amount is zero
1477
+ * @param cents - Amount in cents
1478
+ * @returns True if amount is zero
1479
+ */
1480
+ export declare const isZeroAmount: (cents: number) => boolean;
1481
+
1482
+ export declare const Label: React_2.ForwardRefExoticComponent<LabelProps & React_2.RefAttributes<HTMLLabelElement>>;
1483
+
1484
+ export declare interface LabelProps extends React_2.LabelHTMLAttributes<HTMLLabelElement>, VariantProps<typeof labelVariants> {
1485
+ }
1486
+
1487
+ declare const labelVariants: (props?: ClassProp | undefined) => string;
1488
+
1489
+ export declare function ModalNudge({ trigger, onUpgrade, onDismiss, }: ModalNudgeProps): JSX.Element;
1490
+
1491
+ export declare interface ModalNudgeProps {
1492
+ trigger: NudgeTrigger;
1493
+ onUpgrade: () => void;
1494
+ onDismiss: () => void;
1495
+ theme?: 'light' | 'dark';
1496
+ }
1497
+
1498
+ /**
1499
+ * Money utilities namespace for convenience
1500
+ */
1501
+ export declare const Money: {
1502
+ format: (cents: number, currency: string, minimumFractionDigits?: number, notation?: "standard" | "scientific" | "engineering" | "compact", maximumFractionDigits?: number) => string;
1503
+ formatCompact: (cents: number, currency: string) => string;
1504
+ formatWhole: (cents: number, currency: string) => string;
1505
+ formatRange: (minCents: number, maxCents: number, currency: string) => string;
1506
+ fromCents: (cents: number) => number;
1507
+ toCents: (amount: number) => number;
1508
+ getSymbol: (currency: string) => string;
1509
+ isZero: (cents: number) => boolean;
1510
+ isNegative: (cents: number) => boolean;
1511
+ calculatePercentage: (cents: number, percentage: number) => number;
1512
+ add: (...amounts: number[]) => number;
1513
+ };
1514
+
1515
+ /**
1516
+ * Thrown when the network request fails
1517
+ */
1518
+ export declare class NetworkError extends BillingOSError {
1519
+ constructor(message?: string, originalError?: unknown);
1520
+ }
1521
+
1522
+ /**
1523
+ * Thrown when the requested resource is not found (404)
1524
+ */
1525
+ export declare class NotFoundError extends BillingOSError {
1526
+ constructor(message?: string, data?: unknown);
1527
+ }
1528
+
1529
+ /**
1530
+ * Message content for nudge
1531
+ */
1532
+ export declare interface NudgeMessage {
1533
+ title: string;
1534
+ body: string;
1535
+ cta: string;
1536
+ }
1537
+
1538
+ /**
1539
+ * Nudge trigger data
1540
+ */
1541
+ export declare interface NudgeTrigger {
1542
+ type: NudgeTriggerType;
1543
+ feature?: string;
1544
+ threshold?: number;
1545
+ actual?: number;
1546
+ message: NudgeMessage;
1547
+ suggestedPlan: SuggestedPlan;
1548
+ }
1549
+
1550
+ /**
1551
+ * Type of nudge trigger
1552
+ */
1553
+ export declare type NudgeTriggerType = 'usage_threshold' | 'feature_access' | 'time_based' | 'custom';
1554
+
1555
+ /**
1556
+ * Convenience function to open checkout modal
1557
+ */
1558
+ export declare function openCheckout(options: CheckoutOpenOptions): Promise<{
1559
+ success: boolean;
1560
+ subscription?: Subscription;
1561
+ error?: Error;
1562
+ }>;
1563
+
1564
+ /**
1565
+ * Paginated response wrapper
1566
+ */
1567
+ export declare interface PaginatedResponse<T> {
1568
+ data: T[];
1569
+ meta: PaginationMeta;
1570
+ }
1571
+
1572
+ /**
1573
+ * Pagination metadata
1574
+ */
1575
+ export declare interface PaginationMeta {
1576
+ total: number;
1577
+ page: number;
1578
+ page_size: number;
1579
+ total_pages: number;
1580
+ }
1581
+
1582
+ /**
1583
+ * Parse ISO date string to Date object
1584
+ * @param date - ISO date string
1585
+ * @returns Date object
1586
+ */
1587
+ export declare const parseDate: (date: string) => Date;
1588
+
1589
+ export declare function PaymentBottomSheet({ priceId, isOpen, onClose, onSuccess, existingSubscriptionId, theme, }: PaymentBottomSheetProps): JSX.Element;
1590
+
1591
+ export declare interface PaymentBottomSheetProps {
1592
+ /**
1593
+ * Price ID to purchase
1594
+ */
1595
+ priceId: string;
1596
+ /**
1597
+ * Open/close state
1598
+ */
1599
+ isOpen: boolean;
1600
+ /**
1601
+ * Callback when user closes sheet
1602
+ */
1603
+ onClose: () => void;
1604
+ /**
1605
+ * Callback when payment succeeds
1606
+ */
1607
+ onSuccess: (subscriptionId: string) => void;
1608
+ /**
1609
+ * Optional: Subscription ID if upgrading
1610
+ */
1611
+ existingSubscriptionId?: string;
1612
+ /**
1613
+ * Optional: Custom theme
1614
+ */
1615
+ theme?: 'light' | 'dark';
1616
+ }
1617
+
1618
+ /**
1619
+ * Payment method
1620
+ */
1621
+ export declare interface PaymentMethod {
1622
+ id: string;
1623
+ type: 'card' | 'bank_account';
1624
+ card?: {
1625
+ brand: string;
1626
+ last4: string;
1627
+ exp_month: number;
1628
+ exp_year: number;
1629
+ };
1630
+ is_default: boolean;
1631
+ created_at: string;
1632
+ }
1633
+
1634
+ export declare function PaymentMethodCard({ paymentMethod, onSetDefault, onRemove, isSettingDefault, isRemoving, className, }: PaymentMethodCardProps): JSX.Element | null;
1635
+
1636
+ declare interface PaymentMethodCardProps {
1637
+ paymentMethod: PortalPaymentMethod;
1638
+ onSetDefault?: (id: string) => void;
1639
+ onRemove?: (id: string) => void;
1640
+ isSettingDefault?: boolean;
1641
+ isRemoving?: boolean;
1642
+ className?: string;
1643
+ }
1644
+
1645
+ export declare function PaymentMethodsTab({ paymentMethods, onAddPaymentMethod, onSetDefault, onRemove, settingDefaultId, removingId, isLoading, className, }: PaymentMethodsTabProps): JSX.Element;
1646
+
1647
+ declare interface PaymentMethodsTabProps {
1648
+ paymentMethods: PortalPaymentMethod[];
1649
+ onAddPaymentMethod: () => void;
1650
+ onSetDefault: (id: string) => void;
1651
+ onRemove: (id: string) => void;
1652
+ settingDefaultId?: string;
1653
+ removingId?: string;
1654
+ isLoading?: boolean;
1655
+ className?: string;
1656
+ }
1657
+
1658
+ /**
1659
+ * Plan information
1660
+ */
1661
+ export declare interface PlanInfo {
1662
+ product_id: string;
1663
+ product_name: string;
1664
+ price_id: string;
1665
+ amount: number;
1666
+ currency: string;
1667
+ interval: string;
1668
+ }
1669
+
1670
+ /**
1671
+ * Billing address
1672
+ */
1673
+ export declare interface PortalAddress {
1674
+ line1: string;
1675
+ line2?: string;
1676
+ city: string;
1677
+ state: string;
1678
+ postalCode: string;
1679
+ country: string;
1680
+ }
1681
+
1682
+ /**
1683
+ * Available plan for upgrade/downgrade
1684
+ */
1685
+ export declare interface PortalAvailablePlan {
1686
+ id: string;
1687
+ name: string;
1688
+ price: {
1689
+ amount: number;
1690
+ currency: string;
1691
+ interval: 'day' | 'week' | 'month' | 'year';
1692
+ };
1693
+ type: 'upgrade' | 'downgrade' | 'current';
1694
+ }
1695
+
1696
+ /**
1697
+ * Input for canceling subscription via portal
1698
+ */
1699
+ export declare interface PortalCancelSubscriptionInput {
1700
+ cancelAtPeriodEnd: boolean;
1701
+ cancellationReason?: 'too_expensive' | 'missing_features' | 'found_alternative' | 'no_longer_needed' | 'other';
1702
+ feedback?: string;
1703
+ }
1704
+
1705
+ /**
1706
+ * Response for subscription cancellation
1707
+ */
1708
+ export declare interface PortalCancelSubscriptionResponse {
1709
+ subscription: {
1710
+ id: string;
1711
+ status: string;
1712
+ cancelAtPeriodEnd: boolean;
1713
+ canceledAt: string;
1714
+ currentPeriodEnd: string;
1715
+ };
1716
+ message: string;
1717
+ }
1718
+
1719
+ /**
1720
+ * Card details for portal
1721
+ */
1722
+ export declare interface PortalCardDetails {
1723
+ brand: 'visa' | 'mastercard' | 'amex' | 'discover' | 'diners' | 'jcb' | 'unionpay';
1724
+ last4: string;
1725
+ expMonth: number;
1726
+ expYear: number;
1727
+ }
1728
+
1729
+ /**
1730
+ * Customer details for portal
1731
+ */
1732
+ export declare interface PortalCustomer {
1733
+ id: string;
1734
+ email: string;
1735
+ name: string;
1736
+ billingAddress?: PortalAddress;
1737
+ }
1738
+
1739
+ /**
1740
+ * Feature type for portal
1741
+ */
1742
+ export declare type PortalFeatureType = 'boolean_flag' | 'usage_quota' | 'numeric_limit';
1743
+
1744
+ /**
1745
+ * Feature with usage tracking for portal
1746
+ */
1747
+ export declare interface PortalFeatureWithUsage {
1748
+ id: string;
1749
+ name: string;
1750
+ title: string;
1751
+ type: PortalFeatureType;
1752
+ properties: Record<string, unknown>;
1753
+ usage?: PortalUsageInfo;
1754
+ enabled?: boolean;
1755
+ }
1756
+
1757
+ /**
1758
+ * Invoice details for portal
1759
+ */
1760
+ export declare interface PortalInvoice {
1761
+ id: string;
1762
+ number: string;
1763
+ date: string;
1764
+ dueDate: string;
1765
+ status: 'paid' | 'open' | 'failed' | 'void';
1766
+ amount: number;
1767
+ currency: string;
1768
+ pdfUrl: string | null;
1769
+ lineItems: PortalLineItem[];
1770
+ failureReason?: string;
1771
+ }
1772
+
1773
+ /**
1774
+ * Query keys for portal-related queries
1775
+ */
1776
+ export declare const portalKeys: {
1777
+ all: readonly ["portal"];
1778
+ data: () => readonly ["portal", "data"];
1779
+ setupIntent: () => readonly ["portal", "setupIntent"];
1780
+ };
1781
+
1782
+ /**
1783
+ * Line item in an invoice
1784
+ */
1785
+ export declare interface PortalLineItem {
1786
+ description: string;
1787
+ quantity: number;
1788
+ amount: number;
1789
+ }
1790
+
1791
+ /**
1792
+ * Payment method for portal
1793
+ */
1794
+ export declare interface PortalPaymentMethod {
1795
+ id: string;
1796
+ type: 'card' | 'bank_account';
1797
+ card?: PortalCardDetails;
1798
+ isDefault: boolean;
1799
+ }
1800
+
1801
+ /**
1802
+ * Price information for portal
1803
+ */
1804
+ export declare interface PortalPrice {
1805
+ id: string;
1806
+ amount: number;
1807
+ currency: string;
1808
+ interval: 'day' | 'week' | 'month' | 'year';
1809
+ intervalCount: number;
1810
+ }
1811
+
1812
+ /**
1813
+ * Product information for portal
1814
+ */
1815
+ export declare interface PortalProduct {
1816
+ id: string;
1817
+ name: string;
1818
+ description?: string;
1819
+ }
1820
+
1821
+ /**
1822
+ * Subscription details for portal
1823
+ */
1824
+ export declare interface PortalSubscription {
1825
+ id: string;
1826
+ status: 'active' | 'trialing' | 'past_due' | 'canceled' | 'unpaid';
1827
+ product: PortalProduct;
1828
+ price: PortalPrice;
1829
+ currentPeriodStart: string;
1830
+ currentPeriodEnd: string;
1831
+ cancelAtPeriodEnd: boolean;
1832
+ trialEnd: string | null;
1833
+ canceledAt: string | null;
1834
+ features: PortalFeatureWithUsage[];
1835
+ }
1836
+
1837
+ declare type PortalTab = 'subscription' | 'invoices' | 'payment' | 'settings';
1838
+
1839
+ /**
1840
+ * Input for updating subscription via portal
1841
+ */
1842
+ export declare interface PortalUpdateSubscriptionInput {
1843
+ newPriceId: string;
1844
+ prorationBehavior?: 'always_invoice' | 'create_prorations' | 'none';
1845
+ }
1846
+
1847
+ /**
1848
+ * Response for subscription update
1849
+ */
1850
+ export declare interface PortalUpdateSubscriptionResponse {
1851
+ subscription: {
1852
+ id: string;
1853
+ status: string;
1854
+ proration?: {
1855
+ credited: number;
1856
+ charged: number;
1857
+ total: number;
1858
+ };
1859
+ };
1860
+ upcomingInvoice?: {
1861
+ amountDue: number;
1862
+ dueDate: string;
1863
+ };
1864
+ }
1865
+
1866
+ /**
1867
+ * Usage information for a feature
1868
+ */
1869
+ export declare interface PortalUsageInfo {
1870
+ consumed: number;
1871
+ limit: number;
1872
+ percentage: number;
1873
+ resetDate?: string;
1874
+ }
1875
+
1876
+ /**
1877
+ * Input for previewing a plan change
1878
+ */
1879
+ export declare interface PreviewChangeInput {
1880
+ new_price_id: string;
1881
+ effective_date?: ChangeEffectiveTiming;
1882
+ }
1883
+
1884
+ /**
1885
+ * Response from POST /subscriptions/:id/preview-change
1886
+ */
1887
+ export declare interface PreviewChangeResponse {
1888
+ current_plan: PlanInfo;
1889
+ new_plan: PlanInfo;
1890
+ proration: ProrationInfo;
1891
+ change_type: ChangeType;
1892
+ effective_date: string;
1893
+ next_billing_date: string;
1894
+ notes: string[];
1895
+ }
1896
+
1897
+ export declare interface Price {
1898
+ id: string;
1899
+ amount: number;
1900
+ currency: string;
1901
+ interval?: string;
1902
+ interval_count?: number;
1903
+ }
1904
+
1905
+ export declare function PricingCard({ product, selectedInterval, currentSubscription, onSelectPlan, }: PricingCardProps): JSX.Element;
1906
+
1907
+ export declare interface PricingCardProps {
1908
+ product: PricingProduct;
1909
+ selectedInterval: 'month' | 'year';
1910
+ currentSubscription: PricingCurrentSubscription | null;
1911
+ onSelectPlan: (priceId: string) => void;
1912
+ theme?: 'light' | 'dark';
1913
+ }
1914
+
1915
+ /**
1916
+ * Current subscription info for pricing table
1917
+ */
1918
+ export declare interface PricingCurrentSubscription {
1919
+ id: string;
1920
+ productId: string;
1921
+ priceId: string;
1922
+ status: 'active' | 'trialing' | 'past_due' | 'canceled';
1923
+ currentPeriodEnd: string;
1924
+ cancelAtPeriodEnd: boolean;
1925
+ }
1926
+
1927
+ /**
1928
+ * Feature in pricing table
1929
+ */
1930
+ export declare interface PricingFeature {
1931
+ id: string;
1932
+ name: string;
1933
+ title: string;
1934
+ type: 'boolean_flag' | 'usage_quota' | 'numeric_limit';
1935
+ properties: PricingFeatureProperties;
1936
+ }
1937
+
1938
+ /**
1939
+ * Feature properties for pricing table
1940
+ */
1941
+ export declare interface PricingFeatureProperties {
1942
+ limit?: number;
1943
+ period?: 'month' | 'year';
1944
+ unit?: string;
1945
+ }
1946
+
1947
+ /**
1948
+ * Price for a product
1949
+ */
1950
+ export declare interface PricingPrice {
1951
+ id: string;
1952
+ amount: number;
1953
+ currency: string;
1954
+ interval: 'month' | 'year' | 'week' | 'day';
1955
+ intervalCount: number;
1956
+ }
1957
+
1958
+ /**
1959
+ * Product in pricing table
1960
+ */
1961
+ export declare interface PricingProduct {
1962
+ id: string;
1963
+ name: string;
1964
+ description: string;
1965
+ prices: PricingPrice[];
1966
+ features: PricingFeature[];
1967
+ isCurrentPlan: boolean;
1968
+ trialDays: number;
1969
+ highlighted?: boolean;
1970
+ }
1971
+
1972
+ export declare function PricingTable({ planIds, showIntervalToggle, defaultInterval, onSelectPlan, theme, title, description, useCheckoutModal, onPlanChanged, customer: customerProp, }: PricingTableProps): JSX.Element;
1973
+
1974
+ export declare interface PricingTableProps {
1975
+ planIds?: string[];
1976
+ showIntervalToggle?: boolean;
1977
+ defaultInterval?: 'month' | 'year';
1978
+ onSelectPlan?: (priceId: string) => void;
1979
+ theme?: 'light' | 'dark';
1980
+ title?: string;
1981
+ description?: string;
1982
+ /** Use the new iframe-based checkout modal instead of bottom sheet */
1983
+ useCheckoutModal?: boolean;
1984
+ /** Callback when plan is changed (for upgrade/downgrade flows) */
1985
+ onPlanChanged?: (subscription: any) => void;
1986
+ /** Customer information to prefill in checkout (overrides context) */
1987
+ customer?: {
1988
+ email?: string;
1989
+ name?: string;
1990
+ };
1991
+ }
1992
+
1993
+ export declare interface Product {
1994
+ id: string;
1995
+ name: string;
1996
+ description?: string;
1997
+ features?: string[];
1998
+ prices?: Price[];
1999
+ }
2000
+
2001
+ export declare const Progress: React_2.ForwardRefExoticComponent<ProgressProps & React_2.RefAttributes<HTMLDivElement>>;
2002
+
2003
+ declare interface ProgressProps extends React_2.HTMLAttributes<HTMLDivElement> {
2004
+ value?: number;
2005
+ max?: number;
2006
+ indicatorClassName?: string;
2007
+ }
2008
+
2009
+ /**
2010
+ * Proration details
2011
+ */
2012
+ export declare interface ProrationInfo {
2013
+ unused_time_credit: number;
2014
+ new_plan_charge: number;
2015
+ immediate_payment: number;
2016
+ credit_applied: number;
2017
+ breakdown: string;
2018
+ }
2019
+
2020
+ export declare const RadioGroup: React_2.ForwardRefExoticComponent<RadioGroupProps & React_2.RefAttributes<HTMLDivElement>>;
2021
+
2022
+ export declare const RadioGroupItem: React_2.ForwardRefExoticComponent<RadioGroupItemProps & React_2.RefAttributes<HTMLInputElement>>;
2023
+
2024
+ declare interface RadioGroupItemProps extends Omit<React_2.InputHTMLAttributes<HTMLInputElement>, 'type'> {
2025
+ value: string;
2026
+ }
2027
+
2028
+ declare interface RadioGroupProps extends Omit<React_2.HTMLAttributes<HTMLDivElement>, 'onChange'> {
2029
+ value?: string;
2030
+ defaultValue?: string;
2031
+ onValueChange?: (value: string) => void;
2032
+ name?: string;
2033
+ }
2034
+
2035
+ /**
2036
+ * Thrown when rate limit is exceeded (429)
2037
+ */
2038
+ export declare class RateLimitError extends BillingOSError {
2039
+ constructor(message?: string, data?: unknown);
2040
+ }
2041
+
2042
+ /**
2043
+ * Response for retrying an invoice
2044
+ */
2045
+ export declare interface RetryInvoiceResponse {
2046
+ success: boolean;
2047
+ invoice: {
2048
+ id: string;
2049
+ status: 'paid' | 'open' | 'failed' | 'void';
2050
+ amount: number;
2051
+ };
2052
+ }
2053
+
2054
+ export declare const ScrollArea: React_2.ForwardRefExoticComponent<ScrollAreaProps & React_2.RefAttributes<HTMLDivElement>>;
2055
+
2056
+ declare interface ScrollAreaProps extends React_2.HTMLAttributes<HTMLDivElement> {
2057
+ /**
2058
+ * The orientation of the scrollable area
2059
+ */
2060
+ orientation?: 'vertical' | 'horizontal' | 'both';
2061
+ /**
2062
+ * Always show the custom scrollbar (instead of only on hover)
2063
+ */
2064
+ alwaysShowScrollbar?: boolean;
2065
+ }
2066
+
2067
+ export declare const ScrollBar: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & {
2068
+ orientation?: "vertical" | "horizontal";
2069
+ } & React_2.RefAttributes<HTMLDivElement>>;
2070
+
2071
+ export declare const Select: React_2.ForwardRefExoticComponent<SelectProps & React_2.RefAttributes<HTMLSelectElement>>;
2072
+
2073
+ export declare const SelectOption: React_2.ForwardRefExoticComponent<React_2.OptionHTMLAttributes<HTMLOptionElement> & React_2.RefAttributes<HTMLOptionElement>>;
2074
+
2075
+ declare interface SelectProps extends React_2.SelectHTMLAttributes<HTMLSelectElement> {
2076
+ onValueChange?: (value: string) => void;
2077
+ }
2078
+
2079
+ export declare const Separator: React_2.ForwardRefExoticComponent<SeparatorProps & React_2.RefAttributes<HTMLDivElement>>;
2080
+
2081
+ declare interface SeparatorProps extends React_2.HTMLAttributes<HTMLDivElement> {
2082
+ orientation?: 'horizontal' | 'vertical';
2083
+ decorative?: boolean;
2084
+ }
2085
+
2086
+ /**
2087
+ * Thrown when the server returns a 500 error
2088
+ */
2089
+ export declare class ServerError extends BillingOSError {
2090
+ constructor(message?: string, data?: unknown);
2091
+ }
2092
+
2093
+ /**
2094
+ * Hook for managing session tokens with auto-fetch and auto-refresh
2095
+ */
2096
+ export declare interface SessionTokenData {
2097
+ sessionToken: string;
2098
+ expiresAt: string;
2099
+ }
2100
+
2101
+ export declare function SettingsTab({ customer, onSave, isSaving, isLoading, className, }: SettingsTabProps): JSX.Element;
2102
+
2103
+ declare interface SettingsTabProps {
2104
+ customer: PortalCustomer;
2105
+ onSave: (data: {
2106
+ name?: string;
2107
+ email?: string;
2108
+ billingAddress?: PortalAddress;
2109
+ }) => void;
2110
+ isSaving?: boolean;
2111
+ isLoading?: boolean;
2112
+ className?: string;
2113
+ }
2114
+
2115
+ /**
2116
+ * Setup intent response for adding cards
2117
+ */
2118
+ export declare interface SetupIntentResponse {
2119
+ clientSecret: string;
2120
+ stripePublishableKey: string;
2121
+ }
2122
+
2123
+ export declare function Sheet({ open, onOpenChange, children }: SheetProps): JSX.Element;
2124
+
2125
+ export declare const SheetClose: React_2.ForwardRefExoticComponent<React_2.ButtonHTMLAttributes<HTMLButtonElement> & React_2.RefAttributes<HTMLButtonElement>>;
2126
+
2127
+ export declare const SheetContent: React_2.ForwardRefExoticComponent<SheetContentProps & React_2.RefAttributes<HTMLDivElement>>;
2128
+
2129
+ declare interface SheetContentProps extends React_2.HTMLAttributes<HTMLDivElement>, VariantProps<typeof sheetVariants> {
2130
+ }
2131
+
2132
+ export declare const SheetDescription: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLParagraphElement> & React_2.RefAttributes<HTMLParagraphElement>>;
2133
+
2134
+ export declare const SheetFooter: {
2135
+ ({ className, ...props }: React_2.HTMLAttributes<HTMLDivElement>): JSX.Element;
2136
+ displayName: string;
2137
+ };
2138
+
2139
+ export declare const SheetHeader: {
2140
+ ({ className, ...props }: React_2.HTMLAttributes<HTMLDivElement>): JSX.Element;
2141
+ displayName: string;
2142
+ };
2143
+
2144
+ declare interface SheetProps {
2145
+ open?: boolean;
2146
+ onOpenChange?: (open: boolean) => void;
2147
+ children: React_2.ReactNode;
2148
+ }
2149
+
2150
+ export declare const SheetTitle: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLHeadingElement> & React_2.RefAttributes<HTMLHeadingElement>>;
2151
+
2152
+ export declare const SheetTrigger: React_2.ForwardRefExoticComponent<SheetTriggerProps & React_2.RefAttributes<HTMLButtonElement>>;
2153
+
2154
+ declare interface SheetTriggerProps extends React_2.ButtonHTMLAttributes<HTMLButtonElement> {
2155
+ asChild?: boolean;
2156
+ }
2157
+
2158
+ declare const sheetVariants: (props?: ({
2159
+ side?: "left" | "right" | "bottom" | "top" | null | undefined;
2160
+ } & ClassProp) | undefined) => string;
2161
+
2162
+ export declare function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): JSX.Element;
2163
+
2164
+ /**
2165
+ * Subscription represents a customer subscription
2166
+ */
2167
+ export declare interface Subscription {
2168
+ id: string;
2169
+ customer_id: string;
2170
+ price_id: string;
2171
+ status: SubscriptionStatus;
2172
+ current_period_start: string;
2173
+ current_period_end: string;
2174
+ cancel_at_period_end: boolean;
2175
+ trial_start?: string;
2176
+ trial_end?: string;
2177
+ canceled_at?: string;
2178
+ metadata?: Record<string, string>;
2179
+ created_at: string;
2180
+ updated_at: string;
2181
+ }
2182
+
2183
+ /**
2184
+ * Query keys for subscription-related queries
2185
+ */
2186
+ export declare const subscriptionKeys: {
2187
+ all: readonly ["subscriptions"];
2188
+ lists: () => readonly ["subscriptions", "list"];
2189
+ list: (filters?: Record<string, unknown>) => readonly ["subscriptions", "list", Record<string, unknown> | undefined];
2190
+ details: () => readonly ["subscriptions", "detail"];
2191
+ detail: (id: string) => readonly ["subscriptions", "detail", string];
2192
+ preview: (id: string, input: UpdateSubscriptionInput) => readonly ["subscriptions", "preview", string, UpdateSubscriptionInput];
2193
+ };
2194
+
2195
+ /**
2196
+ * Price preview for subscription changes
2197
+ */
2198
+ export declare interface SubscriptionPreview {
2199
+ proration_amount: number;
2200
+ next_invoice_amount: number;
2201
+ next_invoice_date: string;
2202
+ }
2203
+
2204
+ /**
2205
+ * Subscription status
2206
+ */
2207
+ export declare type SubscriptionStatus = 'active' | 'canceled' | 'incomplete' | 'incomplete_expired' | 'past_due' | 'trialing' | 'unpaid';
2208
+
2209
+ export declare function SubscriptionTab({ subscription, onChangePlan, onCancelSubscription, onReactivate, onAddPaymentMethod, isLoading, className, }: SubscriptionTabProps): JSX.Element;
2210
+
2211
+ declare interface SubscriptionTabProps {
2212
+ subscription: PortalSubscription | null;
2213
+ availablePlans: PortalAvailablePlan[];
2214
+ onChangePlan: () => void;
2215
+ onCancelSubscription: () => void;
2216
+ onReactivate: () => void;
2217
+ onAddPaymentMethod: () => void;
2218
+ isLoading?: boolean;
2219
+ className?: string;
2220
+ }
2221
+
2222
+ /**
2223
+ * Suggested plan for upgrade
2224
+ */
2225
+ export declare interface SuggestedPlan {
2226
+ id: string;
2227
+ priceId: string;
2228
+ name: string;
2229
+ price: {
2230
+ amount: number;
2231
+ currency: string;
2232
+ interval: string;
2233
+ };
2234
+ highlights: string[];
2235
+ }
2236
+
2237
+ export declare const Tabs: React_2.ForwardRefExoticComponent<TabsProps & React_2.RefAttributes<HTMLDivElement>>;
2238
+
2239
+ export declare const TabsContent: React_2.ForwardRefExoticComponent<TabsContentProps & React_2.RefAttributes<HTMLDivElement>>;
2240
+
2241
+ declare interface TabsContentProps extends React_2.HTMLAttributes<HTMLDivElement> {
2242
+ value: string;
2243
+ }
2244
+
2245
+ export declare const TabsList: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & React_2.RefAttributes<HTMLDivElement>>;
2246
+
2247
+ declare interface TabsProps extends React_2.HTMLAttributes<HTMLDivElement> {
2248
+ value?: string;
2249
+ defaultValue?: string;
2250
+ onValueChange?: (value: string) => void;
2251
+ }
2252
+
2253
+ export declare const TabsTrigger: React_2.ForwardRefExoticComponent<TabsTriggerProps & React_2.RefAttributes<HTMLButtonElement>>;
2254
+
2255
+ declare interface TabsTriggerProps extends React_2.ButtonHTMLAttributes<HTMLButtonElement> {
2256
+ value: string;
2257
+ }
2258
+
2259
+ export declare const Textarea: React_2.ForwardRefExoticComponent<Omit<React_2.DetailedHTMLProps<React_2.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & React_2.RefAttributes<HTMLTextAreaElement>>;
2260
+
2261
+ export declare function ToastNudge({ trigger, onUpgrade, onDismiss, }: ToastNudgeProps): JSX.Element;
2262
+
2263
+ export declare interface ToastNudgeProps {
2264
+ trigger: NudgeTrigger;
2265
+ onUpgrade: () => void;
2266
+ onDismiss: () => void;
2267
+ theme?: 'light' | 'dark';
2268
+ }
2269
+
2270
+ /**
2271
+ * Thrown when the API request fails due to authentication issues (401)
2272
+ */
2273
+ export declare class UnauthorizedError extends BillingOSError {
2274
+ constructor(message?: string, data?: unknown);
2275
+ }
2276
+
2277
+ /**
2278
+ * Input for updating customer billing
2279
+ */
2280
+ export declare interface UpdateCustomerBillingInput {
2281
+ name?: string;
2282
+ email?: string;
2283
+ billingAddress?: PortalAddress;
2284
+ }
2285
+
2286
+ /**
2287
+ * Input for updating a customer
2288
+ */
2289
+ export declare interface UpdateCustomerInput {
2290
+ email?: string;
2291
+ name?: string;
2292
+ metadata?: Record<string, string>;
2293
+ }
2294
+
2295
+ /**
2296
+ * Input for updating a subscription
2297
+ */
2298
+ export declare interface UpdateSubscriptionInput {
2299
+ price_id?: string;
2300
+ cancel_at_period_end?: boolean;
2301
+ metadata?: Record<string, string>;
2302
+ }
2303
+
2304
+ export declare function UpgradeNudge({ trigger, style, autoDismiss, onUpgrade, onDismiss, theme, }: UpgradeNudgeProps): JSX.Element | null;
2305
+
2306
+ export declare interface UpgradeNudgeProps {
2307
+ /**
2308
+ * Nudge trigger data (from API or usage check)
2309
+ */
2310
+ trigger: NudgeTrigger;
2311
+ /**
2312
+ * Display style
2313
+ * - 'banner': Top banner (non-intrusive)
2314
+ * - 'toast': Toast notification (bottom-right)
2315
+ * - 'modal': Modal dialog (more prominent)
2316
+ */
2317
+ style?: 'banner' | 'toast' | 'modal';
2318
+ /**
2319
+ * Auto-dismiss after N milliseconds (0 = no auto-dismiss)
2320
+ */
2321
+ autoDismiss?: number;
2322
+ /**
2323
+ * Callback when user clicks upgrade
2324
+ */
2325
+ onUpgrade?: (priceId: string) => void;
2326
+ /**
2327
+ * Callback when user dismisses nudge
2328
+ */
2329
+ onDismiss?: () => void;
2330
+ /**
2331
+ * Optional: Custom theme
2332
+ */
2333
+ theme?: 'light' | 'dark';
2334
+ }
2335
+
2336
+ /**
2337
+ * Component that prompts users to upgrade when they hit limits or access denied features
2338
+ *
2339
+ * @example
2340
+ * ```tsx
2341
+ * <UpgradePrompt
2342
+ * feature="Advanced Analytics"
2343
+ * description="Upgrade to Pro to access advanced analytics and reporting"
2344
+ * />
2345
+ * ```
2346
+ */
2347
+ export declare function UpgradePrompt({ feature, title, description, isQuotaExceeded, usage, limit, className, onUpgradeClick, }: UpgradePromptProps): JSX.Element;
2348
+
2349
+ export declare interface UpgradePromptProps {
2350
+ /**
2351
+ * Feature that requires upgrade
2352
+ */
2353
+ feature?: string;
2354
+ /**
2355
+ * Title text
2356
+ */
2357
+ title?: string;
2358
+ /**
2359
+ * Description text
2360
+ */
2361
+ description?: string;
2362
+ /**
2363
+ * Whether it's a quota exceeded prompt
2364
+ */
2365
+ isQuotaExceeded?: boolean;
2366
+ /**
2367
+ * Current usage (for quota exceeded)
2368
+ */
2369
+ usage?: number;
2370
+ /**
2371
+ * Usage limit (for quota exceeded)
2372
+ */
2373
+ limit?: number;
2374
+ /**
2375
+ * Custom className for styling
2376
+ */
2377
+ className?: string;
2378
+ /**
2379
+ * Click handler for upgrade button
2380
+ */
2381
+ onUpgradeClick?: () => void;
2382
+ }
2383
+
2384
+ export declare function UsageBar({ title, usage, unit, className }: UsageBarProps): JSX.Element;
2385
+
2386
+ declare interface UsageBarProps {
2387
+ title: string;
2388
+ usage: PortalUsageInfo;
2389
+ unit?: string;
2390
+ className?: string;
2391
+ }
2392
+
2393
+ /**
2394
+ * Response from GET /sdk/usage/check
2395
+ */
2396
+ export declare interface UsageCheckResponse {
2397
+ shouldShowNudge: boolean;
2398
+ trigger?: NudgeTrigger;
2399
+ }
2400
+
2401
+ /**
2402
+ * Component to display usage metrics for features
2403
+ *
2404
+ * @example
2405
+ * ```tsx
2406
+ * // Show all usage metrics
2407
+ * <UsageDisplay />
2408
+ *
2409
+ * // Show specific feature usage
2410
+ * <UsageDisplay featureKey="api_calls" />
2411
+ * ```
2412
+ */
2413
+ export declare function UsageDisplay({ featureKey, title, showProgress, showResetTimer, className, }: UsageDisplayProps): JSX.Element;
2414
+
2415
+ export declare interface UsageDisplayProps {
2416
+ /**
2417
+ * Optional feature key to show usage for specific feature
2418
+ */
2419
+ featureKey?: string;
2420
+ /**
2421
+ * Custom title
2422
+ */
2423
+ title?: string;
2424
+ /**
2425
+ * Whether to show a progress bar
2426
+ */
2427
+ showProgress?: boolean;
2428
+ /**
2429
+ * Whether to show reset timer
2430
+ */
2431
+ showResetTimer?: boolean;
2432
+ /**
2433
+ * Custom className for styling
2434
+ */
2435
+ className?: string;
2436
+ }
2437
+
2438
+ /**
2439
+ * Usage event for tracking
2440
+ */
2441
+ export declare interface UsageEvent {
2442
+ customer_id?: string;
2443
+ feature_key: string;
2444
+ quantity: number;
2445
+ timestamp?: string;
2446
+ idempotency_key?: string;
2447
+ metadata?: Record<string, string>;
2448
+ }
2449
+
2450
+ /**
2451
+ * Usage metric
2452
+ */
2453
+ export declare interface UsageMetric {
2454
+ feature_key: string;
2455
+ feature_title: string;
2456
+ product_name: string;
2457
+ consumed: number;
2458
+ limit: number;
2459
+ remaining: number;
2460
+ percentage_used: number;
2461
+ period_start: string;
2462
+ period_end: string;
2463
+ resets_in_days: number;
2464
+ }
2465
+
2466
+ /**
2467
+ * Usage metrics response
2468
+ */
2469
+ export declare interface UsageMetrics {
2470
+ feature_key: string;
2471
+ current_usage: number;
2472
+ limit?: number;
2473
+ period_start: string;
2474
+ period_end: string;
2475
+ }
2476
+
2477
+ /**
2478
+ * Add a payment method
2479
+ */
2480
+ export declare function useAddPaymentMethod(options?: Omit<UseMutationOptions<AddPaymentMethodResponse, Error, AddPaymentMethodInput>, 'mutationFn'>): UseMutationResult<AddPaymentMethodResponse, Error, AddPaymentMethodInput, unknown>;
2481
+
2482
+ /**
2483
+ * Fetch available plans for upgrade/downgrade
2484
+ *
2485
+ * @param subscriptionId - Subscription ID
2486
+ * @param options - React Query options
2487
+ *
2488
+ * @example
2489
+ * ```tsx
2490
+ * function AvailablePlans({ subscriptionId }: { subscriptionId: string }) {
2491
+ * const { data, isLoading } = useAvailablePlans(subscriptionId)
2492
+ *
2493
+ * if (isLoading) return <div>Loading plans...</div>
2494
+ *
2495
+ * return (
2496
+ * <div>
2497
+ * <h3>Upgrades:</h3>
2498
+ * {data?.available_upgrades.map(plan => (
2499
+ * <div key={plan.price_id}>{plan.product_name}</div>
2500
+ * ))}
2501
+ * </div>
2502
+ * )
2503
+ * }
2504
+ * ```
2505
+ */
2506
+ export declare function useAvailablePlans(subscriptionId: string, options?: Omit<UseQueryOptions<AvailablePlansResponse>, 'queryKey' | 'queryFn'>): UseQueryResult<AvailablePlansResponse, Error>;
2507
+
2508
+ /**
2509
+ * Hook to access the BillingOS context
2510
+ *
2511
+ * Must be used within a BillingOSProvider.
2512
+ *
2513
+ * @throws Error if used outside of BillingOSProvider
2514
+ *
2515
+ * @example
2516
+ * ```tsx
2517
+ * function MyComponent() {
2518
+ * const { client, customerId } = useBillingOS()
2519
+ *
2520
+ * // Use client to make API calls
2521
+ * const subscription = await client.getSubscription(id)
2522
+ *
2523
+ * return <div>Customer: {customerId}</div>
2524
+ * }
2525
+ * ```
2526
+ */
2527
+ export declare function useBillingOS(): BillingOSContextValue;
2528
+
2529
+ export { useBillingOSQueryClient }
2530
+
2531
+ /**
2532
+ * Cancel subscription with feedback
2533
+ */
2534
+ export declare function useCancelPortalSubscription(subscriptionId: string, options?: Omit<UseMutationOptions<PortalCancelSubscriptionResponse, Error, PortalCancelSubscriptionInput>, 'mutationFn'>): UseMutationResult<PortalCancelSubscriptionResponse, Error, PortalCancelSubscriptionInput, unknown>;
2535
+
2536
+ /**
2537
+ * Cancel a subscription
2538
+ *
2539
+ * @param subscriptionId - Subscription ID to cancel
2540
+ * @param options - React Query mutation options
2541
+ *
2542
+ * @example
2543
+ * ```tsx
2544
+ * function CancelButton({ subscriptionId }: { subscriptionId: string }) {
2545
+ * const cancelSubscription = useCancelSubscription(subscriptionId, {
2546
+ * onSuccess: () => {
2547
+ * alert('Subscription cancelled')
2548
+ * }
2549
+ * })
2550
+ *
2551
+ * const handleCancel = (immediately: boolean) => {
2552
+ * if (confirm('Are you sure you want to cancel?')) {
2553
+ * cancelSubscription.mutate({ immediately })
2554
+ * }
2555
+ * }
2556
+ *
2557
+ * return (
2558
+ * <div>
2559
+ * <button onClick={() => handleCancel(false)}>
2560
+ * Cancel at period end
2561
+ * </button>
2562
+ * <button onClick={() => handleCancel(true)}>
2563
+ * Cancel immediately
2564
+ * </button>
2565
+ * </div>
2566
+ * )
2567
+ * }
2568
+ * ```
2569
+ */
2570
+ export declare function useCancelSubscription(subscriptionId: string, options?: Omit<UseMutationOptions<Subscription, Error, {
2571
+ immediately?: boolean;
2572
+ }>, 'mutationFn'>): UseMutationResult<Subscription, Error, {
2573
+ immediately?: boolean;
2574
+ }, unknown>;
2575
+
2576
+ /**
2577
+ * Execute a plan change (upgrade/downgrade)
2578
+ *
2579
+ * @param options - React Query mutation options
2580
+ *
2581
+ * @example
2582
+ * ```tsx
2583
+ * function ChangePlanButton({ subscriptionId }: { subscriptionId: string }) {
2584
+ * const changePlan = useChangePlan({
2585
+ * onSuccess: (response) => {
2586
+ * console.log('Plan changed:', response.subscription.id)
2587
+ * }
2588
+ * })
2589
+ *
2590
+ * const handleChange = () => {
2591
+ * changePlan.mutate({
2592
+ * subscriptionId,
2593
+ * input: {
2594
+ * new_price_id: 'price_456',
2595
+ * confirm_amount: 1999
2596
+ * }
2597
+ * })
2598
+ * }
2599
+ *
2600
+ * return (
2601
+ * <button onClick={handleChange} disabled={changePlan.isPending}>
2602
+ * {changePlan.isPending ? 'Changing...' : 'Change Plan'}
2603
+ * </button>
2604
+ * )
2605
+ * }
2606
+ * ```
2607
+ */
2608
+ export declare function useChangePlan(options?: Omit<UseMutationOptions<ChangePlanResponse, Error, {
2609
+ subscriptionId: string;
2610
+ input: ChangePlanInput;
2611
+ }>, 'mutationFn'>): UseMutationResult<ChangePlanResponse, Error, {
2612
+ subscriptionId: string;
2613
+ input: ChangePlanInput;
2614
+ }, unknown>;
2615
+
2616
+ /**
2617
+ * Check if a customer has access to a specific feature
2618
+ *
2619
+ * @param customerId - Customer ID to check
2620
+ * @param featureKey - Feature key to check access for
2621
+ * @param options - React Query options
2622
+ *
2623
+ * @example
2624
+ * ```tsx
2625
+ * function FeatureGate({ children }: { children: React.ReactNode }) {
2626
+ * const { data: entitlement, isLoading } = useCheckEntitlement(
2627
+ * 'cus_123',
2628
+ * 'advanced_analytics'
2629
+ * )
2630
+ *
2631
+ * if (isLoading) return <div>Checking access...</div>
2632
+ * if (!entitlement?.has_access) {
2633
+ * return <UpgradePrompt feature="advanced_analytics" />
2634
+ * }
2635
+ *
2636
+ * return <>{children}</>
2637
+ * }
2638
+ * ```
2639
+ */
2640
+ export declare function useCheckEntitlement(customerId: string, featureKey: string, options?: Omit<UseQueryOptions<Entitlement>, 'queryKey' | 'queryFn'>): UseQueryResult<Entitlement, Error>;
2641
+
2642
+ /**
2643
+ * Hook for programmatically opening checkout
2644
+ */
2645
+ export declare function useCheckout(): {
2646
+ openCheckout: (options: Omit<CheckoutOpenOptions, "sessionToken" | "apiUrl">) => Promise<CheckoutResult>;
2647
+ closeCheckout: () => void;
2648
+ isLoading: boolean;
2649
+ error: Error | null;
2650
+ };
2651
+
2652
+ /**
2653
+ * Hook to confirm a checkout after payment
2654
+ */
2655
+ export declare function useConfirmCheckout(options?: {
2656
+ onSuccess?: (data: ConfirmCheckoutResponse) => void;
2657
+ onError?: (error: Error) => void;
2658
+ }): UseMutationResult<ConfirmCheckoutResponse, Error, {
2659
+ clientSecret: string;
2660
+ paymentMethodId: string;
2661
+ }, unknown>;
2662
+
2663
+ /**
2664
+ * Hook to create a checkout session
2665
+ */
2666
+ export declare function useCreateCheckout(input: CreateCheckoutInput | null, options?: {
2667
+ enabled?: boolean;
2668
+ onSuccess?: (data: CreateCheckoutResponse) => void;
2669
+ onError?: (error: Error) => void;
2670
+ }): UseQueryResult<CheckoutSession, Error>;
2671
+
2672
+ /**
2673
+ * Create a new subscription
2674
+ *
2675
+ * @param options - React Query mutation options
2676
+ *
2677
+ * @example
2678
+ * ```tsx
2679
+ * function CreateSubscriptionButton() {
2680
+ * const createSubscription = useCreateSubscription({
2681
+ * onSuccess: (subscription) => {
2682
+ * console.log('Subscription created:', subscription.id)
2683
+ * // Redirect to success page
2684
+ * },
2685
+ * onError: (error) => {
2686
+ * console.error('Failed to create subscription:', error)
2687
+ * }
2688
+ * })
2689
+ *
2690
+ * const handleClick = () => {
2691
+ * createSubscription.mutate({
2692
+ * customer_id: 'cus_123',
2693
+ * price_id: 'price_456',
2694
+ * trial_days: 14
2695
+ * })
2696
+ * }
2697
+ *
2698
+ * return (
2699
+ * <button
2700
+ * onClick={handleClick}
2701
+ * disabled={createSubscription.isPending}
2702
+ * >
2703
+ * {createSubscription.isPending ? 'Creating...' : 'Subscribe'}
2704
+ * </button>
2705
+ * )
2706
+ * }
2707
+ * ```
2708
+ */
2709
+ export declare function useCreateSubscription(options?: Omit<UseMutationOptions<Subscription, Error, CreateSubscriptionInput>, 'mutationFn'>): UseMutationResult<Subscription, Error, CreateSubscriptionInput, unknown>;
2710
+
2711
+ /**
2712
+ * Get all entitlements for a customer
2713
+ *
2714
+ * @param customerId - Customer ID
2715
+ * @param options - React Query options
2716
+ *
2717
+ * @example
2718
+ * ```tsx
2719
+ * function EntitlementsList({ customerId }: { customerId: string }) {
2720
+ * const { data: entitlements, isLoading } = useEntitlements(customerId)
2721
+ *
2722
+ * if (isLoading) return <div>Loading...</div>
2723
+ *
2724
+ * return (
2725
+ * <ul>
2726
+ * {entitlements?.map(entitlement => (
2727
+ * <li key={entitlement.feature_key}>
2728
+ * {entitlement.feature_key}: {entitlement.has_access ? '✓' : '✗'}
2729
+ * {entitlement.limit && ` (${entitlement.usage}/${entitlement.limit})`}
2730
+ * </li>
2731
+ * ))}
2732
+ * </ul>
2733
+ * )
2734
+ * }
2735
+ * ```
2736
+ */
2737
+ export declare function useEntitlements(customerId: string, options?: Omit<UseQueryOptions<Entitlement[]>, 'queryKey' | 'queryFn'>): UseQueryResult<Entitlement[], Error>;
2738
+
2739
+ /**
2740
+ * Hook to check if user has access to a feature
2741
+ */
2742
+ export declare function useFeature(featureKey: string, options?: {
2743
+ refetchInterval?: number;
2744
+ enabled?: boolean;
2745
+ }): UseQueryResult<FeatureAccess, Error>;
2746
+
2747
+ /**
2748
+ * Hook to get all feature entitlements for the current user
2749
+ */
2750
+ export declare function useFeatureEntitlements(): UseQueryResult< {
2751
+ entitlements: FeatureEntitlement[];
2752
+ }, Error>;
2753
+
2754
+ /**
2755
+ * Hook that combines feature access check and tracks when access is denied
2756
+ */
2757
+ export declare function useFeatureGate(featureKey: string, options?: {
2758
+ onAccessDenied?: () => void;
2759
+ onQuotaExceeded?: (usage: number, limit: number) => void;
2760
+ }): {
2761
+ hasAccess: boolean;
2762
+ isQuotaExceeded: boolean;
2763
+ usage: number;
2764
+ limit: number;
2765
+ remaining: number;
2766
+ data: FeatureAccess;
2767
+ error: Error;
2768
+ isError: true;
2769
+ isPending: false;
2770
+ isLoading: false;
2771
+ isLoadingError: false;
2772
+ isRefetchError: true;
2773
+ isSuccess: false;
2774
+ isPlaceholderData: false;
2775
+ status: "error";
2776
+ dataUpdatedAt: number;
2777
+ errorUpdatedAt: number;
2778
+ failureCount: number;
2779
+ failureReason: Error | null;
2780
+ errorUpdateCount: number;
2781
+ isFetched: boolean;
2782
+ isFetchedAfterMount: boolean;
2783
+ isFetching: boolean;
2784
+ isInitialLoading: boolean;
2785
+ isPaused: boolean;
2786
+ isRefetching: boolean;
2787
+ isStale: boolean;
2788
+ isEnabled: boolean;
2789
+ refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<FeatureAccess, Error>>;
2790
+ fetchStatus: FetchStatus;
2791
+ promise: Promise<FeatureAccess>;
2792
+ } | {
2793
+ hasAccess: boolean;
2794
+ isQuotaExceeded: boolean;
2795
+ usage: number;
2796
+ limit: number;
2797
+ remaining: number;
2798
+ data: FeatureAccess;
2799
+ error: null;
2800
+ isError: false;
2801
+ isPending: false;
2802
+ isLoading: false;
2803
+ isLoadingError: false;
2804
+ isRefetchError: false;
2805
+ isSuccess: true;
2806
+ isPlaceholderData: false;
2807
+ status: "success";
2808
+ dataUpdatedAt: number;
2809
+ errorUpdatedAt: number;
2810
+ failureCount: number;
2811
+ failureReason: Error | null;
2812
+ errorUpdateCount: number;
2813
+ isFetched: boolean;
2814
+ isFetchedAfterMount: boolean;
2815
+ isFetching: boolean;
2816
+ isInitialLoading: boolean;
2817
+ isPaused: boolean;
2818
+ isRefetching: boolean;
2819
+ isStale: boolean;
2820
+ isEnabled: boolean;
2821
+ refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<FeatureAccess, Error>>;
2822
+ fetchStatus: FetchStatus;
2823
+ promise: Promise<FeatureAccess>;
2824
+ } | {
2825
+ hasAccess: boolean;
2826
+ isQuotaExceeded: boolean;
2827
+ usage: number;
2828
+ limit: number;
2829
+ remaining: number;
2830
+ data: undefined;
2831
+ error: Error;
2832
+ isError: true;
2833
+ isPending: false;
2834
+ isLoading: false;
2835
+ isLoadingError: true;
2836
+ isRefetchError: false;
2837
+ isSuccess: false;
2838
+ isPlaceholderData: false;
2839
+ status: "error";
2840
+ dataUpdatedAt: number;
2841
+ errorUpdatedAt: number;
2842
+ failureCount: number;
2843
+ failureReason: Error | null;
2844
+ errorUpdateCount: number;
2845
+ isFetched: boolean;
2846
+ isFetchedAfterMount: boolean;
2847
+ isFetching: boolean;
2848
+ isInitialLoading: boolean;
2849
+ isPaused: boolean;
2850
+ isRefetching: boolean;
2851
+ isStale: boolean;
2852
+ isEnabled: boolean;
2853
+ refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<FeatureAccess, Error>>;
2854
+ fetchStatus: FetchStatus;
2855
+ promise: Promise<FeatureAccess>;
2856
+ } | {
2857
+ hasAccess: boolean;
2858
+ isQuotaExceeded: boolean;
2859
+ usage: number;
2860
+ limit: number;
2861
+ remaining: number;
2862
+ data: undefined;
2863
+ error: null;
2864
+ isError: false;
2865
+ isPending: true;
2866
+ isLoading: true;
2867
+ isLoadingError: false;
2868
+ isRefetchError: false;
2869
+ isSuccess: false;
2870
+ isPlaceholderData: false;
2871
+ status: "pending";
2872
+ dataUpdatedAt: number;
2873
+ errorUpdatedAt: number;
2874
+ failureCount: number;
2875
+ failureReason: Error | null;
2876
+ errorUpdateCount: number;
2877
+ isFetched: boolean;
2878
+ isFetchedAfterMount: boolean;
2879
+ isFetching: boolean;
2880
+ isInitialLoading: boolean;
2881
+ isPaused: boolean;
2882
+ isRefetching: boolean;
2883
+ isStale: boolean;
2884
+ isEnabled: boolean;
2885
+ refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<FeatureAccess, Error>>;
2886
+ fetchStatus: FetchStatus;
2887
+ promise: Promise<FeatureAccess>;
2888
+ } | {
2889
+ hasAccess: boolean;
2890
+ isQuotaExceeded: boolean;
2891
+ usage: number;
2892
+ limit: number;
2893
+ remaining: number;
2894
+ data: undefined;
2895
+ error: null;
2896
+ isError: false;
2897
+ isPending: true;
2898
+ isLoadingError: false;
2899
+ isRefetchError: false;
2900
+ isSuccess: false;
2901
+ isPlaceholderData: false;
2902
+ status: "pending";
2903
+ dataUpdatedAt: number;
2904
+ errorUpdatedAt: number;
2905
+ failureCount: number;
2906
+ failureReason: Error | null;
2907
+ errorUpdateCount: number;
2908
+ isFetched: boolean;
2909
+ isFetchedAfterMount: boolean;
2910
+ isFetching: boolean;
2911
+ isLoading: boolean;
2912
+ isInitialLoading: boolean;
2913
+ isPaused: boolean;
2914
+ isRefetching: boolean;
2915
+ isStale: boolean;
2916
+ isEnabled: boolean;
2917
+ refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<FeatureAccess, Error>>;
2918
+ fetchStatus: FetchStatus;
2919
+ promise: Promise<FeatureAccess>;
2920
+ } | {
2921
+ hasAccess: boolean;
2922
+ isQuotaExceeded: boolean;
2923
+ usage: number;
2924
+ limit: number;
2925
+ remaining: number;
2926
+ data: FeatureAccess;
2927
+ isError: false;
2928
+ error: null;
2929
+ isPending: false;
2930
+ isLoading: false;
2931
+ isLoadingError: false;
2932
+ isRefetchError: false;
2933
+ isSuccess: true;
2934
+ isPlaceholderData: true;
2935
+ status: "success";
2936
+ dataUpdatedAt: number;
2937
+ errorUpdatedAt: number;
2938
+ failureCount: number;
2939
+ failureReason: Error | null;
2940
+ errorUpdateCount: number;
2941
+ isFetched: boolean;
2942
+ isFetchedAfterMount: boolean;
2943
+ isFetching: boolean;
2944
+ isInitialLoading: boolean;
2945
+ isPaused: boolean;
2946
+ isRefetching: boolean;
2947
+ isStale: boolean;
2948
+ isEnabled: boolean;
2949
+ refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<FeatureAccess, Error>>;
2950
+ fetchStatus: FetchStatus;
2951
+ promise: Promise<FeatureAccess>;
2952
+ };
2953
+
2954
+ /**
2955
+ * Simplified hook to check if a customer has access to a feature
2956
+ * Returns a boolean directly instead of the full Entitlement object
2957
+ *
2958
+ * @param customerId - Customer ID to check
2959
+ * @param featureKey - Feature key to check access for
2960
+ * @param options - React Query options
2961
+ *
2962
+ * @example
2963
+ * ```tsx
2964
+ * function PremiumFeature() {
2965
+ * const hasAccess = useHasFeature('cus_123', 'premium_features')
2966
+ *
2967
+ * if (!hasAccess) {
2968
+ * return <div>Upgrade to access this feature</div>
2969
+ * }
2970
+ *
2971
+ * return <div>Premium feature content here</div>
2972
+ * }
2973
+ * ```
2974
+ */
2975
+ export declare function useHasFeature(customerId: string, featureKey: string, options?: Omit<UseQueryOptions<Entitlement>, 'queryKey' | 'queryFn'>): boolean;
2976
+
2977
+ /**
2978
+ * Check if a customer is approaching their usage limit
2979
+ *
2980
+ * @param customerId - Customer ID
2981
+ * @param featureKey - Feature key
2982
+ * @param threshold - Threshold percentage (0-100) to warn at (default: 80)
2983
+ * @param options - React Query options
2984
+ * @returns Boolean indicating if customer is approaching limit
2985
+ *
2986
+ * @example
2987
+ * ```tsx
2988
+ * function UsageWarning({ customerId }: { customerId: string }) {
2989
+ * const isApproachingLimit = useIsApproachingLimit(
2990
+ * customerId,
2991
+ * 'api_calls',
2992
+ * 80 // Warn at 80%
2993
+ * )
2994
+ *
2995
+ * if (!isApproachingLimit) return null
2996
+ *
2997
+ * return (
2998
+ * <Alert variant="warning">
2999
+ * You're approaching your API call limit. Upgrade to increase your quota.
3000
+ * </Alert>
3001
+ * )
3002
+ * }
3003
+ * ```
3004
+ */
3005
+ export declare function useIsApproachingLimit(customerId: string, featureKey: string, threshold?: number, options?: Omit<UseQueryOptions<UsageMetrics>, 'queryKey' | 'queryFn'>): boolean;
3006
+
3007
+ /**
3008
+ * Fetch all portal data for the current customer
3009
+ * Returns subscription, invoices, payment methods, customer info, and available plans
3010
+ */
3011
+ export declare function usePortalData(options?: Omit<UseQueryOptions<CustomerPortalData>, 'queryKey' | 'queryFn'>): UseQueryResult<CustomerPortalData, Error>;
3012
+
3013
+ /**
3014
+ * Preview a plan change with proration details
3015
+ *
3016
+ * @param options - React Query mutation options
3017
+ *
3018
+ * @example
3019
+ * ```tsx
3020
+ * function PlanChangePreview({ subscriptionId }: { subscriptionId: string }) {
3021
+ * const previewChange = usePreviewPlanChange()
3022
+ *
3023
+ * const handlePreview = async (newPriceId: string) => {
3024
+ * const preview = await previewChange.mutateAsync({
3025
+ * subscriptionId,
3026
+ * input: { new_price_id: newPriceId }
3027
+ * })
3028
+ * console.log('Proration:', preview.proration.immediate_payment)
3029
+ * }
3030
+ *
3031
+ * return <button onClick={() => handlePreview('price_123')}>Preview</button>
3032
+ * }
3033
+ * ```
3034
+ */
3035
+ export declare function usePreviewPlanChange(options?: Omit<UseMutationOptions<PreviewChangeResponse, Error, {
3036
+ subscriptionId: string;
3037
+ input: PreviewChangeInput;
3038
+ }>, 'mutationFn'>): UseMutationResult<PreviewChangeResponse, Error, {
3039
+ subscriptionId: string;
3040
+ input: PreviewChangeInput;
3041
+ }, unknown>;
3042
+
3043
+ /**
3044
+ * Hook to fetch products for pricing table
3045
+ */
3046
+ export declare function usePricingTableProducts(options?: UseProductsOptions): UseQueryResult<GetProductsResponse, Error>;
3047
+
3048
+ /**
3049
+ * Hook to fetch products for pricing table
3050
+ */
3051
+ export declare function useProducts(): UseQueryResult< {
3052
+ products: Product[];
3053
+ }, Error>;
3054
+
3055
+ export declare interface UseProductsOptions {
3056
+ /**
3057
+ * Optional array of plan IDs to filter
3058
+ */
3059
+ planIds?: string[];
3060
+ /**
3061
+ * Whether to enable the query
3062
+ */
3063
+ enabled?: boolean;
3064
+ }
3065
+
3066
+ /**
3067
+ * Reactivate a canceled subscription
3068
+ */
3069
+ export declare function useReactivatePortalSubscription(subscriptionId: string, options?: Omit<UseMutationOptions<void, Error, void>, 'mutationFn'>): UseMutationResult<void, Error, void, unknown>;
3070
+
3071
+ /**
3072
+ * Reactivate a canceled subscription
3073
+ *
3074
+ * @param subscriptionId - Subscription ID to reactivate
3075
+ * @param options - React Query mutation options
3076
+ *
3077
+ * @example
3078
+ * ```tsx
3079
+ * function ReactivateButton({ subscriptionId }: { subscriptionId: string }) {
3080
+ * const reactivateSubscription = useReactivateSubscription(subscriptionId)
3081
+ *
3082
+ * return (
3083
+ * <button
3084
+ * onClick={() => reactivateSubscription.mutate()}
3085
+ * disabled={reactivateSubscription.isPending}
3086
+ * >
3087
+ * Reactivate Subscription
3088
+ * </button>
3089
+ * )
3090
+ * }
3091
+ * ```
3092
+ */
3093
+ export declare function useReactivateSubscription(subscriptionId: string, options?: Omit<UseMutationOptions<Subscription, Error, void>, 'mutationFn'>): UseMutationResult<Subscription, Error, void, unknown>;
3094
+
3095
+ /**
3096
+ * Remove a payment method
3097
+ */
3098
+ export declare function useRemovePaymentMethod(options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'>): UseMutationResult<void, Error, string, unknown>;
3099
+
3100
+ /**
3101
+ * Retry a failed invoice
3102
+ */
3103
+ export declare function useRetryInvoice(options?: Omit<UseMutationOptions<RetryInvoiceResponse, Error, {
3104
+ invoiceId: string;
3105
+ paymentMethodId?: string;
3106
+ }>, 'mutationFn'>): UseMutationResult<RetryInvoiceResponse, Error, {
3107
+ invoiceId: string;
3108
+ paymentMethodId?: string;
3109
+ }, unknown>;
3110
+
3111
+ /**
3112
+ * Hook to manage session tokens with automatic fetching and refreshing
3113
+ *
3114
+ * @example
3115
+ * // Auto-fetch from endpoint
3116
+ * const { token, isLoading } = useSessionToken({
3117
+ * tokenUrl: '/api/billingos-session',
3118
+ * });
3119
+ *
3120
+ * @example
3121
+ * // Manual token
3122
+ * const { token } = useSessionToken({
3123
+ * token: 'bos_session_abc123...',
3124
+ * });
3125
+ */
3126
+ export declare function useSessionToken(options?: UseSessionTokenOptions): UseSessionTokenReturn;
3127
+
3128
+ export declare interface UseSessionTokenOptions {
3129
+ /** URL to fetch session token from (e.g., /api/billingos-session) */
3130
+ tokenUrl?: string;
3131
+ /** Manually provided session token */
3132
+ token?: string;
3133
+ /** How many seconds before expiry to refresh (default: 300 = 5 minutes) */
3134
+ refreshBeforeExpiry?: number;
3135
+ /** Enable auto-refresh (default: true) */
3136
+ autoRefresh?: boolean;
3137
+ /** Callback when token is refreshed */
3138
+ onTokenRefresh?: (token: string) => void;
3139
+ /** Callback when token fetch fails */
3140
+ onError?: (error: Error) => void;
3141
+ }
3142
+
3143
+ export declare interface UseSessionTokenReturn {
3144
+ /** Current session token */
3145
+ token: string | null;
3146
+ /** When the token expires */
3147
+ expiresAt: Date | null;
3148
+ /** Whether the token is currently being fetched */
3149
+ isLoading: boolean;
3150
+ /** Any error that occurred */
3151
+ error: Error | null;
3152
+ /** Manually refresh the token */
3153
+ refresh: () => Promise<void>;
3154
+ /** Whether the token is valid (not expired) */
3155
+ isValid: boolean;
3156
+ }
3157
+
3158
+ /**
3159
+ * Set default payment method
3160
+ */
3161
+ export declare function useSetDefaultPaymentMethod(options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'>): UseMutationResult<void, Error, string, unknown>;
3162
+
3163
+ /**
3164
+ * Get setup intent for adding a new payment method
3165
+ */
3166
+ export declare function useSetupIntent(options?: Omit<UseQueryOptions<SetupIntentResponse>, 'queryKey' | 'queryFn'>): UseQueryResult<SetupIntentResponse, Error>;
3167
+
3168
+ /**
3169
+ * Fetch a single subscription by ID
3170
+ *
3171
+ * @param id - Subscription ID
3172
+ * @param options - React Query options
3173
+ *
3174
+ * @example
3175
+ * ```tsx
3176
+ * function SubscriptionDetails({ id }: { id: string }) {
3177
+ * const { data: subscription, isLoading, error } = useSubscription(id)
3178
+ *
3179
+ * if (isLoading) return <div>Loading...</div>
3180
+ * if (error) return <div>Error: {error.message}</div>
3181
+ *
3182
+ * return (
3183
+ * <div>
3184
+ * <h1>Subscription Status: {subscription.status}</h1>
3185
+ * <p>Next billing: {subscription.current_period_end}</p>
3186
+ * </div>
3187
+ * )
3188
+ * }
3189
+ * ```
3190
+ */
3191
+ export declare function useSubscription(id: string, options?: Omit<UseQueryOptions<Subscription>, 'queryKey' | 'queryFn'>): UseQueryResult<Subscription, Error>;
3192
+
3193
+ /**
3194
+ * Preview subscription changes before applying them
3195
+ *
3196
+ * @param subscriptionId - Subscription ID
3197
+ * @param input - Proposed changes
3198
+ * @param options - React Query options
3199
+ *
3200
+ * @example
3201
+ * ```tsx
3202
+ * function UpgradePreview({ subscriptionId }: { subscriptionId: string }) {
3203
+ * const { data: preview, isLoading } = useSubscriptionPreview(
3204
+ * subscriptionId,
3205
+ * { price_id: 'price_pro_plan' }
3206
+ * )
3207
+ *
3208
+ * if (isLoading) return <div>Calculating...</div>
3209
+ *
3210
+ * return (
3211
+ * <div>
3212
+ * <p>Proration: ${preview?.proration_amount / 100}</p>
3213
+ * <p>Next invoice: ${preview?.next_invoice_amount / 100}</p>
3214
+ * <p>Billing date: {preview?.next_invoice_date}</p>
3215
+ * </div>
3216
+ * )
3217
+ * }
3218
+ * ```
3219
+ */
3220
+ export declare function useSubscriptionPreview(subscriptionId: string, input: UpdateSubscriptionInput, options?: Omit<UseQueryOptions<SubscriptionPreview>, 'queryKey' | 'queryFn'>): UseQueryResult<SubscriptionPreview, Error>;
3221
+
3222
+ /**
3223
+ * Fetch a list of subscriptions (paginated)
3224
+ *
3225
+ * @param params - Query parameters (customer_id, pagination)
3226
+ * @param options - React Query options
3227
+ *
3228
+ * @example
3229
+ * ```tsx
3230
+ * function SubscriptionsList() {
3231
+ * const { data, isLoading } = useSubscriptions({
3232
+ * customer_id: 'cus_123',
3233
+ * page: 1,
3234
+ * page_size: 10
3235
+ * })
3236
+ *
3237
+ * if (isLoading) return <div>Loading...</div>
3238
+ *
3239
+ * return (
3240
+ * <div>
3241
+ * {data?.data.map(subscription => (
3242
+ * <SubscriptionCard key={subscription.id} subscription={subscription} />
3243
+ * ))}
3244
+ * <p>Total: {data?.meta.total}</p>
3245
+ * </div>
3246
+ * )
3247
+ * }
3248
+ * ```
3249
+ */
3250
+ export declare function useSubscriptions(params?: {
3251
+ customer_id?: string;
3252
+ page?: number;
3253
+ page_size?: number;
3254
+ }, options?: Omit<UseQueryOptions<PaginatedResponse<Subscription>>, 'queryKey' | 'queryFn'>): UseQueryResult<PaginatedResponse<Subscription>, Error>;
3255
+
3256
+ /**
3257
+ * Hook to track usage for a feature
3258
+ */
3259
+ export declare function useTrackUsage(): UseMutationResult<unknown, Error, {
3260
+ featureKey: string;
3261
+ quantity: number;
3262
+ metadata?: Record<string, any>;
3263
+ }, unknown>;
3264
+
3265
+ /**
3266
+ * Update customer billing information
3267
+ */
3268
+ export declare function useUpdateCustomerBilling(options?: Omit<UseMutationOptions<CustomerBillingInfo, Error, UpdateCustomerBillingInput>, 'mutationFn'>): UseMutationResult<CustomerBillingInfo, Error, UpdateCustomerBillingInput, unknown>;
3269
+
3270
+ /**
3271
+ * Update subscription (upgrade/downgrade)
3272
+ */
3273
+ export declare function useUpdatePortalSubscription(subscriptionId: string, options?: Omit<UseMutationOptions<PortalUpdateSubscriptionResponse, Error, PortalUpdateSubscriptionInput>, 'mutationFn'>): UseMutationResult<PortalUpdateSubscriptionResponse, Error, PortalUpdateSubscriptionInput, unknown>;
3274
+
3275
+ /**
3276
+ * Update an existing subscription
3277
+ *
3278
+ * @param subscriptionId - Subscription ID to update
3279
+ * @param options - React Query mutation options
3280
+ *
3281
+ * @example
3282
+ * ```tsx
3283
+ * function UpgradeButton({ subscriptionId }: { subscriptionId: string }) {
3284
+ * const updateSubscription = useUpdateSubscription(subscriptionId, {
3285
+ * onSuccess: () => {
3286
+ * console.log('Subscription updated!')
3287
+ * }
3288
+ * })
3289
+ *
3290
+ * const handleUpgrade = () => {
3291
+ * updateSubscription.mutate({
3292
+ * price_id: 'price_pro_plan'
3293
+ * })
3294
+ * }
3295
+ *
3296
+ * return (
3297
+ * <button onClick={handleUpgrade} disabled={updateSubscription.isPending}>
3298
+ * Upgrade to Pro
3299
+ * </button>
3300
+ * )
3301
+ * }
3302
+ * ```
3303
+ */
3304
+ export declare function useUpdateSubscription(subscriptionId: string, options?: Omit<UseMutationOptions<Subscription, Error, UpdateSubscriptionInput>, 'mutationFn'>): UseMutationResult<Subscription, Error, UpdateSubscriptionInput, unknown>;
3305
+
3306
+ /**
3307
+ * Hook to check usage and get nudge trigger
3308
+ */
3309
+ export declare function useUsageCheck(options?: UseUsageCheckOptions): UseQueryResult<UsageCheckResponse, Error>;
3310
+
3311
+ export declare interface UseUsageCheckOptions {
3312
+ /**
3313
+ * Whether to enable the query
3314
+ */
3315
+ enabled?: boolean;
3316
+ /**
3317
+ * Refetch interval in milliseconds (0 = no auto refetch)
3318
+ */
3319
+ refetchInterval?: number;
3320
+ }
3321
+
3322
+ /**
3323
+ * Hook to get usage metrics for features
3324
+ */
3325
+ export declare function useUsageMetrics(featureKey?: string): UseQueryResult< {
3326
+ metrics: UsageMetric[];
3327
+ }, Error>;
3328
+
3329
+ /**
3330
+ * Thrown when the request fails validation (400)
3331
+ */
3332
+ export declare class ValidationError extends BillingOSError {
3333
+ constructor(message?: string, data?: unknown);
3334
+ }
3335
+
3336
+ export declare function WarningBanner({ type, message, actionLabel, onAction, className, }: WarningBannerProps): JSX.Element;
3337
+
3338
+ declare interface WarningBannerProps {
3339
+ type: 'trial_ending' | 'payment_failed' | 'subscription_canceled' | 'past_due';
3340
+ message: string;
3341
+ actionLabel?: string;
3342
+ onAction?: () => void;
3343
+ className?: string;
3344
+ }
3345
+
3346
+ export { }