Configuration
Learn about the billing configuration.
The billing configuration ensures consistent behavior across the application and any billing provider.
- UI: Display accurate data in the user interface, including pricing tables and billing sections.
- Checkout: Generate valid checkout sessions based on your configuration.
- Access: Enable functionality such as feature-gated access tied to specific purchases.
Schema
The billing configuration is composed of the following entities:
- Product: Defines the offering (e.g. Starter, Pro, Enterprise, etc.) with 1-n plans.
- Plan: Defines the payment plan (e.g. Pro Monthly, Pro Yearly. etc) with 1-n prices.
- Price: Defines the type, interval, model, amount and currency.
Following enums define a price more granulary:
- PriceType: Can be
recurringorone-time. - PriceInterval: Can be
month,yearorundefined. - PriceModel: Can be
flat,per_seatormetered.
Multiple prices are required if you want to combine multiple strategies, so more line items will be generate on the invoice.
Good to know: While the schema enforces correct validation rules, some billing providers have limitations or differences in supported features.
Configuration
The configuration is located at packages/billing/src/config.ts. A simple monthly pro plan would look like this:
export const billingConfig = createBillingConfig({
products: [
{
id: 'pro',
name: 'Pro',
description: 'Best for most teams.',
label: 'Get started',
recommended: true,
features: ['Feature 1', 'Feature 2'],
plans: [
{
id: 'plan-pro-month',
displayIntervals: [PriceInterval.Month],
trialDays: 7,
prices: [
{
id: 'price-pro-month-id',
interval: PriceInterval.Month,
type: PriceType.Recurring,
model: PriceModel.Flat,
cost: 24,
currency: 'USD'
}
]
}
]
}
]
});It's important to differentiate the technical terms product and plan. Often in marketing the term plan is used for everything, but technically the term only refers to a payment plan of a product.