Shopify / koa-shopify-auth

DEPRECATED Middleware to authenticate a Koa application with Shopify
MIT License
80 stars 63 forks source link

Can't create webhook for SUBSCRIPTION_CONTRACTS_CREATE topic #87

Closed nimirium closed 3 years ago

nimirium commented 3 years ago

Issue summary

I'm building a custom shopify app, where I register a webhook for SUBSCRIPTION_CONTRACTS_CREATE and SUBSCRIPTION_CONTRACTS_UPDATE topic.

Expected behavior

I expect the webhook to be registered successfully, like when I register PRODUCTS_CREATEtopic.

Actual behavior

The webhook isn't registered, and I get this traceback:

(node:53083) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'webhookSubscriptions' of null
    at Object.<anonymous> (/Users/sophie/Projects/shopify-app/node_modules/@shopify/shopify-api/dist/webhooks/registry.js:92:44)
    at step (/Users/sophie/Projects/shopify-app/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:143:27)
    at Object.next (/Users/sophie/Projects/shopify-app/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:124:57)
    at fulfilled (/Users/sophie/Projects/shopify-app/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:114:62)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Steps to reproduce the problem

  1. use koa-shopify-auth version 4.1.2
  2. Add this code to your custom/public shopify app afterAuth:
            Shopify.Webhooks.Registry.register({
                shop,
                accessToken,
                path: '/webhooks',
                topic: 'SUBSCRIPTION_CONTRACTS_CREATE',
                apiVersion: ApiVersion.April21,  // I also tried '2021-07' and ApiVersion.January21
                webhookHandler: (_topic, shop, _body) => { console.log('Subscription Contract was created!'); }
            });
nimirium commented 3 years ago

wrong library, please excuse me