Subscription billing

SaaS billing: what you're signing up for if you build it

Every SaaS billing system starts as a cron job that charges a card once a month. It stops being one the first time a customer upgrades on the 17th, a card expires, or someone in Germany asks why there's no VAT on the invoice. Here's what subscription billing software does that the cron job doesn't, and a checklist for deciding which parts to build, with the subscription material from chapters 7 and 24.

SaaS billing is everything between "the customer picked a plan" and "the revenue is in the books": charging on a schedule, changing plans mid-period, recovering failed payments, issuing invoices, collecting tax, and reporting revenue correctly. Subscription billing software sells that as a product. The charge itself is the smallest part.

The hidden work

The list a build estimate usually leaves out. Each row is something a billing product does for you, and something your code does if you build.

JobWhat it actually involvesWhat goes wrong without it
ProrationCredits and charges when a plan, quantity or price changes mid-period, previewed before the customer confirmsOvercharges become disputes; undercharges leak quietly
DunningRetries on a schedule, card-update emails, a grace period, then pause or cancelFailed renewals turn into churn nobody chose. See dunning
TaxWorking out whether you owe sales tax, VAT or GST where the customer is, at what rate, then registering and filingLiabilities you find out about later, with interest. See sales tax for SaaS and EU VAT OSS
InvoicingNumbered invoices, credit notes, the legal fields each country requires, PDFs, resendsFinance teams that can't pay you, and an accountant who can't close the year
Revenue recognitionSpreading an annual prepayment over the months it covers, handling refunds and creditsBooking cash as revenue. See revenue recognition for SaaS
EntitlementsTurning subscription status into feature access, limits and seat counts in your appPaid customers locked out, or cancelled ones still in
Plan migrationsMoving existing customers to new prices: grandfathering, renewal-date changes, noticeA pricing change that takes a quarter of engineering
CurrencyPrices per currency, not converted on the fly; one currency per subscriptionMixed-currency invoice history that breaks accounting

None of these is hard alone. The cost is that they interact: a plan change during dunning, in a different currency, on an annual plan with tax. Chapter 7's edge cases below are that list in practice.

What buying costs

Two published prices, checked 14 November 2026, as reference points rather than a ranking:

  • Stripe Billing: 0.7% of Billing volume pay-as-you-go, on top of card processing, or monthly plans from $620 a month on a 1-year contract (Stripe). It handles proration, dunning, invoicing and usage meters. Tax is a separate product, and you remain the seller who registers and files.
  • Paddle: 5% + 50 cents per checkout transaction, with tax compliance included because Paddle is the merchant of record (Paddle).

On a $50 monthly renewal with a US card, Stripe is $1.45 + $0.30 = $1.75 processing plus $0.35 Billing (0.7% x $50), $2.10 in all, before tax. Paddle is $2.50 + $0.50 = $3.00, with tax registration and filing done for you. The $0.90 difference is the price of not doing tax compliance yourself; whether that's cheap depends on how many places you sell. The merchant of record fee calculator runs the numbers at your volume, and Stripe vs Paddle compares the rest.

Other vendors publish pricing too; check their own pages on the day you decide, because billing prices change more often than billing requirements.

Build vs buy: the checklist

Count the answers. Mostly "yes" to the first group means buy; mostly "yes" to the second means building some of it may be justified.

Buy if:

  • Your pricing fits flat, per-seat, tiered or metered prices without contortions.
  • You sell to more than one country, or will soon, and tax is a question you'd rather not own. If tax is the main reason, a merchant of record takes it off your books entirely.
  • Finance needs invoices, credit notes and revenue reports this quarter, not after a rebuild.
  • Billing is not what your product is. Every engineer on proration isn't on the product.
  • You have no one who wants to be on call for the renewal run on the 1st.

Consider building parts if:

  • Your pricing genuinely doesn't fit any vendor's model (complex contracts, custom rating, usage across many dimensions).
  • You already run your own payment orchestration across several processors, and a billing vendor tied to one processor would undo it.
  • Billing fees at your volume exceed the cost of a team to maintain the system, with your actual salaries in the arithmetic.
  • You need billing data in your own database in real time, and webhooks plus an API sync won't do.

The common middle path: buy the billing engine and build the edges. Keep entitlements, usage metering and the pricing page in your code, where they change with your product, and let the vendor own invoices, dunning, proration and the renewal run. If you build anything, build it on a state machine and idempotency keys first; chapter 7 makes that case, and both are cheaper to get right than to retrofit.

The month-end anchor, refunds after cancel, plan changes during dunning, credit balances, currency and tax-locale changes. The cases a homegrown system meets in its first year. From chapter 7.

4. Handle Edge Cases

The fun part - dealing with all the weird stuff customers do:

The 31st-of-the-month customer. Customer subscribed on Jan 31. February has 28 days. Most processors clamp to the last day of the short month, then resume the original anniversary in the next long month (Feb 28 -> Mar 31). Confirm your code does the same; rolling over to Mar 1 silently shifts the customer's anniversary forever.

Refund-after-cancel. Customer cancels mid-cycle, gets prorated refund. Three days later, asks for a full refund instead. Decide your refund policy in writing and put it in the support tool. Without a written policy, support agents make inconsistent decisions and chargebacks spike.

