diff --git a/BTCPayServer.Tests/POSTests.cs b/BTCPayServer.Tests/POSTests.cs index 08afdcff5..db39f9803 100644 --- a/BTCPayServer.Tests/POSTests.cs +++ b/BTCPayServer.Tests/POSTests.cs @@ -172,6 +172,8 @@ orange: donation: price: 1.02 custom: true +goodies: + price: 0 "; vmpos.Currency = "EUR"; vmpos.Template = AppService.SerializeTemplate(MigrationStartupTask.ParsePOSYML(vmpos.Template)); @@ -182,7 +184,7 @@ donation: Assert.Equal("EUR", vmview.CurrencyCode); // apple shouldn't be available since we it's set to "disabled: true" above - Assert.Equal(2, vmview.Items.Length); + Assert.Equal(3, vmview.Items.Length); Assert.Equal("orange", vmview.Items[0].Title); Assert.Equal("donation", vmview.Items[1].Title); // orange is available @@ -192,6 +194,14 @@ donation: Assert.IsType(publicApps .ViewPointOfSale(app.Id, PosViewType.Cart, 0, choiceKey: "apple").Result); + var redirectToCheckout = Assert.IsType(publicApps.ViewPointOfSale(app.Id, PosViewType.Cart, 0, choiceKey: "goodies").Result); + Assert.Equal("InvoiceReceipt", redirectToCheckout.ActionName); + var invoiceId = redirectToCheckout.RouteValues!["invoiceId"]!.ToString(); + var client = await user.CreateClient(); + var inv = await client.GetInvoice(user.StoreId, invoiceId); + Assert.Equal(0, inv.Amount); + Assert.NotEqual(InvoiceType.TopUp, inv.Type); + // List appList = Assert.IsType(Assert.IsType(apps.ListApps(user.StoreId).Result).Model); app = appList.Apps[0]; diff --git a/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs b/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs index c60ce5829..0cfa1dd2c 100644 --- a/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs +++ b/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs @@ -232,6 +232,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers { order.AddLine(new($"Custom Amount {i + 1}", 1, jposData.Amounts[i], settings.DefaultTaxRate)); } + foreach (var cartItem in jposData.Cart) { var itemChoice = choices.FirstOrDefault(item => item.Id == cartItem.Id); @@ -322,7 +323,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers var receiptData = new PosReceiptData(); var summary = order.Calculate(); - bool isTopup = summary.PriceTaxIncludedWithTips == 0 && currentView == PosViewType.Static; + var isTopup = selectedChoices.FirstOrDefault().Price is null && currentView == PosViewType.Static; if (!isTopup) { jposData.ItemsTotal = summary.ItemsTotal;