[ING-70] feat(multi-entity): support billing_entity_code#358
Open
mariohd wants to merge 2 commits into
Open
Conversation
## Context Multi-Entity Billing lets a customer's resources be scoped to a billing entity other than their default. The Ruby client needs to forward the optional billing_entity_code request param on writes and accept the billing_entity_codes filter on list endpoints so callers can target a specific entity. ## Description Adds billing_entity_code to subscription create/update, wallet create, one-off invoice create, and invoice preview payloads. When omitted, the API falls back to the customer's billing entity, so existing callers are unaffected. Subscription and wallet responses surface the field automatically through the client's OpenStruct deserialization (invoices and credit notes already exposed it). Adds the billing_entity_codes[] filter to the subscriptions, wallets and payment_requests list specs; the existing get_all already forwards options to the query string, so the list filters are test-only changes on the client side.
00c9872 to
81befc2
Compare
lovrocolic
approved these changes
Jun 15, 2026
aquinofb
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Multi-Entity Billing lets a customer's resources be scoped to a billing entity other than their default. The Ruby client needs to forward the optional
billing_entity_coderequest param on writes, surface it on the response side, and accept thebilling_entity_codesfilter on list endpoints so callers can target a specific entity.Closes ING-70 but will not be merged until the feature is 100% released to clients.
Changes
Request params —
billing_entity_code(String) added to:POST /subscriptionsandPUT /subscriptions/:external_id— sharedSubscription#whitelist_params, so create and update both pick it up.POST /wallets(andPOST /customers/:id/walletsvia the sameCustomers::Wallets::WhitelistParams).POST /invoices(one-off) —Invoice#one_off_params, now.compacted so the new optional field is dropped from the JSON when unset.POST /invoices/preview— added to thepreviewslice.When omitted, the API falls back to the customer's billing entity, so existing callers are unaffected.
Response read-back — Subscription and Wallet response objects expose
billing_entity_codeautomatically through the client'sJSON.parse(..., object_class: OpenStruct)deserialization. No production change required; the subscription factory carries the field so existing-response specs read it back, and dedicated wallet/subscription contexts assert it round-trips. Invoice and CreditNote already exposed it.List filters —
billing_entity_codes[](Array) for:GET /subscriptions,GET /wallets,GET /payment_requests.Connection#get_allalready forwards arbitrary options throughURI.encode_www_form, following the existing'status[]'convention, so this is a test-only change on the client side — specs lock in the query-string shape (billing_entity_codes%5B%5D=…).GET /invoicesandGET /credit_notesalready worked.Tests
Targeted specs added:
spec/lago/api/resources/subscription_spec.rb— create / update withbilling_entity_code;get_allwithbilling_entity_codes[].spec/lago/api/resources/wallet_spec.rb— create withbilling_entity_code(asserts read-back);get_allwithbilling_entity_codes[].spec/lago/api/resources/invoice_spec.rb— create withbilling_entity_code; preview withbilling_entity_code.spec/lago/api/resources/payment_request_spec.rb—get_allwithbilling_entity_codes[].