// routes/api/retrieve/payment_transactions.ts import { define } from "../../../utils.ts"; import { getTransactionsByLease } from "../../../services/paymentService.ts"; import { SessionCookie } from "../../auth/callback.ts"; export const handler = define.handlers({ async GET(ctx) { try { const stateData: SessionCookie = ctx.state.data; const url = new URL(ctx.req.url); const lease_id = url.searchParams.get("lease_id"); if (!lease_id) { return new Response( JSON.stringify({ error: "Lease ID is required", }), { status: 400, headers: { "Content-Type": "application/json" }, }, ); } const result = await getTransactionsByLease(lease_id); return new Response( JSON.stringify({ success: true, transactions: result, }), { status: 200, headers: { "Content-Type": "application/json" }, }, ); } catch (e) { return new Response(JSON.stringify({ error: e }), { status: 500, headers: { "Content-Type": "application/json" }, }); } }, });