Cursor·Prompt

Cursor Prompt: Complete Stripe Integration

When to Use This Prompt

Use this when adding paid plans to your SaaS. This covers the complete payment lifecycle.

The Prompt

Add complete Stripe payment integration:

1. Products and pricing:
   - Create products and prices in Stripe (or use existing)
   - Pricing page component showing all tiers

2. Checkout flow:
   - Stripe Checkout session creation (API route)
   - Success and cancel pages
   - Checkout button component

3. Subscription management:
   - Customer portal link for managing subscriptions
   - Subscription status check middleware
   - Grace period handling for failed payments

4. Webhooks:
   - /api/webhooks/stripe endpoint
   - Handle: checkout.session.completed, customer.subscription.updated, customer.subscription.deleted, invoice.payment_failed
   - Update user subscription status in database

5. Database:
   - subscriptions table (user_id, stripe_customer_id, status, plan, current_period_end)
   - payments table (user_id, amount, status, stripe_payment_id)

Use Stripe SDK v14+. Environment variables: STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY.

What to Customize

Adjust the pricing tiers and webhook events for your specific billing model.

Expected Output

Complete Stripe integration with checkout, subscriptions, webhooks, and database tables. About 10-12 files.