@using BTCPayServer.Payments @using BTCPayServer.Payments.Lightning @using BTCPayServer.Plugins.PointOfSale.Models @using BTCPayServer.Services @using BTCPayServer.Services.Invoices @using BTCPayServer.Services.Stores @using LNURL @inject BTCPayNetworkProvider BTCPayNetworkProvider @inject StoreRepository StoreRepository @inject PaymentMethodHandlerDictionary Handlers @model BTCPayServer.Plugins.PointOfSale.Models.ViewPointOfSaleViewModel @inject DisplayFormatter DisplayFormatter @{ var store = await StoreRepository.FindStore(Model.StoreId); Layout = "PointOfSale/Public/_Layout"; Context.Request.Query.TryGetValue("cryptocode", out var cryptoCodeValues); var cryptoCode = cryptoCodeValues.FirstOrDefault() ?? "BTC"; var pmi = PaymentTypes.LNURL.GetPaymentMethodId(cryptoCode); var supported = store.GetPaymentMethodConfig(pmi, Handlers); if (supported is not null && !store.GetEnabledPaymentIds().Contains(pmi)) { supported = null; } } @section PageHeadContent { } @if (supported is null) { } else { }
@if (!string.IsNullOrEmpty(Model.Description)) {
@Safe.Raw(Model.Description)
}
@if (supported is not null) { if (Model.ShowCustomAmount) { Model.Items = Model.Items.Concat(new[] { new ViewPointOfSaleViewModel.Item() { Description = "Create invoice to pay custom amount", Title = "Custom amount", BuyButtonText = Model.CustomButtonText, PriceType = ViewPointOfSaleViewModel.ItemPriceType.Topup } }).ToArray(); } }
@for (var x = 0; x < Model.Items.Length; x++) { var item = Model.Items[x]; var formatted = DisplayFormatter.Currency(item.Price ?? 0, Model.CurrencyCode, DisplayFormatter.CurrencyFormat.Symbol); if (item.PriceType == ViewPointOfSaleViewModel.ItemPriceType.Fixed && item.Price == 0) continue;
@Safe.Raw(item.Title)
@switch (item.PriceType) { case ViewPointOfSaleViewModel.ItemPriceType.Topup: Any amount break; case ViewPointOfSaleViewModel.ItemPriceType.Minimum: @formatted minimum break; case ViewPointOfSaleViewModel.ItemPriceType.Fixed: @formatted break; default: throw new ArgumentOutOfRangeException(); } @if (item.Inventory.HasValue) { @(item.Inventory > 0 ? $"{item.Inventory} left" : "Sold out") }
@if (!string.IsNullOrWhiteSpace(item.Description)) {

@Safe.Raw(item.Description)

}
@if (item.Inventory is null or > 0) { if (supported != null) { var lnurlEndpoint = new Uri(Url.Action("GetLNURLForApp", "UILNURL", new { cryptoCode = cryptoCode, appid = Model.AppId, ItemCode = item.Id }, Context.Request.Scheme, Context.Request.Host.ToString())); var lnUrl = LNURL.EncodeUri(lnurlEndpoint, "payRequest", supported.UseBech32Scheme); } }
}