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) {
|
export async function paymentStatus(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { c_invoice_id, startdate, enddate } = req.query as any;
|
const { c_invoice_id, startdate, enddate } = req.body as any;
|
||||||
if (!c_invoice_id) {
|
|
||||||
return res.status(400).json({ error: "c_invoice_id is required" });
|
|
||||||
}
|
|
||||||
|
|
||||||
const where: any = { c_invoice_id: Number(c_invoice_id) };
|
const where: any = {};
|
||||||
if (startdate || enddate) {
|
if (startdate || enddate) {
|
||||||
where.created_at = {} as any;
|
where.created_at = {} as any;
|
||||||
if (startdate) {
|
if (startdate) {
|
||||||
|
|
@ -462,17 +459,38 @@ export async function paymentStatus(req: Request, res: Response) {
|
||||||
where.created_at.lte = e;
|
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({
|
const rows = await db.transactions_lines.findMany({
|
||||||
where: {
|
where: {
|
||||||
...where,
|
...where,
|
||||||
not: {
|
AND: [
|
||||||
|
{
|
||||||
|
NOT: {
|
||||||
c_invoice_id: null,
|
c_invoice_id: null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
transactions: {
|
||||||
|
status: "COMPLETED",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
include: { transactions: true },
|
include: { transactions: true },
|
||||||
orderBy: { created_at: "desc" },
|
orderBy: { created_at: "desc" },
|
||||||
});
|
});
|
||||||
|
return res.json({ count: rows.length, data: rows });
|
||||||
|
|
||||||
const result = rows.map((r: any) => ({
|
const result = rows.map((r: any) => ({
|
||||||
id: r.id,
|
id: r.id,
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ export const setRoutes = () => {
|
||||||
transferController.MidsuitPayment(req, res)
|
transferController.MidsuitPayment(req, res)
|
||||||
);
|
);
|
||||||
// Payment status lookup by c_invoice_id (optionally limit by startdate/enddate)
|
// 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)
|
transferController.paymentStatus(req, res)
|
||||||
);
|
);
|
||||||
// Signature generation for testing (uses PRIVATE_KEY_PATH file)
|
// Signature generation for testing (uses PRIVATE_KEY_PATH file)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue