> ## Documentation Index
> Fetch the complete documentation index at: https://razorpay.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Recover Payment Status After a Timeout or Missed Callback

> Find the final status of a payment when a webhook, a browser callback or an API response does not reach you, without fulfilling an order twice.

Available in
🇮🇳 India

Use this page when your server does not know how a payment ended: the webhook did not arrive, the customer closed the browser before the callback, or an API call timed out. It is for developers who run a Razorpay Payment Gateway integration and need to bring their own order records back in line with Razorpay. It brings together the recovery guidance from the webhook, fetch API and checkout pages, and links to each page that owns the detail.

## When to rely on webhooks and when to fetch

Webhooks are your source of truth and fetch APIs are your safety net. Webhooks are delivered in near real-time and are asynchronous, so for business-critical flows you can also poll the payment APIs.

| You need to | Use | Why |
| - | - | - |
| Decide when to fulfil | Webhook: `payment.captured` or `order.paid` | It is pushed to you as soon as the payment is captured. |
| Know an attempt failed | Webhook: `payment.failed`. Fallback: `GET /v1/orders/:id/payments` | Mark the attempt failed and keep the order open. |
| Capture, if you capture manually | Webhook: `payment.authorized`. Fallback: `GET /v1/payments/:id` | Capture inside your capture window, or the payment is refunded. |
| Track a refund | Webhooks: `refund.processed`, `refund.failed`. Fallback: `GET /v1/payments/:id/refunds` | Update the order and tell the customer. |
| Show the customer a result after the callback | Verify the signature. Fetch the payment once if you are unsure | The webhook may land a few seconds after the customer returns. |
| Catch up on a payment with no webhook | Fetch: `GET /v1/orders/:id/payments` | Covers delayed or failed webhooks. |
| Recover after your endpoint was down | Fetch every order from the outage window | The webhook may have been disabled while your endpoint was failing. |
| Reconcile every day | Fetch payments and settlements by date | Confirms your books match Razorpay's. |

The browser callback can be lost, blocked or forged, and it never fires if the customer closes the browser tab. Treat it as a hint: verify the signature and show a result, but fulfil only from the webhook or a fetch.

