From 239a011e60f47e6b0adc96d8db652b76716b53c3 Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Fri, 11 May 2018 11:31:21 +0200 Subject: [PATCH 1/6] add new properties and change types to decimal --- BTCPayServer.Tests/UnitTest1.cs | 40 +++++++++--------- .../InvoiceNotificationManager.cs | 2 +- BTCPayServer/Models/InvoiceResponse.cs | 23 ++++++++++- .../Services/Invoices/InvoiceEntity.cs | 41 +++++++++++++++---- 4 files changed, 74 insertions(+), 32 deletions(-) diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 630a7c3af..f82a4bc0a 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -276,7 +276,7 @@ namespace BTCPayServer.Tests var invoice = user.BitPay.CreateInvoice(new Invoice() { Buyer = new Buyer() { email = "test@fwf.com" }, - Price = 5000.0, + Price = 5000.0m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -308,7 +308,7 @@ namespace BTCPayServer.Tests var invoice = user.BitPay.CreateInvoice(new Invoice() { Buyer = new Buyer() { email = "test@fwf.com" }, - Price = 5000.0, + Price = 5000.0m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -440,7 +440,7 @@ namespace BTCPayServer.Tests var invoice = user.BitPay.CreateInvoice(new Invoice() { - Price = 0.01, + Price = 0.01m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -473,7 +473,7 @@ namespace BTCPayServer.Tests var invoice = user.BitPay.CreateInvoice(new Invoice() { - Price = 0.01, + Price = 0.01m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -501,7 +501,7 @@ namespace BTCPayServer.Tests await Task.Delay(TimeSpan.FromSeconds(RandomUtils.GetUInt32() % 5)); var invoice = await user.BitPay.CreateInvoiceAsync(new Invoice() { - Price = 0.01, + Price = 0.01m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -554,7 +554,7 @@ namespace BTCPayServer.Tests acc.RegisterDerivationScheme("BTC"); var invoice = acc.BitPay.CreateInvoice(new Invoice() { - Price = 5.0, + Price = 5.0m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -656,7 +656,7 @@ namespace BTCPayServer.Tests user.RegisterDerivationScheme("BTC"); var invoice = user.BitPay.CreateInvoice(new Invoice() { - Price = 5000.0, + Price = 5000.0m, Currency = "USD" }, Facade.Merchant); var payment1 = invoice.BtcDue + Money.Coins(0.0001m); @@ -756,7 +756,7 @@ namespace BTCPayServer.Tests message.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Encoders.Base64.EncodeData(Encoders.ASCII.DecodeData(apiKey))); var invoice = new Invoice() { - Price = 5000.0, + Price = 5000.0m, Currency = "USD" }; message.Content = new StringContent(JsonConvert.SerializeObject(invoice), Encoding.UTF8, "application/json"); @@ -798,7 +798,7 @@ namespace BTCPayServer.Tests storeController.Rates(vm).Wait(); var invoice2 = user.BitPay.CreateInvoice(new Invoice() { - Price = 5000.0, + Price = 5000.0m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -822,7 +822,7 @@ namespace BTCPayServer.Tests // First we try payment with a merchant having only BTC var invoice1 = user.BitPay.CreateInvoice(new Invoice() { - Price = 5000.0, + Price = 5000.0m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -840,7 +840,7 @@ namespace BTCPayServer.Tests var invoice2 = user.BitPay.CreateInvoice(new Invoice() { - Price = 5000.0, + Price = 5000.0m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -896,7 +896,7 @@ namespace BTCPayServer.Tests // Despite it is called BitcoinAddress it should be LTC because BTC is not available Assert.Null(invoice.BitcoinAddress); - Assert.NotEqual(1.0, invoice.Rate); + Assert.NotEqual(1.0m, invoice.Rate); Assert.NotEqual(invoice.BtcDue, invoice.CryptoInfo[0].Due); // Should be BTC rate cashCow.SendToAddress(invoiceAddress, invoice.CryptoInfo[0].Due); @@ -983,7 +983,7 @@ namespace BTCPayServer.Tests // First we try payment with a merchant having only BTC var invoice = user.BitPay.CreateInvoice(new Invoice() { - Price = 5000.0, + Price = 5000.0m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -1015,7 +1015,7 @@ namespace BTCPayServer.Tests user.RegisterDerivationScheme("LTC"); invoice = user.BitPay.CreateInvoice(new Invoice() { - Price = 5000.0, + Price = 5000.0m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -1137,7 +1137,7 @@ namespace BTCPayServer.Tests var invoice = user.BitPay.CreateInvoice(new Invoice() { - Price = 1.5, + Price = 1.5m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -1150,7 +1150,7 @@ namespace BTCPayServer.Tests invoice = user.BitPay.CreateInvoice(new Invoice() { - Price = 5.5, + Price = 5.5m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -1199,7 +1199,7 @@ namespace BTCPayServer.Tests Assert.Equal("$5.00", vmview.Items[0].Price.Formatted); Assert.IsType(apps.ViewPointOfSale(appId, 0, "orange").Result); var invoice = user.BitPay.GetInvoices().First(); - Assert.Equal(10.00, invoice.Price); + Assert.Equal(10.00m, invoice.Price); Assert.Equal("CAD", invoice.Currency); Assert.Equal("orange", invoice.ItemDesc); } @@ -1250,7 +1250,7 @@ namespace BTCPayServer.Tests user.RegisterDerivationScheme("BTC"); var invoice = user.BitPay.CreateInvoice(new Invoice() { - Price = 5000.0, + Price = 5000.0m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -1355,12 +1355,12 @@ namespace BTCPayServer.Tests { var localInvoice = user.BitPay.GetInvoice(invoice.Id, Facade.Merchant); Assert.Equal("complete", localInvoice.Status); - Assert.NotEqual(0.0, localInvoice.Rate); + Assert.NotEqual(0.0m, localInvoice.Rate); }); invoice = user.BitPay.CreateInvoice(new Invoice() { - Price = 5000.0, + Price = 5000.0m, Currency = "USD", PosData = "posData", OrderId = "orderId", diff --git a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs index 9845b2d53..0a2d9a057 100644 --- a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs +++ b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs @@ -207,7 +207,7 @@ namespace BTCPayServer.HostedServices if (btcCryptoInfo != null) { #pragma warning disable CS0618 - notification.Rate = (double)dto.Rate; + notification.Rate = dto.Rate; notification.Url = dto.Url; notification.BTCDue = dto.BTCDue; notification.BTCPaid = dto.BTCPaid; diff --git a/BTCPayServer/Models/InvoiceResponse.cs b/BTCPayServer/Models/InvoiceResponse.cs index 4ff6f21ed..69382c8bf 100644 --- a/BTCPayServer/Models/InvoiceResponse.cs +++ b/BTCPayServer/Models/InvoiceResponse.cs @@ -79,7 +79,7 @@ namespace BTCPayServer.Models //"price":5 [JsonProperty("price")] - public double Price + public decimal Price { get; set; } @@ -94,7 +94,7 @@ namespace BTCPayServer.Models //"exRates":{"USD":4320.02} [JsonProperty("exRates")] [Obsolete("Use CryptoInfo.ExRates instead")] - public Dictionary ExRates + public Dictionary ExRates { get; set; } @@ -224,6 +224,24 @@ namespace BTCPayServer.Models { get; set; } + + [JsonProperty("paymentSubtotals")] + public Dictionary PaymentSubtotals { get; set; } + + [JsonProperty("paymentTotals")] + public Dictionary PaymentTotals { get; set; } + [JsonProperty("amountPaid")] + public decimal AmountPaid { get; set; } + [JsonProperty("exchangeRates")] + public Dictionary> ExchangeRates{ get; set; } + + [JsonProperty("supportedTransactionCurrencies")] + public Dictionary SupportedTransactionCurrencies { get; set; } + + [JsonProperty("addresses")] + public Dictionary Addresses { get; set; } + [JsonProperty("paymentCodes")] + public Dictionary PaymentCodes{get; set;} } public class Flags { @@ -233,4 +251,5 @@ namespace BTCPayServer.Models get; set; } } + } diff --git a/BTCPayServer/Services/Invoices/InvoiceEntity.cs b/BTCPayServer/Services/Invoices/InvoiceEntity.cs index 765e721ec..29789acef 100644 --- a/BTCPayServer/Services/Invoices/InvoiceEntity.cs +++ b/BTCPayServer/Services/Invoices/InvoiceEntity.cs @@ -12,6 +12,7 @@ using NBXplorer.Models; using NBXplorer; using NBXplorer.DerivationStrategy; using BTCPayServer.Payments; +using NBitpayClient; namespace BTCPayServer.Services.Invoices { @@ -335,7 +336,14 @@ namespace BTCPayServer.Services.Invoices ExpirationTime = ExpirationTime, Status = Status, Currency = ProductInformation.Currency, - Flags = new Flags() { Refundable = Refundable } + Flags = new Flags() { Refundable = Refundable }, + + PaymentSubtotals = new Dictionary(), + PaymentTotals= new Dictionary(), + SupportedTransactionCurrencies = new Dictionary(), + Addresses = new Dictionary(), + PaymentCodes = new Dictionary(), + ExchangeRates = new Dictionary>() }; dto.Url = ServerUrl.WithTrailingSlash() + $"invoice?id=" + Id; @@ -344,10 +352,18 @@ namespace BTCPayServer.Services.Invoices { var accounting = info.Calculate(); var cryptoInfo = new NBitpayClient.InvoiceCryptoInfo(); - cryptoInfo.CryptoCode = info.GetId().CryptoCode; + var price = accounting.TotalDue - accounting.NetworkFee; + var cryptoCode = info.GetId().CryptoCode; + var address = info.GetPaymentMethodDetails()?.GetPaymentDestination(); + var exrates = new Dictionary + { + { ProductInformation.Currency, cryptoInfo.Rate } + }; + + cryptoInfo.CryptoCode = cryptoCode; cryptoInfo.PaymentType = info.GetId().PaymentType.ToString(); cryptoInfo.Rate = info.Rate; - cryptoInfo.Price = (accounting.TotalDue - accounting.NetworkFee).ToString(); + cryptoInfo.Price = price.ToString(); cryptoInfo.Due = accounting.Due.ToString(); cryptoInfo.Paid = accounting.Paid.ToString(); @@ -356,11 +372,9 @@ namespace BTCPayServer.Services.Invoices cryptoInfo.TxCount = accounting.TxCount; cryptoInfo.CryptoPaid = accounting.CryptoPaid.ToString(); - cryptoInfo.Address = info.GetPaymentMethodDetails()?.GetPaymentDestination(); - cryptoInfo.ExRates = new Dictionary - { - { ProductInformation.Currency, (double)cryptoInfo.Rate } - }; + cryptoInfo.Address = address; + + cryptoInfo.ExRates = exrates; var paymentId = info.GetId(); var scheme = info.Network.UriScheme; cryptoInfo.Url = ServerUrl.WithTrailingSlash() + $"i/{paymentId}/{Id}"; @@ -395,10 +409,19 @@ namespace BTCPayServer.Services.Invoices dto.BTCDue = cryptoInfo.Due; dto.PaymentUrls = cryptoInfo.PaymentUrls; } + #pragma warning restore CS0618 dto.CryptoInfo.Add(cryptoInfo); - } + dto.PaymentSubtotals.Add(cryptoCode, price.ToDecimal(MoneyUnit.BTC)); + dto.PaymentTotals.Add(cryptoCode, accounting.CryptoPaid.ToDecimal(MoneyUnit.BTC)); + dto.SupportedTransactionCurrencies.Add(cryptoCode, new InvoiceSupportedTransactionCurrency() + { + Enabled = true + }); + dto.Addresses.Add(cryptoCode, address); + dto.ExchangeRates.Add(cryptoCode, exrates); + } Populate(ProductInformation, dto); Populate(BuyerInformation, dto); From c326998381790101dd2d2cae3663afb6533bc624 Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Fri, 11 May 2018 11:42:13 +0200 Subject: [PATCH 2/6] bump nbitpayclient dependency to .20 --- BTCPayServer/BTCPayServer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 9bec0d419..65beb7461 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -41,7 +41,7 @@ - + From ee4f83ddbaf74e1dd8d39f4b617820f92ef43b22 Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Fri, 11 May 2018 12:21:25 +0200 Subject: [PATCH 3/6] small fixes --- .../HostedServices/InvoiceNotificationManager.cs | 6 +++++- BTCPayServer/Services/Invoices/InvoiceEntity.cs | 11 +++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs index 0a2d9a057..6605e11c8 100644 --- a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs +++ b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs @@ -198,7 +198,11 @@ namespace BTCPayServer.HostedServices PosData = dto.PosData, Price = dto.Price, Status = dto.Status, - BuyerFields = invoice.RefundMail == null ? null : new Newtonsoft.Json.Linq.JObject() { new JProperty("buyerEmail", invoice.RefundMail) } + BuyerFields = invoice.RefundMail == null ? null : new Newtonsoft.Json.Linq.JObject() { new JProperty("buyerEmail", invoice.RefundMail) }, + PaymentSubtotals = dto.PaymentSubtotals, + PaymentTotals = dto.PaymentTotals, + AmountPaid = dto.AmountPaid, + ExchangeRates = dto.ExchangeRates }; // We keep backward compatibility with bitpay by passing BTC info to the notification diff --git a/BTCPayServer/Services/Invoices/InvoiceEntity.cs b/BTCPayServer/Services/Invoices/InvoiceEntity.cs index 29789acef..021d3c928 100644 --- a/BTCPayServer/Services/Invoices/InvoiceEntity.cs +++ b/BTCPayServer/Services/Invoices/InvoiceEntity.cs @@ -352,7 +352,7 @@ namespace BTCPayServer.Services.Invoices { var accounting = info.Calculate(); var cryptoInfo = new NBitpayClient.InvoiceCryptoInfo(); - var price = accounting.TotalDue - accounting.NetworkFee; + var subtotalPrice = accounting.TotalDue - accounting.NetworkFee; var cryptoCode = info.GetId().CryptoCode; var address = info.GetPaymentMethodDetails()?.GetPaymentDestination(); var exrates = new Dictionary @@ -363,7 +363,7 @@ namespace BTCPayServer.Services.Invoices cryptoInfo.CryptoCode = cryptoCode; cryptoInfo.PaymentType = info.GetId().PaymentType.ToString(); cryptoInfo.Rate = info.Rate; - cryptoInfo.Price = price.ToString(); + cryptoInfo.Price = subtotalPrice.ToString(); cryptoInfo.Due = accounting.Due.ToString(); cryptoInfo.Paid = accounting.Paid.ToString(); @@ -413,8 +413,8 @@ namespace BTCPayServer.Services.Invoices #pragma warning restore CS0618 dto.CryptoInfo.Add(cryptoInfo); - dto.PaymentSubtotals.Add(cryptoCode, price.ToDecimal(MoneyUnit.BTC)); - dto.PaymentTotals.Add(cryptoCode, accounting.CryptoPaid.ToDecimal(MoneyUnit.BTC)); + dto.PaymentSubtotals.Add(cryptoCode, subtotalPrice.ToDecimal(MoneyUnit.Satoshi)); + dto.PaymentTotals.Add(cryptoCode, accounting.TotalDue.ToDecimal(MoneyUnit.Satoshi)); dto.SupportedTransactionCurrencies.Add(cryptoCode, new InvoiceSupportedTransactionCurrency() { Enabled = true @@ -422,6 +422,9 @@ namespace BTCPayServer.Services.Invoices dto.Addresses.Add(cryptoCode, address); dto.ExchangeRates.Add(cryptoCode, exrates); } + + //TODO: Populate dto.AmountPaid + //TODO: Populate dto.TransactionCurrency Populate(ProductInformation, dto); Populate(BuyerInformation, dto); From ad67f4ef1823a09eb69128d82d61ff08e7ec27d3 Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Sun, 13 May 2018 09:47:42 +0200 Subject: [PATCH 4/6] update to use longs --- BTCPayServer/Models/InvoiceResponse.cs | 11 ++++++++--- BTCPayServer/Services/Invoices/InvoiceEntity.cs | 12 ++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/BTCPayServer/Models/InvoiceResponse.cs b/BTCPayServer/Models/InvoiceResponse.cs index 69382c8bf..c7ad99dff 100644 --- a/BTCPayServer/Models/InvoiceResponse.cs +++ b/BTCPayServer/Models/InvoiceResponse.cs @@ -226,12 +226,17 @@ namespace BTCPayServer.Models } [JsonProperty("paymentSubtotals")] - public Dictionary PaymentSubtotals { get; set; } + public Dictionary PaymentSubtotals { get; set; } [JsonProperty("paymentTotals")] - public Dictionary PaymentTotals { get; set; } + public Dictionary PaymentTotals { get; set; } + [JsonProperty("amountPaid")] - public decimal AmountPaid { get; set; } + public long AmountPaid { get; set; } + + [JsonProperty("minerFees")] + public long MinerFees { get; set; } + [JsonProperty("exchangeRates")] public Dictionary> ExchangeRates{ get; set; } diff --git a/BTCPayServer/Services/Invoices/InvoiceEntity.cs b/BTCPayServer/Services/Invoices/InvoiceEntity.cs index ae50df206..7529f2e6a 100644 --- a/BTCPayServer/Services/Invoices/InvoiceEntity.cs +++ b/BTCPayServer/Services/Invoices/InvoiceEntity.cs @@ -339,8 +339,8 @@ namespace BTCPayServer.Services.Invoices Currency = ProductInformation.Currency, Flags = new Flags() { Refundable = Refundable }, - PaymentSubtotals = new Dictionary(), - PaymentTotals= new Dictionary(), + PaymentSubtotals = new Dictionary(), + PaymentTotals= new Dictionary(), SupportedTransactionCurrencies = new Dictionary(), Addresses = new Dictionary(), PaymentCodes = new Dictionary(), @@ -351,6 +351,7 @@ namespace BTCPayServer.Services.Invoices dto.CryptoInfo = new List(); foreach (var info in this.GetPaymentMethods(networkProvider)) { + var accounting = info.Calculate(); var cryptoInfo = new NBitpayClient.InvoiceCryptoInfo(); var subtotalPrice = accounting.TotalDue - accounting.NetworkFee; @@ -414,8 +415,8 @@ namespace BTCPayServer.Services.Invoices #pragma warning restore CS0618 dto.CryptoInfo.Add(cryptoInfo); - dto.PaymentSubtotals.Add(cryptoCode, subtotalPrice.ToDecimal(MoneyUnit.Satoshi)); - dto.PaymentTotals.Add(cryptoCode, accounting.TotalDue.ToDecimal(MoneyUnit.Satoshi)); + dto.PaymentSubtotals.Add(cryptoCode, subtotalPrice.Satoshi); + dto.PaymentTotals.Add(cryptoCode, accounting.TotalDue.Satoshi); dto.SupportedTransactionCurrencies.Add(cryptoCode, new InvoiceSupportedTransactionCurrency() { Enabled = true @@ -424,8 +425,11 @@ namespace BTCPayServer.Services.Invoices dto.ExchangeRates.Add(cryptoCode, exrates); } + //TODO: Populate dto.AmountPaid + //TODO: Populate dto.MinerFees //TODO: Populate dto.TransactionCurrency + Populate(ProductInformation, dto); Populate(BuyerInformation, dto); From 559f5352571a07c1c108f29ab70f557c3afbb53c Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Tue, 15 May 2018 16:18:26 +0200 Subject: [PATCH 5/6] add some coverage for bitpay fields --- BTCPayServer.Tests/UnitTest1.cs | 5 +++++ BTCPayServer/Services/Invoices/InvoiceEntity.cs | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 5aee1d360..8f1f76599 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -913,6 +913,11 @@ namespace BTCPayServer.Tests Assert.Single(invoice.CryptoInfo); Assert.Equal("LTC", invoice.CryptoInfo[0].CryptoCode); + Assert.True(invoice.PaymentCodes.ContainsKey("LTC")); + Assert.True(invoice.SupportedTransactionCurrencies.ContainsKey("LTC")); + Assert.True(invoice.SupportedTransactionCurrencies["LTC"].Enabled); + Assert.True(invoice.PaymentSubtotals.ContainsKey("LTC")); + Assert.True(invoice.PaymentTotals.ContainsKey("LTC")); var cashCow = tester.LTCExplorerNode; var invoiceAddress = BitcoinAddress.Create(invoice.CryptoInfo[0].Address, cashCow.Network); var firstPayment = Money.Coins(0.1m); diff --git a/BTCPayServer/Services/Invoices/InvoiceEntity.cs b/BTCPayServer/Services/Invoices/InvoiceEntity.cs index 7529f2e6a..c2264e275 100644 --- a/BTCPayServer/Services/Invoices/InvoiceEntity.cs +++ b/BTCPayServer/Services/Invoices/InvoiceEntity.cs @@ -425,10 +425,7 @@ namespace BTCPayServer.Services.Invoices dto.ExchangeRates.Add(cryptoCode, exrates); } - - //TODO: Populate dto.AmountPaid - //TODO: Populate dto.MinerFees - //TODO: Populate dto.TransactionCurrency + //dto.AmountPaid dto.MinerFees & dto.TransactionCurrency are not supported by btcpayserver as we have multi currency payment support per invoice Populate(ProductInformation, dto); Populate(BuyerInformation, dto); From a6ee337ed0c0d61b2d3bb3ee3d592bc0ea8c399e Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Tue, 15 May 2018 16:25:43 +0200 Subject: [PATCH 6/6] more coverage --- BTCPayServer.Tests/UnitTest1.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 8f1f76599..b5e3df28a 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -1052,6 +1052,16 @@ namespace BTCPayServer.Tests Assert.Single(checkout.AvailableCryptos); Assert.Equal("BTC", checkout.CryptoCode); + Assert.Single(invoice.PaymentCodes); + Assert.Single(invoice.SupportedTransactionCurrencies); + Assert.Single(invoice.SupportedTransactionCurrencies); + Assert.Single(invoice.PaymentSubtotals); + Assert.Single(invoice.PaymentTotals); + Assert.True(invoice.PaymentCodes.ContainsKey("BTC")); + Assert.True(invoice.SupportedTransactionCurrencies.ContainsKey("BTC")); + Assert.True(invoice.SupportedTransactionCurrencies["BTC"].Enabled); + Assert.True(invoice.PaymentSubtotals.ContainsKey("BTC")); + Assert.True(invoice.PaymentTotals.ContainsKey("BTC")); ////////////////////// // Retry now with LTC enabled @@ -1100,6 +1110,18 @@ namespace BTCPayServer.Tests checkout = (Models.InvoicingModels.PaymentModel)((JsonResult)controller.GetStatus(invoice.Id, "LTC").GetAwaiter().GetResult()).Value; Assert.Equal(2, checkout.AvailableCryptos.Count); Assert.Equal("LTC", checkout.CryptoCode); + + + Assert.Equal(2, invoice.PaymentCodes.Count()); + Assert.Equal(2, invoice.SupportedTransactionCurrencies.Count()); + Assert.Equal(2, invoice.SupportedTransactionCurrencies.Count()); + Assert.Equal(2, invoice.PaymentSubtotals.Count()); + Assert.Equal(2, invoice.PaymentTotals.Count()); + Assert.True(invoice.PaymentCodes.ContainsKey("LTC")); + Assert.True(invoice.SupportedTransactionCurrencies.ContainsKey("LTC")); + Assert.True(invoice.SupportedTransactionCurrencies["LTC"].Enabled); + Assert.True(invoice.PaymentSubtotals.ContainsKey("LTC")); + Assert.True(invoice.PaymentTotals.ContainsKey("LTC")); } }