Rename more legacy fields

This commit is contained in:
nicolas.dorier
2024-10-07 21:14:37 +09:00
parent 968223a953
commit 68f24e47cd
8 changed files with 13 additions and 17 deletions

View File

@@ -322,7 +322,7 @@ namespace BTCPayServer.Tests
var checkout = var checkout =
(Models.InvoicingModels.CheckoutModel)((JsonResult)controller.GetStatus(invoice.Id) (Models.InvoicingModels.CheckoutModel)((JsonResult)controller.GetStatus(invoice.Id)
.GetAwaiter().GetResult()).Value; .GetAwaiter().GetResult()).Value;
Assert.Single(checkout.AvailableCryptos); Assert.Single(checkout.AvailablePaymentMethods);
Assert.Equal("LTC", checkout.PaymentMethodCurrency); Assert.Equal("LTC", checkout.PaymentMethodCurrency);
////////////////////// //////////////////////
@@ -477,7 +477,7 @@ namespace BTCPayServer.Tests
var checkout = var checkout =
(Models.InvoicingModels.CheckoutModel)((JsonResult)controller.GetStatus(invoice.Id, null) (Models.InvoicingModels.CheckoutModel)((JsonResult)controller.GetStatus(invoice.Id, null)
.GetAwaiter().GetResult()).Value; .GetAwaiter().GetResult()).Value;
Assert.Single(checkout.AvailableCryptos); Assert.Single(checkout.AvailablePaymentMethods);
Assert.Equal("BTC", checkout.PaymentMethodCurrency); Assert.Equal("BTC", checkout.PaymentMethodCurrency);
Assert.Single(invoice.PaymentCodes); Assert.Single(invoice.PaymentCodes);
@@ -538,7 +538,7 @@ namespace BTCPayServer.Tests
controller = tester.PayTester.GetController<UIInvoiceController>(null); controller = tester.PayTester.GetController<UIInvoiceController>(null);
checkout = (Models.InvoicingModels.CheckoutModel)((JsonResult)controller.GetStatus(invoice.Id, "LTC") checkout = (Models.InvoicingModels.CheckoutModel)((JsonResult)controller.GetStatus(invoice.Id, "LTC")
.GetAwaiter().GetResult()).Value; .GetAwaiter().GetResult()).Value;
Assert.Equal(2, checkout.AvailableCryptos.Count); Assert.Equal(2, checkout.AvailablePaymentMethods.Count);
Assert.Equal("LTC", checkout.PaymentMethodCurrency); Assert.Equal("LTC", checkout.PaymentMethodCurrency);
Assert.Equal(2, invoice.PaymentCodes.Count()); Assert.Equal(2, invoice.PaymentCodes.Count());

View File

