Reputation: 650
I am trying to setup Razorpay Webhook in rails. Have done other developments in rails but pricing is new to me. i already setup and tested Webhook in razorpay dashboard and used requestbin.com to get the payload results(JSON) as mentioned in this doc https://razorpay.com/docs/webhooks/
Now, should i create a new POST route and capture the payload results(JSON) in controller and update the database accordingly?! Or is there any other way for handling Webhooks in Rails?
If it is so simple like above what is this gem https://github.com/razorpay/razorpay-ruby used for?
Upvotes: 0
Views: 871
Reputation: 17834
Handling Webhooks require 3 things,
POST
endpoint in your applicationRazorpay
dashboardAfter doing this, you can handle the callback in your own way according to the requirement. Preferebly Webhook callbacks params should be moved to a background service and return 204
request everytime.
Hope that helps!
Upvotes: 1
Reputation: 26
https://github.com/razorpay/razorpay-ruby is simply a ruby wrapper razorpay provides for all create/fetch methods.
In razorpay you can set up a web hook by first creating a handler path on your controller and expose it to them. You can add this route on their web hooks/add under settings on your razorpay merchant dashboard.
To make this callback more secure, razorpay allows you to setup a web hook signature from the dashboard and the above mentioned gem has a wrapper method that helps you verify the signature as well.
Upvotes: 1