Shopify_app: Webhooks not being generated in client shops

Created on 10 Jun 2016  路  15Comments  路  Source: Shopify/shopify_app

I hope I am not misunderstanding the documentation but after running the following rails command I thought that when a new OAuth session was created the gem would ensure the webhook exists in the clients shop. It seems like the proper line is added to the config/initializers/shopify_app.rb but the webhook is not created on install of the app.

Rails generator code:
shopify_app:add_webhook -t orders/create -a \ http://moedesigns.dyndns.org:3000/webhooks/orders_create

config/initializers/shopify_app.rb code:

  config.webhooks = [
    {topic: 'orders/create', address: 'http://xxxxx.dyndns.org:3000/webhooks/orders_create', format: 'json'},
  ]

Am I wrong to think that the webhook should be automatically generated on the client shop when the app is installed or once the OAuth handshake is complete?

Most helpful comment

The admin endpoint in the browser will only show webhooks that belong to the shop. If you want to see the webhooks that belong to your API Client you need to make an API call to fetch them.

The quickest way to do this to update the example controller that is generated to fetch webhooks instead of products.

All 15 comments

you are reading the docs correctly.

How are you checking that the webhook exists?

@kevinhughes27, I simply visit /admin/webhooks.json to see if they are there. They json object returned is empty:

{
"webhooks": []
}

Also, I setup a few test ones using http://requestb.in and none of the webhooks ever fire. However, if I manually setup the webhook in the shops admin then I do see them fire so I know I am looking for the request properly.

The webhooks admin won't show webhooks created by api clients since its filtered by owner. In that context the shop is the owner not your app. Try querying the webhooks api endpoint with your api client credentials.

Kevin,

I was wondering about that and thought it was the case. After uninstalling my app and re-installing it seems like the webhooks are being created and showing up now. Thanks for the prompt reply and correct answer!

Kevin, I'm a newbie at this, could you please give a code example of how one would check if the webhook has been created. I tried pasting this into the browser: "https://<..api_key..>:<..secret..>@<..shop_name..>.myshopify.com/admin/webhooks.json" and it still getting "{"webhooks":[]}" even after following your tutorial here https://www.youtube.com/watch?v=uYueG-MsMRk almost verbatim. The only difference was that I created orders/create instead of carts/update. Thanks fo your help

The admin endpoint in the browser will only show webhooks that belong to the shop. If you want to see the webhooks that belong to your API Client you need to make an API call to fetch them.

The quickest way to do this to update the example controller that is generated to fetch webhooks instead of products.

Thank you so much, Kevin! For other newbies like me who follow Kevin's webhooks tutorial, here is the the line to add to the Home Controller (index action):
@webhooks = ShopifyAPI::Webhook.find(:all, :params => {:limit => 10})

And then modify the view to display the webhooks:

<h2>Webhooks</h2>

<ul>
  <% @webhooks.each do |webhook| %>
   <li><%= link_to webhook.id, "https://#{@shop_session.url}/admin/webhooks/#{webhook.id}", target: "_top" %>
  <% end %>
</ul>

Hi! I'm trying to setup a webhook at the config/initializers/shopify_app.rb file, and I'm getting this error:

/config/initializers/shopify_app.rb:9:in block in <top (required)>': undefined methodwebhooks=' for #

I'm using gem shopify_api 6.2.0, do you know what's going on with the webhook?

Thanks!

You need to use a newer version of Shopify App to use the webhooks setting

Thank you very much @kevinhughes27 for your response!
I've updated the shopify_app to 7.0.2, and now I'm getting this error:

uninitialized constant AuthenticatedController

What do I have to change?

Thanks!!

All the controllers moved into the ShopifyApp:: namespace

Thank you very much again @kevinhughes27, you are awesome!!

@kevinhuges27 I've my shopify_app.rb set with the config.webhooks topic, address and format. After installation, when I check the Webhook.all I don't see any Webhook registered. How do I see if there were any errors thrown during installation?

I'd place a debugger in the register code to try and see what is happening. I thought we had logging but maybe not (please add if it is missing). My other guess is that the webhooks are being created in the background but you are not running the worker locally meaning the job is queues but never gets ran.

I had the same problem, to fix that I stopped spring, started my local rails server again (rails s) and installed the app on my story again. After that I got my webhooks working.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arialblack14 picture arialblack14  路  5Comments

orenmazor picture orenmazor  路  9Comments

jagthedrummer picture jagthedrummer  路  10Comments

matias-eduardo picture matias-eduardo  路  6Comments

MisinformedDNA picture MisinformedDNA  路  6Comments