diff --git a/BTCPayServer.Tests/AltcoinTests/AltcoinTests.cs b/BTCPayServer.Tests/AltcoinTests/AltcoinTests.cs index 382f5071a..563af1a57 100644 --- a/BTCPayServer.Tests/AltcoinTests/AltcoinTests.cs +++ b/BTCPayServer.Tests/AltcoinTests/AltcoinTests.cs @@ -323,7 +323,7 @@ namespace BTCPayServer.Tests (Models.InvoicingModels.PaymentModel)((JsonResult)controller.GetStatus(invoice.Id) .GetAwaiter().GetResult()).Value; Assert.Single(checkout.AvailableCryptos); - Assert.Equal("LTC", checkout.CryptoCode); + Assert.Equal("LTC", checkout.PaymentMethodCurrency); ////////////////////// @@ -478,7 +478,7 @@ namespace BTCPayServer.Tests (Models.InvoicingModels.PaymentModel)((JsonResult)controller.GetStatus(invoice.Id, null) .GetAwaiter().GetResult()).Value; Assert.Single(checkout.AvailableCryptos); - Assert.Equal("BTC", checkout.CryptoCode); + Assert.Equal("BTC", checkout.PaymentMethodCurrency); Assert.Single(invoice.PaymentCodes); Assert.Single(invoice.SupportedTransactionCurrencies); @@ -539,7 +539,7 @@ namespace BTCPayServer.Tests checkout = (Models.InvoicingModels.PaymentModel)((JsonResult)controller.GetStatus(invoice.Id, "LTC") .GetAwaiter().GetResult()).Value; Assert.Equal(2, checkout.AvailableCryptos.Count); - Assert.Equal("LTC", checkout.CryptoCode); + Assert.Equal("LTC", checkout.PaymentMethodCurrency); Assert.Equal(2, invoice.PaymentCodes.Count()); Assert.Equal(2, invoice.SupportedTransactionCurrencies.Count()); diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 69f713662..4b0f44e1e 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -1655,8 +1655,8 @@ namespace BTCPayServer.Tests // Standard for all uppercase characters in QR codes is still not implemented in all wallets // But we're proceeding with BECH32 being uppercase - Assert.Equal($"bitcoin:{paymentMethodUnified.BtcAddress}", paymentMethodUnified.InvoiceBitcoinUrl.Split('?')[0]); - Assert.Equal($"bitcoin:{paymentMethodUnified.BtcAddress.ToUpperInvariant()}", paymentMethodUnified.InvoiceBitcoinUrlQR.Split('?')[0]); + Assert.Equal($"bitcoin:{paymentMethodUnified.Address}", paymentMethodUnified.InvoiceBitcoinUrl.Split('?')[0]); + Assert.Equal($"bitcoin:{paymentMethodUnified.Address.ToUpperInvariant()}", paymentMethodUnified.InvoiceBitcoinUrlQR.Split('?')[0]); // Fallback lightning invoice should be uppercase inside the QR code, lowercase in payment URI var lightningFallback = paymentMethodUnified.InvoiceBitcoinUrl.Split(new[] { "&lightning=" }, StringSplitOptions.None)[1]; diff --git a/BTCPayServer/Controllers/UIInvoiceController.UI.cs b/BTCPayServer/Controllers/UIInvoiceController.UI.cs index d8ae2de74..5e075f651 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.UI.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.UI.cs @@ -867,7 +867,7 @@ namespace BTCPayServer.Controllers { Activated = prompt.Activated, PaymentMethodName = _prettyName.PrettyName(paymentMethodId), - CryptoCode = prompt.Currency, + PaymentMethodCurrency = prompt.Currency, RootPath = Request.PathBase.Value.WithTrailingSlash(), OrderId = orderId, InvoiceId = invoiceId, @@ -879,9 +879,9 @@ namespace BTCPayServer.Controllers CelebratePayment = storeBlob.CelebratePayment, OnChainWithLnInvoiceFallback = storeBlob.OnChainWithLnInvoiceFallback, CryptoImage = Request.GetRelativePathOrAbsolute(GetPaymentMethodImage(paymentMethodId)), - BtcAddress = prompt.Destination, - BtcDue = ShowMoney(accounting.Due), - BtcPaid = ShowMoney(accounting.Paid), + Address = prompt.Destination, + Due = ShowMoney(accounting.Due), + Paid = ShowMoney(accounting.Paid), InvoiceCurrency = invoice.Currency, // The Tweak is part of the PaymentMethodFee, but let's not show it in the UI as it's negligible. OrderAmount = ShowMoney(accounting.TotalDue - (prompt.PaymentMethodFee - prompt.TweakFee)), @@ -918,6 +918,7 @@ namespace BTCPayServer.Controllers { Displayed = displayedPaymentMethods.Contains(kv.PaymentMethodId), PaymentMethodId = kv.PaymentMethodId, + PaymentMethodName = _prettyName.PrettyName(kv.PaymentMethodId), Order = kv.PaymentMethodId switch { _ when PaymentTypes.CHAIN.GetPaymentMethodId(_NetworkProvider.DefaultNetwork.CryptoCode) == kv.PaymentMethodId => 0, @@ -932,7 +933,7 @@ namespace BTCPayServer.Controllers }; model.PaymentMethodId = paymentMethodId.ToString(); - model.OrderAmountFiat = OrderAmountFromInvoice(model.CryptoCode, invoice, DisplayFormatter.CurrencyFormat.Symbol); + model.OrderAmountFiat = OrderAmountFromInvoice(model.PaymentMethodCurrency, invoice, DisplayFormatter.CurrencyFormat.Symbol); if (storeBlob.PlaySoundOnPayment) { diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index 3170fb04f..1528e69d0 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -15,7 +15,8 @@ namespace BTCPayServer.Models.InvoicingModels [JsonConverter(typeof(PaymentMethodIdJsonConverter))] public PaymentMethodId PaymentMethodId { get; set; } public bool Displayed { get; set; } - public string Order { get; set; } + public string PaymentMethodName { get; set; } + public int Order { get; set; } [JsonExtensionData] public Dictionary AdditionalData { get; set; } = new(); } @@ -33,10 +34,10 @@ namespace BTCPayServer.Models.InvoicingModels public bool IsUnsetTopUp { get; set; } public bool OnChainWithLnInvoiceFallback { get; set; } public bool CelebratePayment { get; set; } - public string CryptoCode { get; set; } + public string PaymentMethodCurrency { get; set; } public string InvoiceId { get; set; } - public string BtcAddress { get; set; } - public string BtcDue { get; set; } + public string Address { get; set; } + public string Due { get; set; } public string CustomerEmail { get; set; } public bool ShowRecommendedFee { get; set; } public decimal FeeRate { get; set; } @@ -55,7 +56,7 @@ namespace BTCPayServer.Models.InvoicingModels public string InvoiceBitcoinUrlQR { get; set; } public int TxCount { get; set; } public int TxCountForFee { get; set; } - public string BtcPaid { get; set; } + public string Paid { get; set; } public string StoreSupportUrl { get; set; } public string OrderId { get; set; } diff --git a/BTCPayServer/Payments/Bitcoin/BitcoinPaymentModelExtension.cs b/BTCPayServer/Payments/Bitcoin/BitcoinPaymentModelExtension.cs index c0d20cfe0..7dc1dfd2e 100644 --- a/BTCPayServer/Payments/Bitcoin/BitcoinPaymentModelExtension.cs +++ b/BTCPayServer/Payments/Bitcoin/BitcoinPaymentModelExtension.cs @@ -57,7 +57,7 @@ namespace BTCPayServer.Payments.Bitcoin var bip21Case = _Network.SupportLightning && context.StoreBlob.OnChainWithLnInvoiceFallback; - var amountInSats = bip21Case && context.StoreBlob.LightningAmountInSatoshi && context.Model.CryptoCode == "BTC"; + var amountInSats = bip21Case && context.StoreBlob.LightningAmountInSatoshi && context.Model.PaymentMethodCurrency == "BTC"; string? lightningFallback = null; if (context.Model.Activated && bip21Case) { @@ -119,10 +119,10 @@ namespace BTCPayServer.Payments.Bitcoin // model.InvoiceBitcoinUrlQR: bitcoin:bcrt1qxp2qa5dhn7?amount=0.00044007&lightning=LNBCRT4400... } - if (_Network.CryptoCode.Equals("BTC", StringComparison.InvariantCultureIgnoreCase) && _bech32Prefix is not null && context.Model.BtcAddress.StartsWith(_bech32Prefix, StringComparison.OrdinalIgnoreCase)) + if (_Network.CryptoCode.Equals("BTC", StringComparison.InvariantCultureIgnoreCase) && _bech32Prefix is not null && context.Model.Address.StartsWith(_bech32Prefix, StringComparison.OrdinalIgnoreCase)) { context.Model.InvoiceBitcoinUrlQR = context.Model.InvoiceBitcoinUrlQR.Replace( - $"{_Network.NBitcoinNetwork.UriScheme}:{context.Model.BtcAddress}", $"{_Network.NBitcoinNetwork.UriScheme}:{context.Model.BtcAddress.ToUpperInvariant()}", + $"{_Network.NBitcoinNetwork.UriScheme}:{context.Model.Address}", $"{_Network.NBitcoinNetwork.UriScheme}:{context.Model.Address.ToUpperInvariant()}", StringComparison.OrdinalIgnoreCase); // model.InvoiceBitcoinUrlQR: bitcoin:BCRT1QXP2QA5DHN...?amount=0.00044007&lightning=LNBCRT4400... } @@ -144,9 +144,9 @@ namespace BTCPayServer.Payments.Bitcoin { NumberFormat = { NumberGroupSeparator = " " } }; - model.CryptoCode = "sats"; - model.BtcDue = Money.Parse(model.BtcDue).ToUnit(MoneyUnit.Satoshi).ToString("N0", satoshiCulture); - model.BtcPaid = Money.Parse(model.BtcPaid).ToUnit(MoneyUnit.Satoshi).ToString("N0", satoshiCulture); + model.PaymentMethodCurrency = "sats"; + model.Due = Money.Parse(model.Due).ToUnit(MoneyUnit.Satoshi).ToString("N0", satoshiCulture); + model.Paid = Money.Parse(model.Paid).ToUnit(MoneyUnit.Satoshi).ToString("N0", satoshiCulture); model.OrderAmount = Money.Parse(model.OrderAmount).ToUnit(MoneyUnit.Satoshi).ToString("N0", satoshiCulture); model.NetworkFee = new Money(model.NetworkFee, MoneyUnit.BTC).ToUnit(MoneyUnit.Satoshi); model.Rate = model.InvoiceCurrency is "BTC" or "SATS" diff --git a/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentModelExtension.cs b/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentModelExtension.cs index 016af162f..ad4224054 100644 --- a/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentModelExtension.cs +++ b/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentModelExtension.cs @@ -44,13 +44,13 @@ namespace BTCPayServer.Payments.LNURLPay var lnurl = paymentLinkExtension.GetPaymentLink(context.Prompt, context.UrlHelper); if (lnurl is not null) { - context.Model.BtcAddress = lnurl.Replace(UriScheme, ""); + context.Model.Address = lnurl.Replace(UriScheme, ""); context.Model.InvoiceBitcoinUrl = lnurl; context.Model.InvoiceBitcoinUrlQR = lnurl.ToUpperInvariant().Replace(UriScheme.ToUpperInvariant(), UriScheme); } context.Model.CheckoutBodyComponentName = LightningPaymentModelExtension.CheckoutBodyComponentName; context.Model.PeerInfo = handler.ParsePaymentPromptDetails(context.Prompt.Details).NodeInfo; - if (context.StoreBlob.LightningAmountInSatoshi && context.Model.CryptoCode == "BTC") + if (context.StoreBlob.LightningAmountInSatoshi && context.Model.PaymentMethodCurrency == "BTC") { BitcoinPaymentModelExtension.PreparePaymentModelForAmountInSats(context.Model, context.Prompt.Rate, _displayFormatter); } diff --git a/BTCPayServer/Payments/Lightning/LightningPaymentModelExtension.cs b/BTCPayServer/Payments/Lightning/LightningPaymentModelExtension.cs index 38f4ccb97..8ac3e7b36 100644 --- a/BTCPayServer/Payments/Lightning/LightningPaymentModelExtension.cs +++ b/BTCPayServer/Payments/Lightning/LightningPaymentModelExtension.cs @@ -50,7 +50,7 @@ namespace BTCPayServer.Payments.Lightning if (context.Model.InvoiceBitcoinUrl is not null) context.Model.InvoiceBitcoinUrlQR = $"lightning:{context.Model.InvoiceBitcoinUrl.ToUpperInvariant()?.Substring("LIGHTNING:".Length)}"; context.Model.PeerInfo = handler.ParsePaymentPromptDetails(paymentPrompt.Details).NodeInfo; - if (context.StoreBlob.LightningAmountInSatoshi && context.Model.CryptoCode == "BTC") + if (context.StoreBlob.LightningAmountInSatoshi && context.Model.PaymentMethodCurrency == "BTC") { BitcoinPaymentModelExtension.PreparePaymentModelForAmountInSats(context.Model, paymentPrompt.Rate, _displayFormatter); } diff --git a/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout.cshtml b/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout.cshtml index 4dc23a5e5..9a742cd67 100644 --- a/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout.cshtml +++ b/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout.cshtml @@ -13,9 +13,9 @@ -
+
- +
diff --git a/BTCPayServer/Views/Shared/Lightning/LightningLikeMethodCheckout.cshtml b/BTCPayServer/Views/Shared/Lightning/LightningLikeMethodCheckout.cshtml index a84d680d6..6ba1b168a 100644 --- a/BTCPayServer/Views/Shared/Lightning/LightningLikeMethodCheckout.cshtml +++ b/BTCPayServer/Views/Shared/Lightning/LightningLikeMethodCheckout.cshtml @@ -10,15 +10,15 @@
-
+
- +
-
This payment method is not available when using an insecure connection. Please use HTTPS or Tor.
+
This payment method is not available when using an insecure connection. Please use HTTPS or Tor.
@await Component.InvokeAsync("UiExtensionPoint", new {location = "checkout-lightning-post-content", model = Model})
diff --git a/BTCPayServer/Views/UIInvoice/Checkout-Cheating.cshtml b/BTCPayServer/Views/UIInvoice/Checkout-Cheating.cshtml index ef200378d..c489e743b 100644 --- a/BTCPayServer/Views/UIInvoice/Checkout-Cheating.cshtml +++ b/BTCPayServer/Views/UIInvoice/Checkout-Cheating.cshtml @@ -52,14 +52,14 @@ paying: false, mining: false, expiring: false, - amountRemaining: this.btcDue + amountRemaining: this.due } }, props: { invoiceId: String, paymentMethodId: String, cryptoCode: String, - btcDue: Number, + due: Number, isProcessing: Boolean, isSettled: Boolean }, diff --git a/BTCPayServer/Views/UIInvoice/Checkout-Testing.cshtml b/BTCPayServer/Views/UIInvoice/Checkout-Testing.cshtml index 962df2242..080f7ff7b 100644 --- a/BTCPayServer/Views/UIInvoice/Checkout-Testing.cshtml +++ b/BTCPayServer/Views/UIInvoice/Checkout-Testing.cshtml @@ -5,12 +5,12 @@
- +
- +
- -
@Model.CryptoCode
+ +
@Model.PaymentMethodCurrency
diff --git a/BTCPayServer/Views/UIInvoice/Checkout.cshtml b/BTCPayServer/Views/UIInvoice/Checkout.cshtml index 5110eb6db..2ad7bbc0a 100644 --- a/BTCPayServer/Views/UIInvoice/Checkout.cshtml +++ b/BTCPayServer/Views/UIInvoice/Checkout.cshtml @@ -60,7 +60,7 @@ } else { -

@Model.BtcDue @Model.CryptoCode

+

@Model.Due @Model.PaymentMethodCurrency

}
@@ -73,7 +73,7 @@
-
+