Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Not able to add webhook on the Heroku

Not able to add webhook on the Heroku

jigar_narola
Shopify Partner
2 0 0

Hello,

I am a developer of ruby app with rails framework. I am using shopify_app gem for developing app with shopify.

Gem link: https://github.com/Shopify/shopify_app

I am able to add a webhook in my local using following command: 

rails g shopify_app:add_webhook -t carts/update -a https://example.com/webhooks/carts_update

but I need to deploy the code on the Heroku also and I need webhook on Heroku also. So, How can I add and use webhook for Heroku?

Reply 1 (1)

hassain
Shopify Staff (Retired)
624 104 189

Hey @jigar_narola .

 

I am not sure if I follow your question. Are you asking how do you write code in your Ruby app (that is using the shopify_app gem) to generate and register a Shopify webhook? Or are you asking how to write code that will listen to Shopify webhook notifications and parse the payload?

 

If it's the former, you should be able to do this quite simply with code like this:

new_webhook = ShopifyAPI::Webhook.new({
   topic: "orders/create",
   address: "http://www.example.com/webhook", # substitute url with your endpoint
   format: "json"
})

new_webhook.save

If its the latter, there are helpful guides to follow:
https://medium.com/@kei178/how-to-use-shopify-webhooks-in-rails-78c252a50a1b

https://medium.com/@scottdixon/verifying-shopify-webhooks-with-nodejs-express-ac7845c9e40a

 

To learn more visit the Shopify Help Center or the Community Blog.