For how long to wait for a webhook before you fetch, see [Webhooks and Fetch APIs](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/test-s2s/best-practices/webhooks-and-fetch-apis.md). For how long Razorpay retries a failed webhook delivery and when it disables the webhook, see [Delivery Attempts and Retries](https://razorpay.com/docs/webhooks/best-practices.md#delivery-attempts-and-retries).

## Which fetch call to use

| What you have | Call | What it returns |
| - | - | - |
| The order ID | [Fetch Payments for an Order](https://razorpay.com/docs/api/orders/fetch-payments.md): `GET /v1/orders/:id/payments` | All the authorised or failed payments for that order. |
| The payment ID | [Fetch a Payment With ID](https://razorpay.com/docs/api/payments/fetch-with-id.md): `GET /v1/payments/:id` | The details of that payment, including its `status`. |
| The order ID, and you need the order's own status | [Fetch an Order With ID](https://razorpay.com/docs/api/orders/fetch-with-id.md): `GET /v1/orders/:id` | The details of that order, including its `status`. |
| The payment ID of a payment you refunded | [Fetch Multiple Refunds for a Payment](https://razorpay.com/docs/api/refunds/fetch-multiple-refund-payment.md): `GET /v1/payments/:id/refunds` | The refunds for that payment. |

If one of your own API calls timed out, do not send it again blindly:

| Call that timed out | What to do | Why it is safe |
| - | - | - |
| Create order | Retry with the same `receipt`. Create the order with `unique_receipt: true` so that a retried create returns the same order instead of a duplicate. | Your receipt identifies the purchase. |
| Create payment | Fetch the order's payments first, then retry on the same order. Retry only if no payment is in progress or captured. | A paid order cannot take a second successful payment. |
| Create refund | Retry with the same `X-Refund-Idempotency` header. | Same key, same refund. |

Know more about [Retries and Idempotency](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/test-s2s/best-practices/retries-and-idempotency.md).

When you fetch a pending order, fetch it a few times with growing gaps, then leave it to your reconciler. Do not poll in a tight loop: you hit rate limits and still miss the result.

## Reconcile your local state

Build one state machine with two inputs. Webhooks and fetches update the same order record through the same code.

1. Find the orders in your system that are still `created` or `attempted` after your waiting period.
2. For each order, call `GET /v1/orders/:id/payments`.
3. Act on the result using the table below. Apply the same rules that your webhook handler applies.
4. Run a daily reconciliation as well: fetch payments and settlements by date and confirm that your records match.

| What the fetch shows | What it means | What you do |
| - | - | - |
| The order has no payments | The order stays `created` until a payment is attempted on it. | Keep it open, or expire it on your side after your own timeout. |
| A payment is `failed` | The attempt was not successful. A payment with no response from the bank is also marked as failed after a timeout, and can turn `authorized` later. | Mark the attempt as failed and keep the order open, so that the customer can retry and a late authorisation is caught. |
| A payment is `authorized` | The customer completed the payment and the funds are held, but the payment is not yet captured. | Capture it inside your capture window if you capture manually. Do not fulfil on `authorized` alone. |
| A payment is `captured` | After the successful capture of the payment, the order moves to the `paid` state. | Fulfil the order once. |

Follow these rules in the state machine:

* **Forward-only**: ignore any update that would move a payment or an order back. Never move an order back from `paid`.
* **Accept a late authorisation**: accept `failed` → `authorized`. Know more about [Late Payment Authorisations](https://razorpay.com/docs/payments/payments/late-authorisation.md).
* **Idempotent**: processing the same update twice changes nothing.

If a late authorisation arrives for an order you have already expired or cancelled on your side, or one that was already fulfilled by another payment, refund the payment using the [Create Refund API](https://razorpay.com/docs/api/refunds/create-normal.md) and tell the customer.

An `authorized` payment that you do not capture in time is auto-refunded. The capture timeout and the auto-refund timing are defined in [Payment Capture Settings](https://razorpay.com/docs/payments/payments/capture-settings.md) and [Auto-Refunds](https://razorpay.com/docs/payments/refunds/auto-refunds.md).

## Avoid duplicate fulfilment

Razorpay follows at-least-once delivery for webhooks, so your endpoint can receive the same event more than once. A fetch can also report a payment that a webhook has already told you about.

* **Skip repeated events**: check the `x-razorpay-event-id` header on every webhook. Its value is unique per event and stays the same across the original delivery and every replay. Store the values you have already processed and skip an event if you see the same value again.
* **Do not rely on the order of events**: you may not always receive webhooks in the order in which the events occur. Handle whichever arrives first.
* **Drive fulfilment from the order**: create one order per purchase, store its `order_id` against your cart and retry payments on the same order. Fulfil when the order is `paid`.
* **Use one code path**: with two code paths for webhook and fetch, the same payment is processed differently, or twice.
* **Stop a second payment**: disable the pay button once an order is `paid`. No further payment requests are permitted once the order moves to the `paid` state.
* **Reply to the webhook first**: reply with `2xx` within 5 seconds, then process the event in the background. If your server accepts the event but does not respond in time, the webhook is treated as not processed and is sent again.
* **Verify before you act**: [validate the webhook signature](https://razorpay.com/docs/webhooks/validate-test.md#validate-webhooks) on the raw request body before you update an order.

## Replay a missed webhook from the Dashboard

If your server was unavailable or returned a non-2xx response, you can replay the missed events yourself from the Razorpay Dashboard, without raising a support ticket. Only unacknowledged events are replayed. Events that your server already acknowledged with a 2xx response are not sent again.

1. Log in to the [Razorpay Dashboard](https://dashboard.razorpay.com/) and navigate to **Developers** → **Webhooks**.
2. Click **Replay events**.
3. On the **Replay type** step, select the **Date range** and choose one of the following:
   * **Unacknowledged events**: use this when you know roughly when your endpoint was down but not which events you missed.
   * **Specific events**: use this when you already know the entity IDs, such as payment or order IDs. Select the entity and enter the IDs.
4. On the **Select URLs** step, select the webhook URLs that should receive the replayed events.
5. On the **Select events** step, clear any events you do not want to trigger.
6. Click **Replay events**.

Keep the following in mind:

* If any of the webhook URLs you select is disabled, it is enabled automatically when you replay the events.
* Replayed events are sent exactly as they were originally generated and are signed with your current webhook secret. Replay does not create new payments, orders or any other records.
* A replayed event is a re-delivery of the original event. If your endpoint did process the original event, the replay is a duplicate, so your endpoint must be idempotent.
* There are limits on how old an event can be and how many replays you can trigger. Check them in [Replay Webhook Events](https://razorpay.com/docs/webhooks/replay-events.md#before-you-begin) before you start.

If the webhook was disabled during the outage and you are not replaying events, fix the errors at your end, enable the webhook from the Dashboard and fetch every order from the outage window. Know more about [enabling a webhook](https://razorpay.com/docs/webhooks/setup-edit-payments.md).

## What to give Support

Try the fetch APIs and the Dashboard replay first. If you still need Razorpay to replay a webhook event, raise a request:

1. Log in to your Dashboard.
2. Click **Help** → **Have a query?** → **Technical Support** → **Issue regarding Webhooks/API**.
3. Share details of the event you want to replay and click **Submit**.

Before you raise the request, look up the delivery in the webhook log. On the Dashboard, navigate to **Developers** → **Webhooks** and select the webhook. The log details view shows the webhook events delivered, along with the request and response headers for each delivery attempt.

If you receive a `refund.failed` event, do not re-attempt the refund automatically. Alert your operations team and contact [Razorpay Support](https://razorpay.com/support/).

## Related Information

* [Webhooks and Fetch APIs](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/test-s2s/best-practices/webhooks-and-fetch-apis.md)
* [Payment States and Late Authorisation](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/test-s2s/best-practices/payment-states-and-late-authorisation.md)
* [Retries and Idempotency](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/test-s2s/best-practices/retries-and-idempotency.md)
* [Standard Checkout Integration Guide](https://razorpay.com/docs/developer-tools/integrations/standard-checkout)
* [Webhook Best Practices](https://razorpay.com/docs/webhooks/best-practices.md)
* [Validate and Test Webhooks](https://razorpay.com/docs/webhooks/validate-test.md)
* [Replay Webhook Events](https://razorpay.com/docs/webhooks/replay-events.md)
* [Handle Late Payment Authorisations](https://razorpay.com/docs/payments/payments/late-authorisation/handle.md)
