I bought two cinema tickets in a test checkout, one for seat B7 and one for B8. When a payment is approved, the payment provider notifies the cinema so it can issue the tickets. I wanted to see what would happen if that notification arrived twice. I still had two seats, but there were four ticket codes in front of me: two for B7 and two for B8. If the customer called to ask “Did you charge me twice?”, what would I tell them?
Before answering, I checked three records. The order showed the two seats I’d picked. The payment record showed one charge. In the ticket records, each seat had two different codes. The system had issued tickets for the same seats a second time. If I’d issued a refund then, I’d have returned the only payment for the order.
My first idea was to have the cinema remember which notifications it had handled. That automatic notification is called a webhook. The provider can send it again if it’s still waiting for an acknowledgement, even if the cinema has already issued the tickets. I stored the ID of each notification I processed and ran the test again from scratch. Event evt01 arrived and two tickets were issued. I delivered evt01 again. The count stayed at two. That seemed to settle it.
Then I changed one thing. I sent evt02, another payment approval notification for the same purchase. My events table had never seen that ID, so the backend processed the notification. I was back to four tickets.
That’s when I found the question I’d been missing: what was the customer entitled to receive exactly once? They’d bought two tickets. If I made the order number unique in the tickets table, B7 would get a ticket and B8 would miss out. In this checkout, each purchased seat had its own order line. That was the identity I needed to preserve. With that key, processing the purchase again should leave each person with the same ticket and the same code. That’s what I wanted idempotent ticket issuance to mean.
I added a unique constraint on the order line in the tickets table. Within a single transaction, I recorded the event and attempted to issue each ticket. If a ticket already existed for that line, it kept its code. I sent the three notifications again.
| Protection used | First notification | Same notification again | Another event for the same purchase |
|---|---|---|---|
| None | 2 tickets | 4 tickets | 6 tickets |
| Event ID | 2 tickets | 2 tickets | 4 tickets |
| Event ID and one ticket per purchased order line | 2 tickets | 2 tickets | 2 tickets |
All three tests had one recorded charge. What changed was how many tickets that charge could generate. This local test covered ticket issuance. The payment provider and email delivery were outside its scope.
Now, when I review a checkout, I start with a question the support team can answer too: if we process this purchase again, does the customer get the same ticket code back, or do they get another code that can also open the door? The answer tells me where idempotency belongs.


