SaaS Billing Done Right: Stripe, Usage-Based Billing, and Revenue Leaks
Implement SaaS billing that does not leak revenue: pricing models, ledger-first architecture, Stripe webhooks, metered billing, dunning, trials, and invoicing.
Billing is the one part of a SaaS product where a bug is not a bug — it is money that silently leaves. Revenue leaks hide in failed payments nobody retried, trials that expired without a prompt, usage that was metered but never invoiced, and webhooks that fired twice. This guide covers how to choose among SaaS pricing models, design a billing system architecture that survives edge cases, and integrate Stripe in a way that keeps the ledger honest.

SaaS Pricing Models Come Before Billing Code
Every billing system is a pricing model made executable, so the model has to be decided first. The common SaaS pricing models are flat subscription tiers, per-seat pricing, usage-based billing, and hybrids that combine a base subscription with metered overage. Each one implies different data you must capture, different invoice logic, and different failure cases.
The rule for choosing: price on the unit your customers already associate with value. Seats work when each user gets value independently. Usage works when value scales with a measurable action — messages sent, documents processed, API calls. Do not meter something just because it is easy to count; a metric customers do not recognise as value reads as a tax. If you are still shaping the product, our guide on how to build a successful SaaS product covers where pricing fits in the roadmap.
Billing System Architecture: Own the Ledger, Rent the Rails
The most important billing system architecture decision is where the source of truth lives. The payment gateway executes charges; it should not be the only record of what a customer owes and has paid. Keep your own ledger: a record of subscriptions, entitlements, invoices, and payment events that your product reads, with the gateway's events reconciled into it.
That separation gives you three things. Entitlements can be checked without calling the gateway on every request. Reconciliation becomes a report rather than a mystery. And swapping or adding a payment gateway later touches an adapter, not the product.
A minimal architecture:
- Catalog — products, prices, and plans, referenced by your own identifiers and mapped to gateway IDs in configuration, never hardcoded.
- Subscriptions and entitlements — what each account has, from when, until when.
- Usage records — append-only events for metered features, aggregated per billing period.
- Invoices and payments — generated from the above, reconciled against gateway events.
- Event ingestion — a webhook consumer that verifies, deduplicates, and queues.
Stripe Integration Done Right
A Stripe integration is straightforward on the happy path and unforgiving on the edges. The parts that separate a robust integration from a fragile one are below.
Webhooks, Idempotency, and the Job Queue
Treat every webhook as an at-least-once delivery. Verify the signature, store the event ID, and drop duplicates before doing anything else. Acknowledge quickly and push the real work — updating entitlements, sending emails, adjusting the ledger — onto a job queue; slow handlers cause retries, and retries without idempotency cause double processing. Our API integration checklist for webhooks, retries, and idempotency walks through the pattern in detail.
Also handle events arriving out of order. A subscription update can reach you before the invoice it relates to; write consumers that reconcile state rather than assume sequence.
Configuration, Not Constants
Price and product IDs belong in configuration or in your catalog, not in code. The day you want to test a new tier or change a price should not require a deployment. Keep test-mode and live-mode identifiers separate and validate on startup that every plan in your catalog maps to a real price in the gateway.
Subscription Billing vs Usage-Based Billing
Subscription billing is simpler to build and to forecast: fixed amounts on fixed dates, proration on upgrades and downgrades, and a predictable invoice. The edge cases are plan changes mid-cycle, trials converting into paid plans, and pauses or cancellations that must respect the period already paid for.
Usage-based billing trades predictability for alignment with value. It needs a reliable metering pipeline, clear aggregation rules, and customer-facing visibility of usage before the invoice lands. Surprise invoices are the fastest route to disputes.
Metered Billing Without Surprises
For metered billing, record usage as append-only events with an idempotency key per event, aggregate them into the period at close, and show the running total in the product so the invoice is never a surprise. Add caps and alerts customers can set themselves. Decide in advance how you handle late-arriving events and corrections; a credit note is cleaner than a rewritten invoice.
On Pickles Auction, where real-time bids and escrow flows had to reconcile exactly, the internal ledger was the system of record and the payment provider was strictly an executor — which is what made disputes, refunds, and late corrections tractable instead of forensic.
Failed Payments and Dunning Management
Failed payments are the largest single revenue leak in most subscription products, and most of them are involuntary — expired cards, temporary bank declines, spending limits. Dunning management is the process of recovering them without losing the customer.
The elements that matter:
- Retries on a schedule, spread over days, ideally at times the gateway suggests based on the failure code.
- Customer messaging that starts before the card expires and continues after the first failure, with a one-click path to update payment details.
- Grace periods — do not revoke access on the first failure; keep the service running through the retry window.
- Clear end state — after the final retry, downgrade or pause rather than delete, so recovery remains possible.
Track the recovery outcome per failure reason. This is churn reduction that costs almost nothing per recovered account and compounds every month.
Free Trial Conversion and Checkout Optimization
Free trial conversion is a billing problem as much as a product one. Decide whether trials require a card up front (fewer, better-qualified trials) or not (more trials, more work to convert), and design the end-of-trial sequence accordingly: reminders before expiry, a clear summary of what the customer achieved during the trial, and a checkout that is already prefilled.
Checkout optimization is mostly about removing steps and uncertainty. Show the price, the billing interval, and the next charge date on the same screen. Support the payment methods your customers actually use in their region. Handle authentication challenges and declines inline with a specific message, not a generic error. Instrument every step so drop-offs are visible; our SaaS analytics setup guide shows how to structure those events.
Invoicing Automation and Revenue Recognition
Invoicing automation means invoices are generated, numbered, delivered, and reconciled without a human touching them, including credit notes and tax handling. Generate them from your ledger, attach the gateway's payment reference, and make them available inside the product.
Revenue recognition is where billing meets accounting: a customer who pays annually up front has not given you a year of revenue on day one. Store the service period on every invoice line so recognised revenue can be spread across it, and keep deferred revenue visible in reporting. If your product sits close to regulated financial flows, the considerations in our fintech app development guide apply to billing as well.
Revenue Leak Checklist
Audit an existing billing system, or plan a new one, against this list:
- Internal ledger is the source of truth; the gateway is reconciled into it
- Webhook signatures verified, events deduplicated, processing queued
- Out-of-order events handled by reconciling state, not assuming sequence
- Price and product IDs live in configuration, not code
- Proration rules for upgrades, downgrades, and cancellations are written down and tested
- Usage events are idempotent, aggregated per period, and visible to customers before invoicing
- Retry schedule, grace period, and customer messaging exist for every failed payment
- Trial expiry sequence and prefilled checkout are in place
- Invoices, credit notes, and taxes are generated automatically from the ledger
- Service periods stored per invoice line for revenue recognition
- Monthly reconciliation compares ledger, gateway, and bank
FAQ
Should we build billing ourselves or use a billing platform on top of Stripe? Use the gateway's subscription and invoicing features for the rails, but keep your own ledger and entitlements. Full third-party billing platforms make sense when pricing complexity — many plans, regional taxes, enterprise contracts — outgrows what your team wants to maintain.
How do we add usage-based billing to an existing subscription product? Start by metering silently for a few cycles to learn the distribution, show customers their usage in the product, then introduce a hybrid plan with a base fee and metered overage before moving anyone to pure usage pricing.
What is the single most effective fix for failed payments? A retry schedule combined with pre-expiry card reminders and a one-click update link. Most failures are involuntary, and most customers will fix them if asked clearly and early.
Do we need revenue recognition logic at an early stage? You need the data for it: service periods on invoice lines. The reporting can come later, but reconstructing periods after the fact is painful.
How do we test billing safely? Use the gateway's test mode with scripted scenarios — failed cards, disputes, mid-cycle plan changes, duplicate webhooks — and run them in CI against your ledger logic, not just against the gateway.
If your billing has grown organically and nobody is sure the numbers reconcile, or you are designing pricing for a new product, we can help you build a billing system that does not leak. Contact our team for a billing architecture review or an implementation plan.