From 19b906ec847dbb1f07eeb2d74abd52d195cf6f3e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 6 Dec 2023 21:34:27 -0800 Subject: payment received notification --- lib/mail.js | 2 +- lib/payments.js | 15 ++++++++------- routes/users.js | 1 - templates/payments/received.html | 27 +++++++++++++++++++++++++++ templates/payments/sent.html | 27 --------------------------- 5 files changed, 36 insertions(+), 36 deletions(-) create mode 100644 templates/payments/received.html delete mode 100644 templates/payments/sent.html diff --git a/lib/mail.js b/lib/mail.js index 12580544..d5586aa5 100644 --- a/lib/mail.js +++ b/lib/mail.js @@ -10,7 +10,7 @@ let Charset = "UTF-8"; export let templates = { verifyEmail: "templates/payments/verify.html", - paymentSent: "templates/payments/sent.html" + paymentReceived: "templates/payments/received.html" }; export let mail = async (user, subject, template, params) => { diff --git a/lib/payments.js b/lib/payments.js index 8d7a7ff0..2d0b3330 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -23,7 +23,7 @@ export const types = { bitcoin: "bitcoin", lightning: "lightning", fund: "fund", - classic: "classic", + classic: "classic" }; export let debit = async ( @@ -91,7 +91,7 @@ export let debit = async ( type, ref, tip, - created: Date.now(), + created: Date.now() }; await s(`payment:${id}`, p); @@ -99,9 +99,6 @@ export let debit = async ( l("sent", type, user.username, amount); emit(user.id, "payment", p); - // mail(user, "Payment sent", templates.paymentSent, { - // username: user.username - // }); return p; }; @@ -153,7 +150,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { tip, type, confirmed: true, - created: Date.now(), + created: Date.now() }; if (type === types.bitcoin) invoice.pending += amount; @@ -185,6 +182,10 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { notify(user, `Received ${amount} sats`); callWebhook(invoice, p); + if (user.verified) { + mail(user, "Payment received", templates.paymentReceived, p); + } + mqtt1.publish( username, `pay:${p.amount}:${p.tip}:${p.rate}:${p.created}:${p.id}` @@ -291,7 +292,7 @@ export let payLightning = async (user, payreq, amount, maxfee, memo) => { bolt11: payreq.replace(/\s/g, "").toLowerCase(), amount_msat: amount_msat ? undefined : amount * 1000, maxfee: maxfee * 1000, - retry_for: 5, + retry_for: 5 }); if (!(r.status === "complete" && r.payment_preimage)) diff --git a/routes/users.js b/routes/users.js index 909cf186..b009573f 100644 --- a/routes/users.js +++ b/routes/users.js @@ -225,7 +225,6 @@ export default { "currencies", "currency", "display", - "email", "language", "fiat", "locktime", diff --git a/templates/payments/received.html b/templates/payments/received.html new file mode 100644 index 00000000..9facb849 --- /dev/null +++ b/templates/payments/received.html @@ -0,0 +1,27 @@ + + + + +
+ + + +
+ +
Hello {{username}},
+ +
+ You received {{amount}} sats! +
+ +
Cheers,
+ +
The Coinos Team
+ + diff --git a/templates/payments/sent.html b/templates/payments/sent.html deleted file mode 100644 index 087577e1..00000000 --- a/templates/payments/sent.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - -
- - - -
- -
Hello {{username}},
- -
- Please visit {{link}} to verify your email. -
- -
Thanks!
- -
The Coinos Team
- - -- cgit v1.2.3