Topic

Subscription Billing, Metering & Entitlements

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.

Suggested reading order

  1. Usage Metering Without Lost or Double-Billed Events: Where to Deduplicate

    Count usage so that retries and late events are neither lost nor billed twice.

    Lab finding: Redis marker first: 2,018 lost, 191 double-billed. Marker cleared on error: 92 lost, 196 double-billed. Unique key in the ledger: exactly 200,000.

  2. Stripe Webhooks Out of Order: Why created Timestamps Fail and What to Do Instead

    Keep subscription state correct when provider events arrive late, twice, or out of order.

    Lab finding: Arrival order: 30.5%. created guard with a NULL start: 100%. created guard otherwise: about 14%. Fetching the current object: 0%.

  3. Entitlements for Subscription Plans: Data Model, Caching, and Stale Permissions

    Turn plans into feature and quota checks without serving stale permissions.

    Lab finding: Messages only: up to 58 minutes. With a 60 s cache lifetime: 38 s. With a 5 s version poll: 1.6 s.

  4. Subscription Proration in Practice: Month Lengths, Rounding, and Plan Changes

    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.

  5. Failed Payments and Dunning: Declines, Retries, Access States, and a Tested Policy

    Handle failed payments with a versioned policy that duplicate events cannot confuse.

Put numbers on it: Tenant Unit Economics Calculator

All guides in this topic