Validating that Store has Pay Button enabled

This commit is contained in:
rockstardev 2018-09-03 23:18:07 -05:00 committed by nicolas.dorier
parent e39d9067f2
commit b5626ef01c
3 changed files with 11 additions and 3 deletions

View File

@ -17,7 +17,7 @@ namespace BTCPayServer.Controllers
_InvoiceController = invoiceController;
_StoreRepository = storeRepository;
}
private InvoiceController _InvoiceController;
private StoreRepository _StoreRepository;
@ -30,9 +30,15 @@ namespace BTCPayServer.Controllers
var store = await _StoreRepository.FindStore(storeId);
if (store == null)
ModelState.AddModelError("Store", "Invalid store");
else
{
var storeBlob = store.GetStoreBlob();
if (!storeBlob.PayButtonEnabled)
ModelState.AddModelError("Store", "Store has not enabled Pay Button");
}
// TODO: extract validation to model
if (model.Price <= 0)
if (model == null || model.Price <= 0)
ModelState.AddModelError("Price", "Price must be greater than 0");
if (!ModelState.IsValid)

View File

@ -302,6 +302,8 @@ namespace BTCPayServer.Data
public string RateScript { get; set; }
public bool PayButtonEnabled { get; set; }
string _LightningDescriptionTemplate;
public string LightningDescriptionTemplate

View File

@ -3,7 +3,7 @@
<div class="container" id="payButtonCtrl">
<div class="row">
<form method="POST" action="http://127.0.0.1:14142/pay/4b1AnMtMNuxwG7io2dUcB3TrT3yUbgajjGfJjVfdhBDu">
<form method="POST" action="http://127.0.0.1:14142/pay/9Jy2oFziB7ZPGHVHTBun2VMyvnBz6GELbpxPeJbSfQDw">
<input type="hidden" name="price" value="10" />
<input type="hidden" name="currency" value="USD" />
<input type="image" src="http://127.0.0.1:14142/img/paybutton/pay.png" name="submit" style="width:209px" alt="Pay with BtcPay, Self-Hosted Bitcoin Payment Processor">