The design isn't ready to build exactly as written, but it's close. The code structure is solid, and the payment step needs three changes before you write it. Those changes fit in a short revision tonight and don't affect anything else.

## What's already good
- **Module boundaries.** Orders, payments and inventory each keep their own tables, and the flow lives in an `OrderCheckout` class. That's clean and easy to test.
- **Thin routes and structured logging with the order id.** Both will help a lot when you debug payments in production.
- **The inventory cache.** You weighed the 800 ms warehouse call against staleness and chose on purpose.

## Must fix before building the payment step

**1. Retrying the charge can bill a customer twice.** A timeout doesn't mean the charge failed; often it went through and only the reply was lost.
- *Case:* the charge succeeds at the provider, but the response takes 5.1 s. You retry and the second charge also succeeds.
- *Result:* the customer is billed twice for one order. *Expected:* billed once.
- *Fix:* send an idempotency key with every charge, such as the order id. Most payment providers support this, and with it the retries are safe.

**2. A rollback after a charge erases the record that money was taken.**
- *Case:* the charge goes through at the provider, but the commit fails, or the final retry times out and you roll back.
- *Result:* the customer is charged and no order row exists, so nothing can reconcile or refund it. *Expected:* a `PENDING` or `PAYMENT_UNKNOWN` order you can check against the provider.
- *Fix:* commit the `PENDING` order first, call the provider outside any transaction, then update the status in a second short transaction. If the outcome is unknown, keep the row and reconcile it later, either with a provider webhook or a small sweep job.

**3. The database transaction stays open during the payment calls.** Four attempts at 5 s each can hold a database connection and its row locks for 20 s or more. At 2,000 orders a day, a slow day at the provider would use up your connection pool. Fix #2 solves this too.

The revised flow:

```mermaid
sequenceDiagram
    participant C as Client
    participant S as order-service
    participant DB as Postgres
    participant P as Payment provider
    C->>S: POST /orders (Idempotency-Key)
    S->>S: check inventory cache
    S->>DB: insert order PENDING, commit
    S->>P: charge (idempotency key = order id), retry on timeout
    P-->>S: success / failure / unknown
    S->>DB: set PAID / FAILED / PAYMENT_UNKNOWN, commit
    S-->>C: response
    S->>S: send confirmation email (if PAID)
```

## Worth adding, but these won't block you
- **An idempotency key on `POST /orders`.** A request can take 20 s or more, so clients will retry and create duplicate orders. Store the key alongside the order.
- **Overselling.** With a cache up to 5 minutes old, two buyers can get the last unit. Add one line on what happens then (cancel and refund, or backorder) so the team handles it the same way every time.
- **Tests for failure paths.** Right now only the happy path has an integration test. Add tests for: timeout then success with no double charge, all retries fail, the commit fails after the charge, and a duplicate `POST`. These are the paths most likely to cost real money.
- **Backups.** With only nightly backups, a database failure loses up to a day of paid orders. That might be acceptable at 200 orders a day; write it down as a known risk and revisit it when you get near 2,000.

If you fold changes 1–3 into design.md, you can start tomorrow.

VERDICT: READY WITH CHANGES
