Webhook subscription not working - NodeJS

Webhook subscription not working - NodeJS

NicoSpoke
Shopify Partner
23 0 9

Hello,

We have an app running in our store that we use to subscribe our webhooks to. We've managed to get all the webhooks to fire (this app has been running for the last 2 years) but our most recent webhook topics "customer/create" and "customer/update" are not firing. I'm not sure what we are doing wrong here since the same logic applies to all other webhook events which work totally fine. 

Do I need to do anything else to enable these 2 webhooks?

Thanks!

const webhooks = {
    'checkouts/create': '/webhook/checkout-started',
    'checkouts/update': '/webhook/checkout-updated',
    'orders/create': '/webhook/order-completed',
    'orders/fulfilled': '/webhook/order-fulfilled',
    'orders/cancelled': '/webhook/order-cancelled',
    'refunds/create': '/webhook/order-refunded',
    'customers/create': '/webhook/customer-created',
    'customers/update': '/webhook/customer-updated'
  }

  const requests = Object.keys(webhooks).map(topic => new Promise((resolve, reject) => {
    const path = webhooks[ topic ]

    const form = {
      webhook: {
        address: `${process.env.ORIGIN}${path}`,
        format: 'json',
        topic: topic
      }
    }

    console.log("Webhook created: ", path, topic)

    request.post({
      url: `https://${shop}.myshopify.com/admin/api/${process.env.API_VERSION}/webhooks.json`,
      headers: {
        'X-Shopify-Access-Token': accessToken
      },
      form
    }, (error, response, body) => {
      console.log('Resolving webhook: ', response.statusCode)
      if (response.statusCode === 201) {
        resolve()
      }

      reject({ response, form })
    })
  }))

  Promise.all(requests).then(resolve).catch(reject)

 

Building digital interfaces for Shopify Stores
Reply 1 (1)

awwdam
Shopify Staff
249 42 36

Hey @NicoSpoke, would you be able to provide us with a X-Shopify-Webhook-Id header from a functioning webhook that was set up using this same logic you shared? 

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog