Your Stripe subscription was created but the database wasn't updated because:
- Missing webhook endpoint secret
- Missing price ID environment variables
- Raw body parser was missing (now fixed)
- Go to Stripe Dashboard > Developers > Webhooks
- Click "Add endpoint"
- Enter endpoint URL:
- Local testing: Use ngrok or similar:
https://YOUR_NGROK_URL.ngrok.io/stripe/webhook - Production:
https://your-api-domain.com/stripe/webhook
- Local testing: Use ngrok or similar:
- Select events to listen for:
customer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_succeededinvoice.payment_failedpayment_method.attachedpayment_method.detached
- Click "Add endpoint"
- Copy the "Signing secret" (starts with
whsec_)
- Go to Stripe Dashboard > Products
- Find your subscription products
- For each product, click on it and find the Price ID (starts with
price_) - Note down:
- Individual plan price ID
- Team plan price ID
Add these to your .env file:
# Stripe Webhook Secret (from step 1.6)
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret_here
# Stripe Price IDs (from step 2)
STRIPE_INDIVIDUAL_PRICE_ID=price_your_individual_price_id
STRIPE_TEAM_PRICE_ID=price_your_team_price_idIf testing locally, use ngrok:
# Install ngrok if needed
npm install -g ngrok
# Start your API server
npm run dev
# In another terminal, expose your local server
ngrok http 3001
# Copy the HTTPS URL and update your Stripe webhook endpoint- Make a test subscription in Stripe
- Check your API logs for webhook events
- Verify database is updated:
SELECT * FROM user_billing WHERE stripe_customer_id IS NOT NULL;Since your subscription was already created, you need to manually update the database:
-- Find your user
SELECT id, email FROM users WHERE email = 'your-email@example.com';
-- Update user_billing with Stripe info
UPDATE user_billing
SET
stripe_customer_id = 'cus_xxxxx', -- Get from Stripe dashboard
stripe_subscription_id = 'sub_xxxxx', -- Get from Stripe dashboard
subscription_status = 'active',
subscription_tier = 'individual', -- or 'team'
updated_at = NOW()
WHERE user_id = 'your-user-id';To find your Stripe customer and subscription IDs:
- Go to Stripe Dashboard > Customers
- Search for your email
- Click on the customer
- Copy the Customer ID (cus_xxx)
- Under "Subscriptions", copy the Subscription ID (sub_xxx)
- Check endpoint URL is correct
- Verify signing secret is properly set
- Ensure your server is accessible (use ngrok for local testing)
- Make sure
STRIPE_WEBHOOK_SECRETis set correctly - Verify raw body parser is configured (already fixed in code)
- Check
STRIPE_INDIVIDUAL_PRICE_IDandSTRIPE_TEAM_PRICE_IDmatch your Stripe price IDs - Look at API logs for any errors in
determineSubscriptionTierfunction
- Check for any database errors in logs
- Verify
user_billingtable exists and has correct schema - Ensure Stripe customer ID is linked to user
- Webhook endpoint created in Stripe
- Signing secret added to
.env - Price IDs added to
.env - Server restarted after
.envchanges - Test subscription created
- Webhook event received (check logs)
- Database updated correctly
- User can access premium features