From 3770adb7d3c14efeee32953dc13908a635dee5a0 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Fri, 11 May 2018 12:15:26 -0500 Subject: [PATCH] Displaying fiat value of invoice's order amount in details --- BTCPayServer/Controllers/InvoiceController.UI.cs | 9 ++++----- BTCPayServer/Models/InvoicingModels/PaymentModel.cs | 2 +- BTCPayServer/Views/Invoice/Checkout-Body.cshtml | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index 47a9348c2..74be496df 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -239,9 +239,9 @@ namespace BTCPayServer.Controllers CustomCSSLink = storeBlob.CustomCSS?.AbsoluteUri, CustomLogoLink = storeBlob.CustomLogo?.AbsoluteUri, BtcAddress = paymentMethodDetails.GetPaymentDestination(), - OrderAmount = (accounting.TotalDue - accounting.NetworkFee).ToString(), BtcDue = accounting.Due.ToString(), - FiatDue = FiatDue(accounting.Due, paymentMethod), + OrderAmount = (accounting.TotalDue - accounting.NetworkFee).ToString(), + OrderAmountFiat = OrderAmountFiat(invoice.ProductInformation), CustomerEmail = invoice.RefundMail, RequiresRefundEmail = storeBlob.RequiresRefundEmail, ExpirationSeconds = Math.Max(0, (int)(invoice.ExpirationTime - DateTimeOffset.UtcNow).TotalSeconds), @@ -295,10 +295,9 @@ namespace BTCPayServer.Controllers { return price.ToString("C", _CurrencyNameTable.GetCurrencyProvider(currency)) + $" ({currency})"; } - private string FiatDue(Money btcDue, PaymentMethod paymentMethod) + private string OrderAmountFiat(ProductInformation productInformation) { - var currency = paymentMethod.ParentEntity.ProductInformation.Currency; - return FormatCurrency(btcDue.ToUnit(MoneyUnit.BTC) * paymentMethod.Rate, currency); + return FormatCurrency(productInformation.Price, productInformation.Currency); } [HttpGet] diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index e9c49d6f6..da28a8975 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -36,8 +36,8 @@ namespace BTCPayServer.Models.InvoicingModels public string ItemDesc { get; set; } public string TimeLeft { get; set; } public string Rate { get; set; } - public string FiatDue { get; set; } public string OrderAmount { get; set; } + public string OrderAmountFiat { get; set; } public string InvoiceBitcoinUrl { get; set; } public string InvoiceBitcoinUrlQR { get; set; } public int TxCount { get; set; } diff --git a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml index a61f41176..f979f3b8f 100644 --- a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml @@ -74,7 +74,7 @@
- {{srvModel.fiatDue}} + 1 {{ srvModel.cryptoCode }} = {{ srvModel.rate }}
@@ -85,9 +85,9 @@
- {{$t("Exchange Rate")}} + {{$t("Order Amount in Fiat")}}
-
1 {{ srvModel.cryptoCode }} = {{ srvModel.rate }}
+
{{srvModel.orderAmountFiat}}
{{$t("Order Amount")}}