mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 14:04:12 +01:00
Validate cart cost with explicit amount
This commit is contained in:
parent
9b5c6ece90
commit
c156254600
1 changed files with 14 additions and 0 deletions
|
@ -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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue