Webhooks (Web Callback, HTTP Push API or Reverse API) is one way one web application can send information to another application in real-time when a specific event happens.
Example Suppose you have subscribed to the order.paid webhook event, you will receive a notification every time a user pays you for an order.
APIs send you the data when you request it. For Webhooks, you do not need to make a request. You receive the data when it is available.
Example If you need to know whether a payment link is paid or not, using APIs, you need to keep polling every few seconds until someone pays. However, if you are using Webhooks, you can configure a webhook event payment_link.paid to receive notifications when a customer makes the payment using the link.
You can use Razorpay Webhooks to configure and receive notifications when a specific event occurs.
When one of these events is triggered, we send an HTTP POST payload in JSON to the webhook's configured URL.
You can set up Webhooks from your Razorpay Dashboard and configure separate URLs for Live mode and Test mode. Know more about setting up Payments webhooks and RazorpayX webhooks.
A Test mode webhook receives events for your test transactions. Know more about testing Webhooks.
In webhook URLs, only port numbers 80 and 443 are currently allowed.
Currently, webhooks are available for the following events:
payment.authorized
Sent when the authorization payment has been made for the subscription. A nominal amount is charged to validate the card details and is then automatically refunded.
payment.failed
Sent when the payment attempt for a subscription fails.
subscription.cancelled
Sent when a subscription is cancelled and moved to the cancelled state.
subscription.paused
Sent when a subscription is paused/suspended and moved to the on-hold state.
subscription.resumed
Sent when a subscription is resumed/reactivated and moved to the active state.
Note:
The payload for all these events would contain the subscription entity. They would also contain a payment entity if a payment attempt was made before the event was triggered.