feat: partner itinerary payments, pay API (#52, PR A) #158

Merged
amiryahaya merged 10 commits from feat/partner-payments-52 into main 2026-11-04 14:19:52 +01:00
Owner

What

PR A of #52 (pay API). An organization pays an itinerary's sales whole, from its wallet or by M-Pesa; the itinerary status follows its sales; refunds, emails and PDFs for itinerary sales go to the organization.

  • Migration 0039: payment_method may change while a sale is pending (Completer.SetPaymentMethod).
  • itineraries.Derive + sales.StatusSync hook (runs inside every complete/cancel transaction).
  • payments.Service.PayAsOrganization, mpesa.Starter.StartForOrganization, org-aware Refund.
  • partnerpay: POST /v1/orgs/{id}/itineraries/{iid}/sales/{tid}/pay[/mpesa] (make_payment, Purchase rate class).
  • Org ticket/receipt PDFs (itinerary.view, Heavy class); itinerary sale emails go to the organization.
  • /v1/me pay and M-Pesa start now refuse itinerary sales (review finding).

Design/plan: docs/superpowers/specs|plans/2026-11-04-partner-payments*.md. Cancel/refund is PR B; web, ADR 0034 and CLAUDE.md are PR C.

Verification

  • make cover: total 91.5% (minimum 80%); make lint: 0 issues; contract tests pass.
  • Dual-pass review done: ponytail (no must-fix) and a fresh Opus correctness review (1 Important fixed test-first, 1 hook-busy mapping fixed).

Rulings / deferred

Method switches are not logged (spec corrected). Org PDFs use the Heavy class. Deferred minors: failed M-Pesa leaves the sale processing until expiry; duplicate ownership check; disabled org gets 403 not 409.

🤖 Generated with Claude Code

## What PR A of #52 (pay API). An organization pays an itinerary's sales whole, from its wallet or by M-Pesa; the itinerary status follows its sales; refunds, emails and PDFs for itinerary sales go to the organization. - Migration 0039: `payment_method` may change while a sale is pending (`Completer.SetPaymentMethod`). - `itineraries.Derive` + `sales.StatusSync` hook (runs inside every complete/cancel transaction). - `payments.Service.PayAsOrganization`, `mpesa.Starter.StartForOrganization`, org-aware `Refund`. - `partnerpay`: `POST /v1/orgs/{id}/itineraries/{iid}/sales/{tid}/pay[/mpesa]` (`make_payment`, Purchase rate class). - Org ticket/receipt PDFs (`itinerary.view`, Heavy class); itinerary sale emails go to the organization. - `/v1/me` pay and M-Pesa start now refuse itinerary sales (review finding). Design/plan: `docs/superpowers/specs|plans/2026-11-04-partner-payments*.md`. Cancel/refund is PR B; web, ADR 0034 and CLAUDE.md are PR C. ## Verification - `make cover`: **total 91.5%** (minimum 80%); `make lint`: 0 issues; contract tests pass. - Dual-pass review done: ponytail (no must-fix) and a fresh Opus correctness review (1 Important fixed test-first, 1 hook-busy mapping fixed). ## Rulings / deferred Method switches are not logged (spec corrected). Org PDFs use the Heavy class. Deferred minors: failed M-Pesa leaves the sale `processing` until expiry; duplicate ownership check; disabled org gets 403 not 409. 🤖 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(payments): itinerary sales are paid only by their organization; hook busy is 503 (#52)
All checks were successful
ci / changes (pull_request) Successful in 22s
ci / clients (pull_request) Successful in 1m47s
ci / web-partner (pull_request) Successful in 3m43s
ci / web-ticket (pull_request) Successful in 8m1s
ci / web-admin (pull_request) Successful in 8m50s
ci / api (pull_request) Successful in 11m31s
ci / ci-gate (pull_request) Successful in 4s
1f7b235423
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!158
No description provided.