How to Build·14 min read

How to Implement Subscription Billing in Your SaaS Product

Subscription billing sounds simple until you deal with proration, failed payments, plan changes mid-cycle, and tax compliance across 40 countries. Here is how to build it right the first time.

N

Nate Laquis

Founder & CEO ·

Why Billing Is Harder Than You Think

Most founders treat billing as a weekend project. "Just add Stripe and we are done." Then reality hits. A customer upgrades mid-cycle and expects prorated charges. Another customer's credit card fails and you need to retry without losing them. A third customer in Germany needs a VAT-compliant invoice. A fourth wants to pause their subscription, not cancel it.

Billing touches every part of your application: authentication (which plan gates which features), the database (subscription status, usage tracking), email (receipts, failed payment notifications), and your admin panel (revenue dashboards, customer management). It is one of the most cross-cutting features you will build.

The good news: Stripe handles 90% of the complexity if you integrate it correctly. The bad news: most teams integrate it incorrectly and spend months fixing edge cases they did not anticipate.

SaaS subscription billing dashboard showing recurring revenue metrics

Choosing Your Billing Architecture

There are three main approaches to billing in a SaaS product:

Stripe Billing (Recommended for Most Teams)

Stripe Billing handles subscriptions, invoicing, proration, tax calculation, and the customer portal natively. You define products and prices in Stripe, create subscriptions via the API, and listen for webhook events to update your application state. Stripe takes 2.9% plus $0.30 per transaction (or 0.5% for Stripe Billing with Stripe Tax).

Pros: battle-tested at scale, handles international payments and currency conversion, built-in dunning (failed payment retry), and the Customer Portal eliminates the need to build billing UI from scratch. Cons: you are locked into Stripe's data model and pricing.

Paddle or Lemon Squeezy (Merchant of Record)

These platforms act as the "merchant of record," meaning they handle sales tax, VAT, and compliance globally. You do not need to register for tax in each jurisdiction. Paddle charges 5% plus $0.50 per transaction. Lemon Squeezy charges 5% plus $0.50.

The higher fees are worth it if you sell to consumers globally and do not want to deal with tax compliance. For B2B SaaS selling primarily in the US, Stripe is more cost-effective.

Custom Built (Rarely the Right Choice)

Building billing from scratch only makes sense if you have a truly unusual pricing model that no existing platform supports. Otherwise, you are reinventing Stripe poorly. We have seen teams spend $100K building custom billing systems that Stripe Billing handles for $0 in platform fees.

Setting Up Stripe Billing: The Right Way

Here is the architecture that works for 95% of SaaS products:

Products and Prices

Create your products and prices in Stripe (via the dashboard or API). A "product" is your plan (Starter, Pro, Enterprise). A "price" is the specific billing configuration ($29/month, $290/year). Each product can have multiple prices for different billing intervals.

Store the Stripe price IDs in your application config or environment variables. Your pricing page maps each plan to a Stripe price ID. When a user selects a plan, you create a Stripe Checkout Session or Subscription using that price ID.

The Checkout Flow

Use Stripe Checkout for the payment collection UI. Do not build a custom payment form unless you have a specific reason. Checkout handles card input, validation, 3D Secure authentication, Apple Pay, Google Pay, and is PCI-compliant out of the box. Redirect users to a Stripe-hosted checkout page, or embed it in your app using Stripe Elements.

Syncing Subscription State

This is where most teams make mistakes. Your application needs to know the customer's current plan, subscription status (active, past due, canceled), and feature entitlements. The source of truth is Stripe, not your database.

Set up webhook listeners for these events:

  • customer.subscription.created: New subscription started
  • customer.subscription.updated: Plan changed, payment method updated, or status changed
  • customer.subscription.deleted: Subscription canceled
  • invoice.payment_succeeded: Payment collected successfully
  • invoice.payment_failed: Payment failed (trigger dunning flow)

When you receive these events, update your local database to reflect the current subscription state. Always fetch the latest subscription data from Stripe in the webhook handler rather than relying solely on the event payload, to avoid race conditions.

Developer implementing Stripe subscription billing webhooks and API integration

Handling Plan Changes and Proration

Users will upgrade, downgrade, and switch plans constantly. Getting proration right is critical for customer trust.

Upgrades

When a user upgrades mid-cycle, Stripe calculates the prorated amount automatically. If a user on a $29/month plan upgrades to $99/month on day 15 of a 30-day cycle, Stripe charges the difference for the remaining 15 days ($35 prorated) and starts the $99 charge on the next billing cycle.

In your application, update the user's feature entitlements immediately upon upgrade. Do not wait for the billing cycle. The user paid for the upgrade and expects instant access.

Downgrades

Downgrades are trickier. You have two options: apply the downgrade immediately (Stripe credits the unused portion of the current plan) or schedule the downgrade for the end of the current billing period. We recommend scheduling downgrades. The user has already paid for the current period, so let them use their current features until the cycle ends. This also gives you a window to win them back.

