From a773584f6fff2e5b1cb928bfc070b6e2b62f94d2 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 21 Oct 2020 09:50:45 -0300 Subject: [PATCH] tags and extras metadata in payment details dialog. --- lnbits/core/views/api.py | 9 ++++++++- lnbits/static/js/components.js | 24 +++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index 5dd6a4ee2..0742220a4 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -191,11 +191,18 @@ async def api_payments_pay_lnurl(): ) try: + extra = {} + + if params.get("successAction"): + extra["success_action"] = params["successAction"] + if g.data["comment"]: + extra["comment"] = g.data["comment"] + payment_hash = pay_invoice( wallet_id=g.wallet.id, payment_request=params["pr"], description=g.data.get("description", ""), - extra={"success_action": params.get("successAction")}, + extra=extra, ) except Exception as exc: traceback.print_exc(7) diff --git a/lnbits/static/js/components.js b/lnbits/static/js/components.js index 0d37f520f..682da275a 100644 --- a/lnbits/static/js/components.js +++ b/lnbits/static/js/components.js @@ -1,4 +1,4 @@ -/* global Vue, moment, LNbits, EventHub, decryptLnurlPayAES */ +/* global _, Vue, moment, LNbits, EventHub, decryptLnurlPayAES */ Vue.component('lnbits-fsat', { props: { @@ -179,6 +179,11 @@ Vue.component('lnbits-payment-details', { props: ['payment'], template: `
+
+ + #{{ payment.tag }} + +
Date:
{{ payment.date }} ({{ payment.dateFrom }})
@@ -203,6 +208,15 @@ Vue.component('lnbits-payment-details', {
Payment proof:
{{ payment.preimage }}
+
+
+ + extra + + {{ entry.key }}: +
+
{{ entry.value }}
+
Success action:
@@ -228,6 +242,14 @@ Vue.component('lnbits-payment-details', { this.payment.extra && this.payment.extra.success_action ) + }, + hasTag() { + return this.payment.extra && !!this.payment.extra.tag + }, + extras() { + if (!this.payment.extra) return [] + let extras = _.omit(this.payment.extra, ['tag', 'success_action']) + return Object.keys(extras).map(key => ({key, value: extras[key]})) } } })