System Design Atlas

Ticket sales with assigned seats

07 / 10Worked example

Critical flow

At what point can a successful external payment establish a seat entitlement?

The critical flow begins when the payment service reports Z-17 as successful after H-17 has expired and S-42 has a new hold. The API verifies the signature, deduplicates and persists the event in the inbox, then responds 2xx. The worker subsequently decides between confirmation and compensation in a transaction.

Starting point The starting point is the architecture with inbox, worker and transactional sales inventory.

Assumptions for the example case

Example design for one event with 1,000 numbered seats. Each order contains exactly one seat. Hold, sale, payment and ticket are separate entities. All figures and targets are illustrative assumptions, not provider metrics. Admission scanning, resale, dynamic pricing and multi-seat orders are outside scope. Sources checked on 8 September 2026. The order model covers successful payments, including delayed success; final unpaid cancellations need their own terminal state before implementation.

Check payment feedback as normal, late payment and duplicate

The still valid hold H-17 is paid for and generates exactly one ticket T-17.

Visitors
Payment service
Ticket API
SQL · Allocation/Inbox/Outbox
Confirmation worker
  1. 01 Visitors → Ticket APIPOST /holds/H-17/checkout

    Order B-17 + Idempotency key

  2. 02 Ticket API → SQL · Allocation/Inbox/OutboxH-17: validate hold and expiry

    Seat S-42 is still bound

  3. 03 SQL · Allocation/Inbox/Outbox → Ticket APICommit: B-17 payment_pending + Z-17 + Payment outbox
  4. 04 Ticket API → VisitorsB-17 payment_pending · Request status later
  5. 05 Confirmation worker → SQL · Allocation/Inbox/OutboxRead payment command from outbox
  6. 06 Confirmation worker → Payment servicePayment for B-17: request

    Stable key; reconcile unknown outcome

  7. Payment service returns success asynchronously
  8. 07 Payment service → Ticket APIPOST /payment-events · Success

    Checking the signature; EV-17 Deduplication

  9. 08 Ticket API → SQL · Allocation/Inbox/OutboxSave Webhook inbox

    Commit durably before 2xx

  10. 09 SQL · Allocation/Inbox/Outbox → Ticket APIInbox-Commit
  11. 10 Ticket API → Payment service2xx · Acceptance confirmed
  12. 11 Confirmation worker → SQL · Allocation/Inbox/OutboxRead and lock inbox, B-17, H-17 and current seat allocation
  13. 12 Confirmation worker · Local processingValidate payment association, amount/currency and hold validity at commit
  14. 13 Confirmation worker → SQL · Allocation/Inbox/OutboxH-17 converted + sale allocation + B-17 confirmed + T-17 + inbox completion

    One transaction; no refund command

  15. 14 SQL · Allocation/Inbox/Outbox → Confirmation workerCommit: exactly one ticket
  16. 15 Visitors → Ticket APIGET /orders/B-17 · own order
  17. 16 Ticket API → SQL · Allocation/Inbox/OutboxRead order status
  18. 17 SQL · Allocation/Inbox/Outbox → Ticket APIB-17 confirmed · T-17
  19. 18 Ticket API → VisitorsB-17 confirmed · T-17

Result: The ticket API acknowledges event ingestion to the payment service; ticket confirmation occurs only in the local commit with a valid hold and remains protected as a sale allocation.

All three scenarios use the same participants. Message order, endpoints, durable ingestion, commit and failure timing remain the same on desktop and mobile.

Critical time points

TimestampLocal impactPermitted result
Webhook arrivesSignature and eventId are checked; Inbox is committed before 2xx.Payment service is allowed to resend; no promise arises in the reply.
Worker reads InboxHold, active binding and B-17 are loaded for decision.Valid H-17 can be confirmed.
Hold has expiredS-42 may belong to a new hold.B-17 becomes compensation_pending; no T-17 arises.
Crash after commitB-17, T-17 or Outbox and Inbox completion remain permanent.Restart detects closure and does not produce a second effect.

Webhook arrives

Local impact
Signature and eventId are checked; Inbox is committed before 2xx.
Permitted result
Payment service is allowed to resend; no promise arises in the reply.

Worker reads Inbox

Local impact
Hold, active binding and B-17 are loaded for decision.
Permitted result
Valid H-17 can be confirmed.

Hold has expired

Local impact
S-42 may belong to a new hold.
Permitted result
B-17 becomes compensation_pending; no T-17 arises.

Crash after commit

Local impact
B-17, T-17 or Outbox and Inbox completion remain permanent.
Permitted result
Restart detects closure and does not produce a second effect.

Why 2xx does not confirm a ticket

Durable acceptance
2xx follows only after the deduplicated event is committed to local storage. A crash before that point leads to a retry rather than loss.
Domain validation
The worker checks the current hold at commit. An old or duplicate event creates no new allocation.
Settlement
Late payment success triggers an idempotent refund through the outbox. If it fails, B-17 remains compensation_pending with an assigned investigation owner.

Terms in this step

At least once
External messages can arrive repeatedly. Deduplication and idempotent effect still limit the business effect.
Compensation
A compensation compensates for an external effect that has already occurred if the desired local commitment is no longer permissible.

Try it yourself

Describe late payment success in at least eight messages or local actions. Mark the inbox commit, validation transaction and refund outbox.

A hint for your attempt

The payment service needs a quick acceptance. The local decision must see the current state of H-17 and S-42.

Compare with a possible solution
1–4: Durable ingestion
1. Payment service → API: EV-17 reports Z-17 as successful. 2. API checks the signature. 3. API → store: write a deduplicated inbox entry and wait for the commit. 4. API → payment service: 2xx.
5–8: Local decision
5. Worker → store: read and lock the inbox, B-17, H-17 and seat allocation. 6. The worker validates the payment association and detects expired H-17. 7. It writes compensation_pending, a uniquely keyed refund outbox entry and inbox completion without T-17. 8. The store confirms the joint commit; the new seat allocation is preserved.
9–12: compensation
9. Worker → payment service: refund with a stable key. 10. Payment service → API: confirmed refund EV-18. 11. The API validates and persists EV-18 in the inbox, waits for commit, then responds 2xx. 12. The worker writes refunded and inbox completion atomically. A timeout or failure leaves compensation_pending for retry or investigation.

Apply to your project

What external effect can occur in your system after the local authorization expires?

After the critical process, we look specifically for measured values and trade-offs instead of anticipating infrastructure.