Confirm Webhooks Execution with code provided by Shopify CLI boilerplate

Confirm Webhooks Execution with code provided by Shopify CLI boilerplate

luistmartins
Shopify Partner
21 2 2

I'm trying to extend the code provided by the Shopify CLI for app creation and able to get webhook notifications from Shopify. I believe we are supposed to send a success code response back to Shopify for these events to be completed, but I'm not following how to do this with this approach.

 

The setup starts with registering the POST endpoint for webhooks as

app.post(shopify.config.webhooks.path, shopify.processWebhooks({ webhookHandlers: GDPRWebhookHandlers }));

The GDPRWebhookHandlers is an object containing all the topics you want to subscribe to, with each object key having the following shape:

 

 

 

  ORDERS_EDITED: {
    deliveryMethod: DeliveryMethod.Http,
    callbackUrl: '/api/webhooks',
    callback: async (topic, shop, body, webhookId) => {
      const payload = JSON.parse(body);
      console.log('ORDERS_EDITED', payload);
    },
  },

 

 

 

What's unclear to me is how do you send a success confirmation back to Shopify.  Looks like we don't have the res method available to us inside this callback function so I'm a little confused.

 

Any pointer would be much appreciated.

Reply 1 (1)

luistmartins
Shopify Partner
21 2 2

Okay, I think I can answer my own question here. It looks like that the logic provided by @Shopify/shopify-app-express is handling that response automatically, so no need to do it from the callback function.