From 203c28df3d12ce78f85e2a8b6f150be2f8d4b142 Mon Sep 17 00:00:00 2001 From: lepipele Date: Fri, 13 Apr 2018 14:10:06 -0500 Subject: [PATCH] Extracting transaction string and supporting plural form --- BTCPayServer/Controllers/InvoiceController.UI.cs | 7 ++----- BTCPayServer/Models/InvoicingModels/PaymentModel.cs | 3 ++- BTCPayServer/Views/Invoice/Checkout-Body.cshtml | 9 ++++++++- BTCPayServer/wwwroot/checkout/js/langs/en.js | 5 ++++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index 4aac6b1ab..91c39408d 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -238,7 +238,8 @@ namespace BTCPayServer.Controllers BtcPaid = accounting.Paid.ToString(), Status = invoice.Status, CryptoImage = "/" + GetImage(paymentMethodId, network), - NetworkFeeDescription = $"{accounting.TxRequired} transaction{(accounting.TxRequired > 1 ? "s" : "")} x {paymentMethodDetails.GetTxFee()} {network.CryptoCode}", + NetworkFee = paymentMethodDetails.GetTxFee(), + IsMultiCurrency = invoice.GetPayments().Select(p => p.GetPaymentMethodId()).Concat(new[] { paymentMethod.GetId() }).Distinct().Count() > 1, AllowCoinConversion = storeBlob.AllowCoinConversion, AvailableCryptos = invoice.GetPaymentMethods(_NetworkProvider) .Where(i => i.Network != null) @@ -251,10 +252,6 @@ namespace BTCPayServer.Controllers .ToList() }; - var isMultiCurrency = invoice.GetPayments().Select(p => p.GetPaymentMethodId()).Concat(new[] { paymentMethod.GetId() }).Distinct().Count() > 1; - if (isMultiCurrency) - model.NetworkFeeDescription = $"{accounting.NetworkFee} {network.CryptoCode}"; - var expiration = TimeSpan.FromSeconds(model.ExpirationSeconds); model.TimeLeft = PrettyPrint(expiration); return model; diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index 92d957be4..ec42fd82c 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -43,7 +43,8 @@ namespace BTCPayServer.Models.InvoicingModels public string OrderId { get; set; } public string CryptoImage { get; set; } - public string NetworkFeeDescription { get; internal set; } + public decimal NetworkFee { get; set; } + public bool IsMultiCurrency { get; set; } public int MaxTimeMinutes { get; internal set; } public string PaymentType { get; internal set; } public string PaymentMethodId { get; internal set; } diff --git a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml index 2ab235aac..b974ea885 100644 --- a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml @@ -87,7 +87,14 @@
{{$t("Network Cost")}}
-
{{srvModel.networkFeeDescription }}
+
+ + {{ srvModel.networkFee }} {{ srvModel.cryptoCode }} + + + {{$t("txCount", {count: srvModel.txCount})}} x {{ srvModel.networkFee }} {{ srvModel.cryptoCode }} + +
diff --git a/BTCPayServer/wwwroot/checkout/js/langs/en.js b/BTCPayServer/wwwroot/checkout/js/langs/en.js index a36157bcb..7ed627ff4 100644 --- a/BTCPayServer/wwwroot/checkout/js/langs/en.js +++ b/BTCPayServer/wwwroot/checkout/js/langs/en.js @@ -47,5 +47,8 @@ You can return to {{storeName}} if you would like to submit your payment again." "Archived_Body": "Please contact the store for order information or assistance", // Lightning "BOLT 11 Invoice": "BOLT 11 Invoice", - "Node Info": "Node Info" + "Node Info": "Node Info", + // + "txCount": "{{count}} transaction", + "txCount_plural": "{{count}} transactions" };