setup-stripe
Access: /template setup-stripe or /t setup-stripe
Configure Stripe billing and subscription management for your MakerKit SaaS.
License Required
MakerKit is a commercial product that requires a license. Visit https://makerkit.dev for licensing information.
Overview
The setup-stripe command integrates Stripe for subscription billing, including webhooks, customer portal, and pricing plans. It follows MakerKit's billing architecture patterns.
Usage
bash
/template setup-stripe "Pricing plan descriptions"Examples
bash
# Basic SaaS tiers
/template setup-stripe "Basic ($9/mo), Pro ($29/mo), Enterprise (custom)"
# Usage-based pricing
/template setup-stripe "Starter (free), Growth ($49/mo + $0.01 per API call)"
# Feature-based tiers
/template setup-stripe "Solo (1 user), Team (5 users), Business (unlimited)"What Gets Configured
- Environment Variables - Stripe API keys
- Webhook Endpoints -
/api/stripe/webhook - Customer Portal - Settings and redirect
- Pricing Plans - Products and prices in Stripe
- Database Schema - Subscription tracking tables
- UI Components - Pricing page and billing settings
- Server Actions - Checkout and portal actions
Prerequisites
- MakerKit project with authentication
- Stripe account with API keys
- Valid MakerKit license
Configuration Steps
Add Stripe keys to
.env.local:bashSTRIPE_SECRET_KEY=sk_test_... STRIPE_PUBLISHABLE_KEY=pk_test_... STRIPE_WEBHOOK_SECRET=whsec_...Run the command to set up billing
Configure products in Stripe Dashboard
Test webhook endpoints
Example Implementation
typescript
// src/lib/stripe/plans.ts
export const PRICING_PLANS = [
{
id: 'basic',
name: 'Basic',
price: 9,
currency: 'USD',
interval: 'month',
features: [
'5 projects',
'1 team member',
'Basic support'
],
stripePriceId: process.env.STRIPE_BASIC_PRICE_ID
},
// ... more plans
];Webhook Handling
typescript
// app/api/stripe/webhook/route.ts
export async function POST(request: Request) {
const signature = request.headers.get('stripe-signature')!;
const event = stripe.webhooks.constructEvent(
await request.text(),
signature,
process.env.STRIPE_WEBHOOK_SECRET!
);
switch (event.type) {
case 'checkout.session.completed':
// Handle successful subscription
break;
case 'customer.subscription.updated':
// Handle plan changes
break;
}
}Best Practices
- Use test mode during development
- Implement proper error handling
- Log all billing events
- Set up email notifications
- Handle edge cases (failed payments, cancellations)
Testing
bash
# Test webhook locally
stripe listen --forward-to localhost:3000/api/stripe/webhook
# Trigger test events
stripe trigger payment_intent.succeeded