Skip to content

feat: add billing dispute resolution flow (#463)#578

Merged
greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
Abba073:feature/dispute-resolution
Jun 29, 2026
Merged

feat: add billing dispute resolution flow (#463)#578
greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
Abba073:feature/dispute-resolution

Conversation

@Abba073

@Abba073 Abba073 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the dispute-resolution flow for failed billing deductions, resolving #463.

Changes

New files:

  • src/services/disputeService.ts — state machine, in-memory store, audit trail
  • src/routes/billing/disputes.ts — 5 REST endpoints with RBAC
  • src/routes/billing/disputes.test.ts — 39 tests

Modified:

  • src/routes/billing.ts — mounts /disputes sub-router

Endpoints

Method Path Auth Description
POST /api/billing/disputes Developer Open dispute (references usage_event_id)
GET /api/billing/disputes Developer List own disputes
GET /api/billing/disputes/:id Developer (owner only) Get dispute + audit trail
POST /api/billing/disputes/:id/resolve Admin Resolve → REFUNDED | UPHELD
GET /api/billing/disputes/admin/all Admin List all disputes

State Machine

OPEN → REFUNDED  (admin)
OPEN → UPHELD    (admin)

Acceptance Criteria

  • States transition correctly (OPEN → REFUNDED | UPHELD; double-resolve returns 409)
  • Audit trail written (dispute_events appended on OPENED and RESOLVED)
  • RBAC enforced (requireAuth for developers, adminAuth for resolve/admin-list)
  • Tests cover all paths (open, list, get, resolve, admin-list, all error branches)

Test Output

Tests:    39 passed, 39 total
Coverage: disputeService.ts 100% | disputes.ts 91.83% (>90% requirement met)

Abba073 added 3 commits June 28, 2026 13:39
Closes CalloraOrg#469

- POST   /api/marketplace/plugins          — register a plugin (auth, Zod manifest validation)
- GET    /api/marketplace/plugins          — list all plugins
- GET    /api/marketplace/plugins/:id      — get single plugin
- POST   /api/marketplace/plugins/:id/install    — install + fire sandboxed hook (auth)
- DELETE /api/marketplace/plugins/:id/install    — uninstall (auth)
- DELETE /api/marketplace/plugins/:id            — remove from registry (auth)

Services:
- pluginManifestSchema: Zod schema (id, name, version, semver, hooks enum)
- InMemoryPluginRepository: list/register/install/uninstall/delete
- executeHook: sandboxed stub (no arbitrary code; validates declared hooks only)
- All state changes audit-logged via logger.audit()

Tests: 46 tests, 97.82% coverage (pluginRegistry.ts at 100%)
OpenAPI: added PluginManifest + PluginRecord schemas and 4 path entries
Closes CalloraOrg#463

Endpoints (all under /api/billing/disputes):
  POST   /                 — developer opens dispute (requireAuth)
  GET    /                 — developer lists own disputes (requireAuth)
  GET    /:id              — developer gets dispute + audit trail (requireAuth)
  POST   /:id/resolve      — admin resolves OPEN→REFUNDED|UPHELD (adminAuth)
  GET    /admin/all        — admin lists all disputes (adminAuth)

State machine: OPEN → REFUNDED | UPHELD
Audit trail: dispute_events appended on every transition
RBAC: requireAuth for developers, adminAuth for admin actions

Tests: 39/39 passing
Coverage: disputeService.ts 100% | disputes.ts 91.83%
@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@Abba073 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me greatest0fallt1me merged commit 5dd073b into CalloraOrg:main Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants