Add ability to set default currency for a store (#2998)

This commit is contained in:
Nicolas Dorier
2021-10-20 23:17:40 +09:00
committed by GitHub
parent 407f26b1dc
commit 4cf3249e0b
17 changed files with 129 additions and 64 deletions

View File

@@ -94,7 +94,6 @@ namespace BTCPayServer.Controllers
{
throw new BitpayHttpException(400, "The expirationTime is set too soon");
}
invoice.Currency = invoice.Currency?.Trim().ToUpperInvariant() ?? "USD";
entity.Metadata.OrderId = invoice.OrderId;
entity.Metadata.PosData = invoice.PosData;
entity.ServerUrl = serverUrl;
@@ -164,7 +163,6 @@ namespace BTCPayServer.Controllers
if (invoice.Metadata != null)
entity.Metadata = InvoiceMetadata.FromJObject(invoice.Metadata);
invoice.Checkout ??= new CreateInvoiceRequest.CheckoutOptions();
invoice.Currency = invoice.Currency?.Trim().ToUpperInvariant() ?? "USD";
entity.Currency = invoice.Currency;
if (invoice.Amount is decimal v)
{
@@ -199,7 +197,10 @@ namespace BTCPayServer.Controllers
{
InvoiceLogs logs = new InvoiceLogs();
logs.Write("Creation of invoice starting", InvoiceEventData.EventSeverity.Info);
var storeBlob = store.GetStoreBlob();
if (string.IsNullOrEmpty(entity.Currency))
entity.Currency = storeBlob.DefaultCurrency;
entity.Currency = entity.Currency.Trim().ToUpperInvariant();
entity.Price = Math.Max(0.0m, entity.Price);
var currencyInfo = _CurrencyNameTable.GetNumberFormatInfo(entity.Currency, false);
if (currencyInfo != null)
@@ -218,7 +219,6 @@ namespace BTCPayServer.Controllers
}
var getAppsTaggingStore = _InvoiceRepository.GetAppsTaggingStore(store.Id);
var storeBlob = store.GetStoreBlob();
if (entity.Metadata.BuyerEmail != null)
{