update to use longs

This commit is contained in:
Andrew Camilleri
2018-05-13 09:47:42 +02:00
parent 2c0bcfc0ec
commit ad67f4ef18
2 changed files with 16 additions and 7 deletions

View File

@@ -226,12 +226,17 @@ namespace BTCPayServer.Models
} }
[JsonProperty("paymentSubtotals")] [JsonProperty("paymentSubtotals")]
public Dictionary<string, decimal> PaymentSubtotals { get; set; } public Dictionary<string, long> PaymentSubtotals { get; set; }
[JsonProperty("paymentTotals")] [JsonProperty("paymentTotals")]
public Dictionary<string, decimal> PaymentTotals { get; set; } public Dictionary<string, long> PaymentTotals { get; set; }
[JsonProperty("amountPaid")] [JsonProperty("amountPaid")]
public decimal AmountPaid { get; set; } public long AmountPaid { get; set; }
[JsonProperty("minerFees")]
public long MinerFees { get; set; }
[JsonProperty("exchangeRates")] [JsonProperty("exchangeRates")]
public Dictionary<string, Dictionary<string, decimal>> ExchangeRates{ get; set; } public Dictionary<string, Dictionary<string, decimal>> ExchangeRates{ get; set; }

View File

@@ -339,8 +339,8 @@ namespace BTCPayServer.Services.Invoices
Currency = ProductInformation.Currency, Currency = ProductInformation.Currency,
Flags = new Flags() { Refundable = Refundable }, Flags = new Flags() { Refundable = Refundable },
PaymentSubtotals = new Dictionary<string, decimal>(), PaymentSubtotals = new Dictionary<string, long>(),
PaymentTotals= new Dictionary<string, decimal>(), PaymentTotals= new Dictionary<string, long>(),
SupportedTransactionCurrencies = new Dictionary<string, InvoiceSupportedTransactionCurrency>(), SupportedTransactionCurrencies = new Dictionary<string, InvoiceSupportedTransactionCurrency>(),
Addresses = new Dictionary<string, string>(), Addresses = new Dictionary<string, string>(),
PaymentCodes = new Dictionary<string, InvoicePaymentUrls>(), PaymentCodes = new Dictionary<string, InvoicePaymentUrls>(),
@@ -351,6 +351,7 @@ namespace BTCPayServer.Services.Invoices
dto.CryptoInfo = new List<NBitpayClient.InvoiceCryptoInfo>(); dto.CryptoInfo = new List<NBitpayClient.InvoiceCryptoInfo>();
foreach (var info in this.GetPaymentMethods(networkProvider)) foreach (var info in this.GetPaymentMethods(networkProvider))
{ {
var accounting = info.Calculate(); var accounting = info.Calculate();
var cryptoInfo = new NBitpayClient.InvoiceCryptoInfo(); var cryptoInfo = new NBitpayClient.InvoiceCryptoInfo();
var subtotalPrice = accounting.TotalDue - accounting.NetworkFee; var subtotalPrice = accounting.TotalDue - accounting.NetworkFee;
@@ -414,8 +415,8 @@ namespace BTCPayServer.Services.Invoices
#pragma warning restore CS0618 #pragma warning restore CS0618
dto.CryptoInfo.Add(cryptoInfo); dto.CryptoInfo.Add(cryptoInfo);
dto.PaymentSubtotals.Add(cryptoCode, subtotalPrice.ToDecimal(MoneyUnit.Satoshi)); dto.PaymentSubtotals.Add(cryptoCode, subtotalPrice.Satoshi);
dto.PaymentTotals.Add(cryptoCode, accounting.TotalDue.ToDecimal(MoneyUnit.Satoshi)); dto.PaymentTotals.Add(cryptoCode, accounting.TotalDue.Satoshi);
dto.SupportedTransactionCurrencies.Add(cryptoCode, new InvoiceSupportedTransactionCurrency() dto.SupportedTransactionCurrencies.Add(cryptoCode, new InvoiceSupportedTransactionCurrency()
{ {
Enabled = true Enabled = true
@@ -424,8 +425,11 @@ namespace BTCPayServer.Services.Invoices
dto.ExchangeRates.Add(cryptoCode, exrates); dto.ExchangeRates.Add(cryptoCode, exrates);
} }
//TODO: Populate dto.AmountPaid //TODO: Populate dto.AmountPaid
//TODO: Populate dto.MinerFees
//TODO: Populate dto.TransactionCurrency //TODO: Populate dto.TransactionCurrency
Populate(ProductInformation, dto); Populate(ProductInformation, dto);
Populate(BuyerInformation, dto); Populate(BuyerInformation, dto);