diff --git a/apps/pay/src/routes.ts b/apps/pay/src/routes.ts
index 9ee4d87..1b7fe4c 100644
--- a/apps/pay/src/routes.ts
+++ b/apps/pay/src/routes.ts
@@ -159,11 +159,4 @@ export const routes = new Elysia()
};
})
- // Lightweight status poll
- .get("/checkout/:id/status", async ({ accountId, params, set }) => {
- const [payment] = await sql`
- SELECT status, txid FROM payments WHERE id = ${params.id} AND account_id = ${accountId}
- `;
- if (!payment) { set.status = 404; return { error: "Payment not found" }; }
- return { status: payment.status, txid: payment.txid };
- });
+;
diff --git a/apps/web/src/views/checkout.ejs b/apps/web/src/views/checkout.ejs
index 51fb5a7..207d03b 100644
--- a/apps/web/src/views/checkout.ejs
+++ b/apps/web/src/views/checkout.ejs
@@ -232,16 +232,25 @@
document.getElementById('pay-usd').textContent = data.amount_usd.toFixed(2);
document.getElementById('pay-address').textContent = data.address;
+ // Show current status immediately
+ if (data.status === 'confirming') {
+ document.getElementById('pay-status').innerHTML = `
+
+ Transaction detected, waiting for confirmation...
+ `;
+ if (data.txid) watchedTxids.push(data.txid);
+ }
+
// Start countdown
const expiresAt = new Date(data.expires_at).getTime();
updateCountdown(expiresAt);
countdownInterval = setInterval(() => updateCountdown(expiresAt), 1000);
- // Start SSE stream for instant tx detection on the client
+ // Start SSE for instant tx/block detection
watchAddress(data.coin, data.address);
- // Poll as fallback (for confirmations and in case SSE drops)
- pollInterval = setInterval(() => pollStatus(), 10000);
+ // Poll full checkout as fallback
+ pollInterval = setInterval(() => pollPayment(), 10000);
}
let watchedAddress = null;
@@ -316,9 +325,9 @@
}
}
- async function pollStatus() {
+ async function pollPayment() {
try {
- const res = await fetch(`${PAY_API}/checkout/${paymentId}/status`, { credentials: 'include' });
+ const res = await fetch(`${PAY_API}/checkout/${paymentId}`, { credentials: 'include' });
const data = await res.json();
if (data.status === 'confirming') {
@@ -326,6 +335,7 @@
Transaction detected, waiting for confirmation...
`;
+ if (data.txid && !watchedTxids.includes(data.txid)) watchedTxids.push(data.txid);
} else if (data.status === 'paid') {
clearInterval(pollInterval);
clearInterval(countdownInterval);
@@ -364,7 +374,12 @@
document.getElementById('step-pay').classList.remove('hidden');
document.getElementById('pay-status-section').classList.add('hidden');
document.getElementById('pay-success').classList.remove('hidden');
- } else if (data.status !== 'expired') {
+ } else if (data.status === 'expired') {
+ document.getElementById('step-select').classList.add('hidden');
+ document.getElementById('step-pay').classList.remove('hidden');
+ document.getElementById('pay-status-section').classList.add('hidden');
+ document.getElementById('pay-expired').classList.remove('hidden');
+ } else {
paymentId = data.id;
showPayment(data);
}