**Not ready.** The structure and scale assumptions are fine. The payment flow (steps 3–6) can double-charge customers and can charge them without recording an order. Fix those before you write the checkout code.

## Blockers

1. **Retrying the charge can double-charge.** Step 4 retries on a 5 s timeout, up to 3 times, with no idempotency key. A timeout doesn't mean the charge failed. The first call may have succeeded, so the retry charges the customer again. Generate one idempotency key per order, send it on every attempt, and confirm the provider supports it.

2. **A timed-out charge can leave the customer charged with no order.** If all retries time out, step 6 rolls back and tells the client it failed. But the charge may have gone through. Likewise, if the commit in step 5 fails after a successful charge, the money is taken and the order is gone. You need an explicit unknown-outcome state (for example `PAYMENT_UNKNOWN`). A reconciliation job or provider webhook should resolve it by querying the provider. Never roll back on an ambiguous result.

3. **The transaction stays open across the external call.** It is held through up to 3 × 5 s of payment retries, plus backoff. That ties up a connection and row locks for 15 s or more. The rollback also erases the `PENDING` row, so you lose any record that a payment was attempted. Commit `PENDING` first. Then call the provider outside the transaction. Then run a second short transaction to set `PAID` or `FAILED`.

4. **There is no idempotency on `POST /orders`.** If the client retries after a network drop or a double-click, it creates a second order and a second charge. Require a client-supplied idempotency key with a unique constraint.

5. **A single Postgres instance with nightly backups is too weak for payment data.** You could lose up to 24 hours of orders. The provider still holds the matching charges, so the two sides would disagree and you couldn't rebuild from your own data. At minimum, enable WAL archiving or point-in-time recovery. Decide your recovery targets and write them down.

## Serious gaps (fix before launch, can overlap with building)

6. **Overselling is unmanaged.** The 5-minute stale cache is a fair tradeoff, but nothing decrements or reserves stock when an order succeeds. A popular item can sell far past its real stock within one refresh window. Either decrement the cache locally or reserve stock. Also define what happens when the warehouse later says there isn't enough: backorder, cancel and refund, or something else. Nothing in the design covers what happens if the cache refresh fails.

7. **The confirmation email is sent inline after commit.** If it fails, the order is paid and the customer is never told. If it is sent before the commit finishes, it can announce an order that doesn't exist. Use an outbox table with a retrying worker.

8. **The state machine is incomplete.** There are only `PENDING` and `PAID`. You need `FAILED`, `PAYMENT_UNKNOWN`, `CANCELLED` and `REFUNDED`. You also need a plan for refunds, including the case where you must refund after discovering a stock shortfall.

9. **The test plan covers only the paths that rarely break.** One happy-path integration test won't catch the problems above. Add tests for payment timeout then success on retry, a hard decline, a crash between charge and commit, and a duplicate client request. Use a fake payment provider that can simulate these.

## Minor

- Auth, PCI scope (tokenized card data only?) and rate limiting aren't mentioned.
- Logging should include the idempotency key and the provider's charge ID, not only the order id.
- The 800 ms warehouse call is a fine reason to use the cache. But say what happens when the cache is cold or empty.

## What's good

The module boundaries, the thin routes with an `OrderCheckout` class, and structured logging are all sound. Your volume (2,000 orders a day) doesn't need anything fancier than Postgres and an outbox. These fixes are cheap to make now and expensive to retrofit.

Revise the flow section with the changes in items 1–4 and the recovery plan from item 5 first. That's probably half a day. Then you can start building.

VERDICT: NOT READY
