Recurring Billing in SaaS: What You Need to Plan
Plans, subscriptions, dunning, payment failures, and states that a reliable SaaS billing system must handle.
Erlan Carreira
Software Engineer & Entrepreneur
Recurring billing is a state machine that connects payment, access, communication, and accounting. The checkout creates the initial relationship, but renewals, failures, plan changes, cancellations, and refunds occur asynchronously. The product needs to react to events without duplicating effects.
Direct Response: What to Plan
Model product, pricing, subscription, invoice, payment, and access rights as related but distinct concepts. Use verified webhooks to synchronize events, process them idempotently, and maintain sufficient history for reconciliation and support.
| State/Event | Product Decision |
|---|---|
| Trial started | What resources and limits are released? |
| Active subscription | How to provision rights and communicate renewal? |
| Payment requires action | What message and deadline does the customer receive? |
| Payment failed | Is there a retry, tolerance, or gradual blocking? |
| Upgrade/Downgrade | When do limits and proration take effect? |
| Cancellation | Is it immediate or at the end of the period? |
| Refund | What happens to access, credit, and financial records? |
Webhooks are the Source of Asynchronous Transitions
Stripe's documentation recommends webhooks to track subscriptions because much of the activity occurs outside the initial request. Verify the event signature, respond quickly, and move heavy work to a queue. Store the event identifier to avoid duplicate processing.
Do not assume perfect order. Seek the current state from the provider when necessary and make each handler safe for repetition. Log attempts, results, and reasons for failure. A queue of unprocessed messages needs alerting and controlled reprocessing.
Separate Billing from Authorization
The provider knows invoices and payments; the application knows functionalities and limits. Create a layer of entitlements that translates plan and state into rights. This avoids spreading price checks throughout the code and facilitates legacy plans, promotions, and special contracts.
Delinquency is a Business Decision
Define tolerance period, communication, retries, and data behavior before implementation. Immediate blocking can interrupt a critical operation; indefinite access creates loss. The system should reflect the contractual policy and allow for auditable support.
Upgrade, Downgrade, and Cancellation
Document proration, effective date, and impact on limits. If the customer reduces seats below current usage, define how to regularize. In cancellation, inform the final date, data export, and retention. Do not automatically delete without considering legal obligations and privacy policy.
Technical and Operational Checklist
- Versioned product and pricing catalog.
- Provider identifiers linked to the correct organization.
- Authenticated, idempotent, and observable webhooks.
- Failure queue and reprocessing.
- Entitlements separated from screens and prices.
- Tests for renewal, failure, action, change, and cancellation.
- Clear tolerance and communication policy.
- Reconciliation between subscription, invoice, and access.
- Logs for support without storing inappropriate sensitive data.
- Separate environments and keys.
Primary Sources
See also how much it costs to maintain a SaaS and our approach to SaaS platforms.
Erlan Carreira
Software Engineer & Entrepreneur
Specialist in software development, automation, and SaaS. I write about technology, digital business, AI, and engineering practices for teams committed to execution excellence.