Does anyone have code showing them subscribing to a webhook api using the new cli framework. This is what I have so far, but when I make an order I do not see the code run.
in web/index.ts
app.post(
shopify.config.webhooks.path + ‘/orders’,
shopify.processWebhooks({ webhookHandlers: OrderWebhookHandlers as any })
);
this is what OrderWebhookHandlers is defined as
ORDERS_CREATE: {
deliveryMethod: DeliveryMethod.Http,
callbackUrl: “/api/webhooks”,
callback: async (topic, shop, body, webhookId) => {
const payload = JSON.parse(body);
console.log(‘order create ran’);
// Payload has the following shape:
},
}
this is the path
shopify.config.webhooks.path = /api/webhooks
So all you need to do is just use
shopify.processWebhooks({ webhookHandlers }) and make webhook handlers have this kind of structure.
ORDER_CREATE: {
deliveryMethod: DeliveryMethod.Http,
callbackUrl: shopify.config.webhooks.path,
callback: async (topic, shop, body, webhookId, apiVersion) => {
const payload = JSON.parse(body);
// remove shop data
},
},
I am having issues with the webhook ngrok matching the app ngrok in dev still though
have you found any solution for this? Please let me know @RBTriesHisBest
Neither ORDERS_CREATE or ORDER_CREATE works.
Where did you find this? How did you know it was ORDER_CREATE not ORDERS_CREATE. Is there a list of webhooks to subscribe to in that casing besides the one below? That url says orders/create.
https://shopify.dev/docs/api/admin-rest/2023-04/resources/webhook
1 Like