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)