feat(promos): promo codes, admin CRUD and checkout discount (#28) #99
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/kws!99
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/28-promo-codes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #28.
What
/v1/admin/promo-codes(list, create, get, PUT withversion, DELETE soft) behindadmin_portal.administration.manage. Reads areno-storeand includeused.promo_codeonPOST /v1/me/checkout. Inside the sale transaction: look up (case-insensitive, trimmed), lock the code row, check validity window, park, product, currency (fixed codes) and the use limit, thentotalsdoes the maths. The sale recordspromo_code_id(immutable).FOR UPDATErow lock (taken only for limited codes); lock order cart -> promo -> sale; 3 slock_timeoutso a hot code gives a fast retryable 503. Cancel/expiry give the use back; an idempotent replay never takes one.GrandTotal == 0 && SubTotal == Discount). A total that only rounds to 0 is still a 422.promo_code: "this promo code cannot be used" (no oracle for which codes exist).docs/superpowers/plans/2026-10-26-promo-codes.md(12 rulings), OpenAPI + live contract tests, CLAUDE.md and ADR 0005/0011 amendments.Known limits (ADR 0014)
totalsis golden-tested against legacy, left alone).authtest; a 99.9 % code that rounds the total to 0 reports onlines.Deploy
Migration 0020 only. No worker change, no new environment variables.
Verification
make cover: 89.3 % total (minimum 80 %), re-run just before push.make lint0 issues,make contractok,go test -race ./...green (concurrency test with-race -count=5).🤖 Generated with Claude Code