aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/payments.js10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/payments.js b/lib/payments.js
index 0a59a868..8200cdb0 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -95,8 +95,11 @@ export let debit = async (
export let credit = async (hash, amount, memo, ref, type = types.internal) => {
amount = parseInt(amount);
+
let invoice = await g(`invoice:${hash}`);
if (!invoice) return warn("failed to credit", hash, ", invoice not found");
+
+ let { tip } = invoice;
if (!memo) ({ memo } = invoice);
let user = await g(`user:${invoice.uid}`);
@@ -114,17 +117,12 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
currency,
memo,
ref,
+ tip,
type,
confirmed: true,
created: Date.now(),
};
- let { tip } = invoice;
- if (tip) {
- p.tip = tip;
- p.amount -= tip;
- }
-
invoice.received += amount;
let balance = "balance";