Skip to content

feat(payments): include invoice number in overdue payment reference - #6050

Merged
annvelents merged 2 commits into
mainfrom
feat/claude-overdue-payment-reference-invoice-number
Aug 7, 2026
Merged

feat(payments): include invoice number in overdue payment reference#6050
annvelents merged 2 commits into
mainfrom
feat/claude-overdue-payment-reference-invoice-number

Conversation

@lago-claude-ai-agent

Copy link
Copy Markdown
Contributor

When Lago auto-charges an overdue payment request off-session, the reference sent to the payment provider was hardcoded to <billing entity> - Overdue invoices with no invoice number, so reconciling a payment back to an invoice from a provider report meant looking it up in Lago. The checkout-link path (PaymentRequests::Payments::StripeService#description) already appends the number when there is a single invoice; the auto-charge path now does the same, so both paths send the same reference.

Payment requests covering several invoices are deliberately unchanged: listing every number needs a per-provider truncation budget (Adyen caps reference at 80 chars) that has no precedent in the codebase.

## Context

When Lago retries an overdue payment off-session, the reference sent to
the payment provider was hardcoded to "<billing entity> - Overdue
invoices" and never carried an invoice number, even when the payment
request covered a single invoice. Reconciling a payment back to an
invoice from a provider report therefore meant looking each one up in
Lago by hand.

## Description

The auto-charge path now appends the invoice number when the payment
request covers exactly one invoice, so it produces the same reference
the checkout-link path already produces. Payment requests covering
several invoices keep the existing reference.

Signed-off-by: lago-claude-ai-agent[bot] <297187938+lago-claude-ai-agent[bot]@users.noreply.github.com>
@lago-claude-ai-agent

Copy link
Copy Markdown
Contributor Author

PASS — the auto-charge path now builds the same reference as PaymentRequests::Payments::StripeService#description, the logic is copied verbatim from that proven pattern, and the new spec pins it.

Verified: payment_reference matches the existing Invoices::Payments::CreateService#payment_reference shape and placement; the single-invoice spec relies on the with(reference:) stub constraint, so it would not pass on the old string; all reference consumers just forward the value; 2 files, no unrelated churn.

Non-blocking notes for the human reviewer:

  • The multi-invoice case is deliberately left unchanged. That keeps the two Stripe paths consistent and is disclosed in the description, but it is a product call worth an explicit ack.
  • PaymentRequests::Payments::Adyen Service#payment_url_params still sends reference: "Overdue invoices" — no billing entity, no invoice number. Pre-existing divergence, not introduced here, but it means the new code comment's "both payment paths" only holds for Stripe.
  • reference reaches Adyen's payment_params, where the field caps at 80 chars; a long billing entity name plus an invoice number gets closer to that. Same exposure the invoice auto-charge path already has, so no new class of problem.

@lago-claude-ai-agent
lago-claude-ai-agent Bot marked this pull request as ready for review July 30, 2026 08:25
@annvelents
annvelents merged commit f52f02a into main Aug 7, 2026
12 checks passed
@annvelents
annvelents deleted the feat/claude-overdue-payment-reference-invoice-number branch August 7, 2026 08:55
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