diff options
| author | Adam Soltys <[email protected]> | 2023-01-07 23:15:51 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-01-07 23:15:51 -0800 |
| commit | fc22686471eac52ad0cf8b688310c6758b61fea4 (patch) | |
| tree | 480757c5ed7343acb006a23773b0c60d8fc879b1 | |
| parent | 018732b4544fd95b7f1830db8b43dce26ebec1aa (diff) | |
| download | coinos-server-fc22686471eac52ad0cf8b688310c6758b61fea4.tar.gz coinos-server-fc22686471eac52ad0cf8b688310c6758b61fea4.zip | |
payments endpoint
| -rw-r--r-- | routes/invoices.js | 4 | ||||
| -rw-r--r-- | routes/payments.js | 15 |
2 files changed, 16 insertions, 3 deletions
diff --git a/routes/invoices.js b/routes/invoices.js index d689775f..338c66e7 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -20,7 +20,7 @@ app.get("/invoice", async (req, res, next) => { { model: db.User, as: "user", - attributes: ["username", "currency", "profile"] + attributes: ["username", "currency", "profile", "uuid"] }, { model: db.Request, @@ -53,7 +53,7 @@ app.get("/invoice/:text", async (req, res, next) => { include: { model: db.User, as: "user", - attributes: ["username", "currency", "profile"] + attributes: ["username", "currency", "profile", "uuid"] } }); diff --git a/routes/payments.js b/routes/payments.js index da55f1ec..093ad6b5 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -143,7 +143,7 @@ app.get("/payments", auth, async (req, res) => { } }); -app.get("/payment/:redeemcode", async (req, res) => { +app.get("/voucher/:redeemcode", async (req, res) => { try { const { redeemcode } = req.params; let payment = await db.Payment.findOne({ @@ -265,3 +265,16 @@ app.post("/checkRedeemCode", auth, async function(req, res) { const payment = await db.Payment.findOne({ where: { redeemcode } }); res.send(payment); }); + +app.get("/payments/:hash", auth, async function(req, res) { + console.log(req.params.hash) + try { + let payment = await db.Payment.findOne({ + where: { user_id: req.user.id, hash: req.params.hash } + }); + + return payment.get({ plain: true }); + } catch (e) { + console.log(e); + } +}); |
