diff --git a/BTCPayServer.Tests/Checkoutv2Tests.cs b/BTCPayServer.Tests/Checkoutv2Tests.cs index a5c540b4a..c7aab5957 100644 --- a/BTCPayServer.Tests/Checkoutv2Tests.cs +++ b/BTCPayServer.Tests/Checkoutv2Tests.cs @@ -47,7 +47,7 @@ namespace BTCPayServer.Tests s.GoToInvoiceCheckout(invoiceId); Assert.Equal(2, s.Driver.FindElements(By.CssSelector(".payment-method")).Count); - Assert.Contains("Lightning", s.Driver.FindElement(By.CssSelector(".payment-method.active")).Text); + Assert.Contains("Lightning", s.Driver.WaitForElement(By.CssSelector(".payment-method.active")).Text); Assert.DoesNotContain("LNURL", s.Driver.PageSource); var payUrl = s.Driver.FindElement(By.CssSelector(".btn-primary")).GetAttribute("href"); Assert.StartsWith("lightning:", payUrl); @@ -70,6 +70,7 @@ namespace BTCPayServer.Tests var paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo")); Assert.Contains("This invoice will expire in", paymentInfo.Text); + Assert.DoesNotContain("Please send", paymentInfo.Text); TestUtils.Eventually(() => { var expiredSection = s.Driver.FindElement(By.Id("expired")); @@ -109,8 +110,9 @@ namespace BTCPayServer.Tests Assert.Contains("Created transaction", s.Driver.WaitForElement(By.Id("CheatSuccessMessage")).Text); s.Server.ExplorerNode.Generate(1); - Assert.Contains("The invoice hasn't been paid in full", - s.Driver.WaitForElement(By.Id("PaymentInfo")).Text); + paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo")); + Assert.Contains("The invoice hasn't been paid in full", paymentInfo.Text); + Assert.Contains("Please send", paymentInfo.Text); }); // Mine @@ -157,6 +159,16 @@ namespace BTCPayServer.Tests payUrl = s.Driver.FindElement(By.CssSelector(".btn-primary")).GetAttribute("href"); Assert.StartsWith("bitcoin:", payUrl); Assert.DoesNotContain("&LIGHTNING=", payUrl); + + // Expiry message should not show amount for topup invoice + expirySeconds = s.Driver.FindElement(By.Id("ExpirySeconds")); + expirySeconds.Clear(); + expirySeconds.SendKeys("5"); + s.Driver.FindElement(By.Id("Expire")).Click(); + + paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo")); + Assert.Contains("This invoice will expire in", paymentInfo.Text); + Assert.DoesNotContain("Please send", paymentInfo.Text); } [Fact(Timeout = TestTimeout)] diff --git a/BTCPayServer/Controllers/UIInvoiceController.UI.cs b/BTCPayServer/Controllers/UIInvoiceController.UI.cs index 67a49bd21..26a501627 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.UI.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.UI.cs @@ -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(); diff --git a/BTCPayServer/Views/Shared/Lightning/LightningLikeMethodCheckout-v2.cshtml b/BTCPayServer/Views/Shared/Lightning/LightningLikeMethodCheckout-v2.cshtml index 6003606ab..3de6caaf1 100644 --- a/BTCPayServer/Views/Shared/Lightning/LightningLikeMethodCheckout-v2.cshtml +++ b/BTCPayServer/Views/Shared/Lightning/LightningLikeMethodCheckout-v2.cshtml @@ -5,7 +5,7 @@