diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index ba8352fcb..bdf315799 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -505,9 +505,21 @@ namespace BTCPayServer.Tests s.GoToUrl(invoiceUrl); s.Driver.AssertNoError(); - // Alice should be able to delete the store s.Logout(); s.LogIn(alice); + + // Check if we can enable the payment button + s.GoToStore(StoreNavPages.PayButton); + s.Driver.FindElement(By.Id("enable-pay-button")).Click(); + s.Driver.FindElement(By.Id("disable-pay-button")).Click(); + s.FindAlertMessage(); + Assert.False(s.Driver.FindElement(By.Id("AnyoneCanCreateInvoice")).Selected); + s.Driver.SetCheckbox(By.Id("AnyoneCanCreateInvoice"), true); + s.Driver.FindElement(By.Id("Save")).Click(); + s.FindAlertMessage(); + Assert.True(s.Driver.FindElement(By.Id("AnyoneCanCreateInvoice")).Selected); + + // Alice should be able to delete the store s.GoToStore(StoreNavPages.General); s.Driver.FindElement(By.Id("DeleteStore")).Click(); s.Driver.WaitForElement(By.Id("ConfirmInput")).SendKeys("DELETE"); diff --git a/BTCPayServer/Controllers/UIStoresController.cs b/BTCPayServer/Controllers/UIStoresController.cs index 65525e1a8..dd08d999d 100644 --- a/BTCPayServer/Controllers/UIStoresController.cs +++ b/BTCPayServer/Controllers/UIStoresController.cs @@ -992,6 +992,17 @@ namespace BTCPayServer.Controllers return _UserManager.GetUserId(User); } + [HttpPost("{storeId}/disable-anyone-can-pay")] + public async Task DisableAnyoneCanCreateInvoice(string storeId) + { + var blob = CurrentStore.GetStoreBlob(); + blob.AnyoneCanInvoice = false; + CurrentStore.SetStoreBlob(blob); + TempData[WellKnownTempData.SuccessMessage] = "Feature disabled"; + await _Repo.UpdateStore(CurrentStore); + return RedirectToAction(nameof(Payment), new { storeId = storeId }); + } + [Route("{storeId}/paybutton")] public async Task PayButton() { diff --git a/BTCPayServer/Views/UIStores/PayButton.cshtml b/BTCPayServer/Views/UIStores/PayButton.cshtml index 8eb3a2179..d77db18e9 100644 --- a/BTCPayServer/Views/UIStores/PayButton.cshtml +++ b/BTCPayServer/Views/UIStores/PayButton.cshtml @@ -127,7 +127,17 @@

@ViewData["Title"]

+
diff --git a/BTCPayServer/Views/UIStores/PayButtonEnable.cshtml b/BTCPayServer/Views/UIStores/PayButtonEnable.cshtml index 80f2cfc36..2a6a101ac 100644 --- a/BTCPayServer/Views/UIStores/PayButtonEnable.cshtml +++ b/BTCPayServer/Views/UIStores/PayButtonEnable.cshtml @@ -1,20 +1,27 @@ -@{ - ViewData.SetActivePage(StoreNavPages.PayButton, "Pay Button", Context.GetStoreData().Id); +@{ + ViewData.SetActivePage(StoreNavPages.PayButton, "Pay Button", Context.GetStoreData().Id); }

@ViewData["Title"]

-
-

- To start using Pay Button, you need to enable this feature explicitly. - Once you do so, anyone could create an invoice on your store (via API, for example). -

-
- @Html.Hidden("EnableStore", true) - -
-
+
+ +

+ To start using Pay Button, you need to enable this feature explicitly. + Once you do so, anyone could create an invoice on your store (via API, for example). +

+
+ @Html.Hidden("EnableStore", true) + +
+