fix: Change payment status route from GET to POST and update request body handling
Deploy Application / deploy (push) Successful in 1m10s Details

This commit is contained in:
faisolavolut 2025-11-03 10:32:50 +07:00
parent 766404ed8f
commit b75a62dc70
2 changed files with 27 additions and 9 deletions

View File

@ -441,12 +441,9 @@ export async function MidsuitPaymentV2(req: Request, res: Response) {
export async function paymentStatus(req: Request, res: Response) {
try {
const { c_invoice_id, startdate, enddate } = req.query as any;
if (!c_invoice_id) {
return res.status(400).json({ error: "c_invoice_id is required" });
}
const { c_invoice_id, startdate, enddate } = req.body as any;
const where: any = { c_invoice_id: Number(c_invoice_id) };
const where: any = {};
if (startdate || enddate) {
where.created_at = {} as any;
if (startdate) {
@ -462,17 +459,38 @@ export async function paymentStatus(req: Request, res: Response) {
where.created_at.lte = e;
}
}
if (c_invoice_id) {
where.c_invoice_id = Number(c_invoice_id);
}
console.log({
...where,
and: {
NOT: {
c_invoice_id: null,
},
},
});
const rows = await db.transactions_lines.findMany({
where: {
...where,
not: {
AND: [
{
NOT: {
c_invoice_id: null,
},
},
{
transactions: {
status: "COMPLETED",
},
},
],
},
include: { transactions: true },
orderBy: { created_at: "desc" },
});
return res.json({ count: rows.length, data: rows });
const result = rows.map((r: any) => ({
id: r.id,

View File

@ -76,7 +76,7 @@ export const setRoutes = () => {
transferController.MidsuitPayment(req, res)
);
// Payment status lookup by c_invoice_id (optionally limit by startdate/enddate)
router.get("/api/va/status", authMiddleware, async (req, res) =>
router.post("/api/va/status", authMiddleware, async (req, res) =>
transferController.paymentStatus(req, res)
);
// Signature generation for testing (uses PRIVATE_KEY_PATH file)