integratedhub/routes/api/retrieve/payment_transactions.ts
open-swe-dev-andrinoid[bot] 459b975437 Apply patch [skip ci]
2026-01-21 20:11:35 +00:00

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