Not as written, but it is close: the overall shape is right, and four specific changes to the design need to land before you build. Three of them are correctness bugs that would double-charge customers, create duplicate orders, or oversell stock; the fourth is the money column type.

## Must fix before building

**1. Payment retries can charge the customer twice (step 3).**
The provider key is `<order id>-<attempt number>`, so every retry looks like a new charge to the provider.
- **Case:** attempt 1 succeeds at the provider but the response takes longer than 5 s. The service retries with key `…-2`, and the provider charges again.
- **Expected:** one charge per order.
- **Fix:** send the same key (the order id) on every attempt, and trace attempts with a separate metadata field or the logs.
- This also fixes reconciliation, which otherwise has no single charge to look up.

**2. Duplicate `POST /orders` creates two orders (step 1).**
Each instance keeps its seen keys in its own local map, and there are two instances behind the load balancer.
- **Case:** the client times out and retries, and the retry lands on the other instance. That instance has not seen the key, so it creates a second order, decrements stock again and charges again. A restart loses the map the same way.
- **Expected:** the retry returns the first order.
- **Fix:** add an `idempotency_key` column to `orders` with a unique constraint, inserted in the step 2 transaction. On a conflict, return the existing order.

**3. Two concurrent buyers can both get the last unit (step 2).**
The service reads `available`, then writes `available - quantity`. Under Postgres's default isolation, a transaction does not stop another from reading the same value.
- **Case:** `available = 1`. Requests A and B both read 1, both write 0, and both commit, so two orders are placed for one unit.
- **Expected:** one succeeds and the other gets `409`.
- **Fix:** use a conditional update, `UPDATE stock SET available = available - $q WHERE sku = $sku AND available >= $q`, and treat zero rows updated as short. Update the SKUs in sorted order to avoid deadlocks on multi-item carts, and add `CHECK (available >= 0)` as a backstop.

**4. Money is stored as `double precision`.**
Floats cannot represent most decimal amounts exactly, so totals drift (0.1 + 0.2 ≠ 0.3) and will not match the provider's figures. Use integer minor units (cents) or `numeric` for `total` and `unit_price`.

## Should fix, can be done during the build

- **Guard the status changes.** Steps 4, 5 and 6 can touch the same order, and the reconciliation job may run on both instances. Without a guard, a `FAILED` settlement could restore stock twice. Make each change `UPDATE … WHERE status = 'PENDING'` and only restore stock if a row changed.
- **Reconciliation when the provider has no charge.** If an instance crashes after step 2 commits but before the charge call, the provider has no record of the order. The design only says "settles as `PAID` or `FAILED`"; state that "not found" means `FAILED` plus stock restore.
- **Confirmation email can be lost.** A crash between the `PAID` commit and queueing the email means it is never sent. Write the email job in the same transaction as `PAID` (an outbox table), or have reconciliation catch it.
- **Constraints are not stated.** Add primary keys, the foreign key on `order_items.order_id`, and a `CHECK` on `status`.
- **The `202` path.** State how the client learns the result, presumably by polling `GET /orders/{id}`.

## Test plan gaps

The listed tests would pass even with bugs 1 to 3 present. Add:
- Timeout where the first charge actually succeeded: assert the fake provider recorded exactly one charge.
- Duplicate `POST /orders` sent to two different instances, or to a restarted one.
- Two concurrent requests for the last unit, not one sequential request.
- Reconciliation: provider says paid, declined, and not found, plus two reconcilers running at once.
- A crash between step 2 and step 3.

## What is already good

Keeping the payment call outside the database transaction, the `PENDING` state with a reconciliation job, the email never failing the order, the module boundaries and the 30-minute alert are all sound. At 2,000 orders a day, one Postgres database is plenty.

VERDICT: READY WITH CHANGES
