Stripe Webhook Setup - acdc-digital/solopro GitHub Wiki
Stripe Webhook Setup for Subscription Tracking
After deploying your application, you need to set up a Stripe webhook to properly track subscription status changes:
-
Go to the Stripe Dashboard
-
Click "Add endpoint"
-
For the endpoint URL, enter:
https://your-domain.com/api/stripe/webhook
- Replace
your-domain.com
with your actual domain name - Make sure you're using HTTPS
- Replace
-
Select the following events to listen for:
checkout.session.completed
customer.subscription.created
customer.subscription.updated
customer.subscription.deleted
invoice.payment_succeeded
-
After creating the webhook, Stripe will show a signing secret. Copy this value.
-
Add the webhook secret to your environment variables:
- For Convex:
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
- Replace
whsec_your_webhook_secret
with your actual webhook signing secret
- For Convex:
-
Restart your application or redeploy with the new environment variables
Environment Variables
Make sure to set the following environment variables:
# Stripe
STRIPE_SECRET_KEY=sk_your_stripe_secret_key
STRIPE_PUBLIC_KEY=pk_your_stripe_public_key
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
# Other app variables
NEXT_PUBLIC_BASE_URL=https://your-domain.com
Testing Webhooks Locally
To test webhooks during local development:
- Install the Stripe CLI
- Run
stripe login
to authenticate - Forward webhooks to your local server:
stripe listen --forward-to localhost:3000/api/stripe/webhook
- The CLI will display a webhook signing secret. Add this to your local environment variables.