Fallback to manual payment if webln fails - might be due to user intentionally closing out of it v2

This commit is contained in:
Chad Curtis 2025-07-14 13:50:22 +00:00
parent 3101532a2b
commit 6845e6cf7c

View File

@ -262,7 +262,10 @@ export function useZaps(
variant: 'destructive',
});
}
} else if (webln) { // Try WebLN next
}
if (webln) { // Try WebLN next
try {
await webln.sendPayment(newInvoice);
// Clear states immediately on success
@ -279,6 +282,20 @@ export function useZaps(
// Close dialog last to ensure clean state
onZapSuccess?.();
} catch (weblnError) {
console.error('webln payment failed, falling back:', weblnError);
// Show specific WebLN error to user for debugging
const errorMessage = weblnError instanceof Error ? weblnError.message : 'Unknown WebLN error';
toast({
title: 'WebLN payment failed',
description: `${errorMessage}. Falling back to other payment methods...`,
variant: 'destructive',
});
setInvoice(newInvoice);
setIsZapping(false);
}
} else { // Default - show QR code and manual Lightning URI
setInvoice(newInvoice);
setIsZapping(false);