A growing B2B SaaS company outgrows spreadsheets and hand-built invoices. This blueprint shows how we design a billing platform that handles plans, usage-based pricing and invoicing for every tenant, without mixing one customer's data with another's.
Pricing lives in spreadsheets, so every new plan needs engineering work and manual invoice fixes.
Usage data arrives from several services in different formats and is hard to reconcile.
Enterprise prospects ask how tenant data is isolated before they will sign.
Finance cannot see revenue, churn or failed payments without exporting data by hand.
What the Solution Delivers
New plans and price changes launched by configuration instead of code changes
Every invoice traceable to the usage events behind it
Tenant isolation enforced in the database, not only in application code
Finance dashboards for MRR, churn and failed payments without manual exports
Architecture
Billing platform architecture
Product services publish usage events. The metering service aggregates them per tenant, the billing engine prices them against each plan, and Stripe collects payment. Postgres row-level security keeps tenant data separate.
The situation
Many B2B SaaS companies start billing with a payment provider’s hosted checkout and a few scripts. That works for a handful of flat-price plans. It stops working when sales starts offering annual contracts, seat-based tiers, usage-based add-ons and custom enterprise terms. Each exception becomes a manual step, and each manual step becomes a support ticket or a revenue leak.
Our approach
1. Model pricing as data
We start with a two-week discovery where product, finance and engineering agree on a pricing model: plans, features, meters, tiers, proration and trial rules. We store that model in the database as versioned configuration. Changing a price or adding a plan becomes an admin action with an audit trail, not a deployment.
2. Treat usage as an event stream
Product services publish usage events (API calls, seats, storage, messages) to a stream with an idempotency key. The metering service deduplicates, aggregates per tenant and billing period, and keeps the raw events so every invoice line can be traced back to its source. Late or corrected events are handled explicitly instead of silently changing past invoices.
3. Isolate tenants at the data layer
Every table carries a tenant ID, and PostgreSQL row-level security policies enforce it. The API gateway resolves the tenant from the authenticated session and sets it on each database connection. A bug in one query cannot return another customer’s data. This is the answer enterprise security reviews look for.
4. Let the payment provider do payments
We keep the source of truth for plans, usage and invoices in the platform, and use Stripe for what it does best: storing payment methods, charging cards, bank debits and retrying failed payments. Webhooks are verified, processed idempotently and reconciled nightly.
5. Give finance and customers visibility
The customer portal shows current usage, upcoming charges and invoice history, which removes most “why was I charged this?” tickets. The finance console reports MRR, expansion, churn and failed payments from the same data, so the numbers match the invoices.
How we deliver it
We ship in stages behind feature flags, starting with a shadow mode that calculates invoices alongside the existing process and flags differences. Only when the two agree for a full billing cycle do we switch customers over, plan by plan. Infrastructure is defined in Terraform and runs on AWS with automated deployments; see our cloud services.
Is this relevant to you?
If your pricing is limited by what your billing code can handle, or enterprise deals stall on data-isolation questions, this architecture is a good fit. Explore our custom software development service or talk to us about your pricing model.
Building something similar?
We'll walk through your requirements and share how we'd approach architecture, timeline and team for your project.
We use essential technologies to run this site. With your OK, we also use cookieless analytics and Google Maps, which may set cookies. No ads, and we never sell your data. Cookie Policy
Privacy preferences
Choose which optional technologies we may use. Strictly necessary ones are always on because the site can’t work securely without them. Details are in our Cookie Policy.
Your browser sends a Global Privacy Control signal, so optional technologies are off by default.
Strictly necessary
Security and spam protection (Cloudflare, Google reCAPTCHA), form delivery, and remembering these choices.
Always on
Cloudflare Web Analytics counts page views without cookies or cross-site tracking.
Shows our office on Google Maps. Google may set cookies and receive your IP address.