Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Webhook subscription not working - NodeJS

Webhook subscription not working - NodeJS

NicoSpoke
Shopify Partner
23 0 17

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 38

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