The design is sound enough to start building tomorrow, provided you fold four changes into it first; none of them alters the overall shape. The core is right: stock is reserved atomically, the charge happens outside any transaction with the order id as the provider idempotency key, and a reconciliation job settles unknown outcomes.

## Fix before building

**1. High: stock can be restored twice for the same order.**
Nothing says a status change only applies if the order is still `PENDING`, or that the reconciliation job runs on only one of the two instances.
- **Case:** an order for 1 unit of sku A stays `PENDING` after a timeout, and the job on both instances picks it up and sees "declined".
- **Wrong output:** both mark it `FAILED` and both add 1 back, so `available` is one higher than the real stock and you oversell later.
- **Expected:** stock goes back once.
- **Fix:** make every transition `UPDATE orders SET status = … WHERE id = :id AND status = 'PENDING'`, and restore stock or queue the email only when that update changed a row. This also covers the job overlapping with a slow request in steps 4 and 5.

**2. High if prices come from the client, otherwise a documentation gap: the source of `unit_price` and `total` is unstated.**
Step 1 says the client sends "the cart".
- **Case:** if the cart carries prices, a client can post `unit_price: 0.01` for a 500.00 item and be charged 0.01.
- **Fix:** state that the server looks up prices and computes `total`, and name which module owns prices.

**3. Medium: the reconciliation job only handles two provider answers.**
Step 6 says it settles orders as `PAID` or `FAILED`, but the provider can also answer "no such charge" or "still processing".
- **Case:** the instance crashes after step 2 commits and before step 3 sends anything. The provider has no record, so the order stays `PENDING` and holds stock until the 30-minute alert.
- **Fix:** "no such charge" on an order older than the retry window becomes `FAILED` with stock restored, ideally after a void/cancel call so a late charge cannot land. "Still processing" stays `PENDING`.

**4. Medium: the idempotency key's uniqueness scope is unstated.**
- **Case:** if the key is unique globally, customer B sending a key that customer A already used gets customer A's order back.
- **Fix:** make the constraint unique on `(customer_id, idempotency_key)`. Also return `422` when the same key arrives with a different cart.

## Can be fixed during the build

- **Medium: the confirmation email can be lost or never sent.** A crash between the `PAID` commit and the queueing in step 4 drops it, and the design does not say the reconciliation job queues an email when it settles an order as `PAID`. Either write the email request in the same transaction as `PAID` (an outbox table) or have the job send it.
- **Medium: the test list misses the riskiest paths.** Add tests for:
  - the reconciliation job, for each provider answer, and run twice on the same order;
  - two concurrent buyers for the last unit;
  - two concurrent `POST /orders` with the same key;
  - stock restored after a decline;
  - a crash between charge and `PAID`.
- **Low: two orders can deadlock.** One order reserving skus A then B and another reserving B then A can deadlock; Postgres aborts one with an error. Reserve in sorted sku order.
- **Low: missing constraints.** Add a primary key on `order_items (order_id, sku)`, merging duplicate skus in a cart. Add `CHECK (available >= 0)` on `stock` and a `CHECK` on `status`.
- **Low: the request can outlast the load balancer.** Four attempts at 5 s plus backoff can hold the request for about 30 s. Confirm the load balancer timeout is longer, or cut the retries and let the `202` path take over sooner.
- **Low: retry after a decline is undocumented.** Reusing the same key returns the `FAILED` order forever, so say that the client must send a new key.

VERDICT: READY WITH CHANGES
