mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-12 19:02:01 +01:00
Add lnurlpay to balance
This commit is contained in:
parent
2d370b8cea
commit
f08608f766
5 changed files with 34 additions and 13 deletions
|
@ -57,10 +57,10 @@ namespace BTCPayServer.Plugins.BoltcardBalance.Controllers
|
|||
var registration = await _dbContextFactory.GetBoltcardRegistration(issuerKey, boltData, true);
|
||||
if (registration is null)
|
||||
return NotFound();
|
||||
return await GetBalanceView(registration.PullPaymentId);
|
||||
return await GetBalanceView(registration.PullPaymentId, p);
|
||||
}
|
||||
[NonAction]
|
||||
public async Task<IActionResult> GetBalanceView(string ppId)
|
||||
public async Task<IActionResult> GetBalanceView(string ppId, string p)
|
||||
{
|
||||
using var ctx = _dbContextFactory.CreateContext();
|
||||
var pp = await ctx.PullPayments.FindAsync(ppId);
|
||||
|
@ -84,7 +84,8 @@ namespace BTCPayServer.Plugins.BoltcardBalance.Controllers
|
|||
var vm = new BalanceViewModel()
|
||||
{
|
||||
Currency = blob.Currency,
|
||||
AmountDue = blob.Limit - totalPaid
|
||||
AmountDue = blob.Limit - totalPaid,
|
||||
LNUrlPay = Url.Action(nameof(UIBoltcardController.GetPayRequest), "UIBoltcard", new { p }, "lnurlp")
|
||||
};
|
||||
foreach (var payout in payouts)
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace BTCPayServer.Plugins.BoltcardBalance.ViewModels
|
|||
public string Currency { get; set; }
|
||||
public decimal AmountDue { get; set; }
|
||||
public List<Transaction> Transactions { get; set; } = new List<Transaction>();
|
||||
|
||||
public string LNUrlPay { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,18 +13,27 @@
|
|||
<nav id="wizard-navbar">
|
||||
@if (this.ViewData["NoCancelWizard"] is not true)
|
||||
{
|
||||
<button type="button" class="btn btn-secondary only-for-js mt-4" id="lnurlwithdraw-button">
|
||||
<span class="fa fa-qrcode fa-2x" title="Deposit"></span>
|
||||
</button>
|
||||
<a href="#" id="CancelWizard" class="cancel mt-4">
|
||||
<vc:icon symbol="close" />
|
||||
</a>
|
||||
}
|
||||
</nav>
|
||||
<div class="d-flex justify-content-center">
|
||||
<div class="d-flex flex-column">
|
||||
<div class="d-flex flex-column justify-content-center align-items-center">
|
||||
<dl class="mb-0 mt-md-4">
|
||||
<div class="d-flex d-print-inline-block flex-column mb-4">
|
||||
<dt class="h4 fw-semibold text-nowrap text-primary text-print-default order-2 order-sm-1 mb-1">@DisplayFormatter.Currency(Model.AmountDue, Model.Currency)</dt>
|
||||
</div>
|
||||
</dl>
|
||||
<div class="lnurl-pay d-none">
|
||||
<vc:qr-code data="@Model.LNUrlPay" />
|
||||
</div>
|
||||
<div class="lnurl-pay d-flex gap-3 mt-3 mt-sm-0 d-none">
|
||||
<a class="btn btn-primary" target="_blank" href="@Model.LNUrlPay">Deposit from Wallet...</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -67,6 +67,17 @@
|
|||
setState("WaitingForCard");
|
||||
document.getElementById("balance-table").innerHTML = "";
|
||||
});
|
||||
|
||||
document.getElementById("lnurlwithdraw-button").addEventListener("click", function (e) {
|
||||
var el = document.getElementsByClassName("lnurl-pay");
|
||||
for (var i = 0; i < el.length; i++) {
|
||||
if (el[i].classList.contains("d-none"))
|
||||
el[i].classList.remove("d-none");
|
||||
else
|
||||
el[i].classList.add("d-none");
|
||||
}
|
||||
});
|
||||
|
||||
setState("ShowBalance");
|
||||
}
|
||||
else {
|
||||
|
@ -142,7 +153,7 @@
|
|||
}
|
||||
}
|
||||
delegate('click', "#start-scan-btn", startScan);
|
||||
// showBalance("lnurl://ewfw?p=test&c=test");
|
||||
//showBalance("lnurl://ewfw?p=test&c=test");
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace BTCPayServer.Plugins.BoltcardTopUp.Controllers
|
|||
await ctx.Payouts.AddAsync(payout);
|
||||
await ctx.SaveChangesAsync();
|
||||
_boltcardBalanceController.ViewData["NoCancelWizard"] = true;
|
||||
return await _boltcardBalanceController.GetBalanceView(registration.PullPaymentId);
|
||||
return await _boltcardBalanceController.GetBalanceView(registration.PullPaymentId, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue