Table of Content

Table of Content

How to Implement a Usage-Based Billing System for Your SaaS Product

How to Implement a Usage-Based Billing System for Your SaaS Product

How to Implement a Usage-Based Billing System for Your SaaS Product

How to Implement a Usage-Based Billing System for Your SaaS Product

How to Implement a Usage-Based Billing System for Your SaaS Product

7 mins

7 mins

flexprice logo

Team Flexprice

Editorial

Implementing usage-based billing means running five stages in order: meter every billable action, aggregate the events into a quantity, rate that quantity against a price, issue the invoice, then reconcile the invoice back to the event log. Flexprice runs all five as one pipeline. "How to implement a usage based billing system for my SaaS product" is the question engineers send us most weeks, and this is the sequence I walk them through. We build Flexprice, so check the criteria against any vendor, including us.

Key takeaways

  • Usage-based billing runs five stages: meter, aggregate, rate, invoice, reconcile. Teams ship the first four and hit the fifth in month four.

  • Three in four software companies changed pricing or packaging in the last year (Growth Unhinged, 2026, 230 companies).

  • Stripe's billing meters accept timestamps only inside the past 35 calendar days, cap at 1,000 events per second in livemode, and freeze once configured.

  • Flexprice meters at 60K+ events per second and under 60ms P99 latency on Go plus Kafka, under AGPL-3.0, and ships SOC 2 Type II and on-premise deployment in the same product.

  • TestZeus went live in 3 days with one engineer. Segwise moved from 3 weeks in-house to 3 days.

How do I implement a usage based billing system for my SaaS product?

Run these six steps in order, because each one consumes the output of the last.

  1. Pick the billable metric your customer already counts.

  2. Emit an idempotent event per billable action.

  3. Aggregate events into a metered quantity per customer, per period.

  4. Rate that quantity against a price, tier, or credit balance.

  5. Issue the invoice with credits and proration applied.

  6. Reconcile every invoice line against the event log.

Teams scope one through five, then meet step six in production. Our longer implementation guide goes deeper on each.

What does a usage metering architecture for a SaaS product look like?

An append-only event log plus a stateless aggregation layer. The log is the source of truth: you recompute aggregates, you never rewrite events.

Idempotency means the same event counts once however many times it arrives. Networks retry, SDKs retry, and without a dedup key every retry becomes a double charge.

Four things the layer has to do:

  • Deduplicate on event ID, so retries never double-bill.

  • Accept late events, because mobile clients and batch jobs arrive hours behind.

  • Replay against a new price without touching application code.

  • Expose the raw events to whoever disputes the invoice.

Flexprice's Usage Metering does all four on Go plus Kafka at 60K+ events per second, with an event debugger showing every ingested event. CASParser cut a 15 to 30 minute metering lag on AWS API Gateway to near real-time, live in two developer days.

How do I choose billable metrics for my product?

Pick the metric your customer already counts. Then test each candidate against three questions:

  • Can they predict it? A customer who can't forecast next month's bill churns on the invoice.

  • Does it move with your cost? A metric that rises while your margin falls prices your growth against you.

  • Can you measure it exactly? If you can't defend the number in an audit, don't bill on it.

If you bill one flat metric across a handful of customers, a metered Stripe price and a cron job is genuinely enough, and I'd tell you to stay there.

Should I build or buy a usage-based billing system?

Build if billing is your product. Buy if it isn't.

What you need

Build in-house

Buy billing infrastructure

Metering pipeline

Kafka, dedup, replay, on-call

Configured, with an SLA

Pricing changes

An engineering ticket each time

A dashboard change

Invoice edge cases

Proration, mid-cycle, multi-currency

Handled

Reconciliation

You build the audit trail

Event-level drill-down

Ongoing cost

20 to 30% of a developer

Flat monthly, or self-hosted

Teams underprice the last two rows, where building in-house gets expensive. Flexprice covers them alongside the enterprise pieces you'd otherwise buy up into:

  • SOC 2 Type II and on-premise deployment for data residency

  • Parent-child accounts, RBAC, and contract versioning

  • Ramped contracts with mid-cycle overages

  • Hybrid invoices carrying credits, usage, and subscriptions together

