Skip to main content
Ledger turns a pricing page into a catalog, and the catalog into balances your backend checks in real time, so every action is gated and every use is billed. Stripe takes the payments and sends the invoices.

1. Features

A feature is something in your app a plan can include. Its type says how it’s used up:

2. Plans with items and a price

A plan lists items, one per feature it includes: 500 messages, unlimited projects, SSO. It has a price per month or year, or once for a lifetime plan, and can grant credits. A metered item can price usage past its allowance, and a held item can price each seat, flat or in tiers. Plans can also carry trials, rollover and promotion codes. You keep the catalog in a file in your repo and publish it with the CLI.

3. Attach gives the customer a subscription

Attaching a plan to a customer starts their subscription. A customer holds one base plan per product line, plus any recurring add-ons and plans for its workspaces, all on one invoice. A free plan starts at once. A paid plan charges a saved card or returns a Stripe Checkout URL, and starts when Stripe’s signed webhook confirms the payment.

4. Grants become balances

Each period, the subscription grants what the plan includes: the metered allowance, the credits, the held limits. A customer’s balance for a feature is what those grants leave. Allowances renew each period, rollover carries what’s unused forward, and credit packs and top-ups never expire.

5. Check before, track after

Your backend calls check before an action: is it allowed, and what’s left? After the action succeeds, it calls track with a request_id unique to that use. Ledger decides again, spends the balance once, and records a usage event. A retry with the same request_id charges nothing more. Check and track has the calls and the refusals.

6. Ledger bills the usage on the Stripe invoice

Stripe renews the subscription and invoices the plan’s price. While the renewal invoice is still a draft, Ledger adds a line for each overage rate the customer used. Seats ride on the subscription as their own item, at the count the customer holds, so Stripe bills them beside the plan. Invoices and Stripe shows what lands where.

Sandbox and Live

Every workspace has two environments, Sandbox and Live, and the API key picks one: a ledger_test_ key reaches Sandbox, a ledger_live_ key reaches Live, on the same API host. Nothing is shared between them: each has its own catalog, customers, balances, usage and Stripe account, so a test can never touch a real customer. Sandbox comes with a Stripe test account Ledger creates for you (Sandbox); Live uses your own Stripe account (Production checklist).

Next steps

Quickstart

Build the whole loop for a chat app in Sandbox.

Choose a model

Find the pattern that matches your pricing page.