@aios-inc/cashier
v1.8.2
Published
Unified subscription billing for Node.js and TypeScript. One API across payment providers, with typed errors and NestJS support.
Readme
Cashier
Unified subscription billing for Node.js and TypeScript. One API for every payment provider, with typed errors. Stripe and Recurly are supported today.
npm install @aios-inc/cashier stripe recurlyimport { CashierProvider, createCashier } from '@aios-inc/cashier';
const cashier = createCashier({
default: CashierProvider.Stripe,
providers: {
stripe: { apiKey: process.env.STRIPE_SECRET_KEY! },
recurly: { apiKey: process.env.RECURLY_API_KEY! },
},
});
const billing = cashier.use();
const customer = await billing.customers.create({ email: '[email protected]' });
await billing.subscriptions.create({
customer: customer.id,
price: 'price_123',
currency: 'USD',
});To switch providers, change default. Your billing code stays the same. Use cashier.use(CashierProvider.Recurly) to run several providers side by side.
Why Cashier
- One interface. Same methods and the same result shapes on every provider.
- Consistent data. Amounts in cents, uppercase ISO 4217 currencies,
Datetimestamps. - Typed errors.
NotFoundError,PaymentFailedError,RateLimitErrorand more, with the provider error kept ascause. - Framework ready. NestJS and Express packages included.
- No extra dependencies. Only the provider SDKs you install.
Providers
Stripe v13 and Recurly v4.67 or later. Node.js 20 or later.
Packages
@aios-inc/cashier: the core library@aios-inc/cashier-nestjs: NestJS module@aios-inc/cashier-express: Express middleware
Documentation
- API reference: customers, invoices, payments, products, prices and subscriptions
- TypeScript, NestJS, Express
- Drivers and conventions
- Errors
Contributing
See CONTRIBUTING.md and SECURITY.md.
License
MIT © AIOS
