When I run through checkout, I get up to 6 duplicate (with different version) order.updated / state=OPEN events through webhooks. How do I prevent this?
An order.updated
event will only trigger if the orders been updated. There are instances where multiple events will fire but they shouldn’t bee the same events. Do you have an example order_id
where multiple events fired?
Hey @Bryan-Square,
Sure. For example: kVnpsAnseCeHTxaz26YDutfEUfUZY
I should add that the checkout is quite slow. I’m generating a link with the code below (for my single item). In my tests, I’m applying a coupon and then checking out with Google Pay. Something about this causes 6 order.updated events to fire.
val items = client.catalogApi.searchCatalogObjects(
SearchCatalogObjectsRequest.Builder()
.objectTypes(listOf("ITEM"))
.build())
val item = items.objects.first()
val lineItem = OrderLineItem.Builder("1")
.catalogObjectId(item.itemData.variations.first().id)
.build()
val link = checkoutApi.createPaymentLink(
CreatePaymentLinkRequest.Builder()
.order(Order.Builder(configuration.square.location)
.lineItems(listOf(lineItem)).build())
.prePopulatedData(PrePopulatedData(email, null, null))
.build()
)
return link.paymentLink
This is the expected behavior. Currently the entire order isn’t returned in the webhook event. Each version of the order will have some difference from the previous version. Since all the events that you got have a unique version this means that there not duplicates but unique versions of the order.
I don’t get it. Can you explain further? Each is identical except for the version.
Why are 6 versions generated?
That’s correct, each is the same except the version of the webhook. If your application calls RetrieveOrder with the order_id
to get the entire order object for each version you’ll see the fields that have updated.
Can you help me understand why this happens though? It seems weird to send 6 events saying “order is open”.
Is there a better webhook to listen to in order to kick off order fulfillment?
The order items, totals, taxes, discounts, and fees are being calculated or updated which are triggering events. We give a response when an order is created as fast as possible but there are some asynchronous calculations that happen on our servers that update an order which in turn triggers update events. This is why your seeing multiple order.updated
events.