Support for displaying fiat value of invoice

This commit is contained in:
rockstardev 2018-05-09 22:39:13 -05:00
parent 70c98b6901
commit be1128a886
3 changed files with 14 additions and 1 deletions

View file

@ -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")]

View file

@ -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; }

View file

@ -74,7 +74,7 @@
</div>
<div class="single-item-order__right__ex-rate">
1 {{ srvModel.cryptoCode }} = {{ srvModel.rate }}
{{srvModel.fiatDue}}
</div>
</div>
@ -83,6 +83,12 @@
</div>
<line-items>
<div class="line-items">
<div class="line-items__item">
<div class="line-items__item__label">
<span>{{$t("Exchange Rate")}}</span>
</div>
<div class="line-items__item__value">1 {{ srvModel.cryptoCode }} = {{ srvModel.rate }}</div>
</div>
<div class="line-items__item">
<div class="line-items__item__label">{{$t("Order Amount")}}</div>
<div class="line-items__item__value">{{srvModel.orderAmount}} {{ srvModel.cryptoCode }}</div>