# Cancel order

**Flow key:** `order-cancellation`

## Outcome

An authorized customer or agent cancels only an eligible order once, with coherent inventory, payment, fulfillment, notification, and audit consequences.

## Actors

- Customer or support agent
- Order service
- Payment processor
- Fulfillment/inventory service

## Preconditions and entry points

- Synthetic orders exist before and after the cancellation cutoff.
- Refund/void and inventory-restock policies are known.

## Required test data

Use synthetic, isolated, resettable data. Never use real credentials, payment instruments, private customer records, or production notifications.

| Data | Canonical valid seed | Critical variations |
|---|---|---|
| Order | paid unfulfilled cancellable order | pending payment, partly fulfilled, shipped, already canceled |
| Actor | owning customer | support agent, unauthorized user, other tenant |
| Payment | captured test payment | authorization only, gift card, split tender |
| Reason | `Changed my mind` | required/optional, long/Unicode/emoticon, policy-specific |
| Concurrency | single request | fulfillment starts during cancellation, duplicate submits |

## Canonical steps

Treat this as the ordinary successful path inferred from common product behavior. Adapt it to observed labels, business rules, APIs, and implementation evidence; do not invent a requirement.

| Step | User or system action | Expected evidence |
|---:|---|---|
| 1 | Open the order and choose Cancel. | Eligibility, cutoff, affected items, refund, and irreversible consequences are current. |
| 2 | Select/provide a reason and confirm. | Intent names the exact order/items and remains accessible. |
| 3 | Submit once. | Server revalidates state and records one cancellation attempt. |
| 4 | Void/refund payment and release inventory/fulfillment. | Side effects follow policy atomically or expose pending compensation. |
| 5 | Observe updated order and notification. | Status, totals, timeline, next actions, and message agree. |
| 6 | Retry or race with fulfillment. | Final state is unambiguous and no duplicate refund/restock occurs. |

## Alternate paths

- Full order cancellation
- Line-item cancellation
- Support cancellation
- Authorization void
- Pending cancellation requiring merchant approval

## Failure and recovery paths

- Cancellation cutoff passes mid-flow
- Fulfillment race
- Refund fails
- Inventory restock fails
- Response lost after commit

## Completion oracle

- The stated outcome is true in visible UI and authoritative persisted state.
- Exactly one intended business result and no unintended side effect occurred.
- Identity, tenant, authorization, money/data, lifecycle, notifications, integrations, analytics, and audit agree where applicable.
- Refresh, retry, back/forward, and a second authorized read do not reveal a contradictory result.
- Any partial, delayed, canceled, failed, or unknown outcome is labeled truthfully and has a safe recovery path.

## Evidence to capture

- Entry context, actor, tenant, role, feature flags, locale, time zone, and initial identifiers/state.
- Step-level screenshots or DOM state plus request/response, correlation, job, event, and stable business IDs where available.
- Before/after authoritative records, versions, totals, permissions, lifecycle states, and downstream side effects.
- Notifications, audit events, integration deliveries, retries, deduplication, latency, and recovery evidence.
- Untested branches, unsafe-to-run cases, product decisions, and evidence tier.

## Product decisions to resolve

- Exact eligibility, required data, authorization, and validation rules.
- Which steps are synchronous, asynchronous, optional, skippable, reversible, or irreversible.
- Idempotency, concurrency, timeout, retry, cancellation, and compensation semantics.
- Retention, privacy, notification, audit, performance, accessibility, and localization commitments.

## Related CARBON items

- [run start stop cancel](../../items/actions/run-start-stop-cancel.md)
- [delete](../../items/actions/delete.md)
- [payment](../../items/records/payment.md)
- [concurrency and idempotency](../../items/quality/concurrency-and-idempotency.md)

[Back to Commerce and billing flows](index.md)
