Quick Stripe Integration Setup
Follow these steps to get Stripe subscriptions working in CONA.1. Add Environment Variables
Add these toapps/webapp/.env.example and apps/webapp/.env.local:
2. Apply Database Migration
organization table.
3. Set Up Stripe Product
- Go to Stripe Products
- Click Add Product
- Name: “CONA Subscription”
- Add pricing (e.g., $29/month)
- Copy the Price ID → Use as
NEXT_PUBLIC_STRIPE_PRICE_ID
4. Configure Webhook (Production)
- Go to Stripe Webhooks
- Click Add endpoint
- URL:
https://your-domain.com/api/webhooks/stripe - Select events:
customer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedcheckout.session.completed
- Copy the Signing secret → Use as
STRIPE_WEBHOOK_SECRET
5. Local Development Webhook Testing
6. Test the Integration
Test Subscription Flow:
- Navigate to
/subscriptionin your app - Click “Subscribe Now”
- Use test card:
4242 4242 4242 4242 - Complete checkout
- Verify subscription appears as active
Test Cards:
- Success: 4242 4242 4242 4242
- Decline: 4000 0000 0000 0002
- Requires Auth: 4000 0025 0000 3155
7. Protect Routes (Optional)
Add subscription checks to server actions:8. Going to Production
- Switch to live API keys (sk_live_, pk_live_)
- Update webhook endpoint to production URL
- Update webhook secret with production value
- Use production price ID
- Test with real payment method
Useful Links
Troubleshooting
Webhook not receiving events?- Check webhook URL is correct
- Verify webhook secret matches
- Check Stripe Dashboard → Webhooks → Recent deliveries
- Check database has subscription_status = ‘active’
- Verify webhook processed successfully
- Check organization.is_sandbox is false (sandbox orgs bypass checks)
- Verify STRIPE_SECRET_KEY is set
- Check NEXT_PUBLIC_STRIPE_PRICE_ID exists
- Verify price ID is valid in Stripe Dashboard