fix: Change payment status route from GET to POST and update request body handling
Deploy Application / deploy (push) Successful in 1m10s
Details
Deploy Application / deploy (push) Successful in 1m10s
Details
This commit is contained in:
parent
766404ed8f
commit
b75a62dc70
|
|
@ -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: {
|
||||
c_invoice_id: null,
|
||||
},
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue