From a698aa8a5b5c6b688c9abe927ae71cd1d298b502 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 3 Oct 2024 19:21:01 +0900 Subject: [PATCH] Do not crash if payment method disabled when store supports it --- BTCPayServer/Payments/IPaymentMethodHandler.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/BTCPayServer/Payments/IPaymentMethodHandler.cs b/BTCPayServer/Payments/IPaymentMethodHandler.cs index b318e7856..2d3539355 100644 --- a/BTCPayServer/Payments/IPaymentMethodHandler.cs +++ b/BTCPayServer/Payments/IPaymentMethodHandler.cs @@ -121,9 +121,11 @@ namespace BTCPayServer.Payments } foreach (var paymentMethodConfig in store.GetPaymentMethodConfigs()) { - var ctx = new PaymentMethodContext(store, storeBlob, paymentMethodConfig.Value, handlers[paymentMethodConfig.Key], invoiceEntity, invoiceLogs); + if (!handlers.TryGetValue(paymentMethodConfig.Key, out var handler)) + continue; + var ctx = new PaymentMethodContext(store, storeBlob, paymentMethodConfig.Value, handler, invoiceEntity, invoiceLogs); PaymentMethodContexts.Add(paymentMethodConfig.Key, ctx); - if (excludeFilter.Match(paymentMethodConfig.Key) || !handlers.Support(paymentMethodConfig.Key)) + if (excludeFilter.Match(paymentMethodConfig.Key)) ctx.Status = PaymentMethodContext.ContextStatus.Excluded; } }