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" }, }); }, });