mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 22:46:49 +01:00
Add test for Disabling PaymentMethod
This commit is contained in:
parent
d480be925b
commit
7a32f692d1
2 changed files with 58 additions and 1 deletions
|
@ -1296,6 +1296,63 @@ namespace BTCPayServer.Tests
|
||||||
Assert.Equal($"{tpub}-[p2sh]", result.ToString());
|
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<StoresController>();
|
||||||
|
var lightningVM = (LightningNodeViewModel)Assert.IsType<ViewResult>(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<ViewResult>(controller.AddLightningNode(user.StoreId, "BTC")).Model;
|
||||||
|
Assert.False(lightningVM.Enabled);
|
||||||
|
|
||||||
|
var derivationVM = (DerivationSchemeViewModel)Assert.IsType<ViewResult>(controller.AddDerivationScheme(user.StoreId, "BTC")).Model;
|
||||||
|
Assert.True(derivationVM.Enabled);
|
||||||
|
derivationVM.Enabled = false;
|
||||||
|
derivationVM = (DerivationSchemeViewModel)Assert.IsType<ViewResult>(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<ViewResult>(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]
|
[Fact]
|
||||||
public void CanSetPaymentMethodLimits()
|
public void CanSetPaymentMethodLimits()
|
||||||
{
|
{
|
||||||
|
|
|
@ -136,7 +136,7 @@ namespace BTCPayServer.Controllers
|
||||||
};
|
};
|
||||||
paymentMethod.SetLightningUrl(connectionString);
|
paymentMethod.SetLightningUrl(connectionString);
|
||||||
var storeBlob = store.GetStoreBlob();
|
var storeBlob = store.GetStoreBlob();
|
||||||
storeBlob.SetExcluded(paymentMethod.PaymentId , vm.Enabled);
|
storeBlob.SetExcluded(paymentMethod.PaymentId , !vm.Enabled);
|
||||||
store.SetStoreBlob(storeBlob);
|
store.SetStoreBlob(storeBlob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue