Allow Lightning invoice reuse and re-payment from the dashboard.

Store LNbits invoice data on payments, add an invoice endpoint that reuses valid invoices or regenerates expired ones, and wire the booking payment page to fetch and display invoices via a shared watcher hook.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Michilis
2026-07-01 16:48:28 +00:00
co-authored by Cursor
parent 09bfb17f03
commit 78ffd0ae52
10 changed files with 331 additions and 34 deletions
+9
View File
@@ -6,6 +6,7 @@ import type {
TicketValidationResult,
TicketSearchResult,
LiveSearchResult,
LightningInvoice,
} from './types';
export const ticketsApi = {
@@ -137,6 +138,14 @@ export const ticketsApi = {
`/api/lnbits/status/${ticketId}`
),
// Get a Lightning invoice to pay/re-pay a ticket - reuses the stored invoice
// if it's still valid, otherwise generates a fresh one.
getLightningInvoice: (ticketId: string) =>
fetchApi<{ invoice?: LightningInvoice; reused?: boolean; alreadyPaid?: boolean }>(
`/api/lnbits/invoice/${ticketId}`,
{ method: 'POST' }
),
// Get PDF download URL (returns the URL, not the PDF itself)
getPdfUrl: (id: string) => `${API_BASE}/api/tickets/${id}/pdf`,
};
+9
View File
@@ -25,6 +25,15 @@ export interface Event {
updatedAt: string;
}
export interface LightningInvoice {
paymentHash: string;
paymentRequest: string; // BOLT11 invoice
amount: number; // Amount in satoshis
fiatAmount?: number; // Original fiat amount
fiatCurrency?: string; // Original fiat currency
expiresAt?: string;
}
export interface Ticket {
id: string;
bookingId?: string; // Groups multiple tickets from same booking