When a booking drops halfway
The subject of this note is payment without an issued ticket. That condition must not be recorded as a failed purchase. Each stage, from search through to refund, is set out separately.
I observed this condition in travel-agency operations, and I now encounter it on an online travel product. The failure almost always has the same form: two adjacent states, each successful within its own system, and no identified owner for the gap between them.
A booking is not a function
Treat the path as a state machine, not as a method called Book. Every state needs an owner and an exit condition. If “paid” can sit there for hours, you have not designed a state. You have put a label on a row.
- Search
- Hold
- Payment
- Unknown
- Ticket
- Refund
Store state names in the language of the business. A local abbreviation is readable, six months later, only to the person who invented it.
Lend the inventory
Do not sell the seat, room, or unit of capacity at search time. Lend it briefly. Store the expiry on the server, in UTC. The browser timer is a display. The worker that releases expired holds has to run when nobody is looking at the site.
Do not write “whatever is already past” as GETDATE() inside a filtered index. That function is not allowed in a filtered-index predicate, and it should not be: an index cannot recompute membership every second. Releasing a hold is an explicit update, so the rest of the system can see it. If two requests want the same unit of capacity, a long lock on the table is not the fix. A version column, or a unique constraint on free capacity, is cheaper and easier to explain.
Separate payment from issuance
The most costly incident in this field is straightforward: the funds have been captured, the ticket has not been issued, and someone must speak with the traveler the next day. Do not combine both steps in one local database transaction. The payment gateway and the ticket supplier both stand outside that transaction. The available action is to record each intention durably, make the call, and write the result back onto the same row.
Place an idempotency key on capture and on issuance. A retry must not create a second ticket. If the supplier times out, the result is not “failed.” The result is “unknown.” Enquire of the supplier about the status of that same request before trying again.
An alert for rows whose payment is final and whose issuance is not is more useful than a crowded dashboard. Include refunds in the same state machine from the outset. A Boolean flag on the sale row will, six months later, make the finance report and the traveler’s status disagree.
What to count
- Holds that expire without a purchase
- The gap between final payment and final issuance
- How often a supplier returns “unknown”
- Retries that the idempotency key stopped
- Refunds whose money and travel document disagree
If you cannot see these five numbers, you do not have a travel product. You have a search form that sometimes issues a ticket. For the cost of indexes on these same hot tables, read the index note.
Was this note useful?