> ## Documentation Index
> Fetch the complete documentation index at: https://razorpay-60c89f9a-mintlify-audit-missing-sections-1778528421.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# View Notifications using Webhooks

> You can also enable webhooks to receive notifications about the payment as they move through the different states. All information entered by the customer while making the payment will appear in the webhook payload.

Webhooks (Web Callback, HTTP Push API or Reverse API) automatically notify your application when specific events occur. Instead of continuously polling APIs to check for updates, webhooks push notifications directly to your server when events happen.

## Webhooks vs APIs

Here is how webhooks compare to traditional API polling:

## Aspect | APIs | Webhooks

## **Data retrieval** | Pull-based (you request) | Push-based (we send)

## **Timing** | On-demand | Near real-time when events occur

**Resource usage** | Requires polling | Event-driven, efficient

## How Razorpay Webhooks Work

When you subscribe to webhook events, Razorpay sends an HTTP POST request with JSON payload to your configured endpoint URL whenever those events are triggered.

Suppose you have subscribed to the `order.paid` webhook event, you will receive a notification every time a user pays you for an order, in the configured endpoint URL.

### Use Cases

There can be multiple uses for webhook events. Two of these are listed below.

### Capturing Late Authorised Payments

Capturing payments for which you did not receive a response on the client-side is perhaps the most important use case for the `payment.authorized` event.

Sometimes, the communication between the bank and Razorpay or between you and Razorpay may not occur. This could be because of a slow network connection or your customer closing the window while processing the payment. This could lead to a payment being marked as **Failed** on the Dashboard but changed to **Authorized** at a later time. Know more about [late authorisation of payments](/payments/payments/late-authorisation).

You can use webhooks to get notified about payments that get authorised and analyse this data to decide whether to capture the payment or not.

### Notifications on Failed Payments

When a payment attempted by your customer fails, we receive the failed payment status from the bank. This payment gets recorded in our system as **Failed**.

Suppose you have enabled the `payment.failed` webhook, you will receive a notification from us about the failed payment. You can then further analyse this payment and notify your customer about the failure.

### Setup and Configuration

