如何添加 Shopify webhook 并使其正常工作
How to add Shopify webhook and make it works
我通过 运行 shopify generate webhook
在我的应用程序中生成了新的 webhook。之后我看到这个代码被创建
config.webhooks = [
{topic: 'checkouts/create', address: 'https://66562fbc5033.ngrok.io/webhooks/checkouts/create', format: 'json'},
{topic: 'carts/update', address: 'https://66562fbc5033.ngrok.io/webhooks/carts/update', format: 'json'},
{topic: 'carts/update', address: 'https://66562fbc5033.ngrok.io/webhooks/carts/create', format: 'json'},
{topic: 'app/uninstalled', address: 'https://66562fbc5033.ngrok.io/webhooks/app/uninstalled', format: 'json'},
]
然后我转到我的商店并从设置 -> 通知 -> 创建新的 webhook 添加新的 webhook
不过好像不行
这是控制器
class HomeController < AuthenticatedController
def index
@products = ShopifyAPI::Product.find(:all, params: { limit: 10 })
@webhooks = ShopifyAPI::Webhook.find(:all)
end
end
这是模板文件
<h2>Webhooks</h2>
<% if @webhooks.present? %>
<ul>
<% @webhooks.each do |webhook| %>
<li><%= webhook.topic %> : <%= webhook.address %></li>
<% end %>
</ul>
<% else %>
<p>This app has not created any webhooks for this Shop. Add webhooks to your ShopifyApp initializer if you need webhooks</p>
<% end %>
这是我的应用程序中显示的内容
那我错过了什么?任何帮助!
我通过 运行 shopify generate webhook
在我的应用程序中生成了新的 webhook。之后我看到这个代码被创建
config.webhooks = [
{topic: 'checkouts/create', address: 'https://66562fbc5033.ngrok.io/webhooks/checkouts/create', format: 'json'},
{topic: 'carts/update', address: 'https://66562fbc5033.ngrok.io/webhooks/carts/update', format: 'json'},
{topic: 'carts/update', address: 'https://66562fbc5033.ngrok.io/webhooks/carts/create', format: 'json'},
{topic: 'app/uninstalled', address: 'https://66562fbc5033.ngrok.io/webhooks/app/uninstalled', format: 'json'},
]
然后我转到我的商店并从设置 -> 通知 -> 创建新的 webhook 添加新的 webhook 不过好像不行
这是控制器
class HomeController < AuthenticatedController
def index
@products = ShopifyAPI::Product.find(:all, params: { limit: 10 })
@webhooks = ShopifyAPI::Webhook.find(:all)
end
end
这是模板文件
<h2>Webhooks</h2>
<% if @webhooks.present? %>
<ul>
<% @webhooks.each do |webhook| %>
<li><%= webhook.topic %> : <%= webhook.address %></li>
<% end %>
</ul>
<% else %>
<p>This app has not created any webhooks for this Shop. Add webhooks to your ShopifyApp initializer if you need webhooks</p>
<% end %>
这是我的应用程序中显示的内容
那我错过了什么?任何帮助!