Can the Same Gift Card Be Used Twice?
Lay out two request schedules and compare duplicate claims with wallet credits that overwrite each other.
You’re reading a preview. Premium includes the full lesson and specialist practice. View the full curriculum.
Two requests see the same unused gift card
A gift card can add 100 points to a wallet once. Request A checks that it is unused. Before A marks it used, request B checks too. Both requests now believe they can continue.
The mistake is easier to see when we lay the events out in order:
| Moment | A | B |
|---|---|---|
| 1 | Reads unused | |
| 2 | Reads unused | |
| 3 | Adds points | |
| 4 | Attempts to add points | |
| 5 | Marks the card used |
A final balance can hide another event
Suppose the wallet starts at 0. If A writes 100 and B later reads 100 and writes 200, the card produced duplicate credit.
If both requests instead read 0 and both write 100, the final balance is only 100. That does not prove the claim was accepted just once: an update may have overwritten another update. Inspect the redemption records and card state as well as the balance.
A different problem appears when two legitimate cards, worth 100 and 200, share one wallet. Both credits should survive, for a total of 300. Locking each card separately does not prevent a stale wallet write from losing one credit.