Aadhvika.io
SaaS DevelopmentWritten by Aadhvika Team

Building Subscription Billing for SaaS: Plans, Trials and Proration

Plans, free trials, upgrades and proration are where SaaS billing gets tricky. Here is how to model subscriptions, handle webhooks and avoid the most common billing bugs.

BillingSubscriptionsWebhooks
Three SaaS pricing plan cards (Starter, Pro, Business) with the Pro plan highlighted as popular

Billing looks simple until you build it. Charging a card every month is the easy part; the hard part is everything around it: free trials, plan upgrades in the middle of a cycle, failed payments, tax, refunds and keeping your app's idea of "who has paid" perfectly in sync with your payment provider. This guide covers the design decisions that save SaaS teams the most pain.

Don't build a billing engine from scratch

For most products, the right move is to use a payment provider that already handles subscriptions, such as Stripe Billing, Razorpay Subscriptions or Paddle, and build a thin layer on top. You get PCI-compliant card handling, invoices, retries and tax features without owning that risk yourself.

Model your plans and entitlements separately

A common mistake is hard-coding plan names in the application, such as if (plan === "pro"). Instead, separate three concepts:

  • Plan: what the customer pays for (Starter, Pro, Business), including price and billing interval.
  • Entitlements: what the plan allows (seats, projects, API calls, features).
  • Usage: what the customer has consumed so far.

Your code then checks entitlements, not plan names, which makes it easy to add new plans, custom enterprise deals and add-ons without touching application logic.

Handling free trials

  • Decide whether to require a card up front. Card-required trials convert better; no-card trials attract more sign-ups.
  • Store the trial end date on the subscription and send reminders a few days before it ends.
  • Define what happens at expiry: downgrade to a free tier, restrict access, or retain data read-only for a grace period.

Upgrades, downgrades and proration

When a customer upgrades mid-cycle, they should pay only for the time remaining on the new plan and be credited for unused time on the old one. This is called proration. Let your payment provider calculate it, and show the customer a clear preview before they confirm. For downgrades, it is often simpler and fairer to apply the change at the end of the current billing period.

Webhooks are the source of truth

Never assume a payment succeeded because your frontend said so. Payment providers send webhook events such as invoice.paid, invoice.payment_failed and customer.subscription.updated, and your backend should update its records from those events.

  1. Verify the webhook signature on every request.
  2. Make handlers idempotent, because providers may deliver the same event more than once.
  3. Process events in a queue so slow work never causes timeouts and retries.
  4. Log every event so you can replay it when debugging.

Failed payments and dunning

A meaningful share of churn is involuntary: expired cards and temporary bank declines. Set up automatic retries, send friendly emails that link to a card-update page, and give customers a short grace period before restricting access.

Conclusion

Keep billing boring: use a proven provider, model entitlements separately from plans, trust webhooks and design for failed payments from day one. Your future self, and your finance team, will thank you.

FAQ

Frequently Asked Questions

In almost all cases, no. Use a payment provider's subscription features for cards, invoices, retries and tax, and build only a thin layer for plans, entitlements and webhooks on top.

Ready to build your digital product?

Share your idea and get a scoped estimate with a realistic timeline — not a sales sequence.

  • Free scoped quote
  • Fixed price, no surprises
  • You own the code
  • Reply in 1 business day
Chat on WhatsApp