SilverWebBuzz

 Join Silver Webbuzz at GITEX Global 2023 – The Year to Imagine AI in Everything. Meet us.

Shopify WebHook

Shopify WebHook
Get in Touch With Us
Submitting the form below will ensure a prompt response from us.

    A Shopify Webhook is a way for Shopify to automatically notify your server when certain events happen in a store — like when an order is placed, a product is updated, or a customer account is created.

    Instead of constantly polling Shopify’s API to check if something new has happened, you set up a webhook, and Shopify pushes the information to your app or server as soon as the event occurs.

    Key Points:

    • Webhooks send an HTTP POST request to the URL you specify.
    • The request body contains data (in JSON format) related to the event.
    • You can create webhooks manually inside Shopify Admin or programmatically via Shopify’s API.
    • Shopify expects your server to quickly respond with a 200 OK status.
    • Shopify signs the webhook payload so you can verify it’s authentic.

    Example Events:

    • orders/create
    • products/update
    • customers/create
    • carts/update
    • app/uninstalled

    How to Create a Shopify Webhook (Simple Steps):

    1. From Shopify Admin:

    • Go to Settings > Notifications > Webhooks.
    • Click Create webhook.
    • Choose an event and format (usually JSON).
    • Enter the URL where Shopify should send the webhook.

    Using the Admin API (POST to /admin/api/2023-10/webhooks.json):

    json

    {
         “webhook”: {
              “topic”:       “orders/create”,
              “address”:  “https://yourserver.com/webhooks/orders-create”,
              “format”: “json”
         }
    }

    Webhook Security Tip:

    Shopify includes an HMAC header (X-Shopify-Hmac-Sha256) you should use to verify that the webhook really came from Shopify and not someone else.
    Here’s a quick Node.js example of verifying the webhook:

    javascript

    const crypto = require(‘crypto’);

    function verifyShopifyWebhook(req, secret) {
        const hmacHeader = req.headers[‘x-shopify-hmac-sha256’];
        const body = req.rawBody; // Make sure to use the RAW body
        const hash = crypto.createHmac(‘sha256’, secret).update(body, ‘utf8’).digest(‘base64’);
        return hash === hmacHeader;
    }

    About Author

    Bhavik Koradiya is the CEO / Co. Founder of Silver WebBuzz Pvt. Ltd. Having 18+ years Experience in LAMP technology. I have expert in Magento, Joomla, WordPress, Opencart, e-commerce and many other open source. Specialties: Magento, WordPress, OpenCart, Joomla, JQuery, Any Open source.

    Scroll to Top