Plan changes during dunning. Customer is in PAST_DUE on a $99 plan, attempts to "fix" it by switching to a $29 plan. Most teams want this to (a) update the failed invoice to the new amount, or (b) reject the change until the existing invoice is paid. Either is defensible; just pick one and be consistent.

Refund of credit balance. Customer has $50 in account credit (from previous proration), then cancels. Do you refund the credit to their card? Most products forfeit credits on cancellation, but disclose this in the terms. If you refund credits, watch for fraud (chargeback, then ask for credit refund).

Currency switching. Customer moves from US to EU and asks to be billed in EUR. The clean answer: cancel the USD subscription, create a new EUR one. The trap: try to "convert" the existing subscription, end up with mixed-currency invoice history that breaks your accounting.

Tax-locale changes. Customer moves from a tax-free state to one with sales tax mid-cycle. Most processors apply tax going forward only. Document this so the customer doesn't argue retroactive tax should apply.

Subscription transfer between accounts. "Can you move my Pro subscription to my new email?" The clean answer: customer cancels old account, signs up on new account, you waive the prorated difference. Trying to mutate the customer ID on an existing subscription leaks data into reports and breaks audit trails.

Implementation: src/examples/7-subscriptions-recurring-billing/subscription_testing.py

Four proration policies and who each one suits. You choose one whether you build or buy. From chapter 7.

Proration Policies

There's no universal standard for proration - different businesses pick different policies based on what their customers tolerate:

1. Prorate both sides on the next invoice (Stripe's default, create_prorations). Credit the unused time on the old plan, charge for the remaining time on the new plan, and add both as invoice items to the next invoice. Nothing moves at the moment of the switch; if you want the difference collected now, Stripe's always_invoice bills it immediately. Stripe's own example: a customer moving from $10 to $20 a month halfway through gets a $5 credit and a $10 charge, $5 net. Most accurate, but the next bill varies with the day they switched, and unpredictable amounts confuse non-technical buyers.

2. Next-cycle proration. No mid-cycle charge. The new plan kicks in at the next renewal, and you simply bill the new amount then. Predictable, but you eat the cost of the upgrade for the rest of the current cycle (or you delay benefits until renewal, which kills upgrade conversion).

3. No proration (cycle-based). New plan effective immediately, but you don't credit the old plan. Customer pays full price for both within the cycle. Simple to communicate ("upgrade today, your new plan starts today") but feels unfair on a 28-day-old upgrade.

4. Custom hybrid. Charge full new plan now, credit unused old-plan time toward the next cycle. Common in B2B SaaS where invoices are predictable monthly amounts.

The right policy depends on your customer base. Consumer SaaS leans toward (1) or (2) - any surprise charge causes a chargeback. B2B leans toward (4) - finance teams want stable monthly invoices. Marketplaces and usage-based products often skip proration entirely (3) and lean on metering instead.

Whatever you pick, document it in your terms of service and show the prorated amount in the upgrade UI before the customer confirms. "I didn't expect this charge" is exactly the feeling that turns into a dispute.

Implementation: src/examples/7-subscriptions-recurring-billing/proration.py

If you build anyway

  • Model the subscription as a state machine, and grant access from its status, not from a successful charge.
  • Put an idempotency key on every charge, derived from the subscription and period, never a fresh UUID per retry.
  • Store money as integers or Decimal, never floats, and one currency per subscription.
  • Test with a mocked clock through 13 cycles, leap years, month-ends and DST, before a real customer does it for you.
  • Write down the proration, refund and dunning policies before you write the code, and show the customer the number before they confirm.

Picking the model you'll bill is a separate decision: see subscription pricing models. If you're on Stripe already, Stripe subscriptions covers the statuses, proration and portal.

Questions

What is SaaS billing?

Everything between a customer choosing a plan and the revenue being booked: recurring charges, proration on plan changes, dunning for failed payments, invoicing, tax, revenue recognition, entitlements, plan migrations and currency.

What does subscription billing software do?

It runs the recurring charge and the work around it: proration, retries and card-update emails, invoices and credit notes, and usually usage metering and revenue reports. Some products, such as Paddle as a merchant of record, also collect and file sales tax and VAT.

Should I build or buy subscription billing?

Buy if your pricing fits standard flat, per-seat, tiered or metered prices and billing isn't your product. Consider building parts if your pricing fits no vendor, you orchestrate several processors, or vendor fees at your volume exceed the cost of a team. The common middle path is to buy the engine and build entitlements and metering yourself.

How much does Stripe Billing cost?

0.7% of Billing volume on pay-as-you-go, on top of card processing, or monthly plans from $620 a month on a 1-year contract, checked 14 November 2026. On a $50 US card renewal that's $1.75 processing plus $0.35 Billing, $2.10 in all, before tax.

Does subscription billing software handle sales tax?

It depends on the model. Stripe Billing works with Stripe Tax to calculate and collect, but you remain the seller who registers and files. A merchant of record such as Paddle (5% + 50 cents per transaction) is the seller, so it handles tax registration and filing itself.

What the book adds

What chapters 7 and 24 add

  • A billing engine and subscription state machine in Python
  • Proration math that survives month-ends and leap years
  • A dunning sequence, step by step
  • Usage metering with late and duplicate events handled
  • Testing a year of billing with a mocked clock

30-day money-back · Instant PDF and EPUB

All 42 chapters