From b744fd6167e36c813802f81cc6238cb0c3eecb7d Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 7 Oct 2024 14:51:29 +0900 Subject: [PATCH 01/11] Allow payment methods to modify all the payment model --- .../Controllers/UIInvoiceController.UI.cs | 15 +++++++++---- .../Models/InvoicingModels/PaymentModel.cs | 15 +++++++++++-- .../Bitcoin/BitcoinPaymentModelExtension.cs | 4 ++-- .../Payments/IPaymentModelExtension.cs | 3 ++- .../LNURLPay/LNURLPayPaymentModelExtension.cs | 2 ++ .../LightningPaymentModelExtension.cs | 2 +- .../Payments/MoneroPaymentModelExtension.cs | 21 ++++++++++--------- .../Payments/ZcashPaymentModelExtension.cs | 20 +++++++++--------- 8 files changed, 52 insertions(+), 30 deletions(-) diff --git a/BTCPayServer/Controllers/UIInvoiceController.UI.cs b/BTCPayServer/Controllers/UIInvoiceController.UI.cs index ae594d3cf..6e2e4cc32 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.UI.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.UI.cs @@ -922,7 +922,6 @@ namespace BTCPayServer.Controllers Status = invoice.Status.ToString(), // The Tweak is part of the PaymentMethodFee, but let's not show it in the UI as it's negligible. NetworkFee = prompt.PaymentMethodFee - prompt.TweakFee, - IsMultiCurrency = invoice.GetPayments(false).Select(p => p.PaymentMethodId).Concat(new[] { prompt.PaymentMethodId }).Distinct().Count() > 1, StoreId = store.Id, AvailableCryptos = invoice.GetPaymentPrompts() .Select(kv => @@ -930,8 +929,9 @@ namespace BTCPayServer.Controllers var handler = _handlers[kv.PaymentMethodId]; return new PaymentModel.AvailableCrypto { + Handler = handler, Displayed = displayedPaymentMethods.Contains(kv.PaymentMethodId), - PaymentMethodId = kv.PaymentMethodId.ToString(), + PaymentMethodId = kv.PaymentMethodId, CryptoCode = kv.Currency, PaymentMethodName = _prettyName.PrettyName(kv.PaymentMethodId), IsLightning = handler is ILightningPaymentHandler, @@ -947,8 +947,15 @@ namespace BTCPayServer.Controllers .OrderByDescending(a => a.CryptoCode == _NetworkProvider.DefaultNetwork.CryptoCode).ThenBy(a => a.PaymentMethodName).ThenBy(a => a.IsLightning ? 1 : 0) .ToList() }; - if (_paymentModelExtensions.TryGetValue(paymentMethodId, out var extension)) - extension.ModifyPaymentModel(new PaymentModelContext(model, store, storeBlob, invoice, Url, prompt, handler)); + + foreach (var kv in invoice.GetPaymentPrompts()) + { + if (_paymentModelExtensions.TryGetValue(kv.PaymentMethodId, out var extension) && + _handlers.TryGetValue(kv.PaymentMethodId, out var h)) + { + extension.ModifyPaymentModel(new PaymentModelContext(model, store, storeBlob, invoice, Url, kv, h, paymentMethodId == kv.PaymentMethodId)); + } + } model.UISettings = _viewProvider.TryGetViewViewModel(prompt, "CheckoutUI")?.View as CheckoutUIPaymentMethodSettings; model.PaymentMethodId = paymentMethodId.ToString(); model.OrderAmountFiat = OrderAmountFromInvoice(model.CryptoCode, invoice, DisplayFormatter.CurrencyFormat.Symbol); diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index 5518ffd67..15898ae72 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -1,6 +1,9 @@ using System.Collections.Generic; using BTCPayServer.Client.Models; +using BTCPayServer.JsonConverters; using BTCPayServer.Payments; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace BTCPayServer.Models.InvoicingModels { @@ -9,13 +12,19 @@ namespace BTCPayServer.Models.InvoicingModels public CheckoutUIPaymentMethodSettings UISettings; public class AvailableCrypto { - public string PaymentMethodId { get; set; } + [JsonConverter(typeof(PaymentMethodIdJsonConverter))] + public PaymentMethodId 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 bool Displayed { get; set; } + [JsonIgnore] + public IPaymentMethodHandler Handler { get; internal set; } + + [JsonExtensionData] + public Dictionary AdditionalData { get; set; } = new(); } public StoreBrandingViewModel StoreBranding { get; set; } public string PaymentSoundUrl { get; set; } @@ -58,7 +67,6 @@ namespace BTCPayServer.Models.InvoicingModels public string OrderId { get; set; } public decimal NetworkFee { get; set; } - public bool IsMultiCurrency { get; set; } public int MaxTimeMinutes { get; set; } public string PaymentMethodId { get; set; } public string PaymentMethodName { get; set; } @@ -73,6 +81,9 @@ namespace BTCPayServer.Models.InvoicingModels public int? RequiredConfirmations { get; set; } public long? ReceivedConfirmations { get; set; } + [JsonIgnore] public HashSet ExtensionPartials { get; } = new HashSet(); + [JsonExtensionData] + public Dictionary AdditionalData { get; set; } = new(); } } diff --git a/BTCPayServer/Payments/Bitcoin/BitcoinPaymentModelExtension.cs b/BTCPayServer/Payments/Bitcoin/BitcoinPaymentModelExtension.cs index 1b22e46e3..273cccd01 100644 --- a/BTCPayServer/Payments/Bitcoin/BitcoinPaymentModelExtension.cs +++ b/BTCPayServer/Payments/Bitcoin/BitcoinPaymentModelExtension.cs @@ -46,9 +46,9 @@ namespace BTCPayServer.Payments.Bitcoin public PaymentMethodId PaymentMethodId { get; } public void ModifyPaymentModel(PaymentModelContext context) { - var prompt = context.Prompt; - if (!_handlers.TryGetValue(PaymentMethodId, out var o) || o is not BitcoinLikePaymentHandler handler) + if (context is not { IsSelected: true, Handler: BitcoinLikePaymentHandler handler}) return; + var prompt = context.Prompt; var details = handler.ParsePaymentPromptDetails(prompt.Details); context.Model.ShowRecommendedFee = context.StoreBlob.ShowRecommendedFee; context.Model.FeeRate = details.RecommendedFeeRate.SatoshiPerByte; diff --git a/BTCPayServer/Payments/IPaymentModelExtension.cs b/BTCPayServer/Payments/IPaymentModelExtension.cs index 3881396e7..a50755bbe 100644 --- a/BTCPayServer/Payments/IPaymentModelExtension.cs +++ b/BTCPayServer/Payments/IPaymentModelExtension.cs @@ -11,7 +11,8 @@ namespace BTCPayServer.Payments InvoiceEntity InvoiceEntity, IUrlHelper UrlHelper, PaymentPrompt Prompt, - IPaymentMethodHandler Handler); + IPaymentMethodHandler Handler, + bool IsSelected); public interface IPaymentModelExtension { public PaymentMethodId PaymentMethodId { get; } diff --git a/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentModelExtension.cs b/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentModelExtension.cs index b9abe91f3..14b19dfd2 100644 --- a/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentModelExtension.cs +++ b/BTCPayServer/Payments/LNURLPay/LNURLPayPaymentModelExtension.cs @@ -39,6 +39,8 @@ namespace BTCPayServer.Payments.LNURLPay private const string UriScheme = "lightning:"; public void ModifyPaymentModel(PaymentModelContext context) { + if (context is not { IsSelected: true, Handler: LNURLPayPaymentHandler handler }) + return; var lnurl = paymentLinkExtension.GetPaymentLink(context.Prompt, context.UrlHelper); if (lnurl is not null) { diff --git a/BTCPayServer/Payments/Lightning/LightningPaymentModelExtension.cs b/BTCPayServer/Payments/Lightning/LightningPaymentModelExtension.cs index 7a47ae7c1..7f1573625 100644 --- a/BTCPayServer/Payments/Lightning/LightningPaymentModelExtension.cs +++ b/BTCPayServer/Payments/Lightning/LightningPaymentModelExtension.cs @@ -39,7 +39,7 @@ namespace BTCPayServer.Payments.Lightning public string Badge => "⚡"; public void ModifyPaymentModel(PaymentModelContext context) { - if (!Handlers.TryGetValue(PaymentMethodId, out var o) || o is not LightningLikePaymentHandler handler) + if (context is not { IsSelected: true, Handler: LightningLikePaymentHandler handler }) return; var paymentPrompt = context.InvoiceEntity.GetPaymentPrompt(PaymentMethodId); if (paymentPrompt is null) diff --git a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroPaymentModelExtension.cs b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroPaymentModelExtension.cs index 6af2fbdcc..092cdb105 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroPaymentModelExtension.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroPaymentModelExtension.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using BTCPayServer.Payments; using BTCPayServer.Payments.Bitcoin; +using BTCPayServer.Payments.Lightning; using BTCPayServer.Services.Altcoins.Monero.Services; using BTCPayServer.Services.Invoices; @@ -33,20 +34,20 @@ namespace BTCPayServer.Services.Altcoins.Monero.Payments public void ModifyPaymentModel(PaymentModelContext context) { + if (context is not { IsSelected: true, Handler: MoneroLikePaymentMethodHandler handler }) + return; if (context.Model.Activated) { - if (_handlers.TryGetValue(PaymentMethodId, out var handler)) + var details = context.InvoiceEntity.GetPayments(true) + .Select(p => p.GetDetails(handler)) + .Where(p => p is not null) + .FirstOrDefault(); + if (details is not null) { - var details = context.InvoiceEntity.GetPayments(true) - .Select(p => p.GetDetails(handler)) - .Where(p => p is not null) - .FirstOrDefault(); - if (details is not null) - { - context.Model.ReceivedConfirmations = details.ConfirmationCount; - context.Model.RequiredConfirmations = (int)MoneroListener.ConfirmationsRequired(details, context.InvoiceEntity.SpeedPolicy); - } + context.Model.ReceivedConfirmations = details.ConfirmationCount; + context.Model.RequiredConfirmations = (int)MoneroListener.ConfirmationsRequired(details, context.InvoiceEntity.SpeedPolicy); } + context.Model.InvoiceBitcoinUrl = paymentLinkExtension.GetPaymentLink(context.Prompt, context.UrlHelper); context.Model.InvoiceBitcoinUrlQR = context.Model.InvoiceBitcoinUrl; } diff --git a/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashPaymentModelExtension.cs b/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashPaymentModelExtension.cs index f0fb35265..47a0527cd 100644 --- a/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashPaymentModelExtension.cs +++ b/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashPaymentModelExtension.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using BTCPayServer.Payments; +using BTCPayServer.Services.Altcoins.Monero.Payments; using BTCPayServer.Services.Altcoins.Zcash.Services; using BTCPayServer.Services.Invoices; @@ -32,19 +33,18 @@ namespace BTCPayServer.Services.Altcoins.Zcash.Payments public void ModifyPaymentModel(PaymentModelContext context) { + if (context is not { IsSelected: true, Handler: ZcashLikePaymentMethodHandler handler }) + return; if (context.Model.Activated) { - if (_handlers.TryGetValue(PaymentMethodId, out var handler)) + var details = context.InvoiceEntity.GetPayments(true) + .Select(p => p.GetDetails(handler)) + .Where(p => p is not null) + .FirstOrDefault(); + if (details is not null) { - var details = context.InvoiceEntity.GetPayments(true) - .Select(p => p.GetDetails(handler)) - .Where(p => p is not null) - .FirstOrDefault(); - if (details is not null) - { - context.Model.ReceivedConfirmations = details.ConfirmationCount; - context.Model.RequiredConfirmations = (int)ZcashListener.ConfirmationsRequired(context.InvoiceEntity.SpeedPolicy); - } + context.Model.ReceivedConfirmations = details.ConfirmationCount; + context.Model.RequiredConfirmations = (int)ZcashListener.ConfirmationsRequired(context.InvoiceEntity.SpeedPolicy); } context.Model.InvoiceBitcoinUrl = paymentLinkExtension.GetPaymentLink(context.Prompt, context.UrlHelper); context.Model.InvoiceBitcoinUrlQR = context.Model.InvoiceBitcoinUrl; From 8dcd7e6966bcd9ae7462f7775c48b294ea657315 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 7 Oct 2024 15:18:41 +0900 Subject: [PATCH 02/11] Remove no javascript for checkout --- .../Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs | 1 - .../Lightning/LightningPaymentMethodViewExtension.cs | 3 +-- .../Zcash/Payments/ZcashLikePaymentMethodHandler.cs | 3 +-- BTCPayServer/Views/UIInvoice/CheckoutNoScript.cshtml | 9 +-------- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs b/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs index bc09fc254..7df2d77cb 100644 --- a/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs +++ b/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs @@ -19,7 +19,6 @@ namespace BTCPayServer.Payments.LNURLPay ExtensionPartial = "Lightning/LightningLikeMethodCheckout", CheckoutBodyVueComponentName = "LightningLikeMethodCheckout", CheckoutHeaderVueComponentName = "LightningLikeMethodCheckoutHeader", - NoScriptPartialName = "Lightning/LightningLikeMethodCheckoutNoScript" }); } } diff --git a/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs b/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs index 41eb3ff4d..533c54feb 100644 --- a/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs +++ b/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs @@ -14,8 +14,7 @@ namespace BTCPayServer.Payments.Lightning { ExtensionPartial = "Lightning/LightningLikeMethodCheckout", CheckoutBodyVueComponentName = "LightningLikeMethodCheckout", - CheckoutHeaderVueComponentName = "LightningLikeMethodCheckoutHeader", - NoScriptPartialName = "Lightning/LightningLikeMethodCheckoutNoScript" + CheckoutHeaderVueComponentName = "LightningLikeMethodCheckoutHeader" }); } } diff --git a/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashLikePaymentMethodHandler.cs b/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashLikePaymentMethodHandler.cs index 76714b2f3..252ba7b37 100644 --- a/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashLikePaymentMethodHandler.cs +++ b/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashLikePaymentMethodHandler.cs @@ -108,8 +108,7 @@ namespace BTCPayServer.Services.Altcoins.Zcash.Payments { ExtensionPartial = "Bitcoin/BitcoinLikeMethodCheckout", CheckoutBodyVueComponentName = "BitcoinLikeMethodCheckout", - CheckoutHeaderVueComponentName = "BitcoinLikeMethodCheckoutHeader", - NoScriptPartialName = "Bitcoin/BitcoinLikeMethodCheckoutNoScript" + CheckoutHeaderVueComponentName = "BitcoinLikeMethodCheckoutHeader" }; } diff --git a/BTCPayServer/Views/UIInvoice/CheckoutNoScript.cshtml b/BTCPayServer/Views/UIInvoice/CheckoutNoScript.cshtml index f4bb0114c..957eaa250 100644 --- a/BTCPayServer/Views/UIInvoice/CheckoutNoScript.cshtml +++ b/BTCPayServer/Views/UIInvoice/CheckoutNoScript.cshtml @@ -17,14 +17,7 @@

