@aios-inc/cashier 0.0.0-stage → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Every merge to `main` with a `feat` or `fix` commit is released automatically, and the notes for each version are generated from its commit messages and published on [GitHub Releases](https://github.com/aios-inc/cashier/releases).
4
+
5
+ The first release is summarized below.
6
+
7
+ ## [0.1.0]
8
+
9
+ ### Added
10
+
11
+ - `Cashier` class and a shared `cashier` instance with `use('stripe' | 'recurly', { apiKey })`.
12
+ - Stripe driver built on `stripe` v13 with the API version pinned to `2023-08-16`.
13
+ - Recurly driver built on `recurly` v4.
14
+ - Customers, invoices, products, prices and subscriptions resources with one set of types for both providers.
15
+ - Amounts in minor units and uppercase ISO 4217 currency codes for every provider.
16
+ - Typed errors that extend `CashierError`, mapped from Stripe and Recurly errors.
17
+ - CommonJS and ES module builds with TypeScript declarations.
18
+
19
+ [0.1.0]: https://github.com/aios-inc/cashier/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AIOS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,67 @@
1
- # Temporary Holding Version
1
+ # Cashier
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/@aios-inc/cashier.svg)](https://www.npmjs.com/package/@aios-inc/cashier)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/aios-inc/cashier/blob/main/LICENSE)
5
+
6
+ Unified subscription billing for Node.js and TypeScript. One API for every payment provider, with typed errors. Stripe and Recurly are supported today.
7
+
8
+ ```bash
9
+ npm install @aios-inc/cashier stripe recurly
10
+ ```
11
+
12
+ ```ts
13
+ import { CashierProvider, createCashier } from '@aios-inc/cashier';
14
+
15
+ const cashier = createCashier({
16
+ default: CashierProvider.Stripe,
17
+ providers: {
18
+ stripe: { apiKey: process.env.STRIPE_SECRET_KEY! },
19
+ recurly: { apiKey: process.env.RECURLY_API_KEY! },
20
+ },
21
+ });
22
+
23
+ const billing = cashier.use();
24
+
25
+ const customer = await billing.customers.create({ email: 'jane@example.com' });
26
+
27
+ await billing.subscriptions.create({
28
+ customer: customer.id,
29
+ price: 'price_123',
30
+ currency: 'USD',
31
+ });
32
+ ```
33
+
34
+ To switch providers, change `default`. Your billing code stays the same. Use `cashier.use(CashierProvider.Recurly)` to run several providers side by side.
35
+
36
+ ## Why Cashier
37
+
38
+ - **One interface.** Same methods and the same result shapes on every provider.
39
+ - **Consistent data.** Amounts in cents, uppercase ISO 4217 currencies, `Date` timestamps.
40
+ - **Typed errors.** `NotFoundError`, `PaymentFailedError`, `RateLimitError` and more, with the provider error kept as `cause`.
41
+ - **Framework ready.** NestJS and Express packages included.
42
+ - **No extra dependencies.** Only the provider SDKs you install.
43
+
44
+ ## Providers
45
+
46
+ [Stripe](https://www.npmjs.com/package/stripe) v13 and [Recurly](https://www.npmjs.com/package/recurly) v4.67 or later. Node.js 20 or later.
47
+
48
+ ## Packages
49
+
50
+ - [`@aios-inc/cashier`](https://www.npmjs.com/package/@aios-inc/cashier): the core library
51
+ - [`@aios-inc/cashier-nestjs`](https://github.com/aios-inc/cashier/tree/main/packages/nestjs#readme): NestJS module
52
+ - [`@aios-inc/cashier-express`](https://github.com/aios-inc/cashier/tree/main/packages/express#readme): Express middleware
53
+
54
+ ## Documentation
55
+
56
+ - [API reference](https://github.com/aios-inc/cashier/blob/main/docs/README.md#api-reference): customers, invoices, payments, products, prices and subscriptions
57
+ - [TypeScript](https://github.com/aios-inc/cashier/blob/main/docs/typescript.md), [NestJS](https://github.com/aios-inc/cashier/blob/main/docs/nestjs.md), [Express](https://github.com/aios-inc/cashier/blob/main/docs/express.md)
58
+ - [Drivers and conventions](https://github.com/aios-inc/cashier/blob/main/docs/drivers.md)
59
+ - [Errors](https://github.com/aios-inc/cashier/blob/main/docs/errors.md)
60
+
61
+ ## Contributing
62
+
63
+ See [CONTRIBUTING.md](https://github.com/aios-inc/cashier/blob/main/CONTRIBUTING.md) and [SECURITY.md](https://github.com/aios-inc/cashier/blob/main/SECURITY.md).
64
+
65
+ ## License
66
+
67
+ [MIT](https://github.com/aios-inc/cashier/blob/main/LICENSE) © AIOS
@@ -0,0 +1,482 @@
1
+ interface Customer {
2
+ id: string;
3
+ code: string | null;
4
+ email: string | null;
5
+ name: string | null;
6
+ metadata: Record<string, string>;
7
+ createdAt: Date;
8
+ provider: CashierProvider;
9
+ }
10
+ interface ListCustomersParams {
11
+ email?: string;
12
+ limit?: number;
13
+ }
14
+ interface CreateCustomerParams {
15
+ email: string;
16
+ code?: string;
17
+ firstName?: string;
18
+ lastName?: string;
19
+ metadata?: Record<string, string>;
20
+ }
21
+ interface UpdateCustomerParams {
22
+ email?: string;
23
+ firstName?: string;
24
+ lastName?: string;
25
+ metadata?: Record<string, string>;
26
+ }
27
+ interface CustomersResource {
28
+ get(customerId: string): Promise<Customer>;
29
+ list(params?: ListCustomersParams): Promise<Customer[]>;
30
+ create(params: CreateCustomerParams): Promise<Customer>;
31
+ update(customerId: string, params: UpdateCustomerParams): Promise<Customer>;
32
+ }
33
+
34
+ interface CursorPaginateParams {
35
+ customer: string;
36
+ perPage?: number;
37
+ cursor?: string | null;
38
+ }
39
+ interface CursorPaginator<Item> {
40
+ data: Item[];
41
+ perPage: number;
42
+ hasMorePages: boolean;
43
+ nextCursor: string | null;
44
+ }
45
+
46
+ type ProviderRelation<Relations extends Record<CashierProvider, string>, Provider extends CashierProvider> = (Provider extends CashierProvider ? (relation: Relations[Provider]) => void : never) extends (relation: infer Relation) => void ? Relation : never;
47
+ type LoadedRelations<Fields, Relation extends keyof Fields> = (Relation extends keyof Fields ? (fields: Fields[Relation]) => void : never) extends (fields: infer Loaded) => void ? Loaded : never;
48
+ interface WithParams<Relation extends string> {
49
+ with?: readonly Relation[];
50
+ }
51
+
52
+ type InvoiceStatus = 'draft' | 'open' | 'paid' | 'past_due' | 'failed' | 'void' | 'uncollectible' | 'closed' | 'unknown';
53
+ interface Invoice {
54
+ id: string;
55
+ number: string | null;
56
+ customerId: string | null;
57
+ subscriptionIds: string[];
58
+ billingReason: string | null;
59
+ status: InvoiceStatus;
60
+ currency: string;
61
+ subtotal: number;
62
+ tax: number;
63
+ total: number;
64
+ attemptCount: number;
65
+ hostedInvoiceUrl: string | null;
66
+ createdAt: Date;
67
+ dueDate: Date | null;
68
+ paidAt: Date | null;
69
+ provider: CashierProvider;
70
+ }
71
+ interface InvoiceRelationFields {
72
+ refunds: {
73
+ amountRefunded: number;
74
+ };
75
+ }
76
+ type InvoiceRelation = keyof InvoiceRelationFields;
77
+ interface CashierInvoiceRelations {
78
+ stripe: 'refunds';
79
+ recurly: 'refunds';
80
+ }
81
+ type ProviderInvoiceRelation<Provider extends CashierProvider> = Extract<ProviderRelation<CashierInvoiceRelations, Provider>, InvoiceRelation>;
82
+ type InvoiceWith<Relation extends InvoiceRelation = never> = Invoice & LoadedRelations<InvoiceRelationFields, Relation>;
83
+ type GetInvoiceParams<Relation extends InvoiceRelation = never> = WithParams<Relation>;
84
+ interface ListInvoicesParams<Relation extends InvoiceRelation = never> extends WithParams<Relation> {
85
+ customer: string;
86
+ status?: 'paid';
87
+ limit?: number;
88
+ }
89
+ interface CursorPaginateInvoicesParams<Relation extends InvoiceRelation = never> extends CursorPaginateParams, WithParams<Relation> {
90
+ status?: 'paid';
91
+ }
92
+ type InvoiceCollection = 'charge_automatically' | 'send_invoice';
93
+ interface CreateInvoiceLineItem {
94
+ description: string;
95
+ amount: number;
96
+ }
97
+ interface CreateInvoiceParams {
98
+ customer: string;
99
+ currency: string;
100
+ lineItems: CreateInvoiceLineItem[];
101
+ collection: InvoiceCollection;
102
+ chargeNow?: boolean;
103
+ description?: string;
104
+ dueDate?: Date;
105
+ daysUntilDue?: number;
106
+ paymentMethod?: string;
107
+ paymentMethodTypes?: string[];
108
+ metadata?: Record<string, string>;
109
+ idempotencyKey?: string;
110
+ }
111
+ interface PayInvoiceParams {
112
+ paymentMethod?: string;
113
+ }
114
+ interface InvoicesResource<Provider extends CashierProvider = CashierProvider> {
115
+ get<Relation extends ProviderInvoiceRelation<Provider> = never>(invoiceId: string, params?: GetInvoiceParams<Relation>): Promise<InvoiceWith<Relation>>;
116
+ list<Relation extends ProviderInvoiceRelation<Provider> = never>(params: ListInvoicesParams<Relation>): Promise<InvoiceWith<Relation>[]>;
117
+ cursorPaginate<Relation extends ProviderInvoiceRelation<Provider> = never>(params: CursorPaginateInvoicesParams<Relation>): Promise<CursorPaginator<InvoiceWith<Relation>>>;
118
+ create(params: CreateInvoiceParams): Promise<Invoice>;
119
+ pay(invoiceId: string, params?: PayInvoiceParams): Promise<Invoice>;
120
+ void(invoiceId: string): Promise<Invoice>;
121
+ }
122
+
123
+ type BillingIntervalUnit = 'day' | 'week' | 'month' | 'year';
124
+ interface BillingInterval {
125
+ unit: BillingIntervalUnit;
126
+ count: number;
127
+ }
128
+ interface Price {
129
+ id: string;
130
+ productId: string;
131
+ currency: string;
132
+ unitAmount: number | null;
133
+ type: 'one_time' | 'recurring';
134
+ interval: BillingInterval | null;
135
+ active: boolean;
136
+ createdAt: Date;
137
+ provider: CashierProvider;
138
+ }
139
+ interface ListPricesParams {
140
+ product?: string;
141
+ active?: boolean;
142
+ limit?: number;
143
+ }
144
+ interface PricesResource {
145
+ get(priceId: string): Promise<Price>;
146
+ list(params?: ListPricesParams): Promise<Price[]>;
147
+ }
148
+
149
+ type SubscriptionStatus = 'active' | 'trialing' | 'past_due' | 'unpaid' | 'paused' | 'canceled' | 'incomplete' | 'incomplete_expired' | 'future' | 'failed' | 'unknown';
150
+ interface SubscriptionItem {
151
+ id: string | null;
152
+ priceId: string;
153
+ quantity: number;
154
+ unitAmount: number | null;
155
+ }
156
+ interface Subscription {
157
+ id: string;
158
+ customerId: string | null;
159
+ status: SubscriptionStatus;
160
+ items: SubscriptionItem[];
161
+ currency: string;
162
+ currentPeriodStart: Date | null;
163
+ currentPeriodEnd: Date | null;
164
+ cancelAtPeriodEnd: boolean;
165
+ cancelAt: Date | null;
166
+ canceledAt: Date | null;
167
+ trialEnd: Date | null;
168
+ createdAt: Date;
169
+ metadata: Record<string, string>;
170
+ provider: CashierProvider;
171
+ }
172
+ interface SubscriptionProduct {
173
+ id: string;
174
+ name: string;
175
+ }
176
+ interface SubscriptionPause {
177
+ behavior: string | null;
178
+ resumesAt: Date | null;
179
+ }
180
+ interface SubscriptionDiscount {
181
+ couponId: string;
182
+ name: string | null;
183
+ amountOff: number | null;
184
+ percentOff: number | null;
185
+ }
186
+ interface SubscriptionRelationFields {
187
+ product: {
188
+ product: SubscriptionProduct | null;
189
+ };
190
+ interval: {
191
+ interval: BillingInterval | null;
192
+ };
193
+ pause: {
194
+ pause: SubscriptionPause | null;
195
+ };
196
+ discount: {
197
+ discount: SubscriptionDiscount | null;
198
+ };
199
+ }
200
+ type SubscriptionRelation = keyof SubscriptionRelationFields;
201
+ interface CashierSubscriptionRelations {
202
+ stripe: 'product' | 'interval' | 'pause' | 'discount';
203
+ recurly: 'product' | 'interval' | 'pause' | 'discount';
204
+ }
205
+ type ProviderSubscriptionRelation<Provider extends CashierProvider> = Extract<ProviderRelation<CashierSubscriptionRelations, Provider>, SubscriptionRelation>;
206
+ type SubscriptionWith<Relation extends SubscriptionRelation = never> = Subscription & LoadedRelations<SubscriptionRelationFields, Relation>;
207
+ type SubscriptionStatusFilter = SubscriptionStatus | 'all';
208
+ interface ListSubscriptionsParams<Relation extends SubscriptionRelation = never> extends WithParams<Relation> {
209
+ customer: string;
210
+ status?: SubscriptionStatusFilter;
211
+ limit?: number;
212
+ }
213
+ type SubscriptionScope = {
214
+ customer: string;
215
+ price?: string;
216
+ } | {
217
+ customer?: string;
218
+ price: string;
219
+ };
220
+ type CursorPaginateSubscriptionsParams<Relation extends SubscriptionRelation = never> = Omit<CursorPaginateParams, 'customer'> & WithParams<Relation> & SubscriptionScope & {
221
+ status?: SubscriptionStatusFilter;
222
+ };
223
+ interface CreateSubscriptionParams {
224
+ customer: string;
225
+ price: string;
226
+ currency: string;
227
+ quantity?: number;
228
+ paymentMethod?: string;
229
+ couponCode?: string;
230
+ trialEnd?: Date;
231
+ metadata?: Record<string, string>;
232
+ }
233
+ interface UpdateSubscriptionParams {
234
+ price?: string;
235
+ quantity?: number;
236
+ metadata?: Record<string, string>;
237
+ }
238
+ interface CancelSubscriptionParams {
239
+ atPeriodEnd?: boolean;
240
+ comment?: string;
241
+ }
242
+ interface SubscriptionsResource<Provider extends CashierProvider = CashierProvider> {
243
+ list<Relation extends ProviderSubscriptionRelation<Provider> = never>(params: ListSubscriptionsParams<Relation>): Promise<SubscriptionWith<Relation>[]>;
244
+ cursorPaginate<Relation extends ProviderSubscriptionRelation<Provider> = never>(params: CursorPaginateSubscriptionsParams<Relation>): Promise<CursorPaginator<SubscriptionWith<Relation>>>;
245
+ create(params: CreateSubscriptionParams): Promise<Subscription>;
246
+ get(subscriptionId: string): Promise<Subscription>;
247
+ update(subscriptionId: string, params: UpdateSubscriptionParams): Promise<Subscription>;
248
+ cancel(subscriptionId: string, params?: CancelSubscriptionParams): Promise<Subscription>;
249
+ }
250
+
251
+ type PaymentStatus = 'succeeded' | 'pending' | 'incomplete' | 'failed' | 'canceled' | 'unknown';
252
+ type PaymentDisputeStatus = 'warning_needs_response' | 'warning_under_review' | 'warning_closed' | 'needs_response' | 'under_review' | 'won' | 'lost' | 'unknown';
253
+ declare enum RefundReason {
254
+ Duplicate = "duplicate",
255
+ Fraudulent = "fraudulent",
256
+ RequestedByCustomer = "requested_by_customer"
257
+ }
258
+ type RefundStatus = 'succeeded' | 'pending' | 'failed' | 'canceled' | 'unknown';
259
+ interface PaymentDispute {
260
+ id: string;
261
+ status: PaymentDisputeStatus;
262
+ reason: string;
263
+ createdAt: Date;
264
+ evidenceDueBy: Date | null;
265
+ }
266
+ interface PaymentSubscription {
267
+ id: string;
268
+ status: SubscriptionStatus | null;
269
+ cancelAt: Date | null;
270
+ }
271
+ interface Payment {
272
+ id: string;
273
+ customerId: string | null;
274
+ invoiceId: string | null;
275
+ status: PaymentStatus;
276
+ amount: number;
277
+ currency: string;
278
+ description: string | null;
279
+ createdAt: Date;
280
+ provider: CashierProvider;
281
+ }
282
+ interface Refund {
283
+ id: string;
284
+ paymentId: string;
285
+ status: RefundStatus;
286
+ amount: number;
287
+ currency: string;
288
+ reason: RefundReason | null;
289
+ createdAt: Date;
290
+ provider: CashierProvider;
291
+ }
292
+ interface PaymentRelationFields {
293
+ refunds: {
294
+ amountRefunded: number;
295
+ };
296
+ dispute: {
297
+ dispute: PaymentDispute | null;
298
+ };
299
+ receipt: {
300
+ receiptUrl: string | null;
301
+ };
302
+ reversal: {
303
+ reversed: boolean;
304
+ };
305
+ subscription: {
306
+ subscription: PaymentSubscription | null;
307
+ };
308
+ }
309
+ type PaymentRelation = keyof PaymentRelationFields;
310
+ interface CashierPaymentRelations {
311
+ stripe: 'refunds' | 'dispute' | 'receipt' | 'reversal' | 'subscription';
312
+ recurly: 'refunds' | 'subscription';
313
+ }
314
+ type ProviderPaymentRelation<Provider extends CashierProvider> = Extract<ProviderRelation<CashierPaymentRelations, Provider>, PaymentRelation>;
315
+ type PaymentWith<Relation extends PaymentRelation = never> = Payment & LoadedRelations<PaymentRelationFields, Relation>;
316
+ interface ListPaymentsParams<Relation extends PaymentRelation = never> extends WithParams<Relation> {
317
+ customer: string;
318
+ limit?: number;
319
+ }
320
+ interface CursorPaginatePaymentsParams<Relation extends PaymentRelation = never> extends CursorPaginateParams, WithParams<Relation> {
321
+ }
322
+ interface CreatePaymentParams {
323
+ customer: string;
324
+ currency: string;
325
+ amount: number;
326
+ paymentMethod: string;
327
+ description?: string;
328
+ metadata?: Record<string, string>;
329
+ idempotencyKey?: string;
330
+ }
331
+ interface RefundPaymentParams {
332
+ amount?: number;
333
+ reason?: RefundReason;
334
+ metadata?: Record<string, string>;
335
+ }
336
+ interface PaymentsResource<Provider extends CashierProvider = CashierProvider> {
337
+ list<Relation extends ProviderPaymentRelation<Provider> = never>(params: ListPaymentsParams<Relation>): Promise<PaymentWith<Relation>[]>;
338
+ cursorPaginate<Relation extends ProviderPaymentRelation<Provider> = never>(params: CursorPaginatePaymentsParams<Relation>): Promise<CursorPaginator<PaymentWith<Relation>>>;
339
+ create(params: CreatePaymentParams): Promise<Payment>;
340
+ refund(paymentId: string, params?: RefundPaymentParams): Promise<Refund>;
341
+ }
342
+
343
+ interface Product {
344
+ id: string;
345
+ code: string | null;
346
+ name: string;
347
+ description: string | null;
348
+ active: boolean;
349
+ createdAt: Date;
350
+ provider: CashierProvider;
351
+ }
352
+ interface ListProductsParams {
353
+ active?: boolean;
354
+ limit?: number;
355
+ }
356
+ interface ProductsResource {
357
+ get(productId: string): Promise<Product>;
358
+ list(params?: ListProductsParams): Promise<Product[]>;
359
+ }
360
+
361
+ declare enum CashierProvider {
362
+ Stripe = "stripe",
363
+ Recurly = "recurly"
364
+ }
365
+ interface StripeOptions {
366
+ apiKey: string;
367
+ }
368
+ interface RecurlyOptions {
369
+ apiKey: string;
370
+ }
371
+ interface CashierProviderOptions {
372
+ stripe: StripeOptions;
373
+ recurly: RecurlyOptions;
374
+ }
375
+ type CashierProvidersConfig = {
376
+ [Provider in CashierProvider]?: CashierProviderOptions[Provider];
377
+ };
378
+ interface CashierConfig {
379
+ default?: CashierProvider;
380
+ providers?: CashierProvidersConfig;
381
+ }
382
+ interface CashierDriver<Provider extends CashierProvider = CashierProvider> {
383
+ readonly provider: Provider;
384
+ readonly customers: CustomersResource;
385
+ readonly invoices: InvoicesResource<Provider>;
386
+ readonly payments: PaymentsResource<Provider>;
387
+ readonly products: ProductsResource;
388
+ readonly prices: PricesResource;
389
+ readonly subscriptions: SubscriptionsResource<Provider>;
390
+ }
391
+
392
+ declare class Cashier {
393
+ readonly defaultProvider: CashierProvider | null;
394
+ private readonly providers;
395
+ private readonly drivers;
396
+ constructor(config?: CashierConfig);
397
+ use(): CashierDriver;
398
+ use<Provider extends CashierProvider>(provider: Provider): CashierDriver<Provider>;
399
+ use<Provider extends CashierProvider>(provider: Provider, options: CashierProviderOptions[Provider]): CashierDriver<Provider>;
400
+ }
401
+ declare const createCashier: (config?: CashierConfig) => Cashier;
402
+ declare const cashier: Cashier;
403
+
404
+ type CashierErrorCode = 'not_found' | 'authentication' | 'authorization' | 'validation' | 'payment_failed' | 'payment_method' | 'subscription' | 'rate_limit' | 'conflict' | 'unsupported_operation' | 'provider';
405
+
406
+ interface CashierErrorDetails {
407
+ provider?: CashierProvider;
408
+ providerStatus?: number;
409
+ providerCode?: string;
410
+ cause?: unknown;
411
+ }
412
+ declare abstract class CashierError extends Error {
413
+ abstract readonly code: CashierErrorCode;
414
+ readonly provider?: CashierProvider;
415
+ readonly providerStatus?: number;
416
+ readonly providerCode?: string;
417
+ readonly cause?: unknown;
418
+ constructor(message: string, details?: CashierErrorDetails);
419
+ }
420
+
421
+ declare class NotFoundError extends CashierError {
422
+ readonly code: "not_found";
423
+ }
424
+
425
+ declare class AuthenticationError extends CashierError {
426
+ readonly code: "authentication";
427
+ }
428
+
429
+ declare class AuthorizationError extends CashierError {
430
+ readonly code: "authorization";
431
+ }
432
+
433
+ declare class ValidationError extends CashierError {
434
+ readonly code: "validation";
435
+ }
436
+
437
+ interface PaymentFailedErrorDetails extends CashierErrorDetails {
438
+ declineCode?: string;
439
+ }
440
+ declare class PaymentFailedError extends CashierError {
441
+ readonly code: "payment_failed";
442
+ readonly declineCode?: string;
443
+ constructor(message: string, details?: PaymentFailedErrorDetails);
444
+ }
445
+
446
+ declare class PaymentMethodError extends CashierError {
447
+ readonly code: "payment_method";
448
+ }
449
+
450
+ declare class SubscriptionError extends CashierError {
451
+ readonly code: "subscription";
452
+ }
453
+
454
+ declare class RateLimitError extends CashierError {
455
+ readonly code: "rate_limit";
456
+ }
457
+
458
+ declare class ConflictError extends CashierError {
459
+ readonly code: "conflict";
460
+ }
461
+
462
+ declare class UnsupportedOperationError extends CashierError {
463
+ readonly code: "unsupported_operation";
464
+ }
465
+
466
+ declare class ProviderError extends CashierError {
467
+ readonly code: "provider";
468
+ }
469
+
470
+ interface CashierHttpErrorBody {
471
+ code: CashierErrorCode;
472
+ message: string;
473
+ declineCode?: string;
474
+ }
475
+ interface CashierHttpError {
476
+ status: number;
477
+ body: CashierHttpErrorBody;
478
+ }
479
+ declare const getHttpStatus: (error: CashierError) => number;
480
+ declare const toHttpError: (error: CashierError) => CashierHttpError;
481
+
482
+ export { AuthenticationError, AuthorizationError, type BillingInterval, type BillingIntervalUnit, type CancelSubscriptionParams, Cashier, type CashierConfig, type CashierDriver, CashierError, type CashierErrorCode, type CashierErrorDetails, type CashierHttpError, type CashierHttpErrorBody, type CashierInvoiceRelations, type CashierPaymentRelations, CashierProvider, type CashierProviderOptions, type CashierProvidersConfig, type CashierSubscriptionRelations, ConflictError, type CreateCustomerParams, type CreateInvoiceLineItem, type CreateInvoiceParams, type CreatePaymentParams, type CreateSubscriptionParams, type CursorPaginateInvoicesParams, type CursorPaginateParams, type CursorPaginatePaymentsParams, type CursorPaginateSubscriptionsParams, type CursorPaginator, type Customer, type CustomersResource, type GetInvoiceParams, type Invoice, type InvoiceCollection, type InvoiceRelation, type InvoiceRelationFields, type InvoiceStatus, type InvoiceWith, type InvoicesResource, type ListCustomersParams, type ListInvoicesParams, type ListPaymentsParams, type ListPricesParams, type ListProductsParams, type ListSubscriptionsParams, type LoadedRelations, NotFoundError, type PayInvoiceParams, type Payment, type PaymentDispute, type PaymentDisputeStatus, PaymentFailedError, type PaymentFailedErrorDetails, PaymentMethodError, type PaymentRelation, type PaymentRelationFields, type PaymentStatus, type PaymentSubscription, type PaymentWith, type PaymentsResource, type Price, type PricesResource, type Product, type ProductsResource, ProviderError, type ProviderInvoiceRelation, type ProviderPaymentRelation, type ProviderRelation, type ProviderSubscriptionRelation, RateLimitError, type RecurlyOptions, type Refund, type RefundPaymentParams, RefundReason, type RefundStatus, type StripeOptions, type Subscription, type SubscriptionDiscount, SubscriptionError, type SubscriptionItem, type SubscriptionPause, type SubscriptionProduct, type SubscriptionRelation, type SubscriptionRelationFields, type SubscriptionScope, type SubscriptionStatus, type SubscriptionStatusFilter, type SubscriptionWith, type SubscriptionsResource, UnsupportedOperationError, type UpdateCustomerParams, type UpdateSubscriptionParams, ValidationError, type WithParams, cashier, createCashier, getHttpStatus, toHttpError };