aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-09-18 16:38:32 -0700
committerAdam Soltys <[email protected]>2025-09-18 16:38:32 -0700
commit1347f87dcd92d318fbdd9d364648bc32ee52b4a7 (patch)
tree4667a87859446ca1f7494a3196190e18ec5f7ade /routes
parent8c7fa95d44aabd38fadc3ef955d835ad3379ec6c (diff)
parent3ec79e2f938423d1442886454204973d804f37d9 (diff)
downloadcoinos-server-1347f87dcd92d318fbdd9d364648bc32ee52b4a7.tar.gz
coinos-server-1347f87dcd92d318fbdd9d364648bc32ee52b4a7.zip
Merge branch 'patch-1'
Diffstat (limited to 'routes')
-rw-r--r--routes/invoices.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/routes/invoices.ts b/routes/invoices.ts
index 430c926d..7e98599e 100644
--- a/routes/invoices.ts
+++ b/routes/invoices.ts
@@ -53,11 +53,18 @@ export default {
try {
const { id } = req.params;
const { body } = req;
- if (body.invoice?.tip == null || body.invoice.tip < 0) fail("Invalid tip");
+ const { tip, webhook, secret } = body.invoice;
+ if (tip == null || tip < 0) fail("Invalid tip");
let invoice = await g(`invoice:${id}`);
- const user = await g(`user:${invoice.uid}`);
- invoice.tip = body.invoice.tip;
+ const user = req.user || (await g(`user:${invoice.uid}`));
+
+ if (tip) invoice.tip = tip;
+ if (invoice.uid === user?.id) {
+ if (webhook) invoice.webhook = webhook;
+ if (secret) invoice.secret = secret;
+ }
+
invoice = await generate({ invoice, user });
await s(`invoice:${id}`, invoice);