Skip to content

[codex] Reject unknown services in billing#215

Open
pq198363-ops wants to merge 1 commit into
Agentpay-Org:mainfrom
pq198363-ops:bounty-40-reject-unknown-service
Open

[codex] Reject unknown services in billing#215
pq198363-ops wants to merge 1 commit into
Agentpay-Org:mainfrom
pq198363-ops:bounty-40-reject-unknown-service

Conversation

@pq198363-ops

Copy link
Copy Markdown

Fixes #40.

Summary

  • returns structured 404 not_found from GET /api/v1/billing/:agent/:serviceId when the service is not registered
  • returns structured 404 not_found from POST /api/v1/settle for unknown services before touching the usage accumulator
  • preserves registered zero-price service behavior and existing success response shapes
  • documents the behavior in README and the changelog endpoint

Verification

  • RED: npm run build; $env:NODE_ENV='test'; node --test dist/unknown-service-billing.test.js failed before implementation because unknown service billing and settlement returned 200.
  • GREEN focused: npm run build; $env:NODE_ENV='test'; node --test dist/unknown-service-billing.test.js passed 3 tests.
  • npx prettier --check README.md src/routes/usage.ts src/routes/meta.ts src/unknown-service-billing.test.ts
  • npm run lint
  • clean dist/, then npm run build
  • $env:NODE_ENV='test'; node --test dist/*.test.js dist/**/*.test.js passed 92 tests across 11 suites.
  • git diff --check

Data integrity note

The settlement path now verifies the service exists before reading and resetting the usage key, so an unknown service cannot drain metered usage at a zero price. Registered services with priceStroops: 0 still quote and settle successfully.

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.

Return 404 from settle and billing when the service is unregistered instead of silently pricing at zero

1 participant