From be1128a886aaf8ff102a7ca83e1151dbe56fa485 Mon Sep 17 00:00:00 2001 From: rockstardev Date: Wed, 9 May 2018 22:39:13 -0500 Subject: [PATCH] Support for displaying fiat value of invoice --- BTCPayServer/Controllers/InvoiceController.UI.cs | 6 ++++++ BTCPayServer/Models/InvoicingModels/PaymentModel.cs | 1 + BTCPayServer/Views/Invoice/Checkout-Body.cshtml | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index b8d448739..47a9348c2 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -241,6 +241,7 @@ namespace BTCPayServer.Controllers BtcAddress = paymentMethodDetails.GetPaymentDestination(), OrderAmount = (accounting.TotalDue - accounting.NetworkFee).ToString(), BtcDue = accounting.Due.ToString(), + FiatDue = FiatDue(accounting.Due, paymentMethod), CustomerEmail = invoice.RefundMail, RequiresRefundEmail = storeBlob.RequiresRefundEmail, ExpirationSeconds = Math.Max(0, (int)(invoice.ExpirationTime - DateTimeOffset.UtcNow).TotalSeconds), @@ -294,6 +295,11 @@ namespace BTCPayServer.Controllers { return price.ToString("C", _CurrencyNameTable.GetCurrencyProvider(currency)) + $" ({currency})"; } + private string FiatDue(Money btcDue, PaymentMethod paymentMethod) + { + var currency = paymentMethod.ParentEntity.ProductInformation.Currency; + return FormatCurrency(btcDue.ToUnit(MoneyUnit.BTC) * paymentMethod.Rate, currency); + } [HttpGet] [Route("i/{invoiceId}/status")] diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index e3dcaf149..e9c49d6f6 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -36,6 +36,7 @@ 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 InvoiceBitcoinUrl { get; set; } public string InvoiceBitcoinUrlQR { get; set; } diff --git a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml index 05d2bf70b..a61f41176 100644 --- a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml @@ -74,7 +74,7 @@
- 1 {{ srvModel.cryptoCode }} = {{ srvModel.rate }} + {{srvModel.fiatDue}}
@@ -83,6 +83,12 @@
+
+
+ {{$t("Exchange Rate")}} +
+
1 {{ srvModel.cryptoCode }} = {{ srvModel.rate }}
+
{{$t("Order Amount")}}
{{srvModel.orderAmount}} {{ srvModel.cryptoCode }}