diff --git a/components/ZapButton.tsx b/components/ZapButton.tsx
index 8a824b0..e24c20a 100644
--- a/components/ZapButton.tsx
+++ b/components/ZapButton.tsx
@@ -210,7 +210,7 @@ export default function ZapButton({ event }: { event: any }) {
};
const signedZapRequest = await signEvent();
- params.append('nostr', encodeURIComponent(JSON.stringify(signedZapRequest)));
+ params.append('nostr', JSON.stringify(signedZapRequest));
if (userData?.lud06) {
params.append('lnurl', userData.lud06);
@@ -273,6 +273,58 @@ export default function ZapButton({ event }: { event: any }) {
setIsProcessing(false);
};
+ const checkPaymentStatus = async () => {
+ setIsProcessing(true);
+ try {
+ // Force a re-fetch of zap receipt events
+ const eventFilter = {
+ '#e': [event.id],
+ kinds: [9735],
+ };
+
+ // Manually check relays for new zap events
+ const zapPromises = connectedRelays.map(async (relay) => {
+ return new Promise(async (resolve) => {
+ const timeout = setTimeout(() => resolve([]), 3000); // 3 second timeout
+ try {
+ const sub = relay.sub([eventFilter]);
+ const events: any[] = [];
+
+ sub.on('event', (event) => {
+ // Check if this event contains the current invoice
+ const hasBolt11 = event.tags.some(tag =>
+ tag[0] === 'bolt11' && invoice.includes(tag[1].substring(0, 50))
+ );
+ if (hasBolt11) {
+ events.push(event);
+ }
+ });
+
+ sub.on('eose', () => {
+ clearTimeout(timeout);
+ resolve(events);
+ sub.unsub();
+ });
+ } catch (error) {
+ clearTimeout(timeout);
+ resolve([]);
+ }
+ });
+ });
+
+ const zapEventsArrays = await Promise.all(zapPromises);
+ const newZapEvents = zapEventsArrays.flat();
+
+ if (newZapEvents.length > 0) {
+ setPaymentComplete(true);
+ }
+ } catch (error) {
+ console.error("Error checking payment status:", error);
+ } finally {
+ setIsProcessing(false);
+ }
+ };
+
return (
{invoice}
+ {invoice}
-