From 27fa1e5479f285da62b761e36b7e7fb2b1319158 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 20 Sep 2023 15:35:12 -0700 Subject: shopify attributes --- lib/invoices.js | 6 +++--- lib/whitelist.js | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'lib') 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" ]; -- cgit v1.2.3