@@ -910,11 +910,11 @@ namespace BTCPayServer.Controllers
// The Tweak is part of the PaymentMethodFee, but let's not show it in the UI as it's negligible. // 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, NetworkFee = prompt.PaymentMethodFee - prompt.TweakFee,
StoreId = store.Id, StoreId = store.Id,
AvailableCryptos = invoice.GetPaymentPrompts() AvailablePaymentMethods = invoice.GetPaymentPrompts()
.Select(kv => .Select(kv =>
{ {
var handler = _handlers[kv.PaymentMethodId]; var handler = _handlers[kv.PaymentMethodId];
return new CheckoutModel.AvailableCrypto return new CheckoutModel.AvailablePaymentMethod
{ {
Displayed = displayedPaymentMethods.Contains(kv.PaymentMethodId), Displayed = displayedPaymentMethods.Contains(kv.PaymentMethodId),
PaymentMethodId = kv.PaymentMethodId, PaymentMethodId = kv.PaymentMethodId,

View File

@@ -10,7 +10,7 @@ namespace BTCPayServer.Models.InvoicingModels
public class CheckoutModel public class CheckoutModel
{ {
public string CheckoutBodyComponentName { get; set; } public string CheckoutBodyComponentName { get; set; }
public class AvailableCrypto public class AvailablePaymentMethod
{ {
[JsonConverter(typeof(PaymentMethodIdJsonConverter))] [JsonConverter(typeof(PaymentMethodIdJsonConverter))]
public PaymentMethodId PaymentMethodId { get; set; } public PaymentMethodId PaymentMethodId { get; set; }
@@ -29,7 +29,7 @@ namespace BTCPayServer.Models.InvoicingModels
public string DefaultLang { get; set; } public string DefaultLang { get; set; }
public bool ShowPayInWalletButton { get; set; } public bool ShowPayInWalletButton { get; set; }
public bool ShowStoreHeader { get; set; } public bool ShowStoreHeader { get; set; }
public List<AvailableCrypto> AvailableCryptos { get; set; } = new(); public List<AvailablePaymentMethod> AvailablePaymentMethods { get; set; } = new();
public bool IsModal { get; set; } public bool IsModal { get; set; }
public bool IsUnsetTopUp { get; set; } public bool IsUnsetTopUp { get; set; }
public bool OnChainWithLnInvoiceFallback { get; set; } public bool OnChainWithLnInvoiceFallback { get; set; }

View File

@@ -15,12 +15,9 @@ namespace BTCPayServer.Plugins.NFC
public override void Execute(IServiceCollection applicationBuilder) public override void Execute(IServiceCollection applicationBuilder)
{ {
applicationBuilder.AddSingleton<IUIExtension>(new UIExtension("NFC/CheckoutEnd", applicationBuilder.AddUIExtension("checkout-end", "NFC/CheckoutEnd");
"checkout-end")); applicationBuilder.AddUIExtension("checkout-lightning-post-content", "NFC/LNURLNFCPostContent");
applicationBuilder.AddSingleton<IUIExtension>(new UIExtension("NFC/LNURLNFCPostContent", applicationBuilder.AddUIExtension("checkout-bitcoin-post-content", "NFC/LNURLNFCPostContent");
"checkout-lightning-post-content"));
applicationBuilder.AddSingleton<IUIExtension>(new UIExtension("NFC/LNURLNFCPostContent",
"checkout-bitcoin-post-content"));
base.Execute(applicationBuilder); base.Execute(applicationBuilder);
} }
} }

View File

@@ -19,7 +19,7 @@ Vue.component("lnurl-withdraw-checkout", {
const { const {
onChainWithLnInvoiceFallback: isUnified, onChainWithLnInvoiceFallback: isUnified,
paymentMethodId: activePaymentMethodId, paymentMethodId: activePaymentMethodId,
availableCryptos: availablePaymentMethods, availablePaymentMethods: availablePaymentMethods,
invoiceBitcoinUrl: paymentUrl invoiceBitcoinUrl: paymentUrl
} = this.model } = this.model
const lnurlwAvailable = const lnurlwAvailable =

View File

@@ -12,7 +12,7 @@
ViewData["StoreBranding"] = Model.StoreBranding; ViewData["StoreBranding"] = Model.StoreBranding;
Csp.UnsafeEval(); Csp.UnsafeEval();
var hasPaymentPlugins = UiExtensions.Any(extension => extension.Location == "checkout-payment-method"); var hasPaymentPlugins = UiExtensions.Any(extension => extension.Location == "checkout-payment-method");
var displayedPaymentMethods = Model.AvailableCryptos.Where(c => c.Displayed).ToList(); var displayedPaymentMethods = Model.AvailablePaymentMethods.Where(c => c.Displayed).ToList();
} }
@functions { @functions {
private string ToJsValue(object value) private string ToJsValue(object value)

View File

@@ -1,7 +1,6 @@
@model CheckoutModel @model CheckoutModel
@{ @{
Layout = null; Layout = null;
var displayedPaymentMethods = Model.AvailableCryptos.Where(a => a.Displayed).ToList();
} }
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>

View File

@@ -172,7 +172,7 @@ function initApp() {
: null; : null;
}, },
paymentMethodIds () { paymentMethodIds () {
return this.srvModel.availableCryptos.map(function (c) { return c.paymentMethodId }); return this.srvModel.availablePaymentMethod.map(function (c) { return c.paymentMethodId });
}, },
paymentMethodComponent() { paymentMethodComponent() {
return this.isPluginPaymentMethod return this.isPluginPaymentMethod