App reviews, troubleshooting, and recommendations
this is my OrderWebhookHandlers.js
import { DeliveryMethod } from "@shopify/shopify-api";
export default {
ORDERS_CREATE: {
deliveryMethod: DeliveryMethod.Http,
callbackUrl: "/api/webhooks",
callback: async (topic, shop, body, webhookId) => {
const payload = JSON.parse(body);
},
},
};
and this is my index.js
import GDPRWebhookHandlers from "./gdpr.js";
import OrderWebhookHandlers from "./OrderWebhookHandlers.js";
app.post(
shopify.config.webhooks.path,
shopify.processWebhooks({ webhookHandlers: GDPRWebhookHandlers }),
);
app.post(
shopify.config.webhooks.path,
shopify.api.webhooks.register({ webhookHandlers: OrderWebhookHandlers})
);
the ORDERS_CREATE is not registering. what am I doing wrong? any solution?
Hi,
If I'm not sure about the steps that you are giving... but I'll tell you what works for me:
I've added my Webhook definition inside the GDPRWebhookHandlers (for now, is not the most elegant but works)
When the server start, the processWebhooks will add all the webhook handlers to the library registry; but it will not register them with Shopify.
This is done when the method register is called. And this is done by:
app.get(shopify.config.auth.callbackPath, shopify.auth.callback(),shopify.redirectToShopifyOrAppRoot() );
The last you need is to force this callback. The easy way is to edit the configuration of the scopes in the shipify.app.toml file and restart the server. This will force the re-auth in the admin and will call the callback path.
I hope this helps you!
Cheers!
Hi, did you find a solution, I'm using the same official boilertemplate as you and it doesn't register this webhook.
Ty
There was a similarish post I found and answered there.
There is an "official" way to register webhooks after installation.
https://github.com/Shopify/shopify-api-js/blob/main/docs/guides/webhooks.md
The docs changed here is the new webhooks link
https://github.com/Shopify/shopify-api-js/blob/main/packages/shopify-api/docs/guides/webhooks.md
Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024