Skip to content

feat(multiple-payment-methods): add support for invoice custom section to billing entities#382

Merged
osmarluz merged 4 commits intomainfrom
feat/add-support-for-invoice-custom-section-to-billing-entities
Mar 19, 2026
Merged

feat(multiple-payment-methods): add support for invoice custom section to billing entities#382
osmarluz merged 4 commits intomainfrom
feat/add-support-for-invoice-custom-section-to-billing-entities

Conversation

@osmarluz
Copy link
Contributor

@osmarluz osmarluz commented Mar 17, 2026

Invoice custom section configuration for billing entities

Add an optional invoice_custom_section parameter (accepting skip_invoice_custom_sections and invoice_custom_section_codes) to the following resources, allowing callers to attach or skip custom invoice sections:

  • Subscriptions: create and update
from lago_python_client.models import Subscription, InvoiceCustomSectionInput

invoice_custom_section = InvoiceCustomSectionInput(
    skip_invoice_custom_sections=False,
    invoice_custom_section_codes=['section_code_1']
)

# Create a subscription with invoice custom sections
client.subscriptions.create(Subscription(
    external_customer_id='customer-external-id',
    plan_code='premium',
    external_id='sub-external-id',
    invoice_custom_section=invoice_custom_section
))

# Update a subscription's invoice custom sections
client.subscriptions.update(
    Subscription(invoice_custom_section=invoice_custom_section),
    identifier='sub-external-id'
)

# Response includes applied sections
response.applied_invoice_custom_sections.__root__[0].lago_id  # => "ics_12345"
response.applied_invoice_custom_sections.__root__[0].invoice_custom_section_id  # => "section_001"
  • Wallets: create and update (including within recurring transaction rules), via both /wallets and /customers/:id/wallets endpoints
from lago_python_client.models import (
    Wallet, RecurringTransactionRule, RecurringTransactionRuleList, InvoiceCustomSectionInput
)

invoice_custom_section = InvoiceCustomSectionInput(
    skip_invoice_custom_sections=False,
    invoice_custom_section_codes=['section_code_1']
)

# Create a wallet with invoice custom sections at wallet level
client.wallets.create(Wallet(
    external_customer_id='customer-external-id',
    name='Prepaid Credits',
    rate_amount='1.0',
    currency='USD',
    paid_credits='100',
    granted_credits='50',
    invoice_custom_section=invoice_custom_section
))

# Or via the nested customer wallets endpoint
client.customers.wallets.create('customer-external-id', Wallet(
    name='Prepaid Credits',
    rate_amount='1.0',
    currency='USD',
    paid_credits='100',
    granted_credits='50',
    invoice_custom_section=invoice_custom_section
))

# Update a wallet's invoice custom sections
client.wallets.update(
    Wallet(invoice_custom_section=invoice_custom_section),
    identifier='wallet-lago-id'
)

# Or via the nested customer wallets endpoint
client.customers.wallets.update(
    'customer-external-id',
    'wallet-lago-id',
    Wallet(invoice_custom_section=invoice_custom_section)
)

# With recurring transaction rules and invoice custom sections per rule
client.wallets.create(Wallet(
    external_customer_id='customer-external-id',
    name='Prepaid Credits',
    rate_amount='1.0',
    currency='USD',
    recurring_transaction_rules=RecurringTransactionRuleList(__root__=[
        RecurringTransactionRule(
            paid_credits='100',
            granted_credits='50',
            invoice_custom_section=invoice_custom_section
        )
    ])
))

# Response includes applied sections at wallet and recurring rule levels
response.applied_invoice_custom_sections.__root__[0].lago_id  # => "ics_wallet_001"
response.recurring_transaction_rules.__root__[0].applied_invoice_custom_sections.__root__[0].lago_id  # => "ics_rule_001"
  • Wallet Transactions: create
from lago_python_client.models import WalletTransaction, InvoiceCustomSectionInput

invoice_custom_section = InvoiceCustomSectionInput(
    skip_invoice_custom_sections=False,
    invoice_custom_section_codes=['section_code_1']
)

client.wallet_transactions.create(WalletTransaction(
    wallet_id='wallet-lago-id',
    paid_credits='100',
    granted_credits='100',
    invoice_custom_section=invoice_custom_section
))
  • Invoices: create (one-off)
from lago_python_client.models import OneOffInvoice, InvoiceFee, InvoiceFeesList, InvoiceCustomSectionInput

invoice_custom_section = InvoiceCustomSectionInput(
    skip_invoice_custom_sections=False,
    invoice_custom_section_codes=['section_code_1']
)

client.invoices.create(OneOffInvoice(
    external_customer_id='customer-external-id',
    currency='EUR',
    fees=InvoiceFeesList(__root__=[InvoiceFee(add_on_code='setup_fee', units=1)]),
    invoice_custom_section=invoice_custom_section
))
  • Skip all configurable sections for a resource
from lago_python_client.models import Subscription, InvoiceCustomSectionInput

# Setting skip=True opts the resource out of all configurable sections
skip_sections = InvoiceCustomSectionInput(
    skip_invoice_custom_sections=True
)

client.subscriptions.create(Subscription(
    external_customer_id='customer-external-id',
    plan_code='premium',
    external_id='sub-external-id',
    invoice_custom_section=skip_sections
))

@osmarluz osmarluz marked this pull request as ready for review March 17, 2026 17:32
Copy link

@aquinofb aquinofb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@osmarluz osmarluz merged commit 7103a54 into main Mar 19, 2026
7 checks passed
@osmarluz osmarluz deleted the feat/add-support-for-invoice-custom-section-to-billing-entities branch March 19, 2026 10:04
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.

4 participants