mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Fix decimal points shown in Checkout UI based on currency ( always showed btc decimal precision before) (#1529)
* Fix decimal points shown in Checkout UI based on currency ( always showed btc decimal precision before) * cleanup ShowMoney
This commit is contained in:
@@ -224,6 +224,16 @@ namespace BTCPayServer.Controllers
|
|||||||
: (decimal?)null;
|
: (decimal?)null;
|
||||||
|
|
||||||
var paymentMethodHandler = _paymentMethodHandlerDictionary[paymentMethodId];
|
var paymentMethodHandler = _paymentMethodHandlerDictionary[paymentMethodId];
|
||||||
|
|
||||||
|
var divisibility = _CurrencyNameTable.GetNumberFormatInfo(paymentMethod.GetId().CryptoCode, false)?.CurrencyDecimalDigits;
|
||||||
|
|
||||||
|
string ShowMoney(Money money)
|
||||||
|
{
|
||||||
|
if (!divisibility.HasValue) return money.ToString();
|
||||||
|
var format = $"0{(divisibility.Value > 0 ? "." : string.Empty)}".PadRight(divisibility.Value, '0');
|
||||||
|
return money.ToDecimal(MoneyUnit.BTC).ToString(format, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
var model = new PaymentModel()
|
var model = new PaymentModel()
|
||||||
{
|
{
|
||||||
CryptoCode = network.CryptoCode,
|
CryptoCode = network.CryptoCode,
|
||||||
@@ -236,8 +246,8 @@ namespace BTCPayServer.Controllers
|
|||||||
HtmlTitle = storeBlob.HtmlTitle ?? "BTCPay Invoice",
|
HtmlTitle = storeBlob.HtmlTitle ?? "BTCPay Invoice",
|
||||||
CryptoImage = Request.GetRelativePathOrAbsolute(paymentMethodHandler.GetCryptoImage(paymentMethodId)),
|
CryptoImage = Request.GetRelativePathOrAbsolute(paymentMethodHandler.GetCryptoImage(paymentMethodId)),
|
||||||
BtcAddress = paymentMethodDetails.GetPaymentDestination(),
|
BtcAddress = paymentMethodDetails.GetPaymentDestination(),
|
||||||
BtcDue = accounting.Due.ToString(),
|
BtcDue = ShowMoney(accounting.Due),
|
||||||
OrderAmount = (accounting.TotalDue - accounting.NetworkFee).ToString(),
|
OrderAmount = ShowMoney(accounting.TotalDue - accounting.NetworkFee),
|
||||||
OrderAmountFiat = OrderAmountFromInvoice(network.CryptoCode, invoice.ProductInformation),
|
OrderAmountFiat = OrderAmountFromInvoice(network.CryptoCode, invoice.ProductInformation),
|
||||||
CustomerEmail = invoice.RefundMail,
|
CustomerEmail = invoice.RefundMail,
|
||||||
RequiresRefundEmail = storeBlob.RequiresRefundEmail,
|
RequiresRefundEmail = storeBlob.RequiresRefundEmail,
|
||||||
@@ -253,7 +263,7 @@ namespace BTCPayServer.Controllers
|
|||||||
StoreName = store.StoreName,
|
StoreName = store.StoreName,
|
||||||
PeerInfo = (paymentMethodDetails as LightningLikePaymentMethodDetails)?.NodeInfo,
|
PeerInfo = (paymentMethodDetails as LightningLikePaymentMethodDetails)?.NodeInfo,
|
||||||
TxCount = accounting.TxRequired,
|
TxCount = accounting.TxRequired,
|
||||||
BtcPaid = accounting.Paid.ToString(),
|
BtcPaid = ShowMoney(accounting.Paid),
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
Status = invoice.StatusString,
|
Status = invoice.StatusString,
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|||||||
Reference in New Issue
Block a user