Checkout v2: Minor fixes (#4345)

* Do not show remaining amount for topup invoices in expiry message

As [reported by @petzsch](https://chat.btcpayserver.org/btcpayserver/pl/gg1zy8t5h3dq7nme1nom93migo).

* Fix links on result page in Checkout Classic

Closes #4344.

* Better way to exclude Lightning if BIP21 is active and we have both PMs


Unify margins
This commit is contained in:
d11n
2022-11-24 15:14:56 +01:00
committed by GitHub
parent a4ee1e9805
commit bb60c2ac48
6 changed files with 39 additions and 24 deletions

View File

@@ -798,13 +798,8 @@ namespace BTCPayServer.Controllers
StoreId = store.Id,
AvailableCryptos = invoice.GetPaymentMethods()
.Where(i => i.Network != null &&
// TODO: These cases and implementation need to be discussed
(storeBlob.CheckoutType == CheckoutType.V1 ||
// Exclude LNURL for non-topup invoices
(invoice.IsUnsetTopUp() || i.GetId().PaymentType is not LNURLPayPaymentType)) &&
// Exclude Lightning if OnChainWithLnInvoiceFallback is active
(!storeBlob.OnChainWithLnInvoiceFallback || i.GetId().PaymentType is not LightningPaymentType)
)
// Exclude LNURL for Checkout v2
(storeBlob.CheckoutType == CheckoutType.V1 || i.GetId().PaymentType is not LNURLPayPaymentType))
.Select(kv =>
{
var availableCryptoPaymentMethodId = kv.GetId();
@@ -828,6 +823,16 @@ namespace BTCPayServer.Controllers
.OrderByDescending(a => a.CryptoCode == _NetworkProvider.DefaultNetwork.CryptoCode).ThenBy(a => a.PaymentMethodName).ThenBy(a => a.IsLightning ? 1 : 0)
.ToList()
};
// Exclude Lightning if OnChainWithLnInvoiceFallback is active and we have both payment methods
if (storeBlob.CheckoutType == CheckoutType.V2 && storeBlob.OnChainWithLnInvoiceFallback)
{
var onchainPM = model.AvailableCryptos.Find(c => c.PaymentMethodId == "BTC");
var lightningPM = model.AvailableCryptos.Find(c => c.PaymentMethodId == "BTC_LightningLike");
if (onchainPM != null && lightningPM != null)
{
model.AvailableCryptos.Remove(lightningPM);
}
}
paymentMethodHandler.PreparePaymentModel(model, dto, storeBlob, paymentMethod);
model.UISettings = paymentMethodHandler.GetCheckoutUISettings();
model.PaymentMethodId = paymentMethodId.ToString();