**Not ready to build as written: steps 3–6 can charge a customer twice, or charge them and leave no order behind.** The fix is a rewrite of those four steps, perhaps a couple of hours of design work, and the code structure section can stand. Scale is not the problem: 2,000 orders a day is about one every 43 seconds, so no queues or extra infrastructure are needed.

## Blockers (fix before building)

1. **Retrying a timed-out charge can charge twice.** A timeout means "no answer", not "not charged".
   - Case: the charge for a $80 cart succeeds at the provider in 6 s, the service gave up at 5 s and retries, and the second charge also succeeds.
   - Result: the customer pays $160 for one order; expected is $80.
   - Fix: send an idempotency key (the order id) on every charge attempt, and confirm your provider supports this.

2. **Rolling back on failure erases the only record of a charge that may have gone through.** The `PENDING` row lives inside the open transaction, so it never survives a failure.
   - Case: all attempts time out but one actually charged, or the process crashes between the charge and the commit.
   - Result: the customer is charged, there is no order row, and nothing tells you to refund; expected is a row that says "payment outcome unknown".
   - Fix: commit `PENDING` before calling the provider, then update to `PAID` or `FAILED` in a second short transaction. Add a `PAYMENT_UNKNOWN` state and a small job that asks the provider what happened and settles those orders.

3. **A repeated `POST /orders` creates a second order and a second charge.** The client can wait up to 20 s (four attempts of 5 s), so users will double-click and mobile clients will retry.
   - Fix: the client sends an idempotency key, with a unique constraint on it, and a repeat returns the existing order.

4. **Nothing in the flow reserves or decrements stock.** The check reads a cache up to 5 minutes old and no step reduces it.
   - Case: one unit is left and two customers order it 30 seconds apart.
   - Result: both pass the check and both are charged; expected is that the second is refused.
   - Fix: decrement a local stock count in the same transaction as the `PENDING` insert, with the warehouse refresh reconciling it.
   - You still need to decide what happens when you oversell anyway: refund or backorder.

5. **The test plan covers only the path where nothing goes wrong.** Every blocker above lives in a failure path. Add integration tests with a fake payment provider for:
   - decline
   - timeout then success
   - timeout on every attempt
   - crash after the charge
   - duplicate `POST`
   - last-unit race

## Revised flow

```mermaid
flowchart TD
    A[POST /orders with idempotency key] --> B{Key seen before?}
    B -- yes --> C[Return existing order]
    B -- no --> D[One transaction: reserve stock, insert order PENDING, commit]
    D --> E[Charge provider, order id as idempotency key, retry on timeout]
    E -- charged --> F[Mark PAID, commit]
    E -- declined --> G[Mark FAILED, release stock, return error]
    E -- still no answer --> H[Mark PAYMENT_UNKNOWN, tell client 'processing']
    H --> I[Background job asks provider, settles to PAID or FAILED]
    F --> J[Send confirmation email]
    I -- PAID --> J
```

## Should fix, not blocking

- **Email failure is unspecified.** If the send fails after commit, the order is paid and the customer hears nothing. Record "email pending" on the order and let the same background job retry it; do not fail the request.
- **Declines and timeouts are treated alike.** A declined card should never be retried; only timeouts and provider 5xx errors should.
- **Nightly backups can lose up to 24 hours of paid orders.** Turning on continuous WAL archiving for point-in-time restore is cheap. Whether that risk is acceptable for now is your call.
- **Refunds and cancellation are not mentioned.** Fine for a first version, but say so in the doc.

## What is sound

Module boundaries with no cross-module table reads, thin routes with the flow in `OrderCheckout`, and the order id on every log line are all right and need no change.

You can scaffold the modules tomorrow, but do not write the checkout flow until steps 3–6 are revised.

VERDICT: NOT READY
