diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index f84b96672..4a8282484 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -127,6 +127,9 @@ $(IncludeRazorContentInPack) + + + $(IncludeRazorContentInPack) $(IncludeRazorContentInPack) diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 897e83140..a431ae7e9 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -776,6 +776,12 @@ namespace BTCPayServer.Controllers { var store = StoreData; + var storeBlob = store.GetStoreBlob(); + if (!storeBlob.PayButtonEnabled) + { + return View("PayButtonEnable", null); + } + var appUrl = HttpContext.Request.GetAbsoluteRoot().WithTrailingSlash(); var model = new PayButtonViewModel { @@ -788,5 +794,24 @@ namespace BTCPayServer.Controllers }; return View(model); } + + [HttpPost] + [Route("{storeId}/paybutton")] + public async Task PayButton(bool enableStore) + { + var blob = StoreData.GetStoreBlob(); + blob.PayButtonEnabled = enableStore; + if (StoreData.SetStoreBlob(blob)) + { + await _Repo.UpdateStore(StoreData); + StatusMessage = "Store successfully updated"; + } + + return RedirectToAction(nameof(PayButton), new + { + storeId = StoreData.Id + }); + + } } } diff --git a/BTCPayServer/Views/Stores/PayButton.cshtml b/BTCPayServer/Views/Stores/PayButton.cshtml index 98b319125..b2049ec92 100644 --- a/BTCPayServer/Views/Stores/PayButton.cshtml +++ b/BTCPayServer/Views/Stores/PayButton.cshtml @@ -1,7 +1,8 @@ @model PayButtonViewModel @{ Layout = "../Shared/_NavLayout.cshtml"; - ViewData.SetActivePageAndTitle(StoreNavPages.PayButton, "Pay Button"); + ViewData.SetActivePageAndTitle(StoreNavPages.PayButton); + ViewBag.MainTitle = "Pay Button"; }
diff --git a/BTCPayServer/Views/Stores/PayButtonEnable.cshtml b/BTCPayServer/Views/Stores/PayButtonEnable.cshtml new file mode 100644 index 000000000..57c9f3e6c --- /dev/null +++ b/BTCPayServer/Views/Stores/PayButtonEnable.cshtml @@ -0,0 +1,22 @@ +@{ + Layout = "../Shared/_NavLayout.cshtml"; + ViewData.SetActivePageAndTitle(StoreNavPages.PayButton, "Enable access"); + ViewBag.MainTitle = "Confirm enabling of Pay Button"; +} + +

@ViewData["Title"]

+ +
+
+
+
+

+ To start using Pay Button you need to explicitly enable creation of Invoices by Pay Button. + Once you do so, valid POST requests from any source will allow creation of invoices on your instance of BtcPayServer. +

+ + +
+
+
+