The design is close, and you can start building tomorrow. Most of it is solid: reserving stock with a conditional `UPDATE`, calling the payment provider outside the database transaction, using the order id as the provider's idempotency key, and having a reconciliation job plus an alert for stuck orders. That's the hard part, and you've got it right. There are three gaps that would cause wrong data in production, each a few lines in the doc. Fix them before you write the code that changes order status.

## Fix before building

**1. Orders settled as `FAILED` by the reconciliation job never get their stock back.**
Step 5 restores stock when a card is declined. Step 6 only says the job "settles them as `PAID` or `FAILED`."
- *Case:* a customer buys the last unit, the charge times out on every attempt, and later the provider reports it declined. The job marks the order `FAILED`, but `available` stays at 0, so that unit can never be sold.
- *Fix:* define one "fail order" operation that sets `FAILED` and restores stock in one transaction. Use it in both step 5 and step 6.

**2. Two code paths can settle the same order, which can restore stock twice.**
You run two instances, and as written the 5-minute job runs on both. A slow request can also overlap with the job.
- *Case:* both instances pick up the same declined `PENDING` order. Each one marks it `FAILED` and adds the quantity back, so `available` ends up higher than real stock and you oversell later.
- *Fix:* make every status change conditional, e.g. `UPDATE orders SET status = 'FAILED' WHERE id = :id AND status = 'PENDING'`. Only restore stock if that update changed a row. Also stop the job running on both instances at once, with a Postgres advisory lock or `SELECT … FOR UPDATE SKIP LOCKED`.

**3. The doc doesn't cover a provider answer of "no such charge."**
- *Case:* an instance crashes after step 2 commits but before the charge is sent. The provider has no record of the charge, and the order matches neither `PAID` nor `FAILED`, so it sits in `PENDING` until the 30-minute alert fires.
- *Fix:* say that "not found" means `FAILED` plus stock restored, using the operation from fix 1.

Here is the order lifecycle once those fixes are in:

```mermaid
stateDiagram-v2
    [*] --> PENDING: stock reserved, order inserted
    PENDING --> PAID: charge succeeded (request or reconciliation job)
    PENDING --> FAILED: declined or charge not found (stock restored)
    PAID --> [*]
    FAILED --> [*]
```

Every arrow fires only if the order is still `PENDING` at that moment.

## Worth a line in the doc, but they don't block you

- **Where prices come from.** "The client sends the cart." Confirm that `unit_price` and `total` are looked up on the server, not taken from the request. Otherwise a client can set its own price.
- **What the client does after a `202`.** It needs a way to find out the final result, e.g. `GET /orders/{id}`.
- **Confirmation email when the job settles an order as `PAID`.** Step 4 only queues it on the request path. If the instance crashes between commit and enqueue, the email is lost. At 200 to 2,000 orders a day you can accept that for now, but write it down as known debt, with an outbox table as the later fix.
- **Reusing an idempotency key with a different cart.** Decide whether that returns the original order or a `422`.

## Tests to add to the list

- The reconciliation job settles an order as `PAID`, as `FAILED` (stock restored), and as "charge not found."
- The job and a late request both try to settle the same order, and stock is restored exactly once.
- Two concurrent requests for the last unit: one succeeds and one gets `409`. Your current "buying the last unit" test is sequential.
- Two concurrent `POST /orders` with the same key produce one order and one charge.

Your module split, thin routes and the `OrderCheckout` class fit all of this without changes. The fixes are a shared "fail order" operation, conditional updates and a lock on the job.

VERDICT: READY WITH CHANGES
