Data and states
Which states remain separate even though they are connected in time?
Separate states prevent premature conclusions. Hold H-17 can be held, converted, expired or released. Order B-17 can be payment_pending, confirmed, compensation_pending or refunded. T-17 is created exactly once in the confirmation commit. EV-18 identifies the later refund event. An unknown payment result remains open.
Starting point The starting point is Hold H-17, order B-17 and payment Z-17 from the contracts.
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.
Connect authoritative data, lifecycles and event history
Authoritative allocation, separate lifecycles and a durable event trail
Authoritative sales inventory
Life cycles
Message and impact trace
- Authoritative data
- Inbox and Outbox
- Derived confirmation
Place status and hold are protected together. A ticket is created only with the successful confirmation commit; the refund remains a separate clarification state until the confirmation.
State transitions and conditions
| Entity | Transition | Condition |
|---|---|---|
| H-17 | held → converted | The hold is still valid on commit and S-42 is its active binding. |
| H-17 | held → expired | released | Server time has reached expiresAt, or the visitor assigned to H-17 explicitly releases the hold. Starting or finishing payment does not automatically change a hold to released. |
| B-17 | payment_pending → confirmed | Permanently proven payment success and valid hold are checked together. |
| B-17 | payment_pending → compensation_pending | Payment success arrives after expiration or without a permissible commitment. |
| B-17 | compensation_pending → refunded | The idempotently initiated refund is confirmed. |
H-17
- Transition
- held → converted
- Condition
- The hold is still valid on commit and S-42 is its active binding.
H-17
- Transition
- held → expired | released
- Condition
- Server time has reached expiresAt, or the visitor assigned to H-17 explicitly releases the hold. Starting or finishing payment does not automatically change a hold to released.
B-17
- Transition
- payment_pending → confirmed
- Condition
- Permanently proven payment success and valid hold are checked together.
B-17
- Transition
- payment_pending → compensation_pending
- Condition
- Payment success arrives after expiration or without a permissible commitment.
B-17
- Transition
- compensation_pending → refunded
- Condition
- The idempotently initiated refund is confirmed.
Transaction and external effects
Commit the hold, order, ticket and inbox completion together
T-17 must not occur without a confirmed, valid H-17.
- Trade-off
- The transaction must not contain slow payment communications.
- Reassess
- Measure lock waiting time and conflict rate under the test peak.
Compensation as outbox entry
The local decision remains permanent, even if the payment service is temporarily unavailable.
- Trade-off
- B-17 can remain visible compensation_pending.
- Reassess
- Review rules and operational handling based on the number and age of unresolved compensation cases.
Protecting binding and effect atomically
- Leading relationships
- Each seat belongs to one event and can have many holds over time. At any moment, only one hold or confirmed order may allocate it. Each hold has at most one order; each confirmed order has exactly one ticket. Payment Z-17 is associated with B-17. Inbox event EV-17 and refund event EV-18 have separate identities.
- Competing Access and Time
- Creation, expiry, release and confirmation lock the same seat row V-17/S-42. Within that transaction, an expired held entry becomes expired before a new hold receives the seat. Confirmation also checks the current hold ID. The expiry worker performs cleanup; its punctuality does not determine validity. converted preserves the permanent sale allocation.
- Commit boundary
- expiresAt = creation time + 300 s; at that boundary the hold is expired. The example uses a shared server clock and requires validity at final commit. Validation occurs at the end of the locked transaction; tests must also cover delays between validation and commit. An earlier time check alone does not establish this stricter guarantee.
- Validate the payment's domain association
- Before confirmation, the worker checks payment, order, provider account, expected amount and currency. Another success event for the same payment cannot reset confirmed, compensation_pending or refunded. Ticket and refund commands have unique domain keys. Rollback discards all local changes together, including inbox completion and outbox entries.
Terms in this step
- Transaction
- A transaction makes associated changes visible together or discards them together.
- Outbox
- An outbox durably records an external effect to trigger in the same transaction as the local domain decision.
Try it yourself
Draw the two life cycles and supplement the late payment success. Mark the one transaction that T-17 is allowed to generate.
A hint for your attempt
A state describes an object. Hold and order must therefore not merge into a fuzzy overall status.
Compare with a possible solution
- Life cycles
- H-17 runs held → converted or held → expired/released. B-17 runs payment_pending → confirmed or late success → compensation_pending → refunded.
- Commit
- Only the worker commits valid H-17, B-17 in confirmed, T-17 and inbox completion together. A later refund is a separate effect triggered safely through outbox retries.
Apply to your project
Which domain entities need their own states rather than one combined status?