From 18d3f17ce31e0b7d3e5bdc65083c18c64fe0f4c3 Mon Sep 17 00:00:00 2001 From: wixarm Date: Sun, 1 Feb 2026 09:43:51 +0330 Subject: [PATCH] add: gui sep requests --- index.js | 133 +++++++------------------------------------------------ 1 file changed, 16 insertions(+), 117 deletions(-) diff --git a/index.js b/index.js index 88b7a8c..809a09d 100644 --- a/index.js +++ b/index.js @@ -855,7 +855,7 @@ app.post("/sep-pay-request", async (req, res) => { action: "token", TerminalId: SEP_TERMINAL_ID, Amount: parsedAmount, - ResNum, + ResNum: resNum, RedirectUrl: redirectUrl, CellNumber: phone, SettlementIBANInfo: wages, @@ -961,16 +961,8 @@ app.post("/sepverify", async (req, res) => { } }); -app.get("/sep-pay-requests/gui", async (req, res) => { - const basePath = - (req.baseUrl || "").replace(/\/sep-pay-requests\/gui$/, "") || ""; - const listPath = basePath - ? basePath + "/sep-pay-requests" - : "/sep-pay-requests"; - const submitPathPrefix = basePath - ? basePath + "/sep-pay-request/" - : "/sep-pay-request/"; - +// all-payments: list of saved SEP pay requests (from MongoDB) +app.get("/all-payments", async (req, res) => { let list = []; try { const coll = await getSepPayCollection(); @@ -984,7 +976,7 @@ app.get("/sep-pay-requests/gui", async (req, res) => { _id: doc._id ? doc._id.toString() : doc._id, })); } catch (err) { - console.error("sep-pay-requests gui list error", err); + console.error("all-payments list error", err); } const listJson = JSON.stringify(list) @@ -1000,75 +992,33 @@ app.get("/sep-pay-requests/gui", async (req, res) => { - SEP Pay Requests + همه پرداخت‌ها -

درخواست‌های پرداخت SEP

-

API لیست (JSON)

+

همه پرداخت‌ها

@@ -1077,57 +1027,6 @@ app.get("/sep-pay-requests/gui", async (req, res) => { res.send(html); }); -// List all SEP pay requests (API) -app.get("/sep-pay-requests", async (req, res) => { - try { - const coll = await getSepPayCollection(); - const list = await coll - .find({}) - .sort({ createdAt: -1 }) - .limit(500) - .toArray(); - // Ensure _id is string for GUI - const listWithIds = list.map((doc) => ({ - ...doc, - _id: doc._id ? doc._id.toString() : doc._id, - })); - return res.json(listWithIds); - } catch (err) { - console.error("sep-pay-requests list error", err); - return res.status(500).json({ error: err.message }); - } -}); - -// Manual submit to Taavon (like sepverify does) - use stored or body: authority, refId, cardHolderPan -app.post("/sep-pay-request/:id/submit", async (req, res) => { - const id = req.params.id; - const { authority, refId, cardHolderPan } = req.body; - try { - const coll = await getSepPayCollection(); - const doc = await coll.findOne({ _id: new ObjectId(id) }); - if (!doc) { - return res.status(404).json({ error: "Record not found" }); - } - const province = (doc.provincecode || "").toString().substring(0, 2); - const isLink = - doc.isLink === true || doc.isLink === "true" || doc.isLink === "1"; - const data = { - authority: authority ?? doc.token, - refId: refId ?? doc.traceNo, - cardHolderPan: cardHolderPan ?? doc.securePan, - }; - if (isLink) { - await taavonSendDataZarinPalLink(province, data); - } else { - await taavonSendDataZarinPal(province, data); - } - return res.json({ ok: true, message: "Submitted to Taavon" }); - } catch (err) { - console.error("sep-pay-request submit error", err); - return res.status(500).json({ error: err.message }); - } -}); - //end sep --------------------------------------------------------------------------------------------- // samasat crack