skip to content

In a concert-ticketing checkout, a buyer's payment succeeds a minute after their seat hold expired; how should the booking system decide what happens next?

level: seniorimportance: should knowfreq 42%

answer

  1. a late success is a new claim
  2. re-check who holds the seat now
  3. still free: re-take and confirm
  4. gone: release the money, never resell
  5. payment pending with a hard ceiling

basics

~20 s

Re-check the seat: if it is still free, take it for this buyer and confirm; if someone else now holds or owns it, never sell it twice, release the payment automatically and tell the buyer.

solid answer

~50 s

Treat the late success as a fresh claim rather than a confirmation. One conditional transition decides it: if the seat is still available, or still carries this buyer's lapsed hold, take it and mark it `sold`; if another buyer now holds it under a live hold or has bought it, the late buyer loses. The losing path is automatic: release the money (a refund, or a void if only an authorisation was taken), tell the buyer, and optionally offer a comparable seat they must accept. Never cancel the newer buyer to make room. Decide that rule before launch, apply it in the payment-success handler, and make the handler safe to run twice for the same payment. Then make the case rare: when the buyer submits payment, mark the hold `payment pending` and extend it by a grace period covering the payment step's slow tail, under a hard ceiling.

code

pseudocode · 18 lines
pseudocode
// Illustrative payment-success handler; names are invented.
function onPaymentSucceeded(holdId, paymentRef):
    hold = readHold(holdId)
    result = setSeatIf(
        seat      = hold.seatId,
        to        = Sold(buyer = hold.buyerId, paymentRef = paymentRef),
        condition = seat.status == Available
                 or (seat.status == Held and seat.holdId == holdId)
                 or (seat.status == Held and seat.expiresAt < now()))
    if result.applied:
        markHold(holdId, Confirmed, paymentRef)
        return Confirmed
    if result.current.status == Sold and result.current.paymentRef == paymentRef:
        return Confirmed               // a duplicate callback already won
    markHold(holdId, Lost, paymentRef)
    requestPaymentRelease(paymentRef)  // refund, or void an authorisation; retried until done
    notifyBuyer(hold.buyerId, SeatLost(hold.seatId))
    return SeatLost

go deeper

for a junior

Recall that a payment can finish after a seat hold expires, and that the seat must never be sold twice: either this buyer gets it back because it is still free, or they get their money back.

for a middle

Explain the single conditional transition that re-takes a free seat, why a read-then-write check can let two handlers both win, and why the payment reference is stored on the sold seat.

for a senior

Show the production design: the payment-pending state with a measured grace and a hard ceiling, authorise-then-capture so losing costs a void, safe retries, and the late-payment and losing-share metrics.

for a principal

Own the policy as a product decision: who wins a contested seat, whether to offer substitutes, and how much grace the business accepts against seats held in limbo during an on-sale.

## Why payments land after the hold A seat hold has a time limit; payment does not. Several ordinary things push a success past the deadline: - The buyer submits payment in the last seconds of the countdown. - The bank adds an extra authentication step that the buyer completes slowly. - The payment provider reports the outcome asynchronously, through a callback that can arrive seconds or minutes later, or be retried. - The provider's own latency has a long tail under on-sale load. So "payment succeeded, hold expired" is not a bug to be prevented entirely; it is a state the booking system must have a rule for, decided in advance rather than improvised in the handler. ## The decision When the success arrives, the handler re-reads the seat and applies one **conditional transition**. The possible situations: | Seat state when the success arrives | Outcome | |---|---| | still held by this buyer, not expired | normal confirmation: mark `sold` | | this buyer's hold lapsed, nobody else took it | re-take for this buyer and mark `sold` | | `available` (the lapsed hold was cleaned up) | re-take for this buyer and mark `sold` | | held by another buyer under a live hold, or sold to another buyer | late buyer loses: release payment, notify | | already `sold` to this buyer with this payment | a duplicate callback: report success, change nothing | The important asymmetry is the fourth row. The other buyer acted in good faith on a seat the system told them was free. Cancelling them to honour the earlier buyer just moves the failure to someone else, and their payment may also be in flight. The seat goes to whoever holds a valid claim *now*. What the losing buyer gets is a business rule the system applies automatically: 1. **Release the money.** Refund a captured payment, or void it if only an authorisation was taken. Releasing must itself be safe to retry. 2. **Tell the buyer** immediately and plainly, rather than leaving a confirmation page that never arrives. 3. **Optionally offer a comparable seat**, held for them briefly, which they must accept; silently substituting a different seat is a sale they did not agree to. How the payment is captured, recorded and settled is the payment system's business; this handler only decides whether the booking stands. ## Making the check safe - The transition must be a single conditional write on the seat ("set sold for buyer B if available, or held by B, or held under an expired hold"), not a read followed by a separate write; otherwise two handlers can both decide they won. - Store the payment reference on the sold seat. A retried callback then finds the seat sold with its own reference and reports success instead of refunding a buyer who actually won. - Exactly how retried requests are deduplicated end to end is an idempotency topic; this handler only has to be harmless when run twice. ## Shrinking the window The rule handles late payments; design also makes them rare: - **A `payment pending` state.** When the buyer submits payment, the hold moves to `payment pending` and gains a grace period sized to the payment step's slow tail, measured rather than guessed. Expiry logic skips pending holds until a **hard ceiling**, after which they lapse anyway, so a provider that never answers cannot pin a seat for ever. - **Authorise first, capture on confirmation.** If the payment step only authorises the card and the booking captures after confirming the seat, the losing path is a void rather than a refund the buyer sees on a statement. - **Show the countdown**, so buyers know how long they have and submit payment in time. The grace period is a trade: longer grace means fewer late payments but seats held in limbo longer during an on-sale. The numbers belong to measurement, for example a grace that covers the slowest few percent of observed payment times. ## What to watch - The **late-payment rate**: successes arriving after the original expiry, as a share of all successes. - How many of those **re-took the seat** versus **lost it**; a high losing share at on-sales means holds are too short or the grace too small. - **Automatic releases issued** and their age; a release that has not completed is a buyer charged for nothing. - Pending holds that hit the **hard ceiling**, which point at a payment provider that stopped answering. ## Common mistakes - Refunding every late payment even when the seat is still free, losing a sale and annoying a buyer for no reason. - Confirming every successful payment because "the money arrived", which double-sells the seat. - Letting the grace period be open-ended. - Handling the losing path manually, so buyers wait days for money back.

  • Why not keep the hold alive indefinitely once the buyer has submitted payment?
    A payment provider can fail to answer, or answer hours later, and an open-ended pending state would pin the seat throughout an on-sale. A grace period sized to the slow tail of real payment times, under a hard ceiling, catches nearly every genuine payment while guaranteeing the seat returns to sale. After the ceiling the hold lapses and any later success goes through the normal late-payment rule.
  • Should the system automatically give the losing buyer a different seat?
    Only with their consent. A different seat may have a different price, view or location, so assigning it silently is a sale they did not agree to. A good flow holds a comparable seat briefly and asks; if the buyer declines or does not answer, the payment is released. The release must never wait on that answer.

  • If the money arrived, confirm the seat; the payment is proof of the sale.
  • Any payment after expiry must be refunded even when the seat is still free.
  • The earlier buyer has priority, so cancel whoever took the seat afterwards.
  • Keep holds open as long as payment is pending, with no upper limit.
  • Late payments can be handled manually by support; they are rare.