feat: organization wallet top-up by M-Pesa (#53, PR A) #161

Merged
amiryahaya merged 11 commits from feat/partner-wallet-53 into main 2026-11-05 12:58:30 +01:00
Owner

Summary

Issue #53, PR A: an organization tops up its KWS wallet by M-Pesa.

  • Migration 0041: sale type topup_wallet and table wallet_topups (immutable link to the organization), guards on lines and tickets.
  • POST /v1/orgs/{id}/wallet/top-ups (ewallet.top_up, idempotent, purchase rate class, KES 10 to 250,000 in whole shillings) and GET .../top-ups/{transaction_id} (ewallet.view).
  • M-Pesa start, callback and reconcile run unchanged through Settle; completion credits the organization wallet once (key topup:<sale id>) through partnerwallet.Crediter, no tickets or purchase email. A late payment becomes refund_due and is refunded to the organization wallet.
  • Top-ups cannot be paid from a wallet or waived, are hidden from /v1/me, and are excluded from admin sales reports and the Daily Invoice. Email notify.wallet_topup is sent by the worker.

Review

Dual pass (ponytail complexity, then a fresh correctness review). Fixed test-first: top-ups counted as sales in four reports, checkout key shared across organizations, waive of a top-up, missing enum values.

Coverage

make cover: 91.4% (minimum 80%). make lint: 0 issues.

Owner questions [verify]

M-Pesa and KES only; the limits; a late top-up is credited to the organization wallet; which roles may top up; Daily Invoice has no wallet-liability line for top-ups; no staff view of organization wallets; no statement export.

🤖 Generated with Claude Code

## Summary Issue #53, PR A: an organization tops up its KWS wallet by M-Pesa. - Migration 0041: sale type `topup_wallet` and table `wallet_topups` (immutable link to the organization), guards on lines and tickets. - `POST /v1/orgs/{id}/wallet/top-ups` (`ewallet.top_up`, idempotent, `purchase` rate class, KES 10 to 250,000 in whole shillings) and `GET .../top-ups/{transaction_id}` (`ewallet.view`). - M-Pesa start, callback and reconcile run unchanged through `Settle`; completion credits the organization wallet once (key `topup:<sale id>`) through `partnerwallet.Crediter`, no tickets or purchase email. A late payment becomes `refund_due` and is refunded to the organization wallet. - Top-ups cannot be paid from a wallet or waived, are hidden from `/v1/me`, and are excluded from admin sales reports and the Daily Invoice. Email `notify.wallet_topup` is sent by the worker. ## Review Dual pass (ponytail complexity, then a fresh correctness review). Fixed test-first: top-ups counted as sales in four reports, checkout key shared across organizations, waive of a top-up, missing enum values. ## Coverage `make cover`: **91.4%** (minimum 80%). `make lint`: 0 issues. ## Owner questions [verify] M-Pesa and KES only; the limits; a late top-up is credited to the organization wallet; which roles may top up; Daily Invoice has no wallet-liability line for top-ups; no staff view of organization wallets; no statement export. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
fix(wallet-topup): keep top-ups out of sale reports, per-organization checkout key, no waiver (#53)
Some checks failed
ci / changes (pull_request) Successful in 13s
ci / web-ticket (pull_request) Failing after 1m29s
ci / clients (pull_request) Successful in 1m55s
ci / web-partner (pull_request) Successful in 3m36s
ci / web-admin (pull_request) Successful in 6m42s
ci / api (pull_request) Successful in 16m15s
ci / ci-gate (pull_request) Failing after 3s
8ac6bbfe9a
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
fix(ticket): label the new topup_wallet sale type so the order map stays total (#53)
All checks were successful
ci / changes (pull_request) Successful in 28s
ci / clients (pull_request) Successful in 1m59s
ci / web-partner (pull_request) Successful in 7m43s
ci / web-ticket (pull_request) Successful in 11m19s
ci / api (pull_request) Successful in 11m24s
ci / web-admin (pull_request) Successful in 12m24s
ci / ci-gate (pull_request) Successful in 5s
5e4c6f38d1
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/kws!161
No description provided.