💳 Stripe Integration Setup

Configure Stripe payments, create products, set up webhooks, and test checkout flow.

By Test Staff33 views

Stripe Integration Setup

Get API Keys

  1. Go to Stripe Dashboard
  2. Enable Test mode
  3. Go to Developers → API Keys
  4. Copy keys to .env:
STRIPE_SECRET_KEY="sk_test_..."
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="pk_test_..."

Create Products

Option A: Stripe Dashboard

  1. Products → Add Product
  2. Create pricing plans (e.g., $19/mo, $49/mo)
  3. Copy Price IDs

Option B: Included Script

npm run stripe:setup

Configure Webhooks

  1. Stripe Dashboard → Developers → Webhooks
  2. Add endpoint: https://yourdomain.com/api/webhooks/stripe
  3. Select events:
    • checkout.session.completed
    • invoice.payment_succeeded
    • customer.subscription.deleted
  4. Copy webhook secret:
STRIPE_WEBHOOK_SECRET="whsec_..."

Test Locally

stripe listen --forward-to localhost:3000/api/webhooks/stripe

Test Checkout

  1. Go to /dashboard/upgrade
  2. Click a plan
  3. Use test card: 4242 4242 4242 4242
  4. Check webhook logs

Troubleshooting

  • Webhook not working? Verify secret matches
  • Payment not processing? Check API keys
  • Logs: Check /admin/settings/stripe for errors

Need help? [email protected]

Was this article helpful?

Let us know so we can improve our docs