chore: cleanup unused code, update docs for payment integration

This commit is contained in:
2026-02-06 16:23:23 +01:00
parent 52634f84bf
commit 3c7d475d36
7 changed files with 97 additions and 108 deletions

View File

@@ -4,7 +4,7 @@ import { auth } from '../../services/auth.js'
import { directus } from '../../services/directus.js'
import { categoriesService } from '../../services/categories.js'
import { SUPPORTED_CURRENCIES, getDisplayCurrency } from '../../services/currency.js'
import { createInvoice, openCheckout, pollUntilDone, getPendingInvoice, savePendingInvoice, clearPendingInvoice, getInvoiceStatus } from '../../services/btcpay.js'
import { createInvoice, openCheckout, getPendingInvoice, savePendingInvoice, clearPendingInvoice, getInvoiceStatus } from '../../services/btcpay.js'
import { escapeHTML } from '../../utils/helpers.js'
import '../location-picker.js'
import '../pow-captcha.js'
@@ -723,46 +723,36 @@ class PageCreate extends HTMLElement {
}
async onPaymentSuccess(listingId) {
const days = 30
const expiresAt = new Date()
expiresAt.setDate(expiresAt.getDate() + days)
try {
const days = 30
const expiresAt = new Date()
expiresAt.setDate(expiresAt.getDate() + days)
await directus.updateListing(listingId, {
status: 'published',
payment_status: 'paid',
paid_at: new Date().toISOString(),
expires_at: expiresAt.toISOString()
})
await directus.updateListing(listingId, {
status: 'published',
payment_status: 'paid',
paid_at: new Date().toISOString(),
expires_at: expiresAt.toISOString()
})
} catch (e) {
console.warn('Could not update listing status, webhook will handle it:', e)
}
clearPendingInvoice(listingId)
router.navigate(`/listing/${listingId}`)
router.navigate('/my-listings')
}
async onPaymentReceived(listingId) {
await directus.updateListing(listingId, {
payment_status: 'processing'
})
try {
await directus.updateListing(listingId, {
payment_status: 'processing'
})
} catch (e) {
console.warn('Could not update listing status, webhook will handle it:', e)
}
clearPendingInvoice(listingId)
this.showPaymentSuccess()
}
showPaymentSuccess() {
this.innerHTML = /* html */`
<div class="create-page">
<div class="payment-success">
<div class="success-icon">
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"></circle>
<polyline points="12 6 12 12 16 14"></polyline>
</svg>
</div>
<h2>${t('payment.processing')}</h2>
<p>${t('payment.awaitingHint')}</p>
<a href="#/my-listings" class="btn btn-primary">${t('profile.myListings')}</a>
</div>
</div>
`
router.navigate('/my-listings')
}
showError(message) {
@@ -1011,28 +1001,5 @@ style.textContent = /* css */`
page-create .btn-link:hover {
color: var(--color-primary-hover);
}
page-create .payment-success {
text-align: center;
padding: var(--space-3xl) 0;
}
page-create .success-icon {
color: var(--color-warning, #e6a700);
margin-bottom: var(--space-lg);
}
page-create .payment-success h2 {
margin-bottom: var(--space-md);
}
page-create .payment-success p {
color: var(--color-text-secondary);
margin-bottom: var(--space-xl);
max-width: 400px;
margin-left: auto;
margin-right: auto;
line-height: 1.5;
}
`
document.head.appendChild(style)