Subscribe to zap receipt when zapping, show success for external

payment
This commit is contained in:
2026-08-20 12:24:54 -06:00
parent 644d6a2856
commit 2869ed6677
4 changed files with 138 additions and 1 deletions
+33
View File
@@ -165,6 +165,39 @@ export default class NostrZapService extends Service {
return parseBolt11(invoice);
}
subscribeForZapReceipt(zapRequest, photo, onReceipt) {
const eventId = photo.eventId;
const relays = this.getZapRelays();
const since = Math.floor(Date.now() / 1000) - 10;
return this.nostrRelay.pool
.subscription(relays, {
kinds: [9735],
'#e': [eventId],
since,
})
.subscribe({
next: (event) => {
this.nostrData.store.add(event);
const descTag = event.tags.find((t) => t[0] === 'description');
if (!descTag) return;
try {
const req = JSON.parse(descTag[1]);
if (req.id === zapRequest.id) {
onReceipt(event);
}
} catch {
// Invalid JSON in description tag
}
},
error: (err) => {
console.error('[nostr-zap] Receipt subscription error:', err);
},
});
}
hasWebLN() {
return typeof window !== 'undefined' && typeof window.webln !== 'undefined';
}