feat: BTCPay webhook for auto-publish after confirmation, processing badge

This commit is contained in:
2026-02-06 15:03:56 +01:00
parent fcf22617d0
commit d9202f9ca2
8 changed files with 191 additions and 16 deletions

View File

@@ -678,20 +678,21 @@ class PageCreate extends HTMLElement {
return
}
// Poll for final status after modal close
const result = await pollUntilDone(invoiceId, {
interval: 4000,
timeout: 60000,
onUpdate: (update) => {
if (update.status === 'Processing' && submitBtn) {
submitBtn.textContent = t('payment.processing')
}
}
})
// Check status once after modal close
const currentStatus = await getInvoiceStatus(invoiceId)
if (result.status === 'Settled') {
if (currentStatus.status === 'Settled') {
await this.onPaymentSuccess(listingId)
} else {
return
}
// Processing = payment received, waiting for confirmation
if (currentStatus.status === 'Processing') {
await this.onPaymentReceived(listingId)
return
}
if (currentStatus.status === 'Expired' || currentStatus.status === 'Invalid') {
await directus.updateListing(listingId, { payment_status: 'expired' })
clearPendingInvoice(listingId)
this.showError(t('payment.expired'))
@@ -700,6 +701,15 @@ class PageCreate extends HTMLElement {
submitBtn.disabled = false
submitBtn.textContent = t('create.publish')
}
return
}
// Still "New" - user closed modal without paying
this.showError(t('payment.failed'))
this.submitting = false
if (submitBtn) {
submitBtn.disabled = false
submitBtn.textContent = t('create.publish')
}
} catch (error) {
console.error('Payment failed:', error)
@@ -728,6 +738,15 @@ class PageCreate extends HTMLElement {
router.navigate(`/listing/${listingId}`)
}
async onPaymentReceived(listingId) {
await directus.updateListing(listingId, {
payment_status: 'processing'
})
clearPendingInvoice(listingId)
router.navigate(`/listing/${listingId}`)
}
showError(message) {
let errorDiv = this.querySelector('.form-error')
if (!errorDiv) {