Skip to main content
The plugin exposes a single webhook endpoint that receives event notifications from Razorpay. Configure this endpoint in the Razorpay Dashboard so Razorpay can send events such as payment.captured, order.paid, and subscription.activated.

Endpoint path

The webhook handler follows the plugin’s path convention under your Better Auth mount point:
Confirm the exact path in your server if requests return 404. You can inspect the plugin’s registered endpoints in your framework’s route logs or by listing Better Auth routes.

Headers

Razorpay sends the webhook signature in a request header:
string
required
HMAC-SHA256 hex digest of the raw request body, computed with your webhook secret.
The endpoint also relies on standard Content-Type: application/json headers from Razorpay.

Verification

The plugin verifies the signature using razorpayWebhookSecret from your plugin options. It computes an HMAC-SHA256 of the raw request body and compares it with the header value using a timing-safe comparison.
If verification fails, the endpoint returns an error without invoking your callbacks.

Responses and errors

Supported events

The plugin handles the following Razorpay events and routes each to its corresponding callback. All events also invoke the top-level onEvent handler if you provide one. Subscription webhooks update the local subscription table (status, period dates, counts) before your callbacks fire. See Webhook events for more detail on each event and payload shape.

Local testing

Because Razorpay can only deliver webhooks to a public HTTPS URL, use a tunnel for local development:
Set the Razorpay Dashboard webhook URL to the ngrok HTTPS address plus the endpoint path, for example https://abc123.ngrok.io/api/auth/razorpay/webhook. Choose the events you want to receive and set the same secret you use in razorpayWebhookSecret.

Example configuration