diff --git a/lnbits/__init__.py b/lnbits/__init__.py
index f92d050..8edaa4b 100644
--- a/lnbits/__init__.py
+++ b/lnbits/__init__.py
@@ -30,6 +30,7 @@ Talisman(
"cdnjs.cloudflare.com",
"code.ionicframework.com",
"code.jquery.com",
+ "api.opennode.co",
"fonts.googleapis.com",
"fonts.gstatic.com",
"maxcdn.bootstrapcdn.com",
diff --git a/lnbits/extensions/tpos/config.json b/lnbits/extensions/tpos/config.json
index cdbd8f4..c5789af 100644
--- a/lnbits/extensions/tpos/config.json
+++ b/lnbits/extensions/tpos/config.json
@@ -1,6 +1,6 @@
{
- "name": "TPOS",
- "short_description": "A shareable POS!",
- "icon": "dialpad",
- "contributors": ["talvasconcelos", "arcbtc"]
+ "name": "TPoS",
+ "short_description": "A shareable PoS terminal!",
+ "icon": "dialpad",
+ "contributors": ["talvasconcelos", "arcbtc"]
}
diff --git a/lnbits/extensions/tpos/migrations.py b/lnbits/extensions/tpos/migrations.py
index d01e029..f7b1a17 100644
--- a/lnbits/extensions/tpos/migrations.py
+++ b/lnbits/extensions/tpos/migrations.py
@@ -5,14 +5,16 @@ def m001_initial(db):
"""
Initial tposs table.
"""
- db.execute("""
+ db.execute(
+ """
CREATE TABLE IF NOT EXISTS tposs (
id TEXT PRIMARY KEY,
wallet TEXT NOT NULL,
name TEXT NOT NULL,
currency TEXT NOT NULL
);
- """)
+ """
+ )
def migrate():
diff --git a/lnbits/extensions/tpos/templates/tpos/index.html b/lnbits/extensions/tpos/templates/tpos/index.html
index 05b99f2..cebcd8f 100644
--- a/lnbits/extensions/tpos/templates/tpos/index.html
+++ b/lnbits/extensions/tpos/templates/tpos/index.html
@@ -8,7 +8,7 @@
- New TPoS
+ New TPoS
@@ -31,7 +31,6 @@
-
{{ col.label }}
-
-
-
-
+
+
-
-
- Tiago's Point of Sale
- Is an instant and secure point of sale terminal. A merchant can use the PoS to accept payments to their LNbits wallet, without having to expose the wallet itself, which means it can even be shared with others. For example, a merchant could setup multiple TPoSs for each one of their colleagues, and use TPoS to track which colleague has taken sales. The terminal is optimized for mobile use, and is easily shared as a QR code, via the # share function on the TPoS.
- Created by, Tiago Vasconcelos
+ group="extras"
+ icon="info"
+ label="Info">
+
+
+ Tiago's Point of Sale
+ Is an instant and secure point of sale terminal. A merchant can use the PoS to accept payments to their LNbits wallet, without having to expose the wallet itself, which means it can even be shared with others.
+ For example, a merchant could setup multiple TPoSs for each one of their colleagues, and use TPoS to track which colleague has taken sales. The terminal is optimized for mobile use, and is easily shared as a QR code, via the "#" share function on the TPoS.
+ Created by Tiago Vasconcelos .
+
-
-
-
+
-
+
-
-
-
-
-
-
-
-
-
- Create TPoS
-
- Cancel
+ v-model.trim="formDialog.data.name"
+ label="Name"
+ placeholder="Tiago's PoS">
+
+
+ Create TPoS
+ Cancel
@@ -141,9 +134,13 @@
return {
tposs: [],
currencyOptions: [
- 'USD', 'EUR', 'GBP', 'DZD', 'ARP', 'AUD', 'ATS', 'BSD', 'BBD', 'BEF', 'BMD', 'BRL', 'BGL', 'CAD', 'CLP', 'CNY', 'CYP', 'CSK', 'DKK', 'NLG', 'XCD', 'EGP', 'FJD', 'FIM', 'FRF', 'DEM', 'XAU', 'GRD', 'HKD', 'HUF', 'ISK', 'INR', 'IDR', 'IEP', 'ILS', 'ITL', 'JMD', 'JPY', 'JOD', 'KRW', 'LBP', 'LUF', 'MYR', 'MXP', 'NLG', 'NZD', 'NOK', 'PKR', 'XPD', 'PHP', 'XPT', 'PLZ', 'PTE', 'ROL', 'RUR', 'SAR', 'XAG', 'SGD', 'SKK', 'ZAR', 'KRW', 'ESP', 'XDR', 'SDD', 'SEK', 'CHF', 'TWD', 'THB', 'TTD', 'TRL', 'VEB', 'ZMK', 'EUR', 'XCD', 'XDR', 'XAG', 'XAU', 'XPD', 'XPT',
- ],
-
+ 'USD', 'EUR', 'GBP', 'DZD', 'ARP', 'AUD', 'ATS', 'BSD', 'BBD', 'BEF', 'BMD', 'BRL', 'BGL', 'CAD', 'CLP',
+ 'CNY', 'CYP', 'CSK', 'DKK', 'NLG', 'XCD', 'EGP', 'FJD', 'FIM', 'FRF', 'DEM', 'XAU', 'GRD', 'HKD', 'HUF',
+ 'ISK', 'INR', 'IDR', 'IEP', 'ILS', 'ITL', 'JMD', 'JPY', 'JOD', 'KRW', 'LBP', 'LUF', 'MYR', 'MXP', 'NLG',
+ 'NZD', 'NOK', 'PKR', 'XPD', 'PHP', 'XPT', 'PLZ', 'PTE', 'ROL', 'RUR', 'SAR', 'XAG', 'SGD', 'SKK', 'ZAR',
+ 'KRW', 'ESP', 'XDR', 'SDD', 'SEK', 'CHF', 'TWD', 'THB', 'TTD', 'TRL', 'VEB', 'ZMK', 'EUR', 'XCD', 'XDR',
+ 'XAG', 'XAU', 'XPD', 'XPT'
+ ],
tpossTable: {
columns: [
{name: 'id', align: 'left', label: 'ID', field: 'id'},
@@ -154,13 +151,16 @@
rowsPerPage: 10
}
},
- tposDialog: {
+ formDialog: {
show: false,
data: {}
}
};
},
methods: {
+ closeFormDialog: function () {
+ this.formDialog.data = {};
+ },
getTPoSs: function () {
var self = this;
@@ -170,29 +170,25 @@
this.g.user.wallets[0].inkey
).then(function (response) {
self.tposs = response.data.map(function (obj) {
- console.log(obj)
return mapTPoS(obj);
});
});
},
createTPoS: function () {
var data = {
- name: this.tposDialog.data.name,
- currency: this.tposDialog.data.currency
+ name: this.formDialog.data.name,
+ currency: this.formDialog.data.currency
};
var self = this;
- console.log(this.tposDialog.data.wallet);
-
LNbits.api.request(
'POST',
'/tpos/api/v1/tposs',
- _.findWhere(this.g.user.wallets, {id: this.tposDialog.data.wallet}).inkey,
+ _.findWhere(this.g.user.wallets, {id: this.formDialog.data.wallet}).inkey,
data
).then(function (response) {
self.tposs.push(mapTPoS(response.data));
- self.tposDialog.show = false;
- self.tposDialog.data = {};
+ self.formDialog.show = false;
}).catch(function (error) {
LNbits.utils.notifyApiError(error);
});
@@ -202,7 +198,7 @@
var tpos = _.findWhere(this.tposs, {id: tposId});
this.$q.dialog({
- message: 'Are you sure you want to delete this TPoS link?',
+ message: 'Are you sure you want to delete this TPoS?',
ok: {
flat: true,
color: 'orange'
@@ -235,5 +231,3 @@
});
{% endblock %}
-
-
diff --git a/lnbits/extensions/tpos/templates/tpos/tpos.html b/lnbits/extensions/tpos/templates/tpos/tpos.html
index 1f5716e..5111069 100644
--- a/lnbits/extensions/tpos/templates/tpos/tpos.html
+++ b/lnbits/extensions/tpos/templates/tpos/tpos.html
@@ -1,241 +1,225 @@
-
-
+{% extends "public.html" %}
-
-
-
- TPoS
-
-
-
-
-
-
-
-
+{% block toolbar_title %}{{ tpos.name }}{% endblock %}
-
-
-
-
-
+{% block footer %}{% endblock %}
-
-
-
+{% block page_container %}
+
+
+
+
+
+
{% raw %}{{ famount }}{% endraw %}
+
+ {% raw %}{{ fsat }}{% endraw %} sat
+
+
-
-
1
-
2
-
3
-
C
-
4
-
5
-
6
-
7
-
8
-
9
-
OK
-
DEL
-
0
-
#
+
+
+
+
+
+ 1
+ 2
+ 3
+ C
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ OK
+ DEL
+ 0
+ #
+
+
-
-
-
-
-
-
+
-
-
+ });
+
+{% endblock %}
diff --git a/lnbits/extensions/tpos/views.py b/lnbits/extensions/tpos/views.py
index 98b473b..5edf1d3 100644
--- a/lnbits/extensions/tpos/views.py
+++ b/lnbits/extensions/tpos/views.py
@@ -1,8 +1,5 @@
-import requests
-
from flask import g, abort, render_template
-from lnbits.core.crud import get_wallet
from lnbits.decorators import check_user_exists, validate_uuids
from lnbits.helpers import Status
@@ -19,8 +16,6 @@ def index():
@tpos_ext.route("/")
def tpos(tpos_id):
- tpos = get_tpos(tpos_id) or abort(Status.NOT_FOUND, "tpos does not exist.")
- r = requests.get("https://api.opennode.co/v1/rates")
- r_json = r.json()
- rr = get_wallet(tpos.wallet)
- return render_template("tpos/tpos.html", tpos=tpos.id, inkey=rr.inkey, rate=r_json["data"]["BTC" + tpos.currency][tpos.currency], curr=tpos.currency)
+ tpos = get_tpos(tpos_id) or abort(Status.NOT_FOUND, "TPoS does not exist.")
+
+ return render_template("tpos/tpos.html", tpos=tpos)
diff --git a/lnbits/extensions/tpos/views_api.py b/lnbits/extensions/tpos/views_api.py
index 3f7cb0c..c756c66 100644
--- a/lnbits/extensions/tpos/views_api.py
+++ b/lnbits/extensions/tpos/views_api.py
@@ -1,6 +1,6 @@
from flask import g, jsonify, request
-from lnbits.core.crud import get_user
+from lnbits.core.crud import get_user, get_wallet
from lnbits.core.services import create_invoice
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
from lnbits.helpers import Status
@@ -30,9 +30,7 @@ def api_tposs():
}
)
def api_tpos_create():
- print("poo")
-
- tpos = create_tpos(wallet_id=g.wallet.id, name=g.data["name"], currency=g.data["currency"])
+ tpos = create_tpos(wallet_id=g.wallet.id, **g.data)
return jsonify(tpos._asdict()), Status.CREATED
@@ -50,31 +48,44 @@ def api_tpos_delete(tpos_id):
delete_tpos(tpos_id)
- return '', Status.NO_CONTENT
+ return "", Status.NO_CONTENT
-@tpos_ext.route("/api/v1/tposs/invoice/", methods=["POST"])
+@tpos_ext.route("/api/v1/tposs//invoices/", methods=["POST"])
@api_validate_post_request(schema={"amount": {"type": "integer", "min": 1, "required": True}})
def api_tpos_create_invoice(tpos_id):
-
tpos = get_tpos(tpos_id)
if not tpos:
return jsonify({"message": "TPoS does not exist."}), Status.NOT_FOUND
- try:
- memo = f"TPoS {tpos_id}"
- checking_id, payment_request = create_invoice(wallet_id=tpos.wallet, amount=g.data["amount"], memo=memo)
+ try:
+ checking_id, payment_request = create_invoice(
+ wallet_id=tpos.wallet, amount=g.data["amount"], memo=f"#tpos {tpos.name}"
+ )
except Exception as e:
return jsonify({"message": str(e)}), Status.INTERNAL_SERVER_ERROR
- return jsonify({"checking_id": checking_id, "payment_request": payment_request}), Status.OK
+ return jsonify({"checking_id": checking_id, "payment_request": payment_request}), Status.CREATED
+
+
+@tpos_ext.route("/api/v1/tposs//invoices/", methods=["GET"])
+def api_tpos_check_invoice(tpos_id, checking_id):
+ tpos = get_tpos(tpos_id)
+
+ if not tpos:
+ return jsonify({"message": "TPoS does not exist."}), Status.NOT_FOUND
+
+ try:
+ is_paid = not WALLET.get_invoice_status(checking_id).pending
+ except Exception:
+ return jsonify({"paid": False}), Status.OK
+
+ if is_paid:
+ wallet = get_wallet(tpos.wallet)
+ payment = wallet.get_payment(checking_id)
+ payment.set_pending(False)
-@tpos_ext.route("/api/v1/tposs/invoice/", methods=["GET"])
-def api_tpos_check_invoice(checking_id):
- print(checking_id)
- PAID = WALLET.get_invoice_status(checking_id).paid
+ return jsonify({"paid": True}), Status.OK
- if PAID == True:
- return jsonify({"PAID": True}), Status.OK
- return jsonify({"PAID": False}), Status.OK
+ return jsonify({"paid": False}), Status.OK
diff --git a/lnbits/templates/base.html b/lnbits/templates/base.html
index 9951df0..fbe16f3 100644
--- a/lnbits/templates/base.html
+++ b/lnbits/templates/base.html
@@ -26,11 +26,15 @@
{% block drawer_toggle %}
{% endblock %}
- {% if SITE_TITLE != 'LNbits' %}
- {{ SITE_TITLE }}
- {% else %}
- LN bits
- {% endif %}
+
+ {% block toolbar_title %}
+ {% if SITE_TITLE != 'LNbits' %}
+ {{ SITE_TITLE }}
+ {% else %}
+ LN bits
+ {% endif %}
+ {% endblock %}
+
{% block beta %}
USE WITH CAUTION - LNbits wallet is still in BETA
@@ -49,23 +53,27 @@
{% endblock %}
-
-
- {% block page %}{% endblock %}
-
-
+ {% block page_container %}
+
+
+ {% block page %}{% endblock %}
+
+
+ {% endblock %}
-
-
-
- LN bits, free and open-source lightning wallet
-
-
-
- View project in GitHub
-
-
-
+ {% block footer %}
+
+
+
+ LN bits, free and open-source lightning wallet
+
+
+
+ View project in GitHub
+
+
+
+ {% endblock %}