diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 954784414..014282039 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -1296,6 +1296,63 @@ namespace BTCPayServer.Tests Assert.Equal($"{tpub}-[p2sh]", result.ToString()); } + [Fact] + public void CanDisablePaymentMethods() + { + using (var tester = ServerTester.Create()) + { + tester.Start(); + var user = tester.NewAccount(); + user.GrantAccess(); + user.RegisterDerivationScheme("BTC"); + user.RegisterDerivationScheme("LTC"); + user.RegisterLightningNode("BTC", LightningConnectionType.CLightning); + + var invoice = user.BitPay.CreateInvoice(new Invoice() + { + Price = 1.5m, + Currency = "USD", + PosData = "posData", + OrderId = "orderId", + ItemDesc = "Some description", + FullNotifications = true + }, Facade.Merchant); + + Assert.Equal(3, invoice.CryptoInfo.Length); + + var controller = user.GetController(); + var lightningVM = (LightningNodeViewModel)Assert.IsType(controller.AddLightningNode(user.StoreId, "BTC")).Model; + Assert.True(lightningVM.Enabled); + lightningVM.Enabled = false; + controller.AddLightningNode(user.StoreId, lightningVM, "save", "BTC").GetAwaiter().GetResult(); + lightningVM = (LightningNodeViewModel)Assert.IsType(controller.AddLightningNode(user.StoreId, "BTC")).Model; + Assert.False(lightningVM.Enabled); + + var derivationVM = (DerivationSchemeViewModel)Assert.IsType(controller.AddDerivationScheme(user.StoreId, "BTC")).Model; + Assert.True(derivationVM.Enabled); + derivationVM.Enabled = false; + derivationVM = (DerivationSchemeViewModel)Assert.IsType(controller.AddDerivationScheme(user.StoreId, derivationVM, "BTC").GetAwaiter().GetResult()).Model; + // Confirmation + controller.AddDerivationScheme(user.StoreId, derivationVM, "BTC").GetAwaiter().GetResult(); + Assert.False(derivationVM.Enabled); + derivationVM = (DerivationSchemeViewModel)Assert.IsType(controller.AddDerivationScheme(user.StoreId, "BTC")).Model; + Assert.False(derivationVM.Enabled); + + invoice = user.BitPay.CreateInvoice(new Invoice() + { + Price = 1.5m, + Currency = "USD", + PosData = "posData", + OrderId = "orderId", + ItemDesc = "Some description", + FullNotifications = true + }, Facade.Merchant); + + Assert.Single(invoice.CryptoInfo); + Assert.Equal("LTC", invoice.CryptoInfo[0].CryptoCode); + } + } + [Fact] public void CanSetPaymentMethodLimits() { diff --git a/BTCPayServer/Controllers/StoresController.LightningLike.cs b/BTCPayServer/Controllers/StoresController.LightningLike.cs index 6aafb1aec..869a94de6 100644 --- a/BTCPayServer/Controllers/StoresController.LightningLike.cs +++ b/BTCPayServer/Controllers/StoresController.LightningLike.cs @@ -136,7 +136,7 @@ namespace BTCPayServer.Controllers }; paymentMethod.SetLightningUrl(connectionString); var storeBlob = store.GetStoreBlob(); - storeBlob.SetExcluded(paymentMethod.PaymentId , vm.Enabled); + storeBlob.SetExcluded(paymentMethod.PaymentId , !vm.Enabled); store.SetStoreBlob(storeBlob); }