【问题标题】:shopify uninstall app webhook is not workingshopify 卸载应用程序 webhook 不起作用
【发布时间】:2021-04-19 11:13:32
【问题描述】:

在我的 server.js 文件中,我在 afterAuth 函数中注册了应用程序/卸载的 webhook,如下所示:

const response = await Shopify.Webhooks.Registry.register({
      shop,
      accessToken,
      path: "/webhooks",
      topic: "APP_UNINSTALLED",
      apiVersion: ApiVersion.October20,
      webhookHandler: (topic, shop, body) => {
        //console.log(topic, shop,body);
        delete ACTIVE_SHOPIFY_SHOPS[shop];
      },
    });

我正在听这样的路线

router.post("/webhooks", appUninstallWebhook, async (ctx) => {
try {
  await Shopify.Webhooks.Registry.process(ctx.req, ctx.res);
  console.log(`Webhook processed, returned status code 200`);
} catch (error) {
  console.log(`Failed to process webhook: ${error}`);
}

});

我看到 webhook 已成功注册,但是当我在我的测试 Shopify 商店中删除在 ngrok 上本地运行的应用程序时,我没有看到该 webhook 被触发。

任何帮助都会非常有帮助。

【问题讨论】:

  • 你好,伙计!你过了这一关吗?我被困在完全相同的事情上
  • @DanTurner 不。您可以使用这种方法。这有效 const response = await registerWebhook({ shop, accessToken, address: ${HOST}/webhooks/app/uninstalled, topic: "APP_UNINSTALLED", apiVersion: API_VERSION });然后配置路由 router.post("/webhooks/app/uninstalled", webhook, async (ctx) => { try { console.log(Webhook processed, returned status code 200); } catch (error) { console.log(@987654325 @); } });

标签: node.js reactjs shopify webhooks


【解决方案1】:

不幸的是,我无法让它工作,但我使用另一种方法找到了解决方法。

const response = await registerWebhook({
  shop,
  accessToken,
  address: `${HOST}/webhooks/app/uninstalled`,
  topic: "APP_UNINSTALLED",
  apiVersion: API_VERSION
});

然后配置路由

router.post("/webhooks/app/uninstalled", webhook, async (ctx) => {
  try {
    console.log(`Webhook processed, returned status code 200`);
  } catch (error) {
    console.log(`Failed to process webhook: ${error}`);
  }
});

【讨论】:

  • registerWebhook 来自哪里?
猜你喜欢
  • 2018-07-08
  • 1970-01-01
  • 2014-05-04
  • 1970-01-01
  • 2015-05-08
  • 2018-08-15
  • 1970-01-01
  • 1970-01-01
  • 2019-04-15
相关资源
最近更新 更多