Writing a row safelybeginner
Creating a record means deciding its id, checking it before it lands, and never modifying the list you were handed — because a half-written row is harder to find and fix than a rejected request.
The request timed out, so the phone retried it, so the customer has two identical orders and one of them will be refunded by hand. Make the write safe to repeat.
Sending the same order twice leaves one row, and an invalid draft leaves none.
Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.
Creating a record means deciding its id, checking it before it lands, and never modifying the list you were handed — because a half-written row is harder to find and fix than a rejected request.
A request that times out has not necessarily failed — you just did not hear back — so the client retries, and unless the write recognises that it has already happened the customer is charged twice.