Why Stripe
Stripe is the standard for SaaS payments.
Why?
- Great docs
- Trusted by users
- Handles edge cases
- Works globally
We don't think about payments. Stripe does.
The Implementation
1. Create Stripe Products
In Stripe dashboard, create products and prices.
Note the price IDs.
2. Checkout Sessions
const session = await stripe.checkout.sessions.create({
mode: 'subscription',
line_items: [{ price: 'price_xxx', quantity: 1 }],
success_url: '/success',
cancel_url: '/pricing',
})
Redirect user. Stripe handles payment.
3. Webhooks
When payment succeeds, grant access.
stripe.webhooks.constructEvent(
payload,
signature,
webhookSecret
)
4. Customer Portal
Let users manage their subscription.
const portal = await stripe.billingPortal.sessions.create({
customer: 'cus_xxx',
return_url: '/dashboard'
})
Common Patterns
1. Free Trial
trial_period_days: 14
2. Usage-Based
Track usage. Bill at period end.
Stripe handles metering.
3. Annual Plans
recurring: { interval: 'year' }
The Edge Cases
Failed Payments
Retry logic built-in. Dunning emails.
We don't think about this.
Disputes
Users dispute. It happens.
Stripe handles communication.
Tax
For SaaS, tax is complex.
We use Stripe Tax. Worth the 0.5% fee.
The Honest Answer
Stripe handles payments.
Don't build payment infrastructure.
Use Stripe. Ship faster.