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