aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-09-20 15:35:12 -0700
committerAdam Soltys <[email protected]>2023-09-20 15:38:06 -0700
commit27fa1e5479f285da62b761e36b7e7fb2b1319158 (patch)
tree6e786344c793695b1fdddefd9650f9e16b5ecca2 /lib
parentfb45ea1f665c5fc750e1bd09e3cc23be9c695133 (diff)
downloadcoinos-server-27fa1e5479f285da62b761e36b7e7fb2b1319158.tar.gz
coinos-server-27fa1e5479f285da62b761e36b7e7fb2b1319158.zip
shopify attributes
Diffstat (limited to 'lib')
-rw-r--r--lib/invoices.js6
-rw-r--r--lib/whitelist.js5
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/invoices.js b/lib/invoices.js
index 2e5a8e64..62bbee1c 100644
--- a/lib/invoices.js
+++ b/lib/invoices.js
@@ -2,7 +2,7 @@ import store from "$lib/store";
import { l } from "$lib/logging";
import { emit } from "$lib/sockets";
import { db, g, s } from "$lib/db";
-import { getUser, bip21, fail } from "$lib/utils";
+import { getUser, bip21, fail, SATS } from "$lib/utils";
import { types } from "$lib/payments";
import { v4 } from "uuid";
@@ -13,6 +13,7 @@ export let generate = async ({ invoice, user, sender, memo }) => {
let {
currency,
expiry,
+ fiat,
tip,
amount,
rate,
@@ -26,14 +27,13 @@ export let generate = async ({ invoice, user, sender, memo }) => {
amount = parseInt(amount || 0);
tip = parseInt(tip) || null;
- if (amount < 0) fail("amount out of range");
-
if (user) user = await getUser(user.username);
else if (sender) user = await getUser(sender.username);
else fail("user not provided");
if (!currency) currency = user.currency;
if (!rate) rate = store.rates[currency];
+ if (fiat) amount = Math.round((SATS * fiat) / rate);
if (amount < 0) fail("invalid amount");
let hash, text;
diff --git a/lib/whitelist.js b/lib/whitelist.js
index ed9e8f95..379c3fdc 100644
--- a/lib/whitelist.js
+++ b/lib/whitelist.js
@@ -28,5 +28,8 @@ export default [
"theme",
"twofa",
"username",
- "verified"
+ "verified",
+ "shopifyStore",
+ "shopifyPubkey",
+ "shopifySecret"
];