These docs are for v2.2023.0401. Click to read the latest docs for v2.2025.0301.

Discussions

Ask a Question
Back to all

Idempotent receipts

I'm trying to create/update receipts in my integration, following the flowchart here: https://developers.7shifts.com/docs/sales-integration-update-receipt-data#update-receipts-in-7shifts

The problem comes if the POST times out, I can't know if the receipt was successfully create on 7shifts end or not. This puts me in a bit of a bind, because POST isn't idempotent and will fail on retry if the receipt exists. Inversely, PUT will fail if the receipt doesn't exist. So I don't have a reliable way to retry a POST.

Currently I have an awkward and brittle implementation that on retry will attempt a POST, parse the error message on failure to see if the error indicates it already exists, then try with a PUT. It seems like there should be a better way to do this.