The card was approved. The last item was already gone.
Two customers can receive payment approvals while competing for one item. Agree how stock is reserved, when the order becomes a promise and what happens to a late result.
In this article
Two shoppers reach checkout with the last item in their baskets. Each screen shows it as available. Each customer pays. The warehouse still has one item.
In this hypothetical store, the gateway can have processed both requests correctly. The defect is in the promise the business made around those payments. One customer now needs an explanation that neither approval supplies.
The awkward question belongs before launch: at what point does this store stop offering the same stock to somebody else?
Seeing availability is not securing the item
A page can accurately show one item remaining when it loads. Another purchase can claim it before the first shopper presses Pay. Checking again is necessary, but two requests can also perform that check before either records its claim.
Ask the web team where the final allocation is decided and how competing requests are coordinated there. The check and the claim need a reliable shared decision, not two independent readings of the same number. OWASP’s business logic guidance treats concurrent use of limited resources as something to control and test explicitly.
The implementation depends on the store. PostgreSQL, for example, provides transaction and row locking mechanisms that coordinate conflicting updates. That is one technical building block, not a complete stock reservation design or a requirement to use that database.
Nor should the team simply leave a database transaction open while the shopper enters card details or completes authentication. PostgreSQL warns about holding transactions open for long waits. A customer reservation needs its own durable meaning, owner and expiration policy rather than an indefinite database lock.
Include the other sales routes. A website reservation is unreliable if a staff order or another store can commit the same shared stock without following the allocation rules. Separate gateway accounts do not automatically separate a warehouse’s available quantity.
Two valid purchases are not a duplicate request
Payment duplicate controls answer whether the same operation is being submitted again. These shoppers have different orders and different intended payments. Giving each a unique payment reference is correct; it does not resolve their competition for the last item.
The merchant must agree the order sequence with the web team. Does the store reserve stock before requesting payment? Does it accept an order subject to an availability review? When does it capture an approved authorization, and what does the customer see at each point? The answer should match the business’s actual terms and supported payment arrangement.
Cybersource distinguishes an authorization from the later capture that initiates collection. Delaying capture can leave room for an order review where supported, but it does not allocate stock. An authorization can also affect the customer’s available balance, so collecting approvals for unavailable items is not a consequence free substitute for inventory control.
Keep the two records connected. One describes the reserved item and its order; the other describes the payment operation and its current state. If the payment is declined, the reservation needs the agreed release treatment. If allocation fails after an authorization is confirmed, the team needs the supported payment correction and an accurate customer message.
Do not turn that exception into a silent product substitution. Approval for one item is not the customer’s agreement to a different color, later delivery or replacement product. The commercial resolution still needs the customer’s informed choice.
A reservation can expire while a payment continues
Suppose the store releases a reservation after its waiting period ends. Another order takes the item. The first payment result then arrives. Extending the old reservation after the fact would overwrite the second purchase’s claim.
Ending the stock hold does not establish that the earlier payment failed. Cybersource treats a missing definitive response as an uncertain outcome to investigate. The store must retain that attempt after the reservation expires and decide what to do when the financial result is known.
Have the team define that meeting point explicitly. A late approval should find the current reservation and order state, then enter the agreed review or resolution path. It should not unconditionally mark the item sold, capture again or send a warehouse instruction based on an expired claim.
The same discipline applies to release work. A delayed task that releases an old reservation must not release the item now allocated to a different order. Staff need to see which reservation the action belongs to, not just a product code and a quantity.
Our late payment article follows the customer resolution once the sale has changed. The design decision here is to make that exception visible instead of letting a returning payment response decide who gets the stock.
Rehearse the purchase you cannot fulfill twice
Use two controlled purchases competing for one item in an isolated test system. Pause one before its allocation completes, then let the other proceed. Reverse their order. Repeat with a declined payment, an expired reservation and a delayed result. This is a bounded application test, not a reason to load test a provider’s sandbox.
Judge the result by the promise to each customer. Which order secured the item? Which payment operations were submitted? What does each customer see, and what can the warehouse release? One remaining item should not produce two confirmed promises to ship it.
Also revisit the test after a worker restarts or an event is delivered twice. The right quantity on a final inventory screen is not enough if the store already sent two confirmations or payment corrections. Inspect the order histories and the actions sent downstream.
For a Trolleys merchant, the gateway and merchant records help establish payment activity. Your store’s allocation and fulfillment rules remain the web and operations teams’ responsibility. Bring this scenario into the customer journey review before promising a launch date.
A good checkout does more than accept money. It knows what the business can still promise when two customers want the same thing.