Skip to content

Conversation

@whoAbhishekSah
Copy link
Member

Summary

Simplify transaction and invoice RPCs by always inferring billing_id from org_id. Since each organization can have only one active billing account, passing billing_id separately
is redundant.

Changes

RPCs Updated

This PR updates 4 billing-related RPCs:

  • ListBillingTransactions
  • TotalDebitedTransactions
  • ListInvoices
  • GetUpcomingInvoice

Implementation Details

Proto Changes (raystack/proton#437)

  • Deprecated billing_id parameter in all 4 request messages
  • Made billing_id optional with ignore_empty: true validation (was required in TotalDebitedTransactions)
  • Updated PROTON_COMMIT in Makefile
  • ✅ Fully backwards compatible - old clients continue to work

Handler Changes

  • Handlers now always call customerService.GetByOrgID() to fetch billing account ID
  • The deprecated billing_id parameter is ignored if provided
  • Graceful error handling:
    • Returns empty list/response when billing account doesn't exist (ErrNotFound)
    • Returns bad request for invalid org_id (ErrInvalidUUID, ErrInvalidID)
  • Added org_id to error log lines for better debugging

Authorization Changes

  • Removed redundant ensureBillingAccountBelongToOrg checks from Connect authorization interceptors
  • Since billing_id is always inferred from org_id, separate validation is no longer needed

Migration Guide

For API Clients

  • You can now omit the billing_id parameter when calling these RPCs
  • If you still pass billing_id, it will be ignored and inferred from org_id instead
  • Ensure org_id is always provided

Testing

  • ✅ Build passes
  • ✅ All 4 RPCs tested with valid org_id
  • ✅ Tested empty responses when billing account doesn't exist
  • ✅ Tested error handling for invalid org_id

Related

Deprecate billing_id parameter in 4 RPCs:
- ListBillingTransactionsRequest
- TotalDebitedTransactionsRequest (BREAKING: changed from required to optional)
- ListInvoicesRequest
- GetUpcomingInvoiceRequest

Backend will infer billing_id from org_id since each organization has only
one active billing account.

Updated PROTON_COMMIT to d40c501dac9958d86c945b02f0288fcaf6d6a4e3.
…nvoice RPCs

Update handlers for 4 RPCs to always infer billing_id from org_id:
- ListBillingTransactions
- TotalDebitedTransactions
- ListInvoices
- GetUpcomingInvoice

Changes:
- Use customerService.GetByOrgID() to fetch billing account ID
- Return empty list/response when billing account doesn't exist (ErrNotFound)
- Return bad request for invalid org_id (ErrInvalidUUID, ErrInvalidID)
- Deprecated billing_id parameter is ignored
- Add org_id to error log lines for better debugging
…oice RPCs

Remove ensureBillingAccountBelongToOrg checks from authorization interceptors
for 4 RPCs:
- ListBillingTransactions
- TotalDebitedTransactions
- ListInvoices
- GetUpcomingInvoice

Since billing_id is now always inferred from org_id by handlers, the separate
validation that billing_id belongs to org_id is redundant.
@vercel
Copy link

vercel bot commented Nov 27, 2025

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

Project Deployment Preview Comments Updated (UTC)
frontier Ready Ready Preview Comment Nov 27, 2025 10:16am

@whoAbhishekSah whoAbhishekSah requested a review from rsbh November 27, 2025 10:16
@whoAbhishekSah whoAbhishekSah changed the title Billing simplification transactions refactor(billing): always infer billing_id from org_id in transaction and invoice RPCs Nov 27, 2025
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