The design is solid, and most of it can be built as written tomorrow. Before you code the reconciliation job, settle three small things; the rest can wait or go in during the build. This is about half a day of design work, not a rework.

## What's already strong
- **Stock reservation** is a single conditional `UPDATE ... WHERE available >= :qty`, so you can't oversell.
- **No double charges:** sending the order id as the provider's idempotency key covers retries.
- **Payment call outside the transaction.** You don't hold database locks while waiting on the network.
- **Unknown payment results are handled** with a `202`, a reconciliation job and a 30-minute alert. Many designs skip this case.
- **Email can't fail an order,** and the structure (thin routes, an `OrderCheckout` service class, module boundaries) fits a team of four.

## Fix before building

**1. Status changes must only happen from `PENDING`, and only one reconciler should run.**
Both instances will probably run the 5-minute job. Here's what goes wrong: an order for 1 unit of SKU-A gets declined, but the request path timed out. Both reconcilers pick it up on the same run, and each one marks it `FAILED` and restores stock. SKU-A's `available` goes up by **2 instead of 1**, so you later sell a unit you don't have.
Fix: `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`, and only restore stock or queue the email if that update changed a row. For the job, either run it on one instance only or select orders with `FOR UPDATE SKIP LOCKED`. The conditional update also protects you when the request path and the reconciler overlap.

**2. Say what the reconciler does after it decides.**
Step 6 says it "settles them as PAID or FAILED". Spell out that this follows the same steps as 4 and 5: restore stock when it fails, queue the email when it's paid. Also decide what happens when the provider says **"no such charge"**, for example because the service crashed after inserting the order but before charging. My suggestion is to treat it as `FAILED` and restore the stock. The retries finish well under the 2-minute threshold, so a late charge is unlikely.

**3. Prices come from the server, not the cart.**
The data model has no price source. If `unit_price` and `total` come from the request, a client can send `unit_price: 0.01`. Add one line saying where prices are looked up.

## Small things to do during the build
- **Sort the cart by SKU before reserving stock.** Otherwise orders `[A, B]` and `[B, A]` arriving together can deadlock in Postgres, and one of them gets a 500.
- **Inventory and orders share one transaction in step 2,** so the inventory module needs to accept a transaction passed in from outside. That's fine; just make it a deliberate part of the module's interface.
- **Repeated `Idempotency-Key` with a different cart:** return `422` rather than the old order.
- **Constraints:** primary key on `stock.sku`, `CHECK (available >= 0)`, and a primary key on `order_items`.
- **Status after `202`:** if the client is expected to poll, you need `GET /orders/:id`.
- **Optional:** write the email job in the same transaction that marks the order `PAID`. Right now a crash between the commit and the enqueue loses the email (not the order).

## Tests to add
The current list covers the request path well. Add tests for the reconciler: pending→paid (sends the email), pending→failed (restores stock), provider says "not found", two reconcilers running at once (stock restored once), and two identical `POST /orders` at the same time.

```mermaid
stateDiagram-v2
    [*] --> PENDING: stock reserved
    PENDING --> PAID: charge OK (request or reconciler) → queue email
    PENDING --> FAILED: declined / not found (request or reconciler) → restore stock
    note right of PENDING: every move allowed only from PENDING
```

VERDICT: READY WITH CHANGES
