Checkout v2: Re-add LNURL for top-up invoices (#4556)

My bad, this was excluded erroneously.

Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com>
This commit is contained in:
d11n
2023-01-24 10:10:38 +01:00
committed by GitHub
parent 9f3a3c5f51
commit b46ae7a651
2 changed files with 44 additions and 13 deletions

View File

@@ -651,12 +651,13 @@ namespace BTCPayServer.Controllers
if (paymentMethodId is null)
{
var enabledPaymentIds = store.GetEnabledPaymentIds(_NetworkProvider)
// Exclude LNURL for Checkout v2
.Where(pmId => storeBlob.CheckoutType == CheckoutType.V1 || pmId.PaymentType is not LNURLPayPaymentType)
// Exclude LNURL for Checkout v2 + non-top up invoices
.Where(pmId => storeBlob.CheckoutType == CheckoutType.V1 ||
pmId.PaymentType is not LNURLPayPaymentType || invoice.IsUnsetTopUp())
.ToArray();
// Exclude Lightning if OnChainWithLnInvoiceFallback is active and we have both payment methods
if (storeBlob.CheckoutType == CheckoutType.V2 && storeBlob.OnChainWithLnInvoiceFallback &&
if (storeBlob is { CheckoutType: CheckoutType.V2, OnChainWithLnInvoiceFallback: true } &&
enabledPaymentIds.Contains(btcId) && enabledPaymentIds.Contains(lnId))
{
enabledPaymentIds = enabledPaymentIds.Where(pmId => pmId != lnId).ToArray();
@@ -800,8 +801,10 @@ namespace BTCPayServer.Controllers
StoreId = store.Id,
AvailableCryptos = invoice.GetPaymentMethods()
.Where(i => i.Network != null &&
// Exclude LNURL for Checkout v2
(storeBlob.CheckoutType == CheckoutType.V1 || i.GetId().PaymentType is not LNURLPayPaymentType))
// Exclude LNURL for Checkout v2 + non-top up invoices
(storeBlob.CheckoutType == CheckoutType.V1 ||
i.GetId().PaymentType is not LNURLPayPaymentType ||
invoice.IsUnsetTopUp()))
.Select(kv =>
{
var availableCryptoPaymentMethodId = kv.GetId();
@@ -827,7 +830,7 @@ namespace BTCPayServer.Controllers
};
// Exclude Lightning if OnChainWithLnInvoiceFallback is active and we have both payment methods
if (storeBlob.CheckoutType == CheckoutType.V2 && storeBlob.OnChainWithLnInvoiceFallback)
if (storeBlob is { CheckoutType: CheckoutType.V2, OnChainWithLnInvoiceFallback: true })
{
var onchainPM = model.AvailableCryptos.Find(c => c.PaymentMethodId == btcId.ToString());
var lightningPM = model.AvailableCryptos.Find(c => c.PaymentMethodId == lnId.ToString());