# Stripe Webhook

### 1. **Configure Webhook in Stripe Dashboard**

* **Log in** to your Stripe Dashboard.
* Go to **Developers > Webhooks**.
* Click **+ Add endpoint**.
* Enter **Endpoint URL**.&#x20;

Url Format :&#x20;&#x20;<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.

* **Download ngrok**: Get it from [ngrok.com/download](https://ngrok.com/download).
* **Sign up**: Create an account on their website to get an API key.
* **Setup**: Follow the instructions here: [ngrok setup guide](https://dashboard.ngrok.com/get-started/setup).

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:&#x20;

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

* customer.subscription.created
* &#x20;customer.subscription.deleted
* &#x20;customer.subscription.updated
* &#x20;payment\_intent.succeeded&#x20;

### 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&#x20;

  STRIPE\_WEBHOOK\_SECRET variable.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://zakariaes-organization.gitbook.io/saascore-docs/configuration/stripe/stripe-webhook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
