@billingos/sdk 0.1.2 → 0.1.4

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