diff --git a/apps/web/src/routes/dashboard.ts b/apps/web/src/routes/dashboard.ts index c217d53..cacda2f 100644 --- a/apps/web/src/routes/dashboard.ts +++ b/apps/web/src/routes/dashboard.ts @@ -359,6 +359,19 @@ export const dashboard = new Elysia() return html("checkout", { nav: "settings", account: acc, payApi, invoiceId: params.id, coins, invoice }); }) + .get("/dashboard/checkout/:id/status", async ({ cookie, headers, params, set }) => { + const resolved = await getAccountId(cookie, headers); + if (!resolved?.accountId) { set.status = 401; return { error: "Unauthorized" }; } + const payApi = process.env.PAY_API || "https://pay.pingql.com"; + const key = cookie?.pingql_key?.value; + try { + const res = await fetch(`${payApi}/checkout/${params.id}`, { headers: { "Authorization": `Bearer ${key}` } }); + if (!res.ok) { set.status = res.status; return { error: "Not found" }; } + const data = await res.json(); + return { status: data.status, amount_received: data.amount_received, amount_crypto: data.amount_crypto }; + } catch { set.status = 500; return { error: "Could not fetch status" }; } + }) + .get("/dashboard/checkout/:id/receipt", async ({ cookie, headers, params, set }) => { const resolved = await getAccountId(cookie, headers); if (!resolved?.accountId) return redirect("/dashboard"); diff --git a/apps/web/src/views/checkout.ejs b/apps/web/src/views/checkout.ejs index 2f22a67..52b3084 100644 --- a/apps/web/src/views/checkout.ejs +++ b/apps/web/src/views/checkout.ejs @@ -186,10 +186,10 @@ %> <% if (isPending) { %> - + <% } %> -