Stripe Webhook

1. Configure Webhook in Stripe Dashboard

  • Log in to your Stripe Dashboard.

  • Go to Developers > Webhooks.

  • Click + Add endpoint.

  • Enter Endpoint URL.

Url Format : https://domain.com/api/stripe-webhook

If you want to test in development mode, you'll need to create a webhook in test mode. Since using localhost can be inconvenient, you can use a proxy to obtain an HTTPS link. A good option for this is the ngrok service, which is free.

Make sure to replace port 80 with your actual port (likely 3000). When you run the command ngrok http 3000, you'll receive an HTTPS link. You can use this link to access your site and create a webhook in test mode.

When you're ready to test in live mode, Switch to Live Mode in Stripe Dashboard and follow the same steps to set up your webhook.

Next steps:

Select the events you we wanna listen for ,which are :

  • customer.subscription.created

  • customer.subscription.deleted

  • customer.subscription.updated

  • payment_intent.succeeded

Then, Save the webhook endpoint.

2. Retrieve Webhook Secret

  • After setting up the webhook, click on the endpoint to view its details.

  • Stripe provides a Signing Secret for each webhook endpoint. This secret is used to verify that incoming requests are from Stripe.

  • Copy the Signing Secret (which starts with whsec_) and paste it into your .env file next to

    STRIPE_WEBHOOK_SECRET variable.

Last updated