The design is close to ready. The overall approach is sound: stock is reserved before charging, the payment call is idempotent and made outside any database transaction, and unknown payment results are reconciled later. But two gaps can corrupt data and two leave orders stuck, so fix them in the doc before you start. Each is a small spec change, not a redesign.

## Problems, by severity

**High: the reconciliation job can restore stock twice.**
- You run two instances, and nothing says the job runs on only one. Example: order A is `PENDING` holding 1 unit of SKU X, and the provider reports it declined. Both instances pick up A in the same 5-minute run. Each marks it `FAILED` and each adds 1 back. SKU X ends up with one more unit than you have, so you can oversell.
- The same gap allows a late request-path update to collide with the job.
- **Fix:** every status change must be a guarded update: `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`. Only restore stock or queue the email if that update changed a row. Also run the job on one instance only, for example using a Postgres advisory lock.

**High: the design doesn't say where prices come from.**
- The client sends "the cart", and `unit_price` and `total` are stored. If the prices come from the client, a buyer can pay 0.01 for anything.
- **Fix:** state that prices are read on the server, and say which module owns them.

**Medium-high: the job has no rule for "the provider has no record of this charge".**
- This happens if the instance crashes after committing `PENDING` but before charging, or if every attempt failed before reaching the provider. The job can only settle `PAID` or `FAILED`, so the order stays `PENDING` forever, holding its stock and firing the 30-minute alert.
- **Fix:** define what happens, for example mark it `FAILED` and release the stock after N minutes with no record.
- **To confirm:** check that the provider can look up a charge by idempotency key (your order id). The whole reconciliation step depends on that.

**Medium: a `202` gives the client no way to learn the final result.**
- There is no `GET /orders/{id}` and no notification. Add one.

**Medium: the idempotency key is unique across all customers, and it doesn't check the request body.**
- Customer B reusing a key that customer A already used would get A's order back.
- **Fix:** make it unique on `(customer_id, idempotency_key)`. Return `422` when the same key arrives with a different cart.

**Medium: tests for the riskiest paths are missing.**
- Add tests for:
  - the reconciliation job settling `PAID`, settling `FAILED`, and finding no record
  - two job runs at once, with stock restored exactly once
  - two concurrent `POST /orders` with the same key
  - a decline actually restoring the stock
  - a charge that succeeds and then the `PAID` update fails

**Low-medium: a crash can lose the confirmation email.**
- Step 4 commits `PAID`, then queues the email. A crash between those two steps means no email is sent. The order is still correct, so the impact is customer experience only.
- **Fix:** write a pending-email record in the same transaction that sets `PAID`, and have a worker send it from there.

**Low-medium: step 2 contradicts the module rule.**
- Step 2 updates `stock` and inserts the order in one transaction. That breaks "no module reads another module's tables", unless inventory exposes a reserve function that joins the caller's transaction. Say which one you mean.

**Low:**
- Reserve SKUs in sorted order. Otherwise two carts that lock the same SKUs in opposite order can deadlock.
- Add `CHECK (available >= 0)`, a primary key on `order_items` (`order_id`, `sku`), and foreign keys.
- Say which payment errors are retried. Only timeouts and 5xx errors should be; a decline must never be retried.
- Confirm the worst case for the 4 attempts plus backoff stays well under the job's 2-minute threshold.

## Order status lifecycle with the guarded transitions

```mermaid
stateDiagram-v2
    [*] --> PENDING: stock reserved, order inserted
    PENDING --> PAID: charge succeeded (only if still PENDING)
    PENDING --> FAILED: declined, or no record after N min (only if still PENDING), then restore stock once
    PAID --> [*]: queue confirmation email
    FAILED --> [*]
```

None of these change the architecture. The first four are a few sentences each in the doc, plus the matching tests in your test plan. With those added you can start building tomorrow.

VERDICT: READY WITH CHANGES
