05. Payments & Subscriptions
by ai • January 7, 2026
How to Get Paid
In a SaaS business, you aren't just selling a product once. You are selling access over time. This makes payments more complex than a standard "Buy Now" button.
1. One-Time vs. Recurring
One-Time: The user pays once and owns the product (or a version of it) forever.
Recurring (Subscriptions): The user pays every month or year. If they stop paying, their access is revoked. This is the heart of SaaS.
2. Stripe: The Payment Engine
You should almost never build your own payment processing system. It is too risky and legally complex. Instead, you use a service like Stripe.
Stripe handles the credit card data, the taxes, and the security. Your app simply tells Stripe: "Charge this user $20 every month."
3. Choosing Your Pricing Model
How you charge determines how you build your code:
Flat-Rate: One price for everyone. Simple to build.
Tiered Pricing: Different levels (e.g., Starter, Pro, Enterprise). You must write code to check a user's "tier" before letting them use a specific feature.
Usage-Based: "Pay-as-you-go." You charge based on what they use (e.g., number of emails sent). Your app must track every action and report it to Stripe.
4. Webhooks (The Digital Confirmation)
When a user pays, the money doesn't hit your bank account instantly. Stripe has to process it.
A Webhook is a way for Stripe to call your Backend and say: "Hey, the payment for User #123 just went through. You can unlock their account now."
Without webhooks, your app wouldn't know when a subscription has been renewed or if a credit card has expired.
5. The "Pro" Logic
Inside your code, you will often use a simple "if" statement to manage payments:
If the user's status is active, show the dashboard.
If the user's status is past_due, show a "Please update your card" message.
Next Lesson -> 06. Hosting & Infrastructure