MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
941 stars 278 forks source link

Webhook API Version #615

Closed conspireagency closed 12 months ago

conspireagency commented 1 year ago

Perhaps this is a documentation thing, but I was a little confused in trying to set the API version for webhooks created using this library. The code below works for creating webhooks. In the Shopify rest reference params for webhooks POST create are "api_version" versus the params that shopify-api-node expects are the body of the webhook to be created not the params for the Shopify rest endpoint. This being said, wasn't sure how to set the API version for the webhooks I was creating. Figured it might use the version of the Shopify instance being created, but it actually seems to default to 2021-10.

const shopify = new Shopify({
        shopName: shop.shop,
        accessToken: shop.access_token,
        apiVersion: process.env.SHOPIFY_API_VERSION,
        autoLimit: true,
      });

      const response = await shopify.webhook.create({
        topic: topic,
        address: address,
        format: 'json',
      });
lpinca commented 1 year ago

Yes, the API version can be specified in the constructor. If it is not set, the oldest supported one is used.

lpinca commented 12 months ago

I'm closing this as answered.