feat(payments): wallet pay, waive and settle groundwork (#30) #97
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!97
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/30-payments"
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 #30.
What
paymentstable (migration 0018): append-only record of money that arrived or was waived. Onesucceededrow per sale (partial unique index),(provider, reference)unique,refund_duefor money that cannot buy tickets (#36 will refund it;refund_due->refundedis the only allowed update). A guard trigger refuses delete/truncate and any other change.POST /v1/me/transactions/{id}/pay. Wallet debit, sale completion and payment row in one transaction; a sale that turns out cancelled returnsErrSaleCancelledand the debit is rolled back. Idempotency-Key required.POST /v1/admin/transactions/{id}/waivewith a written reason (1..500). New permissionadmin_portal.payments.waive, held by Finance Manager and Super Admin through a platform-scope grant only (handler checksHasInOrganization(p, "")). Finance Executive and Park Management cannot waive.Providerinterface andService.Settle. Wrong amount/currency, cancelled/released sale, or a second payment for a completed sale becomes arefund_duerow and the caller still commits. No gateway, callback route or M-Pesa job in this PR.sales.Completer.Lock/Sale,CompleteRequest.Actor/Reason,rest.DecodeBodyKeep,rbac.ContextWithAccess; OpenAPI + live contract test; ADR 0012, CLAUDE.md Payments section, spec R-TXN-2/R-PAY.Lock order: sale -> wallet -> seats -> tickets.
Rulings (author's call, no design round)
(provider, reference)is a replay; it ignores the new event's amount, wallet id and waive reason. A repeat under another provider is 409.Parse; references must be unique per charge.Known gaps
Provider.Name()has no non-test reader yet (kept for #31).DecodeBodyKeeprestores a partial body on decode failure (harmless, undocumented).Deploy notes
KWS_MODE=migrate).KWS_MODE=worker) must be running before checkout goes live (unchanged from #26/#29).Verification
make cover: 90.1% total (minimum 80%)make lint: 0 issues;make contract: okgo test -race ./...: 42 packages pass; new concurrency tests also pass with-count=5🤖 Generated with Claude Code