-
Notifications
You must be signed in to change notification settings - Fork 59
Webhooks
Nemo edited this page Jul 31, 2017
·
3 revisions
You can verify Razorpay webhooks with the following code:
Razorpay::Utility.verify_webhook_signature(webhook_body, webhook_signature, webhook_secret)
This will throw a SecurityError
exception if the signature is invalid. The parameters are as follows:
-
webhook_body
: The complete webhook body. You can userequest.raw_post
in Rails,req.body.read
in Rack, orrequest.body.read
in Sinatra. Please consult your framework's documentation for the equivalent. -
webhook_signature
: We send the webhook signature in a request header with the keyX-Razorpay-Signature
. You can read the header usingrequest.headers["X-Razorpay-Signature"]
in Rails,env["HTTP_X_RAZORPAY_SIGNATURE"]
in Rack, orrequest.env["HTTP_X-Razorpay-Signature"]
in Sinatra. -
webhook_secret
: The secret you set at the time of setting up the webhook.
You can parse the webhook after it has been validated by using JSON.parse webhook_body
.
Please see the Razorpay Webhooks Documentation for more details.