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