get duplicated webhook calls for Order Payment

maxwang
Tourist
7 0 2

Dear Sir/Madam,

 

I setup a webhook for Order Payment in my Shopify store. But I got duplicate webhook calls after I made a payment in my store. Can you give me some suggestion on how to fix it?

 

Thanks.

 

Regards,

Max

Replies 8 (8)

Zameer
Shopify Staff
297 31 90

Hey Max,

 

I can definitely have a look to see what's going on here.

 

Could you please provide me with either your shop name or the request id of one of the webhooks you received?

To learn more visit the Shopify Help Center or the Community Blog.

maxwang
Tourist
7 0 2

Hi Zameer,

 

My shop name is: addons.1080tech.com

or sjgr-4584-desa.myshopify.com

 

Thanks.

 

Max

 

 

Zameer
Shopify Staff
297 31 90

Hey Max,

 

I see that for the `orders/paid` topic we sent you 4 webhooks for Order Id 735346622564. 

 

The first 3 webhooks resulted in a `500 Internal Server Error` from your endpoint, which is why we continued to send them for the same order.

 

On the 4th attempt, we received a 200 OK response which is when the webhooks stopped being sent. As per our webhook documentation, Shopify retries sending the webhook up to 19 times until it receives a 200 OK response from the endpoint, or until the webhook is ultimately deleted. I would recommend ensuring your endpoint is able to return the appropriate 200 OK response to Shopify when it receives a webhook, to prevent any retries.

 

Aside from that, I don't see any other repeated webhook attempts over the past 3 days. 

To learn more visit the Shopify Help Center or the Community Blog.

maxwang
Tourist
7 0 2

Hi Zameer,

 

Thanks for supporting.

 

We did some testing yesterday. We got duplicate call almost at same time. I am still testing my code for 735346622564.

 

We got duplicate calls almost at same time. Please check order 734859198564, 734967791716. I got duplicate webhook calls. I monitor the reqeusts. It is not first call return something else than 200, then we got another call. These two webhook calls came in almost at same time.

 

Hope you cuold find more information. 

Regards,

Max

Zameer
Shopify Staff
297 31 90

Hey Max,

 

Could you please provide me with the `X-Request-Id` header of two duplicate webhooks?

 

All I'm seeing on our end is that there are 2 separate webhooks set up. One for 'orders/create' and one for 'orders/paid' both pointing to different callback URLs. So although you for each new paid order, both webhooks would fire, they would do so to different URLs with different topics and webhook id's.

 

If you are reporting that the same webhook subscription and topic is sending two webhooks, the request id's would allow me to dive deeper into the problem.

To learn more visit the Shopify Help Center or the Community Blog.

maxwang
Tourist
7 0 2

Hi Zameer,

I created a new call and tried to capture the request. But I did not find X-Request-Id. Please check web hook request header for two request:

 

POST /api/OrderPayment HTTP/1.1
Content-Type: application/json
X-Shopify-Topic: orders/paid
X-Shopify-Shop-Domain: sjgr-4584-desa.myshopify.com
X-Shopify-Order-Id: 741829640292
X-Shopify-Test: true
X-Shopify-Hmac-Sha256: Zl7Z7UlqUzy6ag4SEWTtSRirZnEWAXW1OYfqLZOzVXw=
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
User-Agent: Ruby
Content-Length: 3912
Connection: close
Host: 3f9ea21c.ngrok.io
X-Forwarded-Proto: https
X-Forwarded-For: 35.237.48.181

 

POST /api/OrderPayment HTTP/1.1
Content-Type: application/json
X-Shopify-Topic: orders/paid
X-Shopify-Shop-Domain: sjgr-4584-desa.myshopify.com
X-Shopify-Order-Id: 741829640292
X-Shopify-Test: true
X-Shopify-Hmac-Sha256: Zl7Z7UlqUzy6ag4SEWTtSRirZnEWAXW1OYfqLZOzVXw=
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
User-Agent: Ruby
Content-Length: 3912
Connection: close
Host: 3f9ea21c.ngrok.io
X-Forwarded-Proto: https
X-Forwarded-For: 35.237.23.232

 

And this time I got three calls. Please check attached gnrok request.

 

Thanks.


Regards,

Max

 

Zameer
Shopify Staff
297 31 90

Ah yes, I see the problem now.

 

Shopify expects a 200 OK response within 5 seconds of sending the webhook, and your webhook responses are timing out.

 

I'm assuming this is probably because you are doing your webhook processing before sending back the response. We recommend that you send back a 200 OK response to Shopify before doing any sort of processing on your end. 

 

Some partners accomplish this using threads, but the implementation is entirely up to you.

To learn more visit the Shopify Help Center or the Community Blog.

KieranG21
Visitor
1 0 0

Getting the same issue, im convinced i'm always returning 200 though, i'm getting duplicated rows in the database, is there something on the object i should be looking for? I am also using Order payments webhook.