Skip to content

Comments

feat(multiple-payment-methods): Add support for payment methods to billing entities#365

Open
osmarluz wants to merge 7 commits intomainfrom
feat/add-support-for-multiple-payment-methods
Open

feat(multiple-payment-methods): Add support for payment methods to billing entities#365
osmarluz wants to merge 7 commits intomainfrom
feat/add-support-for-multiple-payment-methods

Conversation

@osmarluz
Copy link

@osmarluz osmarluz commented Feb 11, 2026

Customer payment methods resource

Introduce a new customer_payment_methods resource on the API client, providing:

  • List payment methods for a customer
payment_methods = client.customer_payment_methods.find_all(
    resource_id='customer-external-id',
    options={'per_page': 10, 'page': 1}
)
payment_methods['payment_methods'] # => list of payment method objects
payment_methods['meta']['total_count'] # => total number of payment methods
  • Delete a payment method by ID
payment_method = client.customer_payment_methods.destroy('customer-external-id', 'payment-method-lago-id')
payment_method.lago_id  # => "payment-method-lago-id"
  • Set as default: mark a specific payment method as the customer's default
payment_method = client.customer_payment_methods.set_as_default('customer-external-id', 'payment-method-lago-id')
payment_method.is_default  # => True

Payment method selection for billing entities

Add an optional payment_method parameter (accepting payment_method_type and payment_method_id) to the following resources, allowing callers to specify which payment method to use:

  • Invoices: create (one-off) and retry_payment
from lago_python_client.models import OneOffInvoice, InvoiceFee, InvoiceFeesList, PaymentMethod

payment_method = PaymentMethod(
    payment_method_type='card',
    payment_method_id='pm_123'
)

# Create a one-off invoice with a specific payment method
client.invoices.create(OneOffInvoice(
    external_customer_id='customer-external-id',
    currency='EUR',
    fees=InvoiceFeesList(__root__=[InvoiceFee(add_on_code='setup_fee', units=1)]),
    payment_method=payment_method
))


# Retry payment with a specific payment method
client.invoices.retry_payment(
    'invoice-lago-id',
    payment_method=payment_method
)
  • Subscriptions: create and update
from lago_python_client.models import Subscription, PaymentMethod

payment_method = PaymentMethod(
    payment_method_type='card',
    payment_method_id='pm_123'
)

# Create a subscription with a specific payment method
client.subscriptions.create(Subscription(
    external_customer_id='customer-external-id',
    plan_code='premium',
    external_id='sub-external-id',
    payment_method=payment_method
))

# Update a subscription's payment method
client.subscriptions.update(
    Subscription(payment_method=payment_method),
    identifier='sub-external-id'
)
  • Wallets: create and update (including within recurring transaction rules)
from lago_python_client.models import (
    Wallet, RecurringTransactionRule, RecurringTransactionRuleList, PaymentMethod
)

payment_method = PaymentMethod(
    payment_method_type='card',
    payment_method_id='pm_123'
)

# Create a wallet with a specific payment method
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',
    payment_method=payment_method
))

# Update a wallet's payment method
client.wallets.update(
    Wallet(payment_method=payment_method),
    identifier='wallet-lago-id'
)

# With recurring transaction rules and a payment method 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',
            payment_method=payment_method
        )
    ])
))
  • Wallet Transactions: create
from lago_python_client.models import WalletTransaction, PaymentMethod

payment_method = PaymentMethod(
    payment_method_type='card',
    payment_method_id='pm_123'
)

client.wallet_transactions.create(WalletTransaction(
    wallet_id='wallet-lago-id',
    paid_credits='100',
    granted_credits='100',
    payment_method=payment_method
))

@osmarluz osmarluz self-assigned this Feb 16, 2026
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