Enhance the protocol-wide billing total to account for disabled services
Description
GET /api/v1/billing/total in src/index.ts sums requests * priceStroops over every usageStore entry, looking up the price by serviceId. It ignores the servicesDisabled state entirely: usage accrued before a service was disabled still contributes to the outstanding-billing total, and usage against a service that was deleted (price falls back to 0) silently contributes nothing — so the "outstanding billing" figure mixes billable, disabled, and orphaned usage with no breakdown. This issue makes the total transparent about disabled and unpriced usage.
Requirements and context
- Repository scope: Agentpay-Org/Agentpay-backend only.
- Break
GET /api/v1/billing/total into { totalStroops, disabledStroops, unpricedRequests } (or an equivalent breakdown) so callers can see how much of the total comes from disabled or unregistered services.
- Keep the existing
totalStroops field's meaning stable (or document any change explicitly) so dashboards do not silently shift.
- Coordinate with the unknown-service handling and bigint-precision directions rather than re-introducing a silent
?? 0.
- Preserve the response being a single round-trip snapshot.
Suggested execution
- Fork the repo and create a branch
git checkout -b enhancement/payments-87-billing-total-breakdown
- Implement changes
- Write code in: the
GET /api/v1/billing/total handler in src/index.ts.
- Write comprehensive tests in: new
src/billing-total-breakdown.test.ts — disabled-service usage surfaced separately, unregistered usage counted as unpriced, total math correct.
- Add documentation: document the breakdown fields in
README.md.
- Add TSDoc on the handler.
- Validate security assumptions: no per-agent leakage in the aggregate.
- Test and commit
Test and commit
- Run
npm test and npm run lint.
- Cover edge cases: all-enabled, some disabled, some unregistered, empty store.
- Include the full
npm test output in the PR description.
Example commit message
feat: break down the protocol billing total by disabled/unpriced usage
Guidelines
- Minimum 95 percent test coverage for impacted modules.
- Clear, reviewer-focused documentation.
- Timeframe: 96 hours.
Community & contribution rewards
- 💬 Join the AgentPay community on Discord for questions, reviews, and faster merges: https://discord.gg/eXvRKkgcv
- ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.
Enhance the protocol-wide billing total to account for disabled services
Description
GET /api/v1/billing/totalinsrc/index.tssumsrequests * priceStroopsover everyusageStoreentry, looking up the price byserviceId. It ignores theservicesDisabledstate entirely: usage accrued before a service was disabled still contributes to the outstanding-billing total, and usage against a service that was deleted (price falls back to0) silently contributes nothing — so the "outstanding billing" figure mixes billable, disabled, and orphaned usage with no breakdown. This issue makes the total transparent about disabled and unpriced usage.Requirements and context
GET /api/v1/billing/totalinto{ totalStroops, disabledStroops, unpricedRequests }(or an equivalent breakdown) so callers can see how much of the total comes from disabled or unregistered services.totalStroopsfield's meaning stable (or document any change explicitly) so dashboards do not silently shift.?? 0.Suggested execution
git checkout -b enhancement/payments-87-billing-total-breakdownGET /api/v1/billing/totalhandler insrc/index.ts.src/billing-total-breakdown.test.ts— disabled-service usage surfaced separately, unregistered usage counted as unpriced, total math correct.README.md.Test and commit
npm testandnpm run lint.npm testoutput in the PR description.Example commit message
feat: break down the protocol billing total by disabled/unpriced usageGuidelines
Community & contribution rewards