Test Webhooks
You can test the webhooks to verify payloads or check if your webhook integration is working. Test events get triggered on a transaction done in the Test mode. As the payload structure remains the same in the Live and Test modes, you can rely on your stage testing. You can test webhooks:- Using request interceptor tools
- On an application running on localhost
- On an application running on your staging environment
Using Request Interceptor Tools
There are many free webhook testing tools available online. However, please note that certain domains are blacklisted for security reasons and cannot be used for webhook URLs. To test webhooks:Choose a webhook testing service.
Create your endpoint.
Copy the endpoint created for you.
Proceed to set up webhooks, but with the following changes:
- Ensure you are using Test mode on the Dashboard.
- Paste the endpoint you copied in the previous step in the Website URL field.
Blacklisted Domains
For security reasons, the following domains are blacklisted and cannot be used as webhook URLs:-
burpcollaborator.net -
oast.pro -
interact.sh -
canarytokens.com -
requestbin.com -
webhook.site -
hookbin.com -
beeceptor.com -
mockbin.org -
ngrok.io -
loca.lt -
metadata.google.internal -
metadata.google.internal. -
localhost -
localhost.localdomain -
.onion -
.local -
.internal -
.corp
Application Running on Localhost
You cannot use localhost directly to receive webhook events as webhook delivery requires a public URL. Due to security restrictions, many common tunneling services are blacklisted. You can handle this by creating a tunnel to your localhost usingzrok. Know more about zrok.
Application Running on Your Staging Environment
You can test your webhook integration in the staging environment before taking it live. You should set up webhooks in the Test mode. You can configure your staging host endpoint in test mode and receive test events on it.754081 when prompted, while setting up, editing or deleting a webhook in test mode.
Validate Webhooks
When your webhooksecret is set, Razorpay uses it to create a hash signature with each payload. This hash signature is passed with each request under the X-Razorpay-Signature header that you need to validate at your end. We provide support for validating the signature in all of our language SDKs.
If you have changed your webhook secret, remember to use the old secret for webhook signature validation while retrying older requests. Using the new secret will lead to a signature mismatch.
X-Razorpay-Signature
: The hash signature is calculated using HMAC with SHA256 algorithm; with your webhook secret set as the key and the webhook request body as the message.
You can also validate the webhook signature yourself using a HMAC as shown below:
Idempotency
There could be scenarios where your endpoint might receive the same webhook event multiple times. This is an expected behaviour based on the webhook design. To handle duplicate webhook events:You can identify the duplicate webhooks using the `x-razorpay-event...
x-razorpay-event-id header. The value for this header is unique per event.Check the value of `x-razorpay-event-id` in the webhook request hea...
x-razorpay-event-id in the webhook request header.Verify if an event with the same header is processed at your end.
Order of Webhooks
Ideally, you should receive a webhook in the order in which the webhook events occur. However, you may not always receive the webhooks in the order.Example - Payments
For example, in the case of a payment, you should receive webhooks in the following order:payment.authorizedpayment.captured
Example - RazorpayX
Take payouts in RazorpayX as an example. For payouts, you should receive webhooks in the following order:`payout.pending` (if you have [Approval Workflow](/x/manage-teams/a...
payout.pending (if you have Approval Workflow enabled on your account)`payout.queued` (in case your [business account does not have suffi...
payout.queued (in case your business account does not have sufficient balance to process the payout)`payout.initiated`
payout.initiated`payout.processed` or `payout.reversed`
payout.processed or payout.reversedprocessed and reversed states are the last states for a payout. Their corresponding webhooks payout.processed or payout.reversed indicate this state change. Any webhook received after these should be ignored.