Confirmation page for enabling Pay Button

This commit is contained in:
rockstardev 2018-09-03 23:48:53 -05:00 committed by nicolas.dorier
parent b5626ef01c
commit deb56e16ec
4 changed files with 52 additions and 1 deletions

View file

@ -127,6 +127,9 @@
</Content>
<Content Update="Views\Server\SSHService.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Views\Stores\PayButtonEnable.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Views\Stores\PayButton.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>

View file

@ -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<IActionResult> 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
});
}
}
}

View file

@ -1,7 +1,8 @@
@model PayButtonViewModel
@{
Layout = "../Shared/_NavLayout.cshtml";
ViewData.SetActivePageAndTitle(StoreNavPages.PayButton, "Pay Button");
ViewData.SetActivePageAndTitle(StoreNavPages.PayButton);
ViewBag.MainTitle = "Pay Button";
}
<div class="container" id="payButtonCtrl">

View file

@ -0,0 +1,22 @@
@{
Layout = "../Shared/_NavLayout.cshtml";
ViewData.SetActivePageAndTitle(StoreNavPages.PayButton, "Enable access");
ViewBag.MainTitle = "Confirm enabling of Pay Button";
}
<h4>@ViewData["Title"]</h4>
<div class="row">
<div class="col-md-10">
<form method="post">
<div class="form-group">
<p>
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.
</p>
<input type="hidden" name="enableStore" value="true" />
<button name="command" type="submit" value="save" class="btn btn-primary">Enable Pay Button</button>
</div>
</form>
</div>
</div>