Yes, you can start building tomorrow. The design is solid. Before or during the first day, fix three things, each a small change to a constraint or a `WHERE` clause. Without them you will get wrong stock counts or one customer's order shown to another.

## What's already right

The hard parts are done well. You commit the stock reservation before calling the payment provider. You reuse the order id as the provider's idempotency key on every retry. "Unknown" is its own outcome (`202` plus a reconciliation job) instead of being treated as a failure. Email can never fail an order. And there's an alert for stuck `PENDING` orders. Most checkout designs miss at least two of these.

## Must fix (small changes)

**1. Only one process may settle an order, and stock comes back only once.** Today the payment request, the reconciliation job on instance A and the same job on instance B can all settle the same order.

- **Example:** a customer buys the last unit, so `available` drops from 1 to 0. The charge times out and the order stays `PENDING`. Both instances run the job, both get "declined" from the provider, both mark the order `FAILED` and both add the unit back. `available` is now 2, but only 1 unit exists.
- **Worse case:** the job marks an order `FAILED` while a slow charge is still running. The charge then succeeds and the order is marked `PAID`, but its stock was already released.
- **Fix:** every status change becomes `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`. Restore stock only when that update changed exactly one row, in the same transaction.

```mermaid
stateDiagram-v2
    [*] --> PENDING: stock reserved
    PENDING --> PAID: charge succeeded (only if still PENDING)
    PENDING --> FAILED: declined or no charge found (only if still PENDING); restore stock once
    PAID --> [*]
    FAILED --> [*]
```

**2. Reconciliation must also restore stock, and must handle "no such charge".** Step 6 settles orders as `PAID` or `FAILED` but never says the stock comes back. If the service crashes between step 2 and step 3, the provider has no record of the charge. Treat that as `FAILED`, using the same guarded transaction as step 5.

**3. Scope the idempotency key to the customer.** Make the unique constraint `(customer_id, idempotency_key)`, not the key alone. Otherwise, if two customers happen to send the same key, the second customer gets the first customer's order back. Also return `422` when a reused key comes with a different cart.

## Worth doing in the first week

- **Lock stock rows in a fixed order.** Sort the SKUs before running the `UPDATE`s. Otherwise two carts holding the same two SKUs in opposite order can deadlock, and one of them fails with a 500.
- **Say where `unit_price` and `total` come from.** If they come from the client's cart, a customer can set their own price. Nothing in the data model holds prices, so name the source the service uses.
- **Add keys and an index:** `stock.sku` as the primary key, a primary key on `order_items`, and an index on `orders (status, created_at)` so the reconciliation query stays fast.
- **Optional, but name the tradeoff:** if the service crashes after committing `PAID` but before queuing the email, that email is lost. At 2,000 orders a day that may be acceptable. If not, a transactional outbox closes the gap: write the email job in the same transaction as the status change.

## Tests to add

Add these to the list in the design:
- Reconciliation finds the charge `PAID`, `FAILED`, or not found.
- Two reconcilers settle the same order, and stock is restored exactly once.
- A slow charge finishes after the reconciler has already settled the order.
- A decline restores stock.
- Two concurrent requests arrive with the same key.
- The same key is reused with a different cart.
- Two carts contain the same SKUs in opposite order.

VERDICT: READY WITH CHANGES
