Pickup details in several waves
An order's pickup details can arrive in more than one wave, minutes apart. Every wave that fills a detail the order did not have sends its own order.updated.
What changed
- More than one
order.updated. The first wave keeps its id,evt_7c21e4b9a0d3_updated. Later waves areevt_7c21e4b9a0d3_updated_2,evt_7c21e4b9a0d3_updated_3and so on, so de-duplicating onevent_idkeeps every one, andGET /v1/events?after=with one of them resumes right after that wave. Each one carriesorder.ready_etaandorder.fulfillmentas the order read when it was written. See More than one order.updated. - The pickup time, when the store gives one.
ready_etacan be null when the order isplacedand fill in later, with anorder.updated. When the store never states a time it stays null. Show it word for word; it is not a timestamp. See Pickup time. test_place_pickup_later. A sandbox test restaurant at 12 Sandbox Way. Its order is placed with no pickup details. About 5 seconds later the name, the order number and the instructions arrive withorder.updated, and about 10 seconds after placement the pickup time arrives with a second one. See Sandbox.- Read the type.
fulfillment.typesays how the person gets the order. Read it rather than assuming pickup.
Why it matters
The pickup time is what the person needs to know when to walk over, and it is often the last detail a store states. With one event per wave, your product hears about it when it arrives instead of on whatever read happens next.
What to do
Subscribe your endpoint to order.updated if it does not already, de-duplicate on event_id, and read the order again on every order.updated:
if (handled.has(payload.event_id)) return;
handled.add(payload.event_id);
if (payload.event === "order.updated") {
const order = await getOrder(payload.order.id);
showPickup(order.ready_eta, order.fulfillment);
}
Then run an order at test_place_pickup_later and check that your product shows the pickup time when the second order.updated arrives.
Breaking changes
None for a handler that de-duplicates on event_id. A handler that treated the order id and the event type together as one event, or that checked event_id against the old pattern, keeps only the first wave and drops the rest, often including the pickup time. Switch it to event_id. The EventId pattern in the OpenAPI spec now allows the _2 suffix.