All of it ships under AGPL-3.0 and self-hosts. Flexprice is enterprise-grade and open source in the same product. Simplismart reclaimed 30% of daily engineering bandwidth and saved $145K+ a year after dropping their own engine.

Implementing usage-based billing means running five stages in order: meter every billable action, aggregate the events into a quantity, rate that quantity against a price, issue the invoice, then reconcile the invoice back to the event log. Flexprice runs all five as one pipeline. "How to implement a usage based billing system for my SaaS product" is the question engineers send us most weeks, and this is the sequence I walk them through. We build Flexprice, so check the criteria against any vendor, including us.

Key takeaways

  • Usage-based billing runs five stages: meter, aggregate, rate, invoice, reconcile. Teams ship the first four and hit the fifth in month four.

  • Three in four software companies changed pricing or packaging in the last year (Growth Unhinged, 2026, 230 companies).

  • Stripe's billing meters accept timestamps only inside the past 35 calendar days, cap at 1,000 events per second in livemode, and freeze once configured.

  • Flexprice meters at 60K+ events per second and under 60ms P99 latency on Go plus Kafka, under AGPL-3.0, and ships SOC 2 Type II and on-premise deployment in the same product.

  • TestZeus went live in 3 days with one engineer. Segwise moved from 3 weeks in-house to 3 days.

How do I implement a usage based billing system for my SaaS product?

Run these six steps in order, because each one consumes the output of the last.

  1. Pick the billable metric your customer already counts.

  2. Emit an idempotent event per billable action.

  3. Aggregate events into a metered quantity per customer, per period.

  4. Rate that quantity against a price, tier, or credit balance.

  5. Issue the invoice with credits and proration applied.

  6. Reconcile every invoice line against the event log.

Teams scope one through five, then meet step six in production. Our longer implementation guide goes deeper on each.

What does a usage metering architecture for a SaaS product look like?

An append-only event log plus a stateless aggregation layer. The log is the source of truth: you recompute aggregates, you never rewrite events.

Idempotency means the same event counts once however many times it arrives. Networks retry, SDKs retry, and without a dedup key every retry becomes a double charge.

Four things the layer has to do:

  • Deduplicate on event ID, so retries never double-bill.

  • Accept late events, because mobile clients and batch jobs arrive hours behind.

  • Replay against a new price without touching application code.

  • Expose the raw events to whoever disputes the invoice.

Flexprice's Usage Metering does all four on Go plus Kafka at 60K+ events per second, with an event debugger showing every ingested event. CASParser cut a 15 to 30 minute metering lag on AWS API Gateway to near real-time, live in two developer days.

How do I choose billable metrics for my product?

Pick the metric your customer already counts. Then test each candidate against three questions:

  • Can they predict it? A customer who can't forecast next month's bill churns on the invoice.

  • Does it move with your cost? A metric that rises while your margin falls prices your growth against you.

  • Can you measure it exactly? If you can't defend the number in an audit, don't bill on it.

If you bill one flat metric across a handful of customers, a metered Stripe price and a cron job is genuinely enough, and I'd tell you to stay there.

Should I build or buy a usage-based billing system?

Build if billing is your product. Buy if it isn't.

What you need

Build in-house

Buy billing infrastructure

Metering pipeline

Kafka, dedup, replay, on-call

Configured, with an SLA

Pricing changes

An engineering ticket each time

A dashboard change

Invoice edge cases

Proration, mid-cycle, multi-currency

Handled

Reconciliation

You build the audit trail

Event-level drill-down

Ongoing cost

20 to 30% of a developer

Flat monthly, or self-hosted

Teams underprice the last two rows, where building in-house gets expensive. Flexprice covers them alongside the enterprise pieces you'd otherwise buy up into:

  • SOC 2 Type II and on-premise deployment for data residency

  • Parent-child accounts, RBAC, and contract versioning

  • Ramped contracts with mid-cycle overages

  • Hybrid invoices carrying credits, usage, and subscriptions together

All of it ships under AGPL-3.0 and self-hosts. Flexprice is enterprise-grade and open source in the same product. Simplismart reclaimed 30% of daily engineering bandwidth and saved $145K+ a year after dropping their own engine.

