Usage-Based Billing for SaaS: Stripe Meters, Redis, UI Widget

When customers pay for actual consumption, any inaccuracy in metering turns into disputes and revenue loss. We develop and configure usage-based billing turnkey: from collecting metrics to charges and a clear interface for the customer. Our engineers build metering so that billing discrepancies are reduced severalfold, and billing works without manual adjustments.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Frequently Asked Questions

Usage-based billing: where consumption metering breaks

Consumption metering doesn't break at the moment of charging — it breaks earlier, along the path an event takes from the client to billing. A metric goes into a queue, gets aggregated in Redis, lands in a billing counter, and turns into a line on an invoice.

At every transition, an event can be lost, duplicated, or arrive late — and the billing discrepancy surfaces only in the final invoice, when the client sees an amount they can't explain.

The most common cause is event loss under peak load. The queue overflows, a worker crashes on a retry, and some operations simply never reach the aggregator.

The second most common is duplicate charges: the client retries a request after a timeout, there's no idempotency on ingestion, and a single operation gets counted twice.

The third is discrepancies between the counter and billing due to different granularity: the aggregator counts by the minute, billing counts by the hour, and at the boundary between days the numbers don't add up.

A separate category is post-hoc counter reconciliation. If consumption data isn't reconciled against the source regularly, the error accumulates over months and is discovered when there's nothing left to recalculate.

Peak load makes everything worse: it's precisely during spikes that the most events are lost, and that's exactly when consumption is at its highest and the cost of an error is greater.

Here's how this gets addressed: idempotent ingestion, reliable event delivery, periodic counter reconciliation, and a transparent UI where the client can see for themselves what the total is made up of.

What correct usage-based billing delivers

Correctly built usage-based billing is not a "counter that counts requests," but a circuit of three layers: event collection, aggregation into billing metrics, and reconciliation with actual charges.

If even one layer is put together "hastily," discrepancies in reconciliations become the norm, and manual disputes with clients become a regular line item in the team's expenses.

The first effect is billing accuracy. Events are written idempotently, with a unique key per operation, so redelivery does not double the invoice.

Aggregation runs over windows with a fixed boundary, rather than "as they arrive" — the total for the period matches what the client sees in their dashboard, down to the last unit.

In practice, the share of discrepancies in reconciliations drops from percentages to fractions of a percent, and disputed invoices stop consuming support time.

The second is resilience to spikes. Counters live in fast storage such as Redis, writes are batched, and heavy aggregates are computed asynchronously. A traffic surge does not bring down metering or turn into a queue that makes the client see a "stuck" limit.

Limits and thresholds are checked on the hot layer, so overages are cut off immediately, rather than after recalculation.

The third is automation of billing and reconciliation with the billing system. Metrics are synchronized with the payment circuit on a schedule, discrepancies are logged and highlighted in the widget before the invoice is issued, rather than after a complaint. Manual labor leaves the process: the engineer only investigates anomalies, not every charge.

Accounting methods: from a counter to billing

Metering consumption almost never comes down to a single counter. An event arrives from the client, settles in an intermediate store, is aggregated over the billing period, and turns into an invoice line.

At every transition, data can be lost or counted twice — which is why the accounting method is chosen not for convenience, but for the errors it permits.

Three working options differ in where the truth about consumption lives and who is responsible for aggregation.

Option When it fits Limitations
Your own event counter A simple metric (requests, volume, active seats), one or two tariffs You write the aggregation, period recalculation, and month closing yourself; idempotency and protection against double charging are on your side
An intermediate store + your own aggregation Several metrics, you need breakdowns by clients and periods, flexible rules Requires a recalculation and reconciliation procedure: a discrepancy between the store and the invoice surfaces at the client's end
A ready-made billing service with consumption metering You need tariff plans, limits, invoices, and taxes without your own accounting Tariff logic is limited by the service's capabilities; events still have to be delivered and not lost

In practice, the most common approach is a combination: an event counter at the input, an intermediate store as a buffer and source of truth for the period, and a billing service at the output for invoices and payments.

Consumption aggregation then runs on a schedule rather than at the moment of a client request, and heavy recalculation does not slow down the main product.

The key question when choosing is what happens when event delivery fails. If the answer is "the client will see an incorrect amount," the option does not fit regardless of convenience. Let's look at how this is closed off with idempotent writes and reconciliation.

How we implement usage-based billing

