mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Displaying Node Info as QR code for Lightning payments (#318)
* Styling elements required for Node info * Allowing switching QR between bolt11 and node info for lightning * Equal width for Bolt11 and Node info buttons * Certain languages were too verbose for display of "Pay with" Fixes: #317
This commit is contained in:
committed by
Nicolas Dorier
parent
657cfe1b23
commit
d459839bf7
@@ -307,7 +307,7 @@ namespace BTCPayServer.Controllers
|
||||
private string GetDisplayName(PaymentMethodId paymentMethodId, BTCPayNetwork network)
|
||||
{
|
||||
return paymentMethodId.PaymentType == PaymentTypes.BTCLike ?
|
||||
network.DisplayName : network.DisplayName + " (via Lightning)";
|
||||
network.DisplayName : network.DisplayName + " (Lightning)";
|
||||
}
|
||||
|
||||
private string GetImage(PaymentMethodId paymentMethodId, BTCPayNetwork network)
|
||||
|
||||
@@ -188,9 +188,15 @@
|
||||
</form>
|
||||
</div>
|
||||
<div class="bp-view payment scan" id="scan">
|
||||
<div class="wrapBtnGroup" v-bind:class="{ invisible: lndModel === null }">
|
||||
<div class="btnGroupLnd">
|
||||
<button onclick="lndToggleBolt11()" v-bind:class="{ active: lndModel != null && lndModel.toggle === 0 }">{{$t("BOLT 11 Invoice")}}</button>
|
||||
<button onclick="lndToggleNode()" v-bind:class="{ active: lndModel != null && lndModel.toggle === 1 }">{{$t("Node Info")}}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="payment__scan">
|
||||
<img v-bind:src="srvModel.cryptoImage" class="qr_currency_icon" />
|
||||
<qrcode v-bind:val="srvModel.invoiceBitcoinUrlQR" v-bind:size="256" bg-color="#f5f5f7" fg-color="#000">
|
||||
<qrcode v-bind:val="scanDisplayQr" v-bind:size="256" bg-color="#f5f5f7" fg-color="#000">
|
||||
</qrcode>
|
||||
</div>
|
||||
<div class="payment__details__instruction__open-wallet">
|
||||
|
||||
@@ -151,6 +151,8 @@
|
||||
},
|
||||
data: {
|
||||
srvModel: srvModel,
|
||||
lndModel: null,
|
||||
scanDisplayQr: "",
|
||||
expiringSoon: false
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9236,7 +9236,7 @@ strong {
|
||||
}
|
||||
|
||||
.bp-view.scan {
|
||||
padding-top: .9em !important;
|
||||
padding-top: 0em !important;
|
||||
}
|
||||
|
||||
.bp-view:not(.active) {
|
||||
@@ -9376,11 +9376,64 @@ strong {
|
||||
border-bottom: 1px dotted;
|
||||
}
|
||||
|
||||
.wrapBtnGroup {
|
||||
text-align: center;
|
||||
margin: -2px 0px 12px;
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
.btnGroupLnd {
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
width: inherit;
|
||||
display: table;
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
font-size: 0px;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.btnGroupLnd button:first-child {
|
||||
border-top-left-radius: 5px;
|
||||
border-bottom-left-radius: 5px;
|
||||
border-right: 0px;
|
||||
}
|
||||
|
||||
.btnGroupLnd button:last-child {
|
||||
border-top-right-radius: 5px;
|
||||
border-bottom-right-radius: 5px;
|
||||
}
|
||||
|
||||
.btnGroupLnd button {
|
||||
display: table-cell;
|
||||
border: solid 1px #24725B;
|
||||
padding: 6px 9px;
|
||||
margin: 0px;
|
||||
font-size: 12px;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.btnGroupLnd button:hover {
|
||||
background-color: #eeffee;
|
||||
}
|
||||
|
||||
.btnGroupLnd button.active {
|
||||
background-color: #329F80;
|
||||
border-color: #329F80;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btnGroupLnd button.active:hover {
|
||||
background-color: #24725B;
|
||||
border-color: #24725B;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.payment__details__instruction__open-wallet {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin: 15px 15px 18px;
|
||||
margin: 0px 15px 18px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
|
||||
.clickable_underline {
|
||||
border-bottom: 1px dotted #ccc;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.payment__currencies:hover .clickable_underline {
|
||||
|
||||
@@ -20,6 +20,17 @@ function resetTabsSlider() {
|
||||
closePaymentMethodDialog(null);
|
||||
}
|
||||
|
||||
function changeCurrency(currency) {
|
||||
if (currency !== null && srvModel.paymentMethodId !== currency) {
|
||||
$(".payment__currencies").hide();
|
||||
$(".payment__spinner").show();
|
||||
checkoutCtrl.scanDisplayQr = "";
|
||||
srvModel.paymentMethodId = currency;
|
||||
fetchStatus();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function onDataCallback(jsonData) {
|
||||
// extender properties used
|
||||
jsonData.shapeshiftUrl = "https://shapeshift.io/shifty.html?destination=" + jsonData.btcAddress + "&output=" + jsonData.paymentMethodId + "&amount=" + jsonData.btcDue;
|
||||
@@ -66,18 +77,24 @@ function onDataCallback(jsonData) {
|
||||
$(".payment__spinner").hide();
|
||||
}
|
||||
|
||||
// updating ui
|
||||
checkoutCtrl.srvModel = jsonData;
|
||||
if (checkoutCtrl.scanDisplayQr === "") {
|
||||
checkoutCtrl.scanDisplayQr = jsonData.invoiceBitcoinUrlQR;
|
||||
}
|
||||
|
||||
function changeCurrency(currency) {
|
||||
if (currency !== null && srvModel.paymentMethodId !== currency) {
|
||||
$(".payment__currencies").hide();
|
||||
$(".payment__spinner").show();
|
||||
srvModel.paymentMethodId = currency;
|
||||
fetchStatus();
|
||||
if (jsonData.isLightning && checkoutCtrl.lndModel === null) {
|
||||
var lndModel = {
|
||||
toggle: 0
|
||||
};
|
||||
|
||||
checkoutCtrl.lndModel = lndModel;
|
||||
}
|
||||
return false;
|
||||
|
||||
if (!jsonData.isLightning) {
|
||||
checkoutCtrl.lndModel = null;
|
||||
}
|
||||
|
||||
// updating ui
|
||||
checkoutCtrl.srvModel = jsonData;
|
||||
}
|
||||
|
||||
function fetchStatus() {
|
||||
@@ -93,6 +110,16 @@ function fetchStatus() {
|
||||
});
|
||||
}
|
||||
|
||||
function lndToggleBolt11() {
|
||||
checkoutCtrl.lndModel.toggle = 0;
|
||||
checkoutCtrl.scanDisplayQr = checkoutCtrl.srvModel.invoiceBitcoinUrlQR;
|
||||
}
|
||||
|
||||
function lndToggleNode() {
|
||||
checkoutCtrl.lndModel.toggle = 1;
|
||||
checkoutCtrl.scanDisplayQr = checkoutCtrl.srvModel.peerInfo;
|
||||
}
|
||||
|
||||
// private methods
|
||||
$(document).ready(function () {
|
||||
// initialize
|
||||
|
||||
Reference in New Issue
Block a user