The design is sound enough to start building tomorrow, provided you make two small additions first: both are places where the doc leaves a gap that can corrupt stock or strand an order. The core choices need no change: atomic stock reservation, charging outside the transaction, the order id as the provider's idempotency key, and a reconciliation job for unknown outcomes.

## Fix before building

**1. An order can be settled twice, which credits stock twice.**
Steps 5 and 6 do not say the status change is conditional on the order still being `PENDING`. With two instances, the reconciliation job runs on both.
- **Case:** order A holds 1 unit of SKU X and its charge was declined. Both instances' jobs pick up A in the same run, and both mark it `FAILED` and restore stock.
- **Wrong result:** `available` goes up by 2, so the service later sells a unit that does not exist.
- **Expected:** it goes up by 1.
- **Fix:** make every settlement `UPDATE orders SET status = ... WHERE id = :id AND status = 'PENDING'`, and restore stock or queue the email only if that update changed a row. This also covers the request handler and the job racing each other.

**2. Reconciliation has no rule for "the provider has never heard of this order".**
Step 6 says the job settles orders as `PAID` or `FAILED` based on the provider's charge status.
- **Case:** the instance crashes after step 2 commits and before the charge call in step 3. The provider has no charge for that order.
- **Wrong result:** the order stays `PENDING` and its stock stays reserved until the 30-minute alert fires and someone fixes it by hand.
- **Expected:** the order is marked `FAILED` and stock is restored.
- **Fix:** state that "not found" settles as `FAILED`, and that "still processing" leaves the order `PENDING`.
- **Check with the provider:** confirm its API can look up a charge by your order id; the design depends on it.
- **Timing constraint to write down:** the worst-case charge attempt window is roughly 27 s (4 attempts of 5 s plus backoff). It must stay well under the 2-minute reconciliation threshold, or "not found" could fail an order whose charge is still in flight.

## Decide as you build

- **Price source:** the doc does not say where `unit_price` and `total` come from. They must be computed server-side, not taken from the cart.
- **Idempotency key scope:** make the unique constraint `(customer_id, idempotency_key)`, so one customer's key can never return another customer's order. Decide what a repeated key with a different cart returns; I suggest `422`.
- **Deadlocks:** two carts containing the same SKUs in opposite order can deadlock in step 2. Update stock rows in sorted SKU order.
- **Email after reconciliation:** step 4 queues the confirmation email, but step 6 does not say the job does too. Also, a crash between the `PAID` commit and the queueing loses the email; say whether that is acceptable.
- **Client after `202`:** the client needs a `GET /orders/{id}` to learn the final outcome, and the doc does not list one.
- **Module boundary:** steps 2 and 5 change `stock` and `orders` in one transaction, while the code structure says no module touches another's tables. State that the inventory module exposes reserve and restore functions that run inside the caller's transaction.
- **Schema:** add primary keys, a `CHECK (available >= 0)` on `stock`, and columns for the provider's charge id and failure reason on `orders`.
- **Scope:** state explicitly that refunds and cancellations are out of scope, since there is no status for them.

## Test plan gaps

The listed integration tests cover the request path only. Add these, written first:

- **Reconciliation outcomes:** one test each for paid, declined, not found and still processing.
- **Double settlement:** two reconciliation runs on the same order restore stock once.
- **Concurrent last unit:** two simultaneous buyers of the last unit get one success and one `409`. The listed "buying the last unit" test reads as a single buyer.
- **Concurrent duplicate request:** two simultaneous `POST /orders` with the same key produce one order and one reservation.
- **Crash recovery:** a crash after reservation but before the charge ends with the order `FAILED` and stock restored.

VERDICT: READY WITH CHANGES