Implementing usage-based billing starts not with code, but with an inventory of what is already being counted.

We look at which events the application currently records, where data is lost, how customer and subscription identifiers are structured, and what happens when the same event is delivered again.

At this stage, gaps surface: some calls are not logged, some are duplicated on retries, and plan limits live in code rather than in configuration.

Next, we design the flow schema: event → receiver → aggregation → billing → display. We pin down exactly where usage is counted, what the closing period is, how we handle late-arriving events, and what we do when an external service is unavailable — buffer or reject.

  1. Audit of current metering: we go through logs, counters, and manual reconciliations, and find the sources of losses and duplicates.
  2. Flow schema: we describe the path of an event from the application to billing, the failure points, and the idempotency rules.
  3. Aggregation setup: counters in Redis for fast limits, periodic export to Stripe Meters for calculations and invoices.
  4. Validation against historical data: we run real events from past periods and reconcile the result with manual calculations.
  5. UI widget: we show the customer their current consumption and remaining limit so there are no surprises on the invoice.
  6. Handover: documentation on the schema, instructions for adding new metrics, and a breakdown of typical failures.

Validation against history is a mandatory step: it shows whether the calculation matches what the customer saw before, and where period boundaries diverge. Without it, the very first invoice raises questions.

After handover, the client's team can add new metrics and change plans without touching the billing core.

Artifacts: configurations, schemas, regulations

With usage-based billing, the customer receives not "access to a repository" but a set of deliverables that allows the system to be operated, handed over to another team, and pass an audit. Below is what exactly remains in hand after implementation.

  • Billing configurations — declarative descriptions of metrics (what we count: API calls, active seats, processing volume), mapping of a meter to a pricing plan, rounding and threshold rules. They can be changed without modifying the billing code.
  • Event flow schemas — from the moment usage is generated to the charge: where the event is born, how it enters the queue, how it is aggregated in Redis, how it is synchronized with Stripe Meters, and what happens on failure at each transition.
  • Access policies — roles for changing tariffs and manual adjustments, separation of rights between product, finance, and support, and a log of who changed what with timestamps.
  • Widget documentation — how to embed the UI component that displays current consumption, what data it pulls, how to configure notification thresholds for the client, and what to show when the limit is exhausted.
  • Reconciliation regulation — a periodic procedure: comparing aggregates in Redis with records in Stripe, the window of acceptable discrepancy, the procedure for investigating discrepancies, and resending events.
  • Rollback instructions — how to revert the previous meter configuration, what to do with already accrued periods, and how to avoid double charges during recalculation.
  • Monitoring map — which signals should be considered alarming (growth in dropped events, aggregate discrepancy, synchronization delay) and who receives them.

The set is designed so that the customer's team can add a new metric or tariff on its own without going into the billing logic. Describe your monetization model — we will come back with an estimate and a plan for each artifact.

Case study: how we reduced billing discrepancies

The product is a pay-as-you-go service: customers are charged for the volume of data processed, and billing calculates charges based on meters.

At the start, reconciliation was done manually: once a week, an analyst exported events from the queue and compared them with what billing had recorded.

At a volume of several million events per day, billing discrepancies reached 4-6% of turnover, and every dispute with a customer turned into a manual investigation lasting several hours.

We rebuilt the accounting loop on a combination of Stripe Meters and Redis. Meters record consumption in a streaming fashion, Redis holds intermediate aggregates and smooths out peak loads, and billing receives already reconciled values.

The key thing is automatic reconciliation: once a day, the system compares raw events with what has been billed and flags discrepancies itself, instead of waiting for a customer complaint.

What changed in the numbers

Metric Before After
Billing discrepancies 4-6% of turnover less than 0.3%
Manual investigations 15-20 per week 1-2 per month
Reconciliation time 6-8 hours automatic, with no involvement
Behavior under peak loads event loss stable

We also separately addressed peak loads: previously, during a traffic spike, some events never reached billing and only surfaced during reconciliation. Now the Redis buffer survives the peak, and missing records are restored from the log — there is no loss of billed charges.

Two months after launch, the share of disputed invoices dropped to single digits, and the team stopped spending a week on investigations. If you have a similar payment model, describe your task, and we will come back with an estimate and a plan.

How does usage-based billing differ from subscriptions?

A subscription sells access: the customer pays a fixed amount for a period regardless of how many requests they sent, how many gigabytes they processed, and how many seats they occupied.

Usage-based billing sells volume: the invoice is formed from actual consumption — the number of operations, processed events, active users, or occupied storage. For a product, these are fundamentally different revenue models, not two ways of issuing the same invoice.

Technically, the difference lies in the point where the amount is born. In a subscription, it is known in advance and lives in the customer's billing profile.

In a pay-per-consumption model, the amount appears only after the system has collected usage events, tied them to an account, and multiplied them by the rate.

That is why accounting for every operation, idempotency on repeated event delivery, and protection against data loss during peak loads are critical here — an error in counting turns into a disputed invoice and refunds.

This is where hybrid models grow from, and in practice they are encountered more often than pure ones. A base subscription covers access and a fixed portion of the value, while consumption beyond the included limit is billed separately.

This way the customer sees a predictable minimum, and the provider sees revenue grow along with the load. Another layer is thresholds and tiers: the price per unit decreases as volume grows, which encourages large customers to stay on a single platform.

For the customer, the choice of model is a question of how they themselves sell their product. If the value for their users grows with volume, a fixed subscription leaves money on the table.

If consumption fluctuates from month to month, paying for actual usage removes the risk of overpaying and lowers the barrier to entry. We break down how this is handled at the level of event accounting, pricing logic, and the interface where the customer sees their consumption.

Common technical concerns

We collect the questions that most often come up during the technical review before launch: they concern not the pricing grid, but the behavior of the system under load and during failures.

How fresh is the data the client sees in the dashboard?

Consumption metrics enter the Redis aggregator in a streaming fashion, so the widget updates almost in real time — the aggregation delay is usually within a few seconds.

Final invoices are calculated based on the closed period, not on "raw" counters, so a discrepancy between the widget and the invoice is excluded: both sources read the same aggregate.

What happens if an event arrives twice?

Each event carries a unique key, and the write is idempotent: a repeat with the same key does not increment the counter.

This covers client-side retries, duplicates during network failures, and redelivery from the queue — consumption does not "inflate" due to infrastructure failures.

Can consumption be recalculated retroactively?

Yes. The recalculation is launched over a date range and rebuilds the aggregates from the source events, after which the invoices for the affected periods are adjusted.

The operation is idempotent: re-running it over the same range yields the same result, so it is safe to restart after a failure.

How does the system behave when a node fails?

The aggregator and the queue are replicated; when a node goes down, the load shifts to the standby one without losing events.

Events are first committed to reliable storage and only then aggregated — if a failure occurs at any step, the data is restored from the journal rather than lost.

How do you verify correctness before launching in prod?

We run a load scenario with duplicates and connection drops, compare the aggregates against a reference recalculation, and check the behavior when a node is disconnected.

We deliver a report with discrepancy metrics before the release — you see how the system withstands failures instead of taking our word for it.

Let's discuss your usage-based billing challenge

Migrating to usage-based billing almost never comes down to the billing itself.

The main work is getting your current metering in order: where consumption events are recorded today, what confirms their accuracy, and what happens to charges when an event is redelivered or a client-side failure occurs.

Until these questions are resolved, any pay-as-you-go plan turns into manual reconciliation at the end of the month.

That's why we start the conversation not with tool selection, but with your metering model. Describe what units you sell — requests, active users, processing volume — how they enter the system, and who is currently responsible for discrepancies. That's enough to understand the scope of work and come back with an estimate and a plan.

What's worth pinning down before kickoff:

  • current metering: event sources, format, the delay between a client action and the record;
  • idempotency: how duplicates are filtered out on redelivery and retries;
  • aggregation: where intermediate totals are calculated and at what frequency;
  • limits and thresholds: what happens when a quota is exceeded and how the client finds out;
  • discrepancies: how charges are reconciled against actual consumption and who handles disputed cases;
  • billing cycle: when the period closes, recalculations, refunds, switching between plans;
  • interface: what the client sees in their dashboard and what exports they need.

Next, we map out the data flow, test it against your real-world scenarios, and only after that propose an implementation. This order removes the main risk — when the system is already charging money but there's no trust in the numbers.

Describe your challenge and current metering — we'll come back with an estimate and a plan.

Our competencies:

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1393
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1368
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1139
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1152
  • Website development for SBH Partners
    Website development for SBH Partners
    1231
  • Website development for Red Pear
    Website development for Red Pear
    641