Pay with @Model.StoreName

@if (Model.Status == "new") { - if (!string.IsNullOrEmpty(Model.UISettings?.NoScriptPartialName)) - { - - } - else - { -

This payment method requires javascript.

- } +

This payment method requires javascript.

@if (displayedPaymentMethods.Count > 1) {
From 0a2d8880ba5110514d428379edc18b467acaec3d Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 7 Oct 2024 15:20:26 +0900 Subject: [PATCH 03/11] Remove CheckoutBodyVueComponentName --- .../Payments/Bitcoin/BitcoinPaymentMethodViewExtension.cs | 4 +--- BTCPayServer/Payments/IPaymentMethodViewExtension.cs | 2 -- .../Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs | 3 +-- .../Payments/Lightning/LightningPaymentMethodViewExtension.cs | 3 +-- .../Monero/Payments/MoneroLikePaymentMethodHandler.cs | 4 +--- .../Altcoins/Zcash/Payments/ZcashLikePaymentMethodHandler.cs | 4 +--- 6 files changed, 5 insertions(+), 15 deletions(-) diff --git a/BTCPayServer/Payments/Bitcoin/BitcoinPaymentMethodViewExtension.cs b/BTCPayServer/Payments/Bitcoin/BitcoinPaymentMethodViewExtension.cs index bfcb6e07a..477f3b7dd 100644 --- a/BTCPayServer/Payments/Bitcoin/BitcoinPaymentMethodViewExtension.cs +++ b/BTCPayServer/Payments/Bitcoin/BitcoinPaymentMethodViewExtension.cs @@ -13,9 +13,7 @@ namespace BTCPayServer.Payments.Bitcoin context.RegisterCheckoutUI(new CheckoutUIPaymentMethodSettings { ExtensionPartial = "Bitcoin/BitcoinLikeMethodCheckout", - CheckoutBodyVueComponentName = "BitcoinLikeMethodCheckout", - CheckoutHeaderVueComponentName = "BitcoinLikeMethodCheckoutHeader", - NoScriptPartialName = "Bitcoin/BitcoinLikeMethodCheckoutNoScript" + CheckoutBodyVueComponentName = "BitcoinLikeMethodCheckout" }); } } diff --git a/BTCPayServer/Payments/IPaymentMethodViewExtension.cs b/BTCPayServer/Payments/IPaymentMethodViewExtension.cs index 00641483d..8cb7d5a10 100644 --- a/BTCPayServer/Payments/IPaymentMethodViewExtension.cs +++ b/BTCPayServer/Payments/IPaymentMethodViewExtension.cs @@ -64,7 +64,5 @@ namespace BTCPayServer.Payments { public string? ExtensionPartial { get; set; } public string? CheckoutBodyVueComponentName { get; set; } - public string? CheckoutHeaderVueComponentName { get; set; } - public string? NoScriptPartialName { get; set; } } } diff --git a/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs b/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs index 7df2d77cb..156fe233e 100644 --- a/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs +++ b/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs @@ -17,8 +17,7 @@ namespace BTCPayServer.Payments.LNURLPay context.RegisterCheckoutUI(new CheckoutUIPaymentMethodSettings() { ExtensionPartial = "Lightning/LightningLikeMethodCheckout", - CheckoutBodyVueComponentName = "LightningLikeMethodCheckout", - CheckoutHeaderVueComponentName = "LightningLikeMethodCheckoutHeader", + CheckoutBodyVueComponentName = "LightningLikeMethodCheckout" }); } } diff --git a/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs b/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs index 533c54feb..697305651 100644 --- a/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs +++ b/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs @@ -13,8 +13,7 @@ namespace BTCPayServer.Payments.Lightning context.RegisterCheckoutUI(new CheckoutUIPaymentMethodSettings() { ExtensionPartial = "Lightning/LightningLikeMethodCheckout", - CheckoutBodyVueComponentName = "LightningLikeMethodCheckout", - CheckoutHeaderVueComponentName = "LightningLikeMethodCheckoutHeader" + CheckoutBodyVueComponentName = "LightningLikeMethodCheckout" }); } } diff --git a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs index 1e216c3cc..7a535da1d 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs @@ -113,9 +113,7 @@ namespace BTCPayServer.Services.Altcoins.Monero.Payments return new CheckoutUIPaymentMethodSettings { ExtensionPartial = "Bitcoin/BitcoinLikeMethodCheckout", - CheckoutBodyVueComponentName = "BitcoinLikeMethodCheckout", - CheckoutHeaderVueComponentName = "BitcoinLikeMethodCheckoutHeader", - NoScriptPartialName = "Bitcoin/BitcoinLikeMethodCheckoutNoScript" + CheckoutBodyVueComponentName = "BitcoinLikeMethodCheckout" }; } diff --git a/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashLikePaymentMethodHandler.cs b/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashLikePaymentMethodHandler.cs index 252ba7b37..8984459f7 100644 --- a/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashLikePaymentMethodHandler.cs +++ b/BTCPayServer/Services/Altcoins/Zcash/Payments/ZcashLikePaymentMethodHandler.cs @@ -106,9 +106,7 @@ namespace BTCPayServer.Services.Altcoins.Zcash.Payments { return new CheckoutUIPaymentMethodSettings { - ExtensionPartial = "Bitcoin/BitcoinLikeMethodCheckout", - CheckoutBodyVueComponentName = "BitcoinLikeMethodCheckout", - CheckoutHeaderVueComponentName = "BitcoinLikeMethodCheckoutHeader" + ExtensionPartial = "Bitcoin/BitcoinLikeMethodCheckout" }; } From ef0ba7b0c41b4d9f95126609a04b3418517d6f15 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 7 Oct 2024 15:49:56 +0900 Subject: [PATCH 04/11] Remove useless properties --- .../Controllers/UIInvoiceController.UI.cs | 15 --------------- .../Bitcoin/BitcoinPaymentMethodViewExtension.cs | 1 - .../Payments/IPaymentMethodViewExtension.cs | 1 - .../LNURLPay/LNURLPaymentMethodViewExtension.cs | 3 +-- .../LightningPaymentMethodViewExtension.cs | 3 +-- .../Payments/MoneroLikePaymentMethodHandler.cs | 3 +-- .../Bitcoin/BitcoinLikeMethodCheckout.cshtml | 6 +++--- .../BitcoinLikeMethodCheckoutNoScript.cshtml | 8 -------- .../Lightning/LightningLikeMethodCheckout.cshtml | 6 +++--- .../LightningLikeMethodCheckoutNoScript.cshtml | 12 ------------ BTCPayServer/Views/UIInvoice/Checkout.cshtml | 4 ++-- BTCPayServer/wwwroot/checkout/checkout.js | 6 +++--- 12 files changed, 14 insertions(+), 54 deletions(-) delete mode 100644 BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckoutNoScript.cshtml delete mode 100644 BTCPayServer/Views/Shared/Lightning/LightningLikeMethodCheckoutNoScript.cshtml diff --git a/BTCPayServer/Controllers/UIInvoiceController.UI.cs b/BTCPayServer/Controllers/UIInvoiceController.UI.cs index 6e2e4cc32..4e095a01f 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.UI.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.UI.cs @@ -711,21 +711,6 @@ namespace BTCPayServer.Controllers return View(model); } - [HttpGet("invoice-noscript")] - public async Task CheckoutNoScript(string? invoiceId, string? id = null, string? paymentMethodId = null, [FromQuery] string? lang = null) - { - //Keep compatibility with Bitpay - invoiceId = invoiceId ?? id; - // - if (invoiceId is null) - return NotFound(); - var model = await GetInvoiceModel(invoiceId, paymentMethodId is null ? null : PaymentMethodId.Parse(paymentMethodId), lang); - if (model == null) - return NotFound(); - - return View(model); - } - private async Task GetInvoiceModel(string invoiceId, PaymentMethodId? paymentMethodId, string? lang) { var invoice = await _InvoiceRepository.GetInvoice(invoiceId); diff --git a/BTCPayServer/Payments/Bitcoin/BitcoinPaymentMethodViewExtension.cs b/BTCPayServer/Payments/Bitcoin/BitcoinPaymentMethodViewExtension.cs index 477f3b7dd..0850a48d5 100644 --- a/BTCPayServer/Payments/Bitcoin/BitcoinPaymentMethodViewExtension.cs +++ b/BTCPayServer/Payments/Bitcoin/BitcoinPaymentMethodViewExtension.cs @@ -13,7 +13,6 @@ namespace BTCPayServer.Payments.Bitcoin context.RegisterCheckoutUI(new CheckoutUIPaymentMethodSettings { ExtensionPartial = "Bitcoin/BitcoinLikeMethodCheckout", - CheckoutBodyVueComponentName = "BitcoinLikeMethodCheckout" }); } } diff --git a/BTCPayServer/Payments/IPaymentMethodViewExtension.cs b/BTCPayServer/Payments/IPaymentMethodViewExtension.cs index 8cb7d5a10..1266b5ac7 100644 --- a/BTCPayServer/Payments/IPaymentMethodViewExtension.cs +++ b/BTCPayServer/Payments/IPaymentMethodViewExtension.cs @@ -63,6 +63,5 @@ namespace BTCPayServer.Payments public class CheckoutUIPaymentMethodSettings { public string? ExtensionPartial { get; set; } - public string? CheckoutBodyVueComponentName { get; set; } } } diff --git a/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs b/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs index 156fe233e..6777c6433 100644 --- a/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs +++ b/BTCPayServer/Payments/LNURLPay/LNURLPaymentMethodViewExtension.cs @@ -16,8 +16,7 @@ namespace BTCPayServer.Payments.LNURLPay context.RegisterPaymentMethodDetails("LNURL/AdditionalPaymentMethodDetails"); context.RegisterCheckoutUI(new CheckoutUIPaymentMethodSettings() { - ExtensionPartial = "Lightning/LightningLikeMethodCheckout", - CheckoutBodyVueComponentName = "LightningLikeMethodCheckout" + ExtensionPartial = "Lightning/LightningLikeMethodCheckout" }); } } diff --git a/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs b/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs index 697305651..2ef202aef 100644 --- a/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs +++ b/BTCPayServer/Payments/Lightning/LightningPaymentMethodViewExtension.cs @@ -12,8 +12,7 @@ namespace BTCPayServer.Payments.Lightning { context.RegisterCheckoutUI(new CheckoutUIPaymentMethodSettings() { - ExtensionPartial = "Lightning/LightningLikeMethodCheckout", - CheckoutBodyVueComponentName = "LightningLikeMethodCheckout" + ExtensionPartial = "Lightning/LightningLikeMethodCheckout" }); } } diff --git a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs index 7a535da1d..b8e8001a6 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs @@ -112,8 +112,7 @@ namespace BTCPayServer.Services.Altcoins.Monero.Payments { return new CheckoutUIPaymentMethodSettings { - ExtensionPartial = "Bitcoin/BitcoinLikeMethodCheckout", - CheckoutBodyVueComponentName = "BitcoinLikeMethodCheckout" + ExtensionPartial = "Bitcoin/BitcoinLikeMethodCheckout" }; } diff --git a/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout.cshtml b/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout.cshtml index ad2e89e2f..ccb8dd4b6 100644 --- a/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout.cshtml +++ b/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout.cshtml @@ -3,7 +3,7 @@ @using BTCPayServer.Abstractions.TagHelpers @model BTCPayServer.Models.InvoicingModels.PaymentModel -