mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
Validate cart cost with explicit amount
This commit is contained in:
@@ -181,6 +181,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
|
|||||||
AppService.TryParsePosCartItems(posData, out var cartItems))
|
AppService.TryParsePosCartItems(posData, out var cartItems))
|
||||||
{
|
{
|
||||||
var choices = _appService.GetPOSItems(settings.Template, settings.Currency);
|
var choices = _appService.GetPOSItems(settings.Template, settings.Currency);
|
||||||
|
var expectedMinimumAmount = 0m;
|
||||||
foreach (var cartItem in cartItems)
|
foreach (var cartItem in cartItems)
|
||||||
{
|
{
|
||||||
var itemChoice = choices.FirstOrDefault(c => c.Id == cartItem.Key);
|
var itemChoice = choices.FirstOrDefault(c => c.Id == cartItem.Key);
|
||||||
@@ -197,6 +198,19 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
|
|||||||
return RedirectToAction(nameof(ViewPointOfSale), new { appId });
|
return RedirectToAction(nameof(ViewPointOfSale), new { appId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
decimal expectedCartItemPrice = 0;
|
||||||
|
if (choice.Price.Type != ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Topup)
|
||||||
|
{
|
||||||
|
expectedCartItemPrice = choice.Price.Value ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedMinimumAmount += expectedCartItemPrice * cartItem.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expectedMinimumAmount > amount)
|
||||||
|
{
|
||||||
|
return RedirectToAction(nameof(ViewPointOfSale), new { appId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user