From ec5356b78d768214bc36343cbbe4e5c6745dad5d Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Wed, 21 Jan 2026 19:20:02 +0000 Subject: [PATCH] Apply patch [skip ci] --- routes/api/receipt/[id].ts | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 routes/api/receipt/[id].ts diff --git a/routes/api/receipt/[id].ts b/routes/api/receipt/[id].ts new file mode 100644 index 0000000..18b025e --- /dev/null +++ b/routes/api/receipt/[id].ts @@ -0,0 +1,52 @@ +import { define } from "../../../../utils.ts"; +import { getTransactionByStripeId } from "../../../../services/paymentService.ts"; + +export const handler = define.handlers({ + async GET(ctx) { + const stripeId = ctx.params.id; + if (!stripeId) { + return new Response("Not Found", { status: 404 }); + } + const tx = await getTransactionByStripeId(stripeId); + if (!tx) { + return new Response("Receipt not found", { status: 404 }); + } + const amount = tx.amount ?? 0; + const date = tx.payment_date || tx.created_on || Date.now(); + const leaseId = tx.lease_id || ""; + const method = tx.payment_method || "-"; + + const html = ` + + + + + Payment Receipt + + + +
+

Payment Receipt

+
Stripe/Payment ID
${stripeId}
+
Lease ID
${leaseId}
+
Amount
$${amount.toLocaleString()}
+
Method
${method}
+
Date
${new Date(date).toLocaleString()}
+
+ + `; + + return new Response(html, { + status: 200, + headers: { "content-type": "text/html; charset=utf-8" }, + }); + }, +}); +