The design is sound and right-sized for 2,000 orders a day, but it is not quite ready to build as written: the reconciliation job in step 6 is underspecified in ways that can corrupt stock or strand a paid customer. Fixing that is a few paragraphs of design, not a rework, so you can still start tomorrow.

## Must fix before building

**1. The reconciliation job can restore stock twice, or never.**
Step 6 says the job settles orders as `PAID` or `FAILED`, but not that `FAILED` restores stock, and nothing guards the status change.
- **If it does not restore stock:** every order that fails through reconciliation permanently loses its reserved units.
- **If it does:** with two instances, both run the job, both see order A as `PENDING`, both get "declined" from the provider, and both restore stock. One unit of a SKU was reserved, two are returned, and you oversell by one.
- **Fix:** make every status change conditional (`UPDATE orders SET status = 'FAILED' WHERE id = :id AND status = 'PENDING'`) and restore stock in the same transaction only if that update changed a row. Use the same code path for step 5 and the job.

**2. The job has no rule for "the provider has never heard of this order".**
- **Failing case:** the instance crashes after step 2 commits and before the charge call in step 3. The order is `PENDING`, stock is reserved, and the provider returns "not found". The design only allows `PAID` or `FAILED`, so the order sits until the 30-minute alert, forever.
- **Fix:** treat "not found" as `FAILED` and restore stock.
- **Residual risk:** a charge request that reaches the provider late could then succeed against an order you already failed. Either cancel or void the charge at the provider when failing, or have the job refund any charge it finds on a `FAILED` order.

**3. The idempotency key is unique globally, not per customer.**
- **Failing case:** customer B sends a key that customer A already used, and gets customer A's order back instead of a new one.
- **Fix:** make the unique constraint `(customer_id, idempotency_key)`.
- **Also specify:** two simultaneous requests with the same key. The second insert hits the constraint, so the service must roll back its stock reservation and return the existing order, not a `500`.

**4. The design does not say where prices come from.**
There is no price table, and step 1 says the client sends "the cart". If `unit_price` comes from the client, a customer can set their own price. State that prices are looked up server-side and that `total` is computed by the service.

## Fix while building

- **Deadlocks in step 2:** two orders reserving SKUs X and Y in opposite order can deadlock, and Postgres will abort one as an error. Update stock rows in sorted SKU order.
- **Lost confirmation email:** a crash between the `PAID` commit and queuing the email in step 4 means the email is never sent. Write the email job in the same transaction as the `PAID` update, or have the job catch `PAID` orders with no email.
- **Missing constraints:** add primary keys, `CHECK (available >= 0)` on `stock`, a `CHECK` on `status`, and an index on `(status, created_at)` for the job.
- **Request duration:** step 3 can hold the request for 20 seconds or more (four 5-second attempts plus backoff). Confirm the load balancer and client timeouts exceed that.

## Test plan gaps

The listed tests cover the request path well. Add:
- Reconciliation: provider says paid, declined, and not found, plus two job runs on the same order at once.
- Two simultaneous buyers for the last unit, and two simultaneous `POST /orders` with the same key.
- A crash after reservation but before the charge.

## What is already right

- The charge happens outside the database transaction.
- The order id is the provider's idempotency key, so retries cannot double-charge.
- The stock reservation is a single conditional update, so it cannot go negative.
- A failed email never fails the order.

VERDICT: READY WITH CHANGES
