Webhook ORDERS_PAID doesnt get send to google pub sub

Webhook ORDERS_PAID doesnt get send to google pub sub

m3_
Shopify Partner
4 0 1

Hello everyone,

this is my first post here. I hope I grabbed the right topic (:

 

In our shopify app the user connects his store to our systems. Once this succeeds, I create a webhook for the topic "ORDERS_PAID" using the graphQl mutation provided in the docs (https://shopify.dev/apps/webhooks/configuration/google-cloud)

After doing so, I double checked and the webhook is correctly registered (graphql show all webhooks endpoint).

Of course I also took care of the steps prior (configuring the pub/sub and app)

 

But I never receive any webhook when changing an orders state to "PAID".

I've tried to fire a manual webhook using shopify CLI which works perfectly fine (I receive the webhook)

 

And the biggest question: It worked just fine a few months ago (We needed to rearrange our priorities and stop working on the app for a bit). Just now when we picked up work again, the delivery is broken.

 

In the partners dashboard I dont see any webhook errors nor any attempts ("No webhook deliveries were found")

Also in google pub/sub console I dont see any message. So most certainly the webhook never gets fired, right?

 

Would be great if anyone could help me out (:

Replies 4 (4)

m3_
Shopify Partner
4 0 1

Small bump

ShopifyDevSup
Shopify Staff
1451 238 497

Hey @m3_ ,

Using the docs and CLI steps for testing webhooks in our dev store environment, we were able to trigger several webhooks setup for both HTTPS and Pub/Sub. 

Have you already tested other webhook subscriptions (ORDERS_CREATE, ORDERS_UPDATED, more here) to confirm if other subscriptions/topics configured are workings as expected? 
 

  1. If no, use the app to create additional subscriptions to rule out any potential app or configuration issues. (If yes, skip)
  2. Once configured, try creating and mutating a few orders to simulate, then confirm if you are receiving payloads for topic corresponding orders events (created, updated, etc).
  3. If any of these are successful, try deleting and creating a new ORDERS_PAID subscription to test again.
  4. If no, I would suggest confirming that Pub/Sub is setup correctly before working through our guide again.


If only the orders/paid topic isn't triggering, you are welcome to share along any unique and affected topic webhookSubscription.ids, along with examples of order.id and timeframes (UTC) that would have triggered those webhooks. We can take a closer look for logs, and pass on any findings, insights or next steps. 

-  Best!

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

m3_
Shopify Partner
4 0 1

 

Hi @ShopifyDevSup thanks for taking care.

For me the CLI webhooks work as well. Webhooks that I trigger via the CLI are sent correctly to my backend.
Also messages from the Google Pub/Sub cloud console directly reach my backend correctly.

So the app configuration as well as the pub/sub integration in my backend seems correct.


I followed your steps regarding the troubleshooting

1. I've created a second Webhook for "ORDERS_CREATE" which doesn't get fired as well.
2. I've deleted all web hooks and tried again which changed nothing in behavior (Still doesn't work)
3. I double and triple checked the pub sub integration variables in the mutation (topic and project)

4. In the partner dashboard of my app, no webhooks are shown to me. Neither failed nor successful ones. (No webhook was ever sent?).

This is how I subscribe to a webhook:

 

export async function subscribeToAWebhook(session) {
    const client = new Shopify.Clients.Graphql(session.shop, session.accessToken);
    const project = xxxxx;
    const topic = xxxxx;

    try {
        await client.query({
            data: {
                query: SUBSCRIBE_WEBHOOK_MUTATION,
                variables: {
                    "topic": "ORDERS_PAID",
                    "webhookSubscription": {
                        "format": "JSON",
                        "pubSubProject": project,
                        "pubSubTopic": topic
                    }
                },
            },
        });
        console.log("webhook placed");
    } catch (error) {
        console.error(error);
        if (error instanceof ShopifyErrors.GraphqlQueryError) {
            throw new Error(`${error.message}\n${JSON.stringify(error.response, null, 2)}`);
        } else {
            throw error;
        }
    }
}

 

 

Response calling "show all web hooks" endpoint:

 

{"body":{"data":{"webhookSubscriptions":{"edges":[{"node":{"id":"gid://shopify/WebhookSubscription/1249155645686","topic":"APP_UNINSTALLED","endpoint":{"__typename":"WebhookHttpEndpoint","callbackUrl":"https://6b33-2a04-4540-7312-c000-4508-8e19-103c-3759.eu.ngrok.io/api/webhooks"}}},{"node":{"id":"gid://shopify/WebhookSubscription/1250042380534","topic":"ORDERS_CREATE","endpoint":{"__typename":"WebhookPubSubEndpoint","pubSubProject":"xxxxxxx","pubSubTopic":"brandsky"}}},{"node":{"id":"gid://shopify/WebhookSubscription/1250042937590","topic":"ORDERS_PAID","endpoint":{"__typename":"WebhookPubSubEndpoint","pubSubProject":"xxxxxxx,"pubSubTopic":"brandsky"}}}]}},"extensions":{"cost":{"requestedQueryCost":22,"actualQueryCost":8,"throttleStatus":{"maximumAvailable":1000,"currentlyAvailable":992,"restoreRate":50}}}},"headers":{}}

 

Id of currently active ORDERS_PAID web hook: gid://shopify/WebhookSubscription/1250042937590

Sample order which hasn't triggered a web hook (Most recent):
Id: 5084057862390
GraphQl Id: gid:\/\/shopify\/Order\/5084057862390
created_at: 2023-01-05T07:37:54+01:00

Configuration in google cloud console:
projects/XXXXX/topics/brandsky 

Thank your for taking care.

PS: Here is a picture (in German) of the Shopify partners dashboard (Webhook section) which shows no data at all

Click to expand...
webhooks in partner dashboardwebhooks in partner dashboard

 

ShopifyDevSup
Shopify Staff
1451 238 497

Hey @m3_ - thanks for the extra context. We do know that sometimes lacking proper app scopes can cause webhooks to be blocked. We've seen some similar issues pop up related to apps not having proper access scopes to access protected customer data (which includes when customer information is surfaced orders.). 

 

I was able to take a look at our logs and it seems like this could be the reason why the webhook was blocked. My recommendation here would be to confirm that your app has access to protected customer data (info on how to get access here).

 

If your app should already have access or the restrictions don't apply (for example, your app is a custom app), just reply back here and we'd be happy to investigate further with you. If you do reply back - could you confirm what version of the webhooks API you're using? 

Hope this helps - let us know if we can clarify anything for you!

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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