how to register orders create webhooks to new shopify cli app

how to register orders create webhooks to new shopify cli app

SADIK112
Shopify Partner
14 0 3

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?

Replies 3 (3)

PauR
Shopify Partner
6 0 3

Hi, did you find a solution, I'm using the same official boilertemplate as you and it doesn't register this webhook.

 

Ty

btrain-004
Shopify Partner
12 0 3

There was a similarish post I found and answered there.

https://community.shopify.com/c/shopify-apps/create-webhook-with-new-shopify-cli/m-p/2124324/highlig...

 

There is an "official" way to register webhooks after installation.

 

https://github.com/Shopify/shopify-api-js/blob/main/docs/guides/webhooks.md

btrain-004
Shopify Partner
12 0 3