The design is close: you can start building tomorrow if you first settle four points that are cheap to decide now and expensive to change later. The core of the checkout flow is solid. You reserve stock and create the order in one transaction, call the payment provider outside any transaction with a stable idempotency key, treat "unknown" as its own outcome, and use a reconciliation job as the safety net. Your scale (2,000 orders a day, two instances) doesn't call for anything heavier.

## Settle before building

**1. Two instances can settle the same order twice.** The reconciliation job runs on both instances, and nothing in the design stops a second settlement.
- *Case:* order 42 is `PENDING` with 1 unit reserved, and the provider reports it declined. Both instances' jobs pick it up, and each marks it `FAILED` and adds the unit back. Stock goes up by 2; it should go up by 1. A late answer from the request path can collide with the job in the same way.
- *Fix:* allow a status change only from `PENDING` (`UPDATE orders SET status = … WHERE id = :id AND status = 'PENDING'`). Restore stock only if that update changed a row, in the same transaction. Steps 4, 5 and the job should all go through this one transition function.

```mermaid
stateDiagram-v2
    [*] --> PENDING: stock reserved
    PENDING --> PAID: charge succeeded
    PENDING --> FAILED: declined (stock restored once)
    PAID --> [*]
    FAILED --> [*]
```

**2. The job doesn't say what to do when the provider has no record of the charge.** If every attempt timed out before reaching the provider, a status lookup returns "not found", which is neither `PAID` nor `FAILED`. Pick a rule. I suggest: after N minutes with no record, mark the order `FAILED` and restore its stock. You could retry the charge instead, but then the job charges cards with no customer present.

**3. The one-transaction rule conflicts with the module boundary.** Step 2 updates `stock` and inserts into `orders` in one transaction. The code-structure section says no module reads another module's tables. Decide how the inventory module joins the orders transaction. The usual answer is that `OrderCheckout` opens the transaction and passes it to `inventory.reserve(tx, items)` and `orders.create(tx, …)`. Settle this before the module layout hardens.

**4. Concurrent duplicate requests.** If the same `Idempotency-Key` arrives twice at the same moment, the second insert hits the unique constraint. That's a database error, not a lookup. Catch it, roll back (which also undoes that request's stock decrement), and return the existing order. Also decide what happens when a reused key arrives with a different cart. Returning `422` is common.

## Smaller items (fine to handle during the build)
- **Deadlocks:** reserve SKUs in sorted order. Otherwise two carts holding the same SKUs in different orders can deadlock each other.
- **Lost confirmation emails:** the service commits `PAID` and then queues the email. A crash between those two steps loses the email. You've accepted that emails never fail an order, but if they must always be sent, write the queue entry in the same transaction (the "outbox" pattern).
- **Where prices come from:** confirm that `unit_price` and `total` are computed on the server, not taken from the client's cart.
- **Client after a `202`:** say how the client learns the final result, for example by polling `GET /orders/{id}`.
- **Tests to add:**
  - reconciliation settling to `PAID`
  - reconciliation settling to `FAILED`, with stock restored once
  - the provider having no record of the charge
  - two jobs racing on one order
  - concurrent duplicate `POST /orders`
  - a decline restoring stock
  - a reused key with a different cart

VERDICT: READY WITH CHANGES
