The design is ready to build from tomorrow with one change. The fix is small: make every status change conditional on the order still being `PENDING`. Without that, stock can be counted back twice and you could oversell.

**What already works well**
- **No double charges by design.** The order id goes to the provider as its idempotency key, and the `Idempotency-Key` column has a unique constraint. Together they cover client retries and your own retries.
- **Stock can't go negative.** The `UPDATE ... WHERE available >= :qty` check handles "last unit" races without extra locking.
- **The payment call happens outside any transaction.** A slow provider won't hold database locks.
- **Unknown payment results are handled.** Returning `202`, reconciling later and alerting after 30 minutes is the right approach. Many designs miss this case entirely.
- **The email can't fail the order**, and the module boundaries and thin routes match how you want the code organised.

**The one change to make before you build**

Two code paths can settle the same order: the live request (steps 4–5) and the reconciliation job (step 6). Nothing stops both from acting on it.

Concrete case: the job runs on both service instances. An order for 1 unit of SKU `A` has been `PENDING` for 3 minutes, so stock for `A` is 0. Both instances' jobs pick it up and the provider says "declined". Each instance marks the order `FAILED` and restores 1 unit. Stock ends at **2** when it should be **1**, and you sell a unit you don't have. A live request that was stalled past 2 minutes can collide with the job the same way.

Fix, building on your existing flow: put all settling in one function that both paths call.

```mermaid
stateDiagram-v2
    [*] --> PENDING: POST /orders (stock reserved)
    PENDING --> PAID: settle(PAID), only if still PENDING; then queue email
    PENDING --> FAILED: settle(FAILED), only if still PENDING; restore stock in same transaction
    PAID --> [*]
    FAILED --> [*]
```

- `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`. Restore stock or queue the email only if that update changed a row. If it changed nothing, the order was already settled: log it and move on. If the request path wanted `PAID` but finds the order `FAILED`, the customer has paid for a failed order, so trigger an alert.
- The same function also covers a gap in step 6: as written, an order the job settles as `PAID` never gets its confirmation email.

**Decide on day 1 (small)**
- **What the job does when the provider has no record of the charge.** This happens when the service crashed between steps 2 and 3. Probably: settle as `FAILED`.
- **How step 2's single transaction fits "no module reads another module's tables".** One option: inventory exposes `reserve(tx, items)` and orders passes in its transaction. That keeps the rule and the atomicity.

**Tests to add to your list** (write these first)
- Reconciliation for each outcome: paid, declined, and provider has no record.
- The job and a live request settling the same order. Stock is restored exactly once.
- Two buyers going for the last unit at the same time: one gets the order, the other gets `409`.
- The same `Idempotency-Key` sent twice at the same moment: one order, with stock reserved once.

VERDICT: READY WITH CHANGES
