mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Add GetPOSItems method
This commit is contained in:
committed by
Andrew Camilleri
parent
9d48358f2a
commit
7b252369e9
@@ -92,7 +92,7 @@ namespace BTCPayServer.Controllers
|
|||||||
Prefixed = new[] { 0, 2 }.Contains(numberFormatInfo.CurrencyPositivePattern),
|
Prefixed = new[] { 0, 2 }.Contains(numberFormatInfo.CurrencyPositivePattern),
|
||||||
SymbolSpace = new[] { 2, 3 }.Contains(numberFormatInfo.CurrencyPositivePattern)
|
SymbolSpace = new[] { 2, 3 }.Contains(numberFormatInfo.CurrencyPositivePattern)
|
||||||
},
|
},
|
||||||
Items = _AppService.Parse(settings.Template, settings.Currency, true),
|
Items = _AppService.GetPOSItems(settings.Template, settings.Currency),
|
||||||
ButtonText = settings.ButtonText,
|
ButtonText = settings.ButtonText,
|
||||||
CustomButtonText = settings.CustomButtonText,
|
CustomButtonText = settings.CustomButtonText,
|
||||||
CustomTipText = settings.CustomTipText,
|
CustomTipText = settings.CustomTipText,
|
||||||
@@ -141,7 +141,7 @@ namespace BTCPayServer.Controllers
|
|||||||
ViewPointOfSaleViewModel.Item choice = null;
|
ViewPointOfSaleViewModel.Item choice = null;
|
||||||
if (!string.IsNullOrEmpty(choiceKey))
|
if (!string.IsNullOrEmpty(choiceKey))
|
||||||
{
|
{
|
||||||
var choices = _AppService.Parse(settings.Template, settings.Currency, true);
|
var choices = _AppService.GetPOSItems(settings.Template, settings.Currency);
|
||||||
choice = choices.FirstOrDefault(c => c.Id == choiceKey);
|
choice = choices.FirstOrDefault(c => c.Id == choiceKey);
|
||||||
if (choice == null)
|
if (choice == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
@@ -177,7 +177,7 @@ namespace BTCPayServer.Controllers
|
|||||||
AppService.TryParsePosCartItems(posData, out var cartItems))
|
AppService.TryParsePosCartItems(posData, out var cartItems))
|
||||||
{
|
{
|
||||||
|
|
||||||
var choices = _AppService.Parse(settings.Template, settings.Currency, true);
|
var choices = _AppService.GetPOSItems(settings.Template, settings.Currency);
|
||||||
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);
|
||||||
@@ -314,7 +314,7 @@ namespace BTCPayServer.Controllers
|
|||||||
ViewPointOfSaleViewModel.Item choice = null;
|
ViewPointOfSaleViewModel.Item choice = null;
|
||||||
if (!string.IsNullOrEmpty(request.ChoiceKey))
|
if (!string.IsNullOrEmpty(request.ChoiceKey))
|
||||||
{
|
{
|
||||||
var choices = _AppService.Parse(settings.PerksTemplate, settings.TargetCurrency, true);
|
var choices = _AppService.GetPOSItems(settings.PerksTemplate, settings.TargetCurrency);
|
||||||
choice = choices.FirstOrDefault(c => c.Id == request.ChoiceKey);
|
choice = choices.FirstOrDefault(c => c.Id == request.ChoiceKey);
|
||||||
if (choice == null)
|
if (choice == null)
|
||||||
return NotFound("Incorrect option provided");
|
return NotFound("Incorrect option provided");
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ namespace BTCPayServer.Services.Apps
|
|||||||
var serializer = new SerializerBuilder().Build();
|
var serializer = new SerializerBuilder().Build();
|
||||||
return serializer.Serialize(mappingNode);
|
return serializer.Serialize(mappingNode);
|
||||||
}
|
}
|
||||||
public ViewPointOfSaleViewModel.Item[] Parse(string template, string currency, bool filterDisabled = false)
|
public ViewPointOfSaleViewModel.Item[] Parse(string template, string currency)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(template))
|
if (string.IsNullOrWhiteSpace(template))
|
||||||
return Array.Empty<ViewPointOfSaleViewModel.Item>();
|
return Array.Empty<ViewPointOfSaleViewModel.Item>();
|
||||||
@@ -341,10 +341,14 @@ namespace BTCPayServer.Services.Apps
|
|||||||
PaymentMethods = c.GetDetailStringList("payment_methods"),
|
PaymentMethods = c.GetDetailStringList("payment_methods"),
|
||||||
Disabled = c.GetDetailString("disabled") == "true"
|
Disabled = c.GetDetailString("disabled") == "true"
|
||||||
})
|
})
|
||||||
.Where(c => filterDisabled ? !c.Disabled : true)
|
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ViewPointOfSaleViewModel.Item[] GetPOSItems(string template, string currency)
|
||||||
|
{
|
||||||
|
return Parse(template, currency).Where(c => !c.Disabled).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
public Contributions GetContributionsByPaymentMethodId(string currency, InvoiceEntity[] invoices, bool softcap)
|
public Contributions GetContributionsByPaymentMethodId(string currency, InvoiceEntity[] invoices, bool softcap)
|
||||||
{
|
{
|
||||||
var contributions = invoices
|
var contributions = invoices
|
||||||
|
|||||||
Reference in New Issue
Block a user