Skip to content

[ING-70] feat(multi-entity): support billing_entity_code#358

Open
mariohd wants to merge 2 commits into
mainfrom
ING-70-multi-billing-entity
Open

[ING-70] feat(multi-entity): support billing_entity_code#358
mariohd wants to merge 2 commits into
mainfrom
ING-70-multi-billing-entity

Conversation

@mariohd

@mariohd mariohd commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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, surface it on the response side, and accept the billing_entity_codes filter 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 /subscriptions and PUT /subscriptions/:external_id — shared Subscription#whitelist_params, so create and update both pick it up.
  • POST /wallets (and POST /customers/:id/wallets via the same Customers::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 the preview slice.

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_code automatically through the client's JSON.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_all already forwards arbitrary options through URI.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 /invoices and GET /credit_notes already worked.

Tests

Targeted specs added:

  • spec/lago/api/resources/subscription_spec.rb — create / update with billing_entity_code; get_all with billing_entity_codes[].
  • spec/lago/api/resources/wallet_spec.rb — create with billing_entity_code (asserts read-back); get_all with billing_entity_codes[].
  • spec/lago/api/resources/invoice_spec.rb — create with billing_entity_code; preview with billing_entity_code.
  • spec/lago/api/resources/payment_request_spec.rbget_all with billing_entity_codes[].
bundle exec rspec --exclude-pattern "spec/integration/**/*"
# 538 examples, 0 failures

## 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.
@mariohd mariohd force-pushed the ING-70-multi-billing-entity branch from 00c9872 to 81befc2 Compare June 12, 2026 12:08
@mariohd mariohd requested review from aquinofb and lovrocolic June 12, 2026 12:27
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.

3 participants