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")]
public Dictionary<string, decimal> PaymentSubtotals { get; set; }
public Dictionary<string, long> PaymentSubtotals { get; set; }
[JsonProperty("paymentTotals")]
public Dictionary<string, decimal> PaymentTotals { get; set; }
public Dictionary<string, long> 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<string, Dictionary<string, decimal>> ExchangeRates{ get; set; }

View File

@@ -339,8 +339,8 @@ namespace BTCPayServer.Services.Invoices
Currency = ProductInformation.Currency,
Flags = new Flags() { Refundable = Refundable },
PaymentSubtotals = new Dictionary<string, decimal>(),
PaymentTotals= new Dictionary<string, decimal>(),
PaymentSubtotals = new Dictionary<string, long>(),
PaymentTotals= new Dictionary<string, long>(),
SupportedTransactionCurrencies = new Dictionary<string, InvoiceSupportedTransactionCurrency>(),
Addresses = new Dictionary<string, string>(),
PaymentCodes = new Dictionary<string, InvoicePaymentUrls>(),
@@ -351,6 +351,7 @@ namespace BTCPayServer.Services.Invoices
dto.CryptoInfo = new List<NBitpayClient.InvoiceCryptoInfo>();
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);