Fix: Incorrect enabled value for v1/stores/{storeId}/payment-methods/{paymentMethod}

This commit is contained in:
nicolas.dorier
2025-01-21 17:46:58 +09:00
parent 5534ddeb28
commit bbe95d780f

View File

@@ -15,6 +15,7 @@ using StoreData = BTCPayServer.Data.StoreData;
using BTCPayServer.ModelBinders; using BTCPayServer.ModelBinders;
using BTCPayServer.Payments; using BTCPayServer.Payments;
using BTCPayServer.Services.Stores; using BTCPayServer.Services.Stores;
using System;
namespace BTCPayServer.Controllers.Greenfield namespace BTCPayServer.Controllers.Greenfield
{ {
@@ -102,9 +103,9 @@ namespace BTCPayServer.Controllers.Greenfield
if (ctx.StripUnknownProperties) if (ctx.StripUnknownProperties)
config = JToken.FromObject(handler.ParsePaymentMethodConfig(config), handler.Serializer); config = JToken.FromObject(handler.ParsePaymentMethodConfig(config), handler.Serializer);
} }
catch catch (Exception ex)
{ {
ModelState.AddModelError(nameof(config), "Invalid configuration"); ModelState.AddModelError(nameof(config), $"Invalid configuration ({ex.Message})");
return this.CreateValidationError(ModelState); return this.CreateValidationError(ModelState);
} }
Store.SetPaymentMethodConfig(paymentMethodId, config); Store.SetPaymentMethodConfig(paymentMethodId, config);
@@ -151,7 +152,7 @@ namespace BTCPayServer.Controllers.Greenfield
method => new GenericPaymentMethodData() method => new GenericPaymentMethodData()
{ {
PaymentMethodId = method.Key.ToString(), PaymentMethodId = method.Key.ToString(),
Enabled = onlyEnabled.GetValueOrDefault(!excludedPaymentMethods.Match(method.Key)), Enabled = !excludedPaymentMethods.Match(method.Key),
Config = includeConfig is true ? JToken.FromObject(method.Value, _handlers[method.Key].Serializer.ForAPI()) : null Config = includeConfig is true ? JToken.FromObject(method.Value, _handlers[method.Key].Serializer.ForAPI()) : null
}).ToArray()); }).ToArray());
} }