**Not ready yet.** The module layout and code structure are fine to build. The payment part of the flow (steps 3–6) has two defects that can take a customer's money without recording an order, and fixing them changes the flow itself, so it can't be patched during coding. The fix is well understood and could be written up in an hour or two, so tomorrow is still realistic if that happens first.

## Must fix before building

**1. Retrying a timed-out charge can charge the customer twice.**
A timeout doesn't mean the charge failed. It means you don't know what happened.
- Case: the first charge call succeeds at the provider, but the response is lost and you hit the 5 s timeout. You retry, and the provider charges the card again.
- Expected: one charge. Actual: two, or up to four if all 3 retries succeed.
- Fix: send an idempotency key (for example, the order id) on every charge attempt, and reuse the same key on each retry. Find out whether your payment provider supports this; the design doesn't name the provider.

**2. The database transaction is held open across the payment call, so a successful charge can be rolled back.**
- Case: the charge succeeds, then the commit fails, or the process crashes before step 5. The `PENDING` order is rolled back.
- Expected: the order is recorded as `PAID`, or the charge is refunded. Actual: the customer is charged, and the database has no trace of the order. Step 6 does the same thing when the "failure" was really an ambiguous timeout.
- There's a second problem: a transaction open for up to about 20 s (4 × 5 s) holds a database connection and row locks on your single Postgres instance. Also, `PENDING` is never visible to anything else, so as written it does nothing.
- Fix: commit `PENDING` in its own transaction before calling the provider, then update the status in a second transaction. If the result is still unknown after the retries, leave the order `PENDING`, tell the client it's processing, and have a reconciliation job ask the provider what actually happened.

```mermaid
flowchart TD
    A[POST /orders with client idempotency key] --> B[Check inventory cache]
    B --> C[Tx 1: insert order PENDING, commit]
    C --> D[Charge provider with order id as idempotency key, retry with same key]
    D -->|success| E[Tx 2: mark PAID]
    D -->|declined| F[Tx 2: mark FAILED, return error]
    D -->|still unknown| G[Leave PENDING, return 'processing']
    G --> H[Reconciliation job queries provider, then PAID or FAILED]
    E --> I[Send confirmation email after commit, failure does not fail the order]
```

## Should decide before building

3. **Duplicate submits.** If someone double-clicks, or the client retries `POST /orders` (likely, since a request can take 20 s), you get two orders and two charges. Accept an idempotency key on the endpoint.
4. **Overselling.** The cache can be up to 5 minutes stale, and the design never reserves or decrements stock. Two customers can buy the last unit. That may be acceptable at 200–2,000 orders a day, but write down what happens when it occurs (refund? backorder?) so it's a decision and not an accident.
5. **Email failure.** Say that the email is sent after the commit and that a send failure doesn't fail the order. A simple outbox table or async job would do.

## Tests to plan now

One happy-path integration test isn't enough for a payment flow. Add tests for:
- a declined charge
- a timeout followed by a successful retry, checking that the same idempotency key is used and only one charge is made
- a timeout on every retry, leaving the order `PENDING` and handing it to reconciliation
- a crash between the charge and the commit
- a duplicate `POST /orders` with the same key

Running these against a fake payment provider will cover most of this.

## What's already good
The context section sizes the problem honestly. The module boundaries ("no module reads another module's tables"), thin routes with an `OrderCheckout` service, and the order id on every log line are all sound and can be built as written.

VERDICT: NOT READY
