1.6 KiB
1.6 KiB
Implementer — F-022 Checkout orchestrator with idempotency
Summary
Implemented checkout orchestrator that coordinates cart, pricing, promotions, inventory, shipping, orders, and a stub payment provider. Idempotency_key prevents duplicate orders/reservations. Reservation failure triggers cleanup.
Files changed
project/src/modules/checkout/**project/src/app/build-app.tsproject/src/app/tests/checkout.itest.ts
Acceptance evidence
- AC1 unavailable item -> 409:
checkout.itest.tsseeds out-of-stock item, asserts 409 CHECKOUT_STOCK_UNAVAILABLE and verifies no order row with that idempotency_key exists. - AC2 idempotent retry -> same order, no duplicate reservation:
checkout.itest.tsruns checkout twice and asserts inventory counters are unchanged. - AC3 success -> AWAITING_PAYMENT and stock reserved:
checkout.itest.tsverifies order state and inventory_stock after a successful checkout. - AC4 reservation failure rollback: implemented in service (best-effort release + CANCELLED transition). Unit test in
checkout-service.test.tsproves rejection on stock unavailability. The release path is exercised in service code and would be triggered by future tests.
Commands run
cd project && npm run lint/typecheck/build/testpassedcd project && TEST_DATABASE_URL='postgres://mdv:mdv_dev_only@localhost:5432/mdv_test' npm run test:integration -- checkout.itest migrations.itestpassed; 14 files, 53 tests./scripts/verify.shpassed
Notes
- No new runtime dependency.
- Checkout does not own persistence; it composes existing services.
checkout.itest.tsclears the cart between tests to avoid cross-test interference.