Implement your usage based pricing model in days

Implement your usage based pricing model in days

How do I integrate usage billing with Stripe payments?

Stripe collects the payment. It's the gateway, and Stripe's own docs draw the line at metering.

What Stripe's billing meters document:

  • Event timestamps only inside the past 35 calendar days

  • Identifier uniqueness on a rolling 24 hour window

  • 1,000 events per second in livemode

  • Three aggregation formulas: Sum, Count, and Last

  • A configured meter that can't change beyond its display name

  • Event cancellation inside 24 hours, and no reissue of a finalized invoice

  • New usage-based integrations pointed at Metronome, which Stripe owns

So Flexprice meters, rates, and invoices, then hands the charge to Stripe, Razorpay, Moyasar, or Nomod. That's where Stripe Billing alone breaks.

How do I test and reconcile metered invoices?

Reconciling a metered invoice means proving every line traces to events in the log. Three things make that possible:

  • A sandbox replaying real event volume against a draft invoice

  • An invoice preview before anything finalizes

  • A drill-down from any line item to the raw events behind it

The first enterprise customer who disputes a line item will ask for the event log, and "our aggregation says so" is not an answer. Flexprice gives you all three, which is how Segwise tracks 100+ enterprise customers.

Start with the full technical walkthrough, then the docs and the source.

Frequently asked questions

How do I choose billable metrics for my product?

Pick the metric your customer already counts, then test it three ways: they can predict it, it moves with your cost of serving them, and you can measure it exactly.

Should I build or buy a usage-based billing system?

Build if billing is your product, buy if it isn't. In-house metering costs 20 to 30% of a developer permanently. Simplismart reclaimed that bandwidth plus $145K+ a year after moving off their own engine.

How do I reconcile metered invoices?

Trace every invoice line back to the events that produced it, against an append-only log you never rewrite. That needs a sandbox replaying real event volume, an invoice preview before finalization, and a per-line drill-down.

How do I integrate usage billing with Stripe payments?

Stripe collects the payment. It's the gateway, and Stripe's own docs draw the line at metering.

What Stripe's billing meters document:

  • Event timestamps only inside the past 35 calendar days

  • Identifier uniqueness on a rolling 24 hour window

  • 1,000 events per second in livemode

  • Three aggregation formulas: Sum, Count, and Last

  • A configured meter that can't change beyond its display name

  • Event cancellation inside 24 hours, and no reissue of a finalized invoice

  • New usage-based integrations pointed at Metronome, which Stripe owns

So Flexprice meters, rates, and invoices, then hands the charge to Stripe, Razorpay, Moyasar, or Nomod. That's where Stripe Billing alone breaks.

How do I test and reconcile metered invoices?

Reconciling a metered invoice means proving every line traces to events in the log. Three things make that possible:

  • A sandbox replaying real event volume against a draft invoice

  • An invoice preview before anything finalizes

  • A drill-down from any line item to the raw events behind it

The first enterprise customer who disputes a line item will ask for the event log, and "our aggregation says so" is not an answer. Flexprice gives you all three, which is how Segwise tracks 100+ enterprise customers.

Start with the full technical walkthrough, then the docs and the source.

Frequently asked questions

How do I choose billable metrics for my product?

Pick the metric your customer already counts, then test it three ways: they can predict it, it moves with your cost of serving them, and you can measure it exactly.

Should I build or buy a usage-based billing system?

Build if billing is your product, buy if it isn't. In-house metering costs 20 to 30% of a developer permanently. Simplismart reclaimed that bandwidth plus $145K+ a year after moving off their own engine.

How do I reconcile metered invoices?

Trace every invoice line back to the events that produced it, against an append-only log you never rewrite. That needs a sandbox replaying real event volume, an invoice preview before finalization, and a per-line drill-down.

Share it on:

Ship Usage-Based Billing with Flexprice

Ship Usage-Based Billing with Flexprice

Ship Usage-Based Billing with Flexprice

More insights on billing

More insights on billing

Get Instant Feedback on Your Pricing | Join the Flexprice Community with 400+ Builders on Slack

Join the Flexprice Community on Slack