diff --git a/BTCPayServer/BTCPayNetwork.cs b/BTCPayServer/BTCPayNetwork.cs index 00c222ab7..685215e6b 100644 --- a/BTCPayServer/BTCPayNetwork.cs +++ b/BTCPayServer/BTCPayNetwork.cs @@ -45,6 +45,7 @@ namespace BTCPayServer public string BlockExplorerLink { get; internal set; } public string UriScheme { get; internal set; } public Money MinFee { get; internal set; } + public string DisplayName { get; set; } [Obsolete("Should not be needed")] public bool IsBTC diff --git a/BTCPayServer/BTCPayNetworkProvider.Bitcoin.cs b/BTCPayServer/BTCPayNetworkProvider.Bitcoin.cs index 911edff2c..b6752d0e2 100644 --- a/BTCPayServer/BTCPayNetworkProvider.Bitcoin.cs +++ b/BTCPayServer/BTCPayNetworkProvider.Bitcoin.cs @@ -17,12 +17,13 @@ namespace BTCPayServer Add(new BTCPayNetwork() { CryptoCode = nbxplorerNetwork.CryptoCode, + DisplayName = "Bitcoin", BlockExplorerLink = NetworkType == NetworkType.Mainnet ? "https://www.smartbit.com.au/tx/{0}" : "https://testnet.smartbit.com.au/tx/{0}", NBitcoinNetwork = nbxplorerNetwork.NBitcoinNetwork, NBXplorerNetwork = nbxplorerNetwork, UriScheme = "bitcoin", - CryptoImagePath = "imlegacy/bitcoin-symbol.svg", - LightningImagePath = "imlegacy/btc-lightning.svg", + CryptoImagePath = "imlegacy/bitcoin.svg", + LightningImagePath = "imlegacy/bitcoin-lightning.svg", DefaultSettings = BTCPayDefaultSettings.GetDefaultSettings(NetworkType), CoinType = NetworkType == NetworkType.Mainnet ? new KeyPath("0'") : new KeyPath("1'") }); diff --git a/BTCPayServer/BTCPayNetworkProvider.BitcoinGold.cs b/BTCPayServer/BTCPayNetworkProvider.BitcoinGold.cs index 6befe5a2e..891483763 100644 --- a/BTCPayServer/BTCPayNetworkProvider.BitcoinGold.cs +++ b/BTCPayServer/BTCPayNetworkProvider.BitcoinGold.cs @@ -10,6 +10,7 @@ namespace BTCPayServer Add(new BTCPayNetwork() { CryptoCode = nbxplorerNetwork.CryptoCode, + DisplayName = "BGold", BlockExplorerLink = NetworkType == NetworkType.Mainnet ? "https://explorer.bitcoingold.org/insight/tx/{0}/" : "https://test-explorer.bitcoingold.org/insight/tx/{0}", NBitcoinNetwork = nbxplorerNetwork.NBitcoinNetwork, NBXplorerNetwork = nbxplorerNetwork, @@ -19,7 +20,7 @@ namespace BTCPayServer "BTG_X = BTG_BTC * BTC_X", "BTG_BTC = bitfinex(BTG_BTC)", }, - CryptoImagePath = "imlegacy/btg-symbol.svg", + CryptoImagePath = "imlegacy/btg.svg", LightningImagePath = "imlegacy/btg-lightning.svg", DefaultSettings = BTCPayDefaultSettings.GetDefaultSettings(NetworkType), CoinType = NetworkType == NetworkType.Mainnet ? new KeyPath("156'") : new KeyPath("1'") diff --git a/BTCPayServer/BTCPayNetworkProvider.Dogecoin.cs b/BTCPayServer/BTCPayNetworkProvider.Dogecoin.cs index be2918623..d583c20e2 100644 --- a/BTCPayServer/BTCPayNetworkProvider.Dogecoin.cs +++ b/BTCPayServer/BTCPayNetworkProvider.Dogecoin.cs @@ -16,6 +16,7 @@ namespace BTCPayServer Add(new BTCPayNetwork() { CryptoCode = nbxplorerNetwork.CryptoCode, + DisplayName = "Dogecoin", BlockExplorerLink = NetworkType == NetworkType.Mainnet ? "https://dogechain.info/tx/{0}" : "https://dogechain.info/tx/{0}", NBitcoinNetwork = nbxplorerNetwork.NBitcoinNetwork, NBXplorerNetwork = nbxplorerNetwork, diff --git a/BTCPayServer/BTCPayNetworkProvider.Feathercoin.cs b/BTCPayServer/BTCPayNetworkProvider.Feathercoin.cs index 2f48274b1..8f9642e2f 100644 --- a/BTCPayServer/BTCPayNetworkProvider.Feathercoin.cs +++ b/BTCPayServer/BTCPayNetworkProvider.Feathercoin.cs @@ -16,6 +16,7 @@ namespace BTCPayServer Add(new BTCPayNetwork() { CryptoCode = nbxplorerNetwork.CryptoCode, + DisplayName = "Feathercoin", BlockExplorerLink = NetworkType == NetworkType.Mainnet ? "https://explorer.feathercoin.com/tx/{0}" : "https://explorer.feathercoin.com/tx/{0}", NBitcoinNetwork = nbxplorerNetwork.NBitcoinNetwork, NBXplorerNetwork = nbxplorerNetwork, diff --git a/BTCPayServer/BTCPayNetworkProvider.Groestlcoin.cs b/BTCPayServer/BTCPayNetworkProvider.Groestlcoin.cs index 538975cd6..50ad0cf33 100644 --- a/BTCPayServer/BTCPayNetworkProvider.Groestlcoin.cs +++ b/BTCPayServer/BTCPayNetworkProvider.Groestlcoin.cs @@ -15,6 +15,7 @@ namespace BTCPayServer Add(new BTCPayNetwork() { CryptoCode = nbxplorerNetwork.CryptoCode, + DisplayName = "Groestlcoin", BlockExplorerLink = NetworkType == NetworkType.Mainnet ? "https://chainz.cryptoid.info/grs/tx.dws?{0}.htm" : "https://chainz.cryptoid.info/grs-test/tx.dws?{0}.htm", NBitcoinNetwork = nbxplorerNetwork.NBitcoinNetwork, NBXplorerNetwork = nbxplorerNetwork, diff --git a/BTCPayServer/BTCPayNetworkProvider.Litecoin.cs b/BTCPayServer/BTCPayNetworkProvider.Litecoin.cs index 42b3de248..c09692f49 100644 --- a/BTCPayServer/BTCPayNetworkProvider.Litecoin.cs +++ b/BTCPayServer/BTCPayNetworkProvider.Litecoin.cs @@ -16,12 +16,13 @@ namespace BTCPayServer Add(new BTCPayNetwork() { CryptoCode = nbxplorerNetwork.CryptoCode, + DisplayName = "Litecoin", BlockExplorerLink = NetworkType == NetworkType.Mainnet ? "https://live.blockcypher.com/ltc/tx/{0}/" : "http://explorer.litecointools.com/tx/{0}", NBitcoinNetwork = nbxplorerNetwork.NBitcoinNetwork, NBXplorerNetwork = nbxplorerNetwork, UriScheme = "litecoin", - CryptoImagePath = "imlegacy/litecoin-symbol.svg", - LightningImagePath = "imlegacy/ltc-lightning.svg", + CryptoImagePath = "imlegacy/litecoin.svg", + LightningImagePath = "imlegacy/litecoin-lightning.svg", DefaultSettings = BTCPayDefaultSettings.GetDefaultSettings(NetworkType), CoinType = NetworkType == NetworkType.Mainnet ? new KeyPath("2'") : new KeyPath("1'") }); diff --git a/BTCPayServer/BTCPayNetworkProvider.Monacoin.cs b/BTCPayServer/BTCPayNetworkProvider.Monacoin.cs index bb086132b..07798cd6e 100644 --- a/BTCPayServer/BTCPayNetworkProvider.Monacoin.cs +++ b/BTCPayServer/BTCPayNetworkProvider.Monacoin.cs @@ -16,6 +16,7 @@ namespace BTCPayServer Add(new BTCPayNetwork() { CryptoCode = nbxplorerNetwork.CryptoCode, + DisplayName = "Monacoin", BlockExplorerLink = NetworkType == NetworkType.Mainnet ? "https://mona.insight.monaco-ex.org/insight/tx/{0}" : "https://testnet-mona.insight.monaco-ex.org/insight/tx/{0}", NBitcoinNetwork = nbxplorerNetwork.NBitcoinNetwork, NBXplorerNetwork = nbxplorerNetwork, diff --git a/BTCPayServer/BTCPayNetworkProvider.Polis.cs b/BTCPayServer/BTCPayNetworkProvider.Polis.cs index 69640dab1..5379477c6 100644 --- a/BTCPayServer/BTCPayNetworkProvider.Polis.cs +++ b/BTCPayServer/BTCPayNetworkProvider.Polis.cs @@ -16,6 +16,7 @@ namespace BTCPayServer Add(new BTCPayNetwork() { CryptoCode = nbxplorerNetwork.CryptoCode, + DisplayName = "Polis", BlockExplorerLink = NetworkType == NetworkType.Mainnet ? "https://insight.polispay.org/tx/{0}" : "https://insight.polispay.org/tx/{0}", NBitcoinNetwork = nbxplorerNetwork.NBitcoinNetwork, NBXplorerNetwork = nbxplorerNetwork, diff --git a/BTCPayServer/BTCPayNetworkProvider.Ufo.cs b/BTCPayServer/BTCPayNetworkProvider.Ufo.cs index 45a3e6d6f..801bd7194 100644 --- a/BTCPayServer/BTCPayNetworkProvider.Ufo.cs +++ b/BTCPayServer/BTCPayNetworkProvider.Ufo.cs @@ -16,6 +16,7 @@ namespace BTCPayServer Add(new BTCPayNetwork() { CryptoCode = nbxplorerNetwork.CryptoCode, + DisplayName = "Ufo", BlockExplorerLink = NetworkType == NetworkType.Mainnet ? "https://chainz.cryptoid.info/ufo/tx.dws?{0}" : "https://chainz.cryptoid.info/ufo/tx.dws?{0}", NBitcoinNetwork = nbxplorerNetwork.NBitcoinNetwork, NBXplorerNetwork = nbxplorerNetwork, diff --git a/BTCPayServer/BTCPayNetworkProvider.Viacoin.cs b/BTCPayServer/BTCPayNetworkProvider.Viacoin.cs index 20116e188..58103a7cc 100644 --- a/BTCPayServer/BTCPayNetworkProvider.Viacoin.cs +++ b/BTCPayServer/BTCPayNetworkProvider.Viacoin.cs @@ -16,6 +16,7 @@ namespace BTCPayServer Add(new BTCPayNetwork() { CryptoCode = nbxplorerNetwork.CryptoCode, + DisplayName = "Viacoin", BlockExplorerLink = NetworkType == NetworkType.Mainnet ? "https://explorer.viacoin.org/tx/{0}" : "https://explorer.viacoin.org/tx/{0}", NBitcoinNetwork = nbxplorerNetwork.NBitcoinNetwork, NBXplorerNetwork = nbxplorerNetwork, diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index 93a4d73e5..1bc736e99 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -189,7 +189,7 @@ namespace BTCPayServer.Controllers _CSP.Add(new ConsentSecurityPolicy("script-src", "'unsafe-eval'")); // Needed by Vue - if(!string.IsNullOrEmpty(model.CustomCSSLink) && + if (!string.IsNullOrEmpty(model.CustomCSSLink) && Uri.TryCreate(model.CustomCSSLink, UriKind.Absolute, out var uri)) { _CSP.Clear(); @@ -248,6 +248,8 @@ namespace BTCPayServer.Controllers { CryptoCode = network.CryptoCode, PaymentMethodId = paymentMethodId.ToString(), + PaymentMethodName = GetDisplayName(paymentMethodId, network), + CryptoImage = GetImage(paymentMethodId, network), IsLightning = paymentMethodId.PaymentType == PaymentTypes.LightningLike, ServerUrl = HttpContext.Request.GetAbsoluteRoot(), OrderId = invoice.OrderId, @@ -279,7 +281,6 @@ namespace BTCPayServer.Controllers TxCount = accounting.TxRequired, BtcPaid = accounting.Paid.ToString(), Status = invoice.Status, - CryptoImage = "/" + GetImage(paymentMethodId, network), NetworkFee = paymentMethodDetails.GetTxFee(), IsMultiCurrency = invoice.GetPayments().Select(p => p.GetPaymentMethodId()).Concat(new[] { paymentMethod.GetId() }).Distinct().Count() > 1, AllowCoinConversion = storeBlob.AllowCoinConversion, @@ -288,10 +289,14 @@ namespace BTCPayServer.Controllers .Select(kv => new PaymentModel.AvailableCrypto() { PaymentMethodId = kv.GetId().ToString(), - CryptoImage = "/" + GetImage(kv.GetId(), kv.Network), + CryptoCode = kv.GetId().CryptoCode, + PaymentMethodName = GetDisplayName(kv.GetId(), kv.Network), + IsLightning = kv.GetId().PaymentType == PaymentTypes.LightningLike, + CryptoImage = GetImage(kv.GetId(), kv.Network), Link = Url.Action(nameof(Checkout), new { invoiceId = invoiceId, paymentMethodId = kv.GetId().ToString() }) }).Where(c => c.CryptoImage != "/") - .ToList() + .OrderByDescending(a => a.CryptoCode == "BTC").ThenBy(a => a.PaymentMethodName).ThenBy(a => a.IsLightning ? 1 : 0) + .ToList() }; var expiration = TimeSpan.FromSeconds(model.ExpirationSeconds); @@ -299,9 +304,17 @@ namespace BTCPayServer.Controllers return model; } + private string GetDisplayName(PaymentMethodId paymentMethodId, BTCPayNetwork network) + { + return paymentMethodId.PaymentType == PaymentTypes.BTCLike ? + network.DisplayName : network.DisplayName + " - Lightning"; + } + private string GetImage(PaymentMethodId paymentMethodId, BTCPayNetwork network) { - return (paymentMethodId.PaymentType == PaymentTypes.BTCLike ? Url.Content(network.CryptoImagePath) : Url.Content(network.LightningImagePath)); + var res = paymentMethodId.PaymentType == PaymentTypes.BTCLike ? + Url.Content(network.CryptoImagePath) : Url.Content(network.LightningImagePath); + return "/" + res; } private string OrderAmountFromInvoice(string cryptoCode, ProductInformation productInformation) @@ -338,7 +351,7 @@ namespace BTCPayServer.Controllers provider = (NumberFormatInfo)provider.Clone(); provider.CurrencyDecimalDigits = divisibility; } - + if (currencyData.Crypto) return price.ToString("C", provider); else diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index da28a8975..78a13d50b 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -12,6 +12,9 @@ namespace BTCPayServer.Models.InvoicingModels public string PaymentMethodId { get; set; } public string CryptoImage { get; set; } public string Link { get; set; } + public string PaymentMethodName { get; set; } + public bool IsLightning { get; set; } + public string CryptoCode { get; set; } } public string HtmlTitle { get; set; } public string CustomCSSLink { get; set; } @@ -30,8 +33,7 @@ namespace BTCPayServer.Models.InvoicingModels public string Status { get; set; } public string MerchantRefLink { get; set; } public int MaxTimeSeconds { get; set; } - - // These properties are not used in client side code + public string StoreName { get; set; } public string ItemDesc { get; set; } public string TimeLeft { get; set; } @@ -45,12 +47,13 @@ namespace BTCPayServer.Models.InvoicingModels public string StoreEmail { get; set; } public string OrderId { get; set; } - public string CryptoImage { get; set; } public decimal NetworkFee { get; set; } public bool IsMultiCurrency { get; set; } - public int MaxTimeMinutes { get; internal set; } - public string PaymentType { get; internal set; } - public string PaymentMethodId { get; internal set; } + public int MaxTimeMinutes { get; set; } + public string PaymentType { get; set; } + public string PaymentMethodId { get; set; } + public string PaymentMethodName { get; set; } + public string CryptoImage { get; set; } public bool AllowCoinConversion { get; set; } public string PeerInfo { get; set; } diff --git a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml index aa596e9fc..e73067e82 100644 --- a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml @@ -42,14 +42,30 @@
-
- @foreach (var crypto in Model.AvailableCryptos) - { - - @crypto.PaymentMethodId - - } -
+ @if (Model.AvailableCryptos.Count > 1) + { +
+ + {{srvModel.paymentMethodName}} ({{srvModel.cryptoCode}}) + + +
+
+ +
+ }
diff --git a/BTCPayServer/Views/Invoice/Checkout.cshtml b/BTCPayServer/Views/Invoice/Checkout.cshtml index 26268045f..1ef0a6909 100644 --- a/BTCPayServer/Views/Invoice/Checkout.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout.cshtml @@ -20,12 +20,15 @@ + - - @if(Model.CustomCSSLink != null) + @if (Model.CustomCSSLink != null) { } + +