Repository navigation
fix(payments): document the missing error statuses and correct the payment definitions - #661
Merged
Merged
Conversation
groyoh
approved these changes
Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
OpenAPI guardian check of
payments(incremental run), compared with lago-api at2d7c3c1and the SDK clients.Description
POST /paymentsdocuments403and404. Recording a manual payment is refused with a forbidden error when the organization is not on a premium plan or when the invoice does not accept a manual payment, and with a not found error when the invoice does not exist.Code references (lago-api at
2d7c3c1)Payments::ManualCreateService#check_preconditionsanswers not found for an unknown invoice and forbidden in the two cases above.Api::V1::PaymentsController#createrenders the error from that service.GET /paymentsandGET /customers/{external_customer_id}/paymentsdocument422. Aninvoice_idthat is not a valid identifier is rejected before the query runs.Code references (lago-api at
2d7c3c1)Queries::PaymentsQueryFiltersContractrequiresinvoice_idto match the identifier format.PaymentsQuery#callreturns early when the filters do not validate, andBaseQuery#validate_filtersturns that into a validation failure.PaymentIndex#payment_indexrenders that error, and both list endpoints go through it.PaymentCreateInput.payment.invoice_idnow usesformat: uuidand says which invoice it points at. Lago looks the invoice up by its identifier inside the organization.Code references (lago-api at
2d7c3c1)Api::V1::PaymentsController#create_paramspermitsinvoice_id.Payments::ManualCreateService#invoicelooks it up by the invoice identifier.db/structure.sqldeclaresinvoices.idas a UUID.PaymentObject.statusnow says that the value is alwayssucceededfor a manual payment, which was not obvious from a description that only talked about payment providers.Code references (lago-api at
2d7c3c1)Payments::ManualCreateService#callcreates the payment with the statussucceeded.V1::PaymentSerializer#serializesends that column asstatus.Wording:
PaymentObject.payment_statusreads as a sentence now,PaymentObject.external_customer_idwas missing its final period, and thereferenceandpaid_atdescriptions ofPaymentCreateInputsay what the field holds and what happens when it is left out.Code references (lago-api at
2d7c3c1)Payments::ManualCreateService#parsed_paid_atleaves the creation timestamp to the current time whenpaid_atis blank.Paymentrequiresreferenceon a manual payment and refuses it on the other kinds.SDK drift (spec is right, needs an
sdk-clients-updaterun)Paymenthas no field forlago_customer_id,lago_payable_id,payable_type,status,payment_provider_code,payment_provider_type,provider_payment_idorprovider_customer_id, all of whichV1::PaymentSerializer#serializesends.PaymentResponsehas the same gaps and also dropsexternal_customer_idandnext_action.Needs human confirmation (not changed)
PaymentObject.payment_statusis documented as always present with one of four values. In lago-api the columnpayments.payable_payment_statusallowsnullandPaymentdeclares the enum withallow_nil, but no creation path that leaves it empty was found, and every payment flow reads the value right after setting it. Making the field nullable would be breaking, so nothing was changed. Can a payment be stored without that status?Agent notes
Run: incremental since 2026-10-11, queue reason for this resource: api. Compatibility checker: WARN (advisory); nothing is breaking. Four warnings are the newly documented
403,404and422statuses, which lago-api already answers, so only their description is new. The fifth is theformat: uuidadded toinvoice_idin the create body, an annotation on a value that already has to be a Lago invoice identifier.The security fix that made
V1::PaymentSerializertolerate a deleted invoice or payment request was checked against the contract and needs no spec change: the customer keys stay always present becausepayments.customer_idisNOT NULL, andinvoice_idsandinvoice_numberscan now come back empty, which the spec already allows since both are plain arrays. The list filters were read side by side withPaymentsQuery: the query also supports a currency filter and a search term, which neither list endpoint passes, so the spec is right not to document them.Deliberately not documented
x402value ofPaymentObject.typeand the x402 settlement object on a payment, unreleased:x402_payments.Docs-guardian leads
BillableMetricObject.aggregation_typeis missingcustom_agg. It is not:BillableMetric::AGGREGATION_TYPESmarks the value as a deprecated type kept for legacy metrics that must not be documented in the public API, so the spec stays as it is. The lead is closed, not deferred.Report-only findings from this run
webhooksis clean and needs no pull request. The registry, therequiredlists and the four keys every webhook payload carries were checked across every file insrc/webhooks/and agree with lago-api. One question came out of it: the documentation site listsadd_on.created,add_on.updated,add_on.deleted,coupon.created,coupon.updated,coupon.deletedandcoupon.terminated, which have no entry inconfig/webhook_event_types.ymland no service underapp/services/webhooks/, so an endpoint cannot subscribe to them today. Pull requests docs(webhooks): Document the coupon webhooks #651 and docs(webhooks): Document the add-on webhooks #652 add exactly those files to the specification and were left untouched by this run. Will lago-api add the matching registry entries and services?Queue
customers(spec+api),api_logs(spec+api),features(spec),payment_requests(spec),invoices(api),payments(api),wallets(api),organizations(api),webhooks(api). Every one was checked.activity_logswas skipped because it already has an open guardian pull request.Deferred to next run
Run started: 2026-10-19T07:51:37Z.
Process feedback for the retro
payment_provider_typeandformat: dateonpaid_at, were both still correct and cost nothing to skip. The settled list works well when it names the exact field.A human must review and merge this PR; the agent never merges. (Remove this line from the squash commit message.)