Hi there, I’m a new developer to Square and have been navigating my way through setting my customers app up thanks to the excellent documentation provided (thanks!). However I’ve run into an issue that I’m not able to identify the cause of.
We appear to be getting two activations of the order.created webhook event for each order that is made (about 3 milliseconds apart). I’ve reviewed past posts on the topic and ensured that we have only a single webhook subscription and that I’m replying with a 200 code quickly (now, I had even more duplicates before because it wasn’t prompt enough) which seem to have been the issue for others. I was wondering if there was anything else I’ve overlooked that could be causing this issue that I can address?
You’ve covered everything that would be causing the duplicates. Do you have an example order that sent two events and what’s your application ID?
Sorry for taking so long to get back to this.
My application ID is: sq0idp-c39kXP62R8R0FHmbFFFpPQ
An example order that sent two webhook activations is: cyow1VMe5jBEhVZMw7z7Xte2zE6YY
This isn’t unexpected. Webhooks may be sent more than once. We recommend that you respond with a 2xx HTTP status code to Square as soon as possible to acknowledge the receipt of the event notification. If your application fails to acknowledge in a timely manner, a duplicated event will be sent that your application has 10 seconds to respond to.
In this particular case I received the second webhook only 4.5 seconds after the first was received which is well within the time I should have to respond. I have a reasonable expectation that the first webhook was responded to was handled within the 10 seconds I have to respond since the first thing my program does is send that acknowledgement before processing and my entire processing time for that order to be handled was under 13 seconds.
Another example order where I received the second webhook about 5 seconds after the first is: mtnWbJqmvzc3G4CAvaaSXTxrANOZY
For that one my entire processing time was under 9 seconds so that would definitely have replied in under 10 seconds.
According to the team this is the expected behavior and duplicate webhooks are expected.