Skip to content

feat: Add structured payment_term support - #438

Draft
annvelents wants to merge 1 commit into
mainfrom
feat/payment-terms
Draft

annvelents wants to merge 1 commit into
mainfrom
feat/payment-terms

Conversation

@annvelents

@annvelents annvelents commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Adds Lago's structured payment_term to the client.

  • New PaymentTerm model: term_type, days, day_of_month, month_offset.
  • Request payment_term on Customer, BillingEntity, BillingEntityUpdate, Subscription, InvoicePreview (top-level), OneOffInvoice and Wallet.
  • Response payment_term on customer, billing entity, organization (read-only), subscription, invoice, payment request invoices and wallet. net_payment_term on invoice responses is now Optional[int] (null for terms the integer can't express).
  • invoices.preview now serializes with exclude_none=True like every other request, so an unset payment_term (and any other unset preview field) is no longer sent as null.

Depends on open lago-api PRs: wallet payment_term needs getlago/lago-api#6580, one-off invoice payment_term needs getlago/lago-api#6579.

Tests: a customer with only net_payment_term sends no payment_term; a subscription update without payment_term sends none; request bodies and response parsing for every resource above; fixtures updated.

Related

annvelents added a commit to getlago/lago-openapi that referenced this pull request Nov 10, 2026
Documents Lago's structured payment terms for everything already merged
on lago-api `main` (#6201 customers and billing entities, #6195
invoices, #6234 subscriptions and invoice preview).

- New `PaymentTermObject`: `term_type` (`due_on_receipt`, `net`,
`end_of_month`, `net_end_of_month`, `days_end_of_month`,
`day_of_month`), `days` 0..365, `day_of_month` 1..31, `month_offset`
0..12 (default 1), with the per-type rules and the
`error_details.payment_term` codes (`invalid_format`,
`invalid_term_type`, `unexpected_fields`, `invalid_days`,
`invalid_day_of_month`, `invalid_month_offset`).
- `payment_term` on: customer create and object; billing entity create,
update and object; organization object (read-only — the default billing
entity's term; `PUT /organizations` takes only `net_payment_term`);
subscription create, update and object; invoice object; invoice preview
(top-level).
- Invoice preview: term resolution and the 422
`subscription_payment_terms_do_not_match`.
- `net_payment_term` marked deprecated (`deprecated: true`,
"**Deprecated.** Use `payment_term` instead.") on every input and
response; on `PUT /organizations` it points to `payment_term` on the
billing entity endpoints. Described as the legacy alias, nullable on
billing entity, organization and invoice responses, with how it
interacts with `payment_term`:
  1. A non-null `payment_term` always wins.
2. `payment_term: null` with a non-null `net_payment_term`: the null is
ignored and the term is `net N`.
3. `payment_term: null` with `net_payment_term` absent or null: clears
both.
  4. Only `net_payment_term` sent, equal to the stored value: no change.
5. Only `net_payment_term` sent, different value: the term is
re-derived.

Rules 2 and 4 depend on the lago-api PR below; merge this after it.

Not included: one-off invoice and wallet `payment_term` (lago-api #6579,
#6580, still open) — a follow-up PR once those merge. No v2 changes (the
v2 endpoints don't expose payment terms).

Overlap: #704 and #710 edit `net_payment_term` in the same three input
schemas. No `src/` conflict; the bundled `openapi.yaml` will need `npm
run build` after whichever merges second. Their `net_payment_term`
wording should then be aligned to the legacy-alias description.

`npm run test`: build OK, redocly and spectral warning counts identical
to `main`, none on payment terms.

## Related
- lago-api, keep the structured term on legacy nulls:
getlago/lago-api#7097
- lago-openapi, payment terms: #716
- SDKs: Ruby getlago/lago-ruby-client#386 · Python
getlago/lago-python-client#438 · Go getlago/lago-go-client#374 · JS
getlago/lago-javascript-client#106 · Rust getlago/lago-rust-client#67

---------

Co-authored-by: annvelents <anna@getlago.com>
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.

1 participant