Trial Periods

Stripe supports trial periods natively. Create the subscription with a trial_period_days parameter. During the trial, the subscription status is "trialing" and no charges are made. At the end of the trial, Stripe automatically charges the card on file.

Build a trial-ending notification system: send emails at 3 days before trial end, 1 day before, and on the day the trial converts. Include a clear CTA to upgrade and a reminder of what they will lose if they do not convert. Trial conversion rates for SaaS products average 15 to 25%. Good onboarding and timely reminders push this above 30%.

Failed Payments and Dunning

Credit cards fail. Cards expire, hit spending limits, get flagged for fraud, or simply decline. Without a dunning strategy, each failed payment is a lost customer.

Stripe's Smart Retries

Stripe Billing includes Smart Retries, which uses machine learning to retry failed payments at optimal times. Enable this in your Stripe dashboard under Billing settings. It recovers an additional 10 to 15% of failed payments compared to fixed retry schedules.

Your Dunning Email Sequence

In addition to Stripe's retries, send emails to the customer:

  • Day 1 (payment fails): "Your payment failed. Please update your card to continue using [Product]." Include a direct link to the Stripe Customer Portal where they can update their payment method.
  • Day 3: "We tried charging your card again. It did not go through. Update your payment method to avoid service interruption."
  • Day 7: "Your account will be downgraded to the free tier in 3 days unless you update your payment method."
  • Day 10: Downgrade or pause the account. Do not delete data. Many customers return weeks later when they realize they need the product.

Grace Periods

Give customers a grace period (7 to 14 days) where their account remains fully functional despite the failed payment. Aggressive account lockout after the first failure creates unnecessary churn. Most failed payments are resolved within a week through retries or card updates.

Tax Compliance: The Part Nobody Wants to Think About

If you sell to customers in the EU, UK, Canada, Australia, or an increasing number of US states, you must collect and remit sales tax or VAT. Ignore this and you accumulate tax liability that compounds monthly.

Stripe Tax

Stripe Tax automatically calculates the correct tax rate based on your customer's location, your business location, and the type of product (digital services have different rates than physical goods). Enable it in your Stripe dashboard and add the automatic_tax parameter to your subscription creation calls. Stripe Tax costs 0.5% per transaction on top of regular Stripe fees.

Alternatives

If you use Paddle or Lemon Squeezy as a merchant of record, tax compliance is included in their fees. They handle collection, filing, and remittance globally. This is the simplest option for small teams that do not want to manage tax registrations.

For larger companies, services like Avalara ($50 to $500/month) or TaxJar (now part of Stripe) offer more granular tax management and filing services.

Common Mistakes

Do not ignore US state sales tax. As of 2026, over 40 US states require sales tax collection on SaaS products if you exceed their economic nexus thresholds (typically $100K in sales or 200 transactions). Do not assume "we are a small startup, nobody will notice." Tax authorities are increasingly auditing SaaS companies, and back taxes with penalties add up fast.

Financial dashboard showing subscription revenue, tax compliance, and billing analytics

Costs and Implementation Timeline

Here is what subscription billing implementation costs:

  • Basic Stripe Billing integration (2 to 3 weeks, $8K to $15K): Stripe Checkout, 2 to 3 pricing plans, webhook integration, subscription status tracking, and Customer Portal for self-service billing management. Suitable for most SaaS MVPs.
  • Full billing system (4 to 6 weeks, $15K to $35K): Everything above plus trial management, proration handling, dunning emails, usage tracking, billing admin dashboard, plan migration tools, and tax compliance with Stripe Tax.
  • Enterprise billing (6 to 10 weeks, $35K to $60K): Custom invoicing, negotiated enterprise pricing, usage-based metering, multi-currency support, revenue recognition reporting, and integration with accounting software (QuickBooks, Xero).

Ongoing Costs

Stripe fees: 2.9% plus $0.30 per transaction (plus 0.5% for Stripe Tax). On $50K MRR, that is roughly $1,700/month in processing fees. Stripe Billing itself has no additional platform fee. Email service for dunning: $50 to $200/month. Tax compliance tools: $0 to $500/month.

The ROI is immediate. Proper dunning alone recovers 10 to 15% of otherwise churned revenue. On $50K MRR, that is $5K to $7.5K/month in saved revenue, far exceeding the implementation cost within two months.

We build billing systems for SaaS companies at every stage. Book a free strategy call to discuss your subscription billing needs.

Need help building this?

Our team has launched 50+ products for startups and ambitious brands. Let's talk about your project.

subscription billingStripe billingSaaS paymentsrecurring revenuepayment integration

Ready to build your product?

Book a free 15-minute strategy call. No pitch, just clarity on your next steps.

Get Started