feat: add receipts to the payment service

This commit is contained in:
2026-03-19 13:40:17 +04:00
parent a7f56c69d3
commit 113c1101c4
6 changed files with 198 additions and 35 deletions
+24
View File
@@ -305,6 +305,30 @@ export const dashboard = new Elysia()
return html("checkout", { nav: "settings", account: acc, payApi, invoiceId: params.id, coins, invoice });
})
// Receipt (proxy to pay service, serves HTML directly)
.get("/dashboard/checkout/:id/receipt", async ({ cookie, headers, params, set }) => {
const resolved = await getAccountId(cookie, headers);
if (!resolved?.accountId) return redirect("/dashboard");
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}/receipt`, {
headers: { "Authorization": `Bearer ${key}` },
});
if (!res.ok) {
const data = await res.json().catch(() => ({}));
set.status = res.status;
return data.error || "Receipt not available";
}
set.headers["content-type"] = "text/html; charset=utf-8";
return await res.text();
} catch {
set.status = 500;
return "Could not load receipt";
}
})
// Create checkout via form POST (no-JS)
.post("/dashboard/checkout", async ({ cookie, headers, body }) => {
const resolved = await getAccountId(cookie, headers);