Following money through a subscription product: usage measurement, payment-provider events, plan entitlements, proration, and failed payments.
Each step between a customer using your product and the money arriving has a failure mode that quietly loses revenue or overcharges someone: usage counted twice or not at all, subscription events applied out of order, stale permissions, rounding that does not add up, and payment failures handled inconsistently. Most guides in this section include a lab that measures one of those failures, so you can check your own system against the same scenario.
Charge the right amount when a customer changes plans in the middle of a period.
Lab finding: 30-day months: +$4.76 in February, -$2.16 in 31-day months. Rounding order: 1 cent. A 365-day year overcharged a leap-year true-up by $16.44.
Move plan checks into data, cache them safely, and enforce seat limits where they cannot be exceeded. A lab shows how long one lost invalidation message keeps a server wrong.
Subscription Billing, Metering & Entitlements9 min read
Which declines to retry, how to limit access while a payment is overdue, what to tell customers, and a tested Go state machine that handles duplicate payment events.
Subscription Billing, Metering & Entitlements10 min read
Design a metering pipeline from event to invoice, and see a lab in which the popular 'set a Redis marker first' pattern lost about 1% of billable usage.
Subscription Billing, Metering & Entitlements10 min read
Proration is simple arithmetic plus policy. A lab computes one upgrade for every 2026 month and shows where 30-day and 365-day shortcuts change the invoice.
Subscription Billing, Metering & Entitlements12 min read
Stripe may deliver events late, twice, or out of order. A lab replays 40,000 events through five handlers; only fetching the current object kept every subscription correct.