frontier icon indicating copy to clipboard operation
frontier copied to clipboard

refactor(billing): Billing simplification entitlement usage

Open whoAbhishekSah opened this issue 1 month ago • 2 comments

Summary

Simplify billing entitlement and usage APIs by automatically inferring billing_id from org_id. Clients now only need to provide org_id when calling these RPCs.

Changes

Proto Updates

  • Deprecated billing_id and project_id fields in:
    • CheckFeatureEntitlementRequest
    • CreateBillingUsageRequest
    • RevertBillingUsageRequest
  • Updated proton ref to 4144445eb0f9cbd1a801a3d0aa5cfce4cc0ea551

Backend Updates

All handlers now always fetch billing_id from org_id:

  • CheckFeatureEntitlement: Uses customerService.GetByOrgID()
  • CreateBillingUsage: Uses customerService.GetByOrgID()
  • RevertBillingUsage: Uses customerService.GetByOrgID()

Removed ensureBillingAccountBelongToOrg validation from CreateBillingUsage authorization interceptor (now redundant).

Error Handling

  • ErrNotFound: Empty response for CheckFeatureEntitlement, CodeNotFound for others
  • ErrInvalidUUID/ErrInvalidID: CodeInvalidArgument
  • Other errors: CodeInternal with logging

Benefits

  • Simpler API: Single required parameter (org_id)
  • More secure: Users cannot provide arbitrary billing_id
  • Consistent: Same behavior across all requests
  • Cleaner code: No conditional logic for inferring billing_id

Breaking Changes

None - deprecated fields are still accepted for backward compatibility but ignored.

whoAbhishekSah avatar Dec 03 '25 08:12 whoAbhishekSah

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
frontier Ready Ready Preview Comment Dec 4, 2025 5:01am

vercel[bot] avatar Dec 03 '25 08:12 vercel[bot]

Pull Request Test Coverage Report for Build 19918211554

Details

  • 18 of 45 (40.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 37.645%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/api/v1beta1connect/billing_check.go 12 15 80.0%
internal/api/v1beta1connect/billing_usage.go 6 30 20.0%
<!-- Total: 18 45
Totals Coverage Status
Change from base Build 19819539745: 0.001%
Covered Lines: 15705
Relevant Lines: 41719

💛 - Coveralls

coveralls avatar Dec 04 '25 04:12 coveralls