Not ready as written, but close: the code structure is fine, and the payment steps (3 to 6) have three flaws that will charge customers incorrectly. All three can be fixed in the doc before you start, without a redesign.

## Must fix before writing payment code

1. **The retry on timeout can charge the customer twice.** A timeout does not mean the charge failed. For example, the provider completes the charge in 5.1 s, the service gives up at 5 s and retries, and the customer is charged twice for one order. Send an idempotency key (the order id) with every charge attempt so the provider treats retries as the same charge.

2. **Rolling back on failure can leave a customer charged with no order.** The `PENDING` row only exists inside the open transaction. If all three attempts time out but one actually went through, or the service crashes after the charge, the rollback erases the order while the money has been taken. Commit the `PENDING` order first, call the provider outside any transaction, then update the status in a second short transaction.

3. **There is no state for "we don't know if the charge went through".** After three timeouts the true outcome is unknown, yet the design treats it as failed. Add a `PAYMENT_UNKNOWN` status, plus a job or provider webhook that asks the provider for the real outcome and settles the order.

Revised flow:

```mermaid
flowchart TD
    A[POST /orders with cart] --> B[Check stock]
    B --> C[Insert order as PENDING and commit]
    C --> D[Charge with order id as idempotency key]
    D -->|success| E[Mark PAID, commit]
    D -->|declined| F[Mark FAILED, return error]
    D -->|timeout after 3 tries| G[Mark PAYMENT_UNKNOWN]
    G --> H[Reconcile with provider later]
    H --> E
    H --> F
    E --> I[Send confirmation email]
```

## Should decide, but not blocking

- **Overselling:** the stock cache is up to 5 minutes stale and the flow never reserves or decrements stock. Two customers can both buy the last unit and both get charged. Either state that you accept this and how you refund or backorder, or make the 800 ms warehouse call once just before charging.
- **Duplicate submissions:** a double-click or a client retry of `POST /orders` creates two orders and two charges. Accept a client-supplied idempotency key on the endpoint.
- **Email failure:** the doc does not say what happens if the email fails after commit. It should not turn a paid order into an error response; log it and retry later.
- **Test plan:** one happy-path integration test misses where the money is lost. Add integration tests for timeout-then-success, a declined card, a crash between charge and commit, and a duplicate `POST`.
- **Backups:** nightly backups mean a failure can lose up to a day of paid orders. Turning on continuous WAL archiving (point-in-time recovery) closes this.

## What is fine

A single service, a single Postgres instance and a synchronous flow are right for 2,000 orders a day and a team of four. The module boundaries, thin routes, `OrderCheckout` service and logging with order id need no changes.

You can start tomorrow on the modules, the schema (with the extra statuses) and the stock check, provided the three payment fixes go into the doc first.

VERDICT: READY WITH CHANGES