* You can set up webhooks from your Dashboard and configure separate URLs for **Live** mode and **Test** mode. Know more about setting up [Payment webhooks](/webhooks/setup-edit-payments) and [Payout webhooks](/webhooks/setup-edit-payouts).
* A **Test** mode webhook receives events for your test transactions. Know more about [testing webhooks](/webhooks/validate-test).
* Webhook URLs must use ports **80** or **443** only.
* Ensure Razorpay webhook IPs are whitelisted on your server. Even if your server accepts all incoming requests, webhooks may still be blocked by cloud security groups or network configurations. Refer to [Razorpay IPs and Certificates](/security/whitelists#webhook-ips) for the complete list of webhook IP addresses.

<Warning>
  **Implementation Considerations**

  Webhooks are the primary and most efficient method for event notifications. They are delivered asynchronously in near real-time. For critical user-facing flows that need instant confirmation (like showing "Payment Successful" immediately), supplement webhooks with API verification.

  **Recommended approach**

  * Rely on webhooks for all automation, which can be asynchronous.
  * If a critical user-facing flow requires instant status, but the webhook notification has not arrived within the time mandated by your business needs, perform an immediate API Fetch call ([Payments](/api/payments/fetch-with-id), [Orders](/api/orders/fetch-with-id) and [Refunds](/api/refunds/fetch-specific-refund-payment)) to verify the status.

  Watch this video to see how to set up a webhook.

  To set up webhooks:

  <Steps>
    <Step title="Step 1">
      Log in to the Dashboard and navigate to **Accounts & Settings**.
    </Step>

    <Step title="Step 2">
      Click **Webhooks** under **Website and app settings**.
    </Step>

    <Step title="Step 3">
      Click the **+ Add New Webhook** button.
    </Step>
  </Steps>

  4. In the **Webhook Setup** pop-up page:
     * Enter the **URL** where you want to receive the webhook payload when an event is triggered. We recommend using an HTTPS URL.
</Warning>

<Info>
  **Handy Tips**

  * You can set up to **30 URLs** to receive Webhook notifications. Webhooks can only be delivered to public URLs.
  * If your URL contains `razorpay` as a domain, you will not be able to add the URL and will receive an error.
  * If you attempt to save a localhost endpoint as part of a webhook setup, you will notice an error. Know more about [testing Webhooks on an application running on localhost](/webhooks/validate-test#application-running-on-localhost).

    * Enter a **Secret** for the webhook endpoint. The secret is used to validate that the webhook is from Razorpay. Do not expose the secret publicly. Know more about [how to validate webhooks](/webhooks/validate-test).
</Info>

<Info>
  **Handy Tips**

  * When setting up the webhook, specify a secret. Use this secret to validate that the webhook is from Razorpay. Entering the secret is optional but recommended. The secret should never be exposed publicly.
  * The webhook secret does not need to be the Razorpay API key secret.

    * In the **Alert Email** field, enter the email address to which the notifications should be sent in case of webhook failure. You will receive webhook related notifications like failures, deactivation and so on.
    * Select the required events from the list of **Active Events**.

  5. Click **Create Webhook**. After you set up a webhook, it appears on the list of webhooks.

  6. You can select the webhook and click **Edit** to make more changes.
</Info>

## Subscribe to Webhook Events

You must subscribe to the following Payment and Order webhook events:

`payment.authorized`
: To receive notifications when the payment made by a customer is in `authorized` state.

`payment.captured`
: To receive notifications when the payment made by a customer is in `captured` state.

`payment.failed`
: To receive notifications when a customer's payment attempt failed.

`order.paid`
: To receive notifications when an order is paid.

### Event Payload: payment.authorized

Below is the sample payload for the `payment.authorized` event.

```json: payment.authorized.payload theme={null}
{
  "entity":"event",
  "account_id":"acc_DLXfTGFm2PS7Cy",
  "event":"payment.authorized",
  "contains":[
    "payment"
  ],
  "payload":{
    "payment":{
      "entity":{
        "id":"pay_DORWaWz6UGwvRx",
        "entity":"payment",
        "amount":70000,
        "currency":"INR",
        "status":"authorized",
        "order_id":"order_DORWL4a5PvwmiR",
        "invoice_id":null,
        "international":false,
        "method":"upi",
        "amount_refunded":0,
        "refund_status":null,
        "captured":false,
        "description":null,
        "card_id":null,
        "bank":null,
        "wallet":null,
        "vpa":"sauravkumar@exampleupi",
        "email":"saurav.kumar@example.com",
        "contact":"+919998887776",
        "notes":{
          "participant_name":"Saurav Kumar",
          "email":"saurav.kumar@example.com",
          "phone":"9998887776"
        },
        "fee":null,
        "tax":null,
        "error_code":null,
        "error_description":null,
        "created_at":1569853622
      }
    }
  },
  "created_at":1569853623
}
```

### Event Payload: payment.captured

Below is the sample payload for the `payment.captured` event.

```json: payment.captured.payload theme={null}
{
  "entity":"event",
  "account_id":"acc_DLXfTGFm2PS7Cy",
  "event":"payment.captured",
  "contains":[
    "payment"
  ],
  "payload":{
    "payment":{
      "entity":{
        "id":"pay_DORWaWz6UGwvRx",
        "entity":"payment",
        "amount":70000,
        "currency":"INR",
        "status":"captured",
        "order_id":"order_DORWL4a5PvwmiR",
        "invoice_id":null,
        "international":false,
        "method":"upi",
        "amount_refunded":0,
        "refund_status":null,
        "captured":true,
        "description":null,
        "card_id":null,
        "bank":null,
        "wallet":null,
        "vpa":"sauravkumar@exampleupi",
        "email":"saurav.kumar@example.com",
        "contact":"+919998887776",
        "notes":{
          "participant_name":"Saurav Kumar",
          "email":"saurav.kumar@example.com",
          "phone":"9998887776"
        },
        "fee":1652,
        "tax":252,
        "error_code":null,
        "error_description":null,
        "created_at":1569853622
      }
    }
  },
  "created_at":1569853628
}
```

### Event Payload: payment.failed

```json: payment.failed.payload theme={null}
{
  "entity":"event",
  "account_id":"acc_CJoeHMNpi0nC7k",
  "event":"payment.failed",
  "contains":[
    "payment"
  ],
  "payload":{
    "payment":{
      "entity":{
        "id":"pay_DM45I1xLvo836m",
        "entity":"payment",
        "amount":1600,
        "currency":"INR",
        "status":"failed",
        "order_id":null,
        "invoice_id":null,
        "international":false,
        "method":"netbanking",
        "amount_refunded":0,
        "refund_status":null,
        "captured":false,
        "description":null,
        "card_id":null,
        "bank":"KKBK",
        "wallet":null,
        "vpa":null,
        "email":"gaurav.kumar@example.com",
        "contact":"+919988776655",
        "notes":{
          "participant_name":"Gaurav Kumar"
        },
        "fee":null,
        "tax":null,
        "error_code":"BAD_REQUEST_ERROR",
        "error_description":"Payment failed",
        "created_at":1569334394
      }
    }
  },
  "created_at":1569334395
}
```

### Event Payload: order.paid

Below is the sample payload for the `order.paid` event.

```json: order.paid.payload theme={null}
{
  "entity":"event",
  "account_id":"acc_DLXfTGFm2PS7Cy",
  "event":"order.paid",
  "contains":[
    "payment",
    "order"
  ],
  "payload":{
    "payment":{
      "entity":{
        "id":"pay_DORWaWz6UGwvRx",
        "entity":"payment",
        "amount":70000,
        "currency":"INR",
        "status":"captured",
        "order_id":"order_DORWL4a5PvwmiR",
        "invoice_id":null,
        "international":false,
        "method":"upi",
        "amount_refunded":0,
        "refund_status":null,
        "captured":true,
        "description":null,
        "card_id":null,
        "bank":null,
        "wallet":null,
        "vpa":"sauravkumar@exampleupi",
        "email":"saurav.kumar@example.com",
        "contact":"+919998887776",
        "notes":{
          "participant_name":"Saurav Kumar",
          "email":"saurav.kumar@example.com",
          "phone":"9998887776"
        },
        "fee":1652,
        "tax":252,
        "error_code":null,
        "error_description":null,
        "created_at":1569853622
      }
    },
    "order":{
      "entity":{
        "id":"order_DORWL4a5PvwmiR",
        "entity":"order",
        "amount":70000,
        "amount_paid":70000,
        "amount_due":0,
        "currency":"INR",
        "receipt":null,
        "offer_id":null,
        "status":"paid",
        "attempts":1,
        "notes":[],
        "created_at":1569853608
      }
    }
  },
  "created_at":1569853628
}
```

### Related Information

[Webhooks FAQs](/webhooks/faqs)
