**Not ready to build from as written.** The payment flow (steps 3–6) can charge a customer twice, or charge them and leave no record of the order. The rest of the design is sound, and the fix is a small rewrite of those steps. You could have a corrected version by tomorrow.

## Blockers

**1. Retrying the charge can double-charge.** Step 4 retries on a 5 s timeout, up to 3 times. A timeout doesn't mean the charge failed. The provider may have charged the card and responded slowly.
- Case: the card is charged £50, the response takes 6 s, and we time out and retry. Without an idempotency key, the provider charges a second £50. We expected one charge and the customer sees two.
- Fix: send an idempotency key (for example the order id) on every charge call, so retries return the original result. Retry only timeouts and 5xx errors, never card declines.

**2. A crash after the charge loses the order.** The `PENDING` insert and the `PAID` update share one transaction (steps 3–5). If the process dies, or the commit fails, after the charge succeeds, the rollback erases the order. The customer is charged and we have no record.
- Case: the charge succeeds, the DB connection drops before commit, and the order row never existed.
- Fix: commit `PENDING` first, outside any long transaction. Then charge, then update the status in a second short transaction. Add a small job that finds orders stuck in `PENDING` and asks the provider what happened.

**3. Step 6 treats "failure" as "not charged".** After 3 timeouts we don't know whether the card was charged. The design needs a state for this, such as `PAYMENT_UNKNOWN`, that the reconciliation job resolves. It also needs a `FAILED` state for real declines. Today the design only names `PENDING` and `PAID`.

## Should fix before or early in the build

- **Holding a DB transaction open during the payment call.** In the current flow it can be held for 15 s or more, which ties up a connection. Blocker 2's fix removes this.
- **Duplicate submits from the client.** If the client retries `POST /orders` after a network blip, you get two orders. Accept a client-supplied idempotency key on the endpoint.
- **Stock is checked but never reserved or decremented.** With a cache up to 5 minutes old, two buyers can both get the last item. At 200–2,000 orders a day, overselling may be acceptable. If so, say that in the doc and say what happens next (backorder, refund). Also say who decrements stock after a sale.
- **Email failure.** Step 5 doesn't say what happens if the email fails. It should not fail the order. Queue or retry it separately.
- **Backups.** Nightly backups on a single instance mean you could lose up to 24 hours of orders and payment records. Decide whether that's acceptable for payments. Point-in-time recovery (WAL archiving) is usually cheap to add.

## Tests

The plan has unit tests plus one happy-path integration test. For this flow, the failure paths are where the bugs are. Add tests for these before writing the code:
- Charge times out, then succeeds on retry: exactly one charge, with the same idempotency key.
- Charge declined: order ends `FAILED`, no retry.
- Crash after charge, before the status update: the reconciliation job fixes the order.
- Duplicate `POST /orders` with the same key: returns the same order.
- Email failure doesn't change the order status.

## What's good

The module boundaries (no cross-module table reads), thin routes with an `OrderCheckout` class, and structured logging with the order id are all sound. The reasoning for accepting the stale cache is stated clearly. The scale numbers fit a single Postgres instance.

VERDICT: NOT READY
