You can start building tomorrow, but first add about six short changes to the doc. The design itself holds up: stock is reserved inside one database transaction, the payment call happens outside any transaction with a stable idempotency key, and orders whose payment result is unknown are handed to a reconciliation job. Nothing needs redesigning. The gaps are in what happens when two pieces of code act on the same order, or when the process crashes partway through. Most of them will lose an email or miscount stock, not take a customer's money twice.

## Order status, as designed and with the missing paths

```mermaid
stateDiagram-v2
    [*] --> PENDING: POST /orders (stock reserved)
    PENDING --> PAID: charge succeeds (request or reconciliation job)
    PENDING --> FAILED: charge declined (request or reconciliation job), stock restored
    PENDING --> PENDING: result unknown, client gets 202
    PENDING --> FAILED: MISSING: provider has no charge for this order
```

## Fix before or while you build

**1. Only change status if the order is still PENDING.** Step 5 (decline) and the reconciliation job can both settle the same order, and both restore stock.
- Case: both instances run the job at the same time (see item 3), or one instance pauses long enough to overlap with the other. Both mark a declined order of 2 units `FAILED`. Expected: stock goes up by 2. Actual: it goes up by 4.
- Fix: `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`. Restore stock only if that update changed a row. This also makes it safe for the request and the job to race.

**2. Say what reconciliation does when the provider has no charge.** The process can crash after step 2 commits but before step 3 makes the charge call.
- Case: the order is `PENDING` and the provider has never seen it. The job asks for its status and gets "not found". Expected: `FAILED`, stock restored. Actual: the doc only defines `PAID` and `FAILED` results, so the order sits until the 30-minute alert fires and holds its stock until someone steps in.
- Fix: treat "not found" as `FAILED` and restore stock. This is only safe if the 2-minute age cutoff is longer than the longest possible request. Write that rule down (see item 6).
- Also confirm the provider really lets you look up a charge by idempotency key. Reconciliation depends on that entirely, and the doc assumes it without saying so.

**3. Run the reconciliation job on only one instance at a time.** With two instances, each run of the job happens twice. Use a Postgres advisory lock, or `SELECT … FOR UPDATE SKIP LOCKED`. Item 1 limits the damage, but you still shouldn't double the calls to the provider.

**4. Make sure every paid order gets its confirmation email.** There are two holes.
- Case A: the job settles an order as `PAID`. Step 4's "queue the email" only exists in the request path, so that customer never gets an email.
- Case B: the process crashes after `PAID` commits but before the email is queued. The email is lost, and nothing goes back to look at `PAID` orders.
- Fix: write an outbox row (a "send this email" record) in the same transaction that sets `PAID`, and do it in both the request path and the job. A worker then sends from that table.

**5. Say where prices come from.** `order_items.unit_price` and `orders.total` exist, but no table holds prices, and the request only sends "the cart".
- Case: a client sends `unit_price: 0.01`. If the server trusts it, you charge one cent.
- Fix: name the price source (a catalog table or service) and compute the total on the server.

**6. Check the worst-case request time against the load balancer.** Four attempts at 5 s each, plus backoff, is about 25–30 s. Confirm the load balancer's idle timeout is longer than that. If it isn't, the client gets a 504 while the server is still charging the card. That's recoverable, because a retry with the same key returns the order, but it's confusing. Keep the 2-minute reconciliation cutoff well above this worst case.

## Smaller items (fine to handle during the build)

- **Idempotency key scope.** Make the unique constraint `(customer_id, idempotency_key)`. With a global constraint, one customer reusing a key could be handed another customer's order. If the same key arrives with a different cart, return `422` instead of the original order.
- **Concurrent duplicate POST.** When two requests with the same key arrive together, the second one fails the unique constraint. Catch that error and return the existing order.
- **Deadlocks.** Sort the SKUs before running the stock updates. Otherwise two carts holding A,B and B,A can deadlock each other.
- **Module boundary.** Step 2 writes to both `stock` (inventory) and `orders` (orders) in one transaction. Decide now how one transaction is shared across those modules, for example passing a unit-of-work object in, so the rule that no module reads another's tables stays true.

## Tests to add

- The reconciliation job settling an order as `PAID`, as `FAILED`, and when the provider says "not found".
- The request path and the job settling the same order at once: stock is restored only once.
- Two concurrent `POST /orders` with the same key.
- Two buyers going for the last unit at the same moment (the current test may only cover one buyer).
- A crash after the reservation commits but before the charge.
- A paid order always produces exactly one outbox row for the email.
- A price sent by the client is ignored.

Items 1–5 are each a sentence or two in the doc plus a test. They are small enough to fold into tomorrow's work, but settle them before writing `OrderCheckout`, not after.

VERDICT: READY WITH CHANGES
