2021-10-29 10:27:33 +02:00
|
|
|
@using BTCPayServer.Payments.Lightning
|
2022-07-18 20:51:53 +02:00
|
|
|
@using BTCPayServer.Plugins.PointOfSale.Models
|
2023-05-23 02:18:57 +02:00
|
|
|
@using BTCPayServer.Services
|
2022-05-27 16:26:31 +09:00
|
|
|
@using BTCPayServer.Services.Stores
|
2021-10-29 10:27:33 +02:00
|
|
|
@using LNURL
|
|
|
|
@inject BTCPayNetworkProvider BTCPayNetworkProvider
|
2022-05-27 16:26:31 +09:00
|
|
|
@inject StoreRepository StoreRepository
|
2022-07-18 20:51:53 +02:00
|
|
|
@model BTCPayServer.Plugins.PointOfSale.Models.ViewPointOfSaleViewModel
|
2023-05-23 02:18:57 +02:00
|
|
|
@inject DisplayFormatter DisplayFormatter
|
2021-10-29 10:27:33 +02:00
|
|
|
@{
|
2022-05-27 16:26:31 +09:00
|
|
|
var store = await StoreRepository.FindStore(Model.StoreId);
|
2023-01-30 09:23:49 +01:00
|
|
|
Layout = "PointOfSale/Public/_Layout";
|
2021-10-29 10:27:33 +02:00
|
|
|
Context.Request.Query.TryGetValue("cryptocode", out var cryptoCodeValues);
|
|
|
|
var cryptoCode = cryptoCodeValues.FirstOrDefault() ?? "BTC";
|
2022-05-27 16:26:31 +09:00
|
|
|
var supported = store.GetSupportedPaymentMethods(BTCPayNetworkProvider).OfType<LNURLPaySupportedPaymentMethod>().OrderBy(method => method.CryptoCode == cryptoCode).FirstOrDefault();
|
|
|
|
if (supported != null && !store.GetEnabledPaymentIds(BTCPayNetworkProvider).Contains(supported.PaymentId))
|
2021-10-29 10:27:33 +02:00
|
|
|
{
|
|
|
|
supported = null;
|
|
|
|
}
|
|
|
|
}
|
2023-02-10 16:26:38 +01:00
|
|
|
@section PageHeadContent {
|
2023-07-22 14:15:41 +02:00
|
|
|
<link href="~/pos/print.css" asp-append-version="true" rel="stylesheet" />
|
2023-02-10 16:26:38 +01:00
|
|
|
}
|
2021-11-05 17:21:33 +02:00
|
|
|
|
2021-10-29 10:27:33 +02:00
|
|
|
@if (supported is null)
|
|
|
|
{
|
|
|
|
<div class="alert alert-warning text-center sticky-top mb-0 rounded-0" role="alert">
|
|
|
|
LNURL is not enabled on your store, which this print feature relies on.
|
2022-05-27 16:26:31 +09:00
|
|
|
<a asp-controller="UIStores" asp-action="LightningSettings" asp-route-cryptoCode="BTC" asp-route-storeId="@store.Id" class="alert-link p-0">
|
2021-11-05 17:21:33 +02:00
|
|
|
Enable LNURL
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
}
|
2023-01-30 09:23:49 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
<div class="alert alert-info alert-dismissible d-flex align-items-center justify-content-center sticky-top mb-0 rounded-0 d-print-none fade show" role="alert">
|
|
|
|
<button type="button" class="btn btn-info me-4 border border-light" onclick="window.print()">
|
|
|
|
<i class="fa fa-print"></i> Print
|
|
|
|
</button>
|
|
|
|
This view is intended for printing only —
|
|
|
|
|
|
|
|
<a asp-route-viewType="static" class="alert-link">Regular version</a>
|
|
|
|
</div>
|
|
|
|
}
|
2023-11-21 10:13:26 +01:00
|
|
|
<div id="PosPrint" class="public-page-wrap">
|
2023-01-30 09:23:49 +01:00
|
|
|
<partial name="_StatusMessage" />
|
2023-12-01 16:13:44 +01:00
|
|
|
<partial name="_StoreHeader" model="(string.IsNullOrEmpty(Model.Title) ? Model.StoreName : Model.Title, Model.StoreBranding)" />
|
2023-01-30 09:23:49 +01:00
|
|
|
@if (!string.IsNullOrEmpty(Model.Description))
|
|
|
|
{
|
|
|
|
<div class="lead text-center">@Safe.Raw(Model.Description)</div>
|
|
|
|
}
|
2023-07-22 14:15:41 +02:00
|
|
|
<main>
|
2023-01-26 01:27:31 +01:00
|
|
|
@if (supported is not null)
|
|
|
|
{
|
|
|
|
if (Model.ShowCustomAmount)
|
|
|
|
{
|
|
|
|
Model.Items = Model.Items.Concat(new[]
|
2021-11-05 17:21:33 +02:00
|
|
|
{
|
2023-01-26 01:27:31 +01:00
|
|
|
new ViewPointOfSaleViewModel.Item()
|
2021-11-05 17:21:33 +02:00
|
|
|
{
|
2023-01-26 01:27:31 +01:00
|
|
|
Description = "Create invoice to pay custom amount",
|
|
|
|
Title = "Custom amount",
|
|
|
|
BuyButtonText = Model.CustomButtonText,
|
2023-05-23 02:18:57 +02:00
|
|
|
PriceType = ViewPointOfSaleViewModel.ItemPriceType.Topup
|
2021-11-05 17:21:33 +02:00
|
|
|
}
|
2023-01-26 01:27:31 +01:00
|
|
|
}).ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-22 14:15:41 +02:00
|
|
|
<div class="posItems">
|
2023-01-30 09:23:49 +01:00
|
|
|
@for (var x = 0; x < Model.Items.Length; x++)
|
2023-01-26 01:27:31 +01:00
|
|
|
{
|
|
|
|
var item = Model.Items[x];
|
2023-07-22 14:15:41 +02:00
|
|
|
var formatted = DisplayFormatter.Currency(item.Price ?? 0, Model.CurrencyCode, DisplayFormatter.CurrencyFormat.Symbol);
|
|
|
|
<div class="d-flex flex-wrap">
|
|
|
|
<div class="card px-0" data-id="@x">
|
|
|
|
<div class="card-body p-3 d-flex flex-column gap-2">
|
|
|
|
<h5 class="card-title m-0">@Safe.Raw(item.Title)</h5>
|
|
|
|
<div class="d-flex gap-2 align-items-center">
|
|
|
|
<span class="fw-semibold">
|
|
|
|
@switch (item.PriceType)
|
|
|
|
{
|
|
|
|
case ViewPointOfSaleViewModel.ItemPriceType.Topup:
|
|
|
|
<span>Any amount</span>
|
|
|
|
break;
|
|
|
|
case ViewPointOfSaleViewModel.ItemPriceType.Minimum:
|
|
|
|
<span>@formatted minimum</span>
|
|
|
|
break;
|
|
|
|
case ViewPointOfSaleViewModel.ItemPriceType.Fixed:
|
|
|
|
@formatted
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new ArgumentOutOfRangeException();
|
|
|
|
}
|
|
|
|
</span>
|
|
|
|
@if (item.Inventory.HasValue)
|
|
|
|
{
|
|
|
|
<span class="badge text-bg-light">
|
|
|
|
@(item.Inventory > 0 ? $"{item.Inventory} left" : "Sold out")
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
@if (!string.IsNullOrWhiteSpace(item.Description))
|
2023-01-26 01:27:31 +01:00
|
|
|
{
|
2023-07-22 14:15:41 +02:00
|
|
|
<p class="card-text">@Safe.Raw(item.Description)</p>
|
2023-01-26 01:27:31 +01:00
|
|
|
}
|
|
|
|
</div>
|
2023-07-22 14:15:41 +02:00
|
|
|
@if (item.Inventory is null or > 0)
|
2023-01-26 01:27:31 +01:00
|
|
|
{
|
|
|
|
if (supported != null)
|
|
|
|
{
|
|
|
|
var lnurlEndpoint = new Uri(Url.Action("GetLNURLForApp", "UILNURL", new
|
|
|
|
{
|
|
|
|
cryptoCode = supported.CryptoCode,
|
|
|
|
appid = Model.AppId,
|
|
|
|
ItemCode = item.Id
|
|
|
|
}, Context.Request.Scheme, Context.Request.Host.ToString()));
|
|
|
|
var lnUrl = LNURL.EncodeUri(lnurlEndpoint, "payRequest", supported.UseBech32Scheme);
|
2023-07-22 14:15:41 +02:00
|
|
|
<a href="@lnUrl" rel="noreferrer noopener" class="card-img-bottom">
|
2023-01-30 09:23:49 +01:00
|
|
|
<vc:qr-code data="@lnUrl.ToString().ToUpperInvariant()" />
|
|
|
|
</a>
|
2023-01-26 01:27:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
2021-10-29 10:27:33 +02:00
|
|
|
</div>
|
2023-01-30 09:23:49 +01:00
|
|
|
</main>
|
2023-07-22 14:15:41 +02:00
|
|
|
<footer class="store-footer d-print-none">
|
2023-03-08 13:39:03 +01:00
|
|
|
<a class="store-powered-by" href="https://btcpayserver.org" target="_blank" rel="noreferrer noopener">
|
2023-01-30 09:23:49 +01:00
|
|
|
Powered by <partial name="_StoreFooterLogo" />
|
|
|
|
</a>
|
|
|
|
</footer>
|
2021-11-05 17:21:33 +02:00
|
|
|
</div>
|