You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The two LNURL responses are built as loosely-typed associative arrays, documented only via array-shape docblocks:
src/Invoice/Application/CallbackUrl.php — returns the pay-params array.
src/Invoice/Application/InvoiceGenerator.php — mapResponseAsArray() returns the invoice array; generateInvoice() also returns the {status, reason} error array.
src/Invoice/InvoiceFacade.php — array-shape docblocks on both methods.
Goal
Introduce typed, immutable response value objects (implementing JsonSerializable) for the pay-params and invoice responses, so construction is type-checked and adding protocol fields (comment/successAction/nostr) is safe — while serializing to the exact same JSON.
Scope / Tasks
Add readonly DTOs, e.g. PayRequestResponse and InvoiceResponse (+ an error representation), implementing JsonSerializable to emit the current keys/shape byte-for-byte (pr, status, memo, successAction, routes, disposable, error; and callback, maxSendable, minSendable, metadata, tag, commentAllowed).
Build responses via the DTOs in CallbackUrl / InvoiceGenerator. JsonResponse in the controller already JSON-encodes; passing a JsonSerializable must produce identical output.
Replace the array-shape docblocks on the facade/generator with the DTO return types (or keep facade returning arrays via jsonSerialize() if that's cleaner for consumers — decide and document).
Update tests to assert against the serialized shape (unchanged JSON).
Implementation notes
The serialized JSON MUST stay identical (this is a wire contract used by wallets) — assert equality against the current expected arrays.
Keep DTOs in src/Shared/Transfer/ or an Application/Response/ namespace consistent with the module layout.
This is a refactor: no behavior/wire change, purely internal typing + DX.
Acceptance criteria
Responses are constructed from typed DTOs; JSON output is byte-identical to today.
Facade consumers get precise types (DTO or a typed array shape).
composer test-all green.
Out of scope
Adding new fields (covered by the LUD/Nostr issues) — this only re-types the existing shape.
Context
The two LNURL responses are built as loosely-typed associative arrays, documented only via array-shape docblocks:
src/Invoice/Application/CallbackUrl.php— returns the pay-params array.src/Invoice/Application/InvoiceGenerator.php—mapResponseAsArray()returns the invoice array;generateInvoice()also returns the{status, reason}error array.src/Invoice/InvoiceFacade.php— array-shape docblocks on both methods.Goal
Introduce typed, immutable response value objects (implementing
JsonSerializable) for the pay-params and invoice responses, so construction is type-checked and adding protocol fields (comment/successAction/nostr) is safe — while serializing to the exact same JSON.Scope / Tasks
PayRequestResponseandInvoiceResponse(+ an error representation), implementingJsonSerializableto emit the current keys/shape byte-for-byte (pr,status,memo,successAction,routes,disposable,error; andcallback,maxSendable,minSendable,metadata,tag,commentAllowed).CallbackUrl/InvoiceGenerator.JsonResponsein the controller already JSON-encodes; passing aJsonSerializablemust produce identical output.jsonSerialize()if that's cleaner for consumers — decide and document).Implementation notes
src/Shared/Transfer/or anApplication/Response/namespace consistent with the module layout.Acceptance criteria
composer test-allgreen.Out of scope