integratedhub/routes/api/retrieve/payment_transactions.ts
2026-02-14 02:20:19 +00:00

46 lines
1.2 KiB
TypeScript

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