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
@@ -16,7 +16,7 @@ import type {
PaymentMethod,
} from './_types';
import { buildPaymentMethods, formatRuc, rucPattern } from './_logic/booking';
import { useLightningWatcher } from './_hooks/useLightningWatcher';
import { useLightningWatcher } from '@/hooks/useLightningWatcher';
import { PayingStep } from './_steps/PayingStep';
import { ManualPaymentStep } from './_steps/ManualPaymentStep';
import { PendingApprovalStep } from './_steps/PendingApprovalStep';
@@ -35,7 +35,6 @@ export default function BookingPage() {
const [step, setStep] = useState<BookingStep>('form');
const [submitting, setSubmitting] = useState(false);
const [bookingResult, setBookingResult] = useState<BookingResult | null>(null);
const [, setPaymentPending] = useState(false);
const [markingPaid, setMarkingPaid] = useState(false);
// State for payer name (when paid under different name)
@@ -245,7 +244,13 @@ export default function BookingPage() {
};
// Watch for Lightning payment confirmation while on the paying step.
useLightningWatcher(step, bookingResult?.ticketId, locale, setPaymentPending, setStep);
useLightningWatcher(
step === 'paying',
bookingResult?.ticketId,
locale,
() => setStep('success'),
() => {}
);
// Handle "I Have Paid" button click
const handleMarkPaymentSent = async () => {
@@ -330,7 +335,6 @@ export default function BookingPage() {
};
setBookingResult(result);
setStep('paying');
setPaymentPending(true);
// Payment confirmation is handled by the paying-step watcher effect.
} else if (formData.paymentMethod === 'bank_transfer' || formData.paymentMethod === 'tpago') {
// Manual payment methods - show payment details