diff --git a/.dockerignore b/.dockerignore index c1a6ffd0c..5a76cae34 100644 --- a/.dockerignore +++ b/.dockerignore @@ -121,3 +121,4 @@ bower_components output .vs +**/launchSettings.json diff --git a/BTCPayServer.Tests/README.md b/BTCPayServer.Tests/README.md index 652c0bca4..14ebab334 100644 --- a/BTCPayServer.Tests/README.md +++ b/BTCPayServer.Tests/README.md @@ -19,6 +19,12 @@ Once you want to stop docker-compose down ``` +If you want to stop, and remove all existing data + +``` +docker-compose down -v +``` + You can run the tests inside a container by running ``` diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index f450ee4c3..ec4fefcdf 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.0.15 + 1.0.0.18 @@ -22,7 +22,7 @@ - + diff --git a/BTCPayServer/Controllers/AccessTokenController.cs b/BTCPayServer/Controllers/AccessTokenController.cs index 4e8601d92..b72c90a4c 100644 --- a/BTCPayServer/Controllers/AccessTokenController.cs +++ b/BTCPayServer/Controllers/AccessTokenController.cs @@ -58,6 +58,12 @@ namespace BTCPayServer.Controllers pairingEntity = await _TokenRepository.GetPairingAsync(request.PairingCode); pairingEntity.SIN = sin; + if(string.IsNullOrEmpty(pairingEntity.Label) && !string.IsNullOrEmpty(request.Label)) + { + pairingEntity.Label = request.Label; + await _TokenRepository.UpdatePairingCode(pairingEntity); + } + var result = await _TokenRepository.PairWithSINAsync(request.PairingCode, sin); if(result != PairingResult.Complete && result != PairingResult.Partial) throw new BitpayHttpException(400, $"Error while pairing ({result})"); diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index 7eae4a662..8d6ab411b 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -92,6 +92,27 @@ namespace BTCPayServer.Controllers return View(model); } + + static Dictionary _CurrencyProviders = new Dictionary(); + private IFormatProvider GetCurrencyProvider(string currency) + { + lock(_CurrencyProviders) + { + if(_CurrencyProviders.Count == 0) + { + foreach(var culture in CultureInfo.GetCultures(CultureTypes.AllCultures).Where(c => !c.IsNeutralCulture)) + { + try + { + _CurrencyProviders.TryAdd(new RegionInfo(culture.LCID).ISOCurrencySymbol, culture); + } + catch { } + } + } + return _CurrencyProviders.TryGet(currency); + } + } + [HttpGet] [Route("i/{invoiceId}")] [Route("invoice")] @@ -112,6 +133,7 @@ namespace BTCPayServer.Controllers var model = new PaymentModel() { + ServerUrl = HttpContext.Request.GetAbsoluteRoot(), OrderId = invoice.OrderId, InvoiceId = invoice.Id, BTCAddress = invoice.DepositAddress.ToString(), @@ -122,7 +144,7 @@ namespace BTCPayServer.Controllers ExpirationSeconds = Math.Max(0, (int)(invoice.ExpirationTime - DateTimeOffset.UtcNow).TotalSeconds), MaxTimeSeconds = (int)(invoice.ExpirationTime - invoice.InvoiceTime).TotalSeconds, ItemDesc = invoice.ProductInformation.ItemDesc, - Rate = invoice.Rate.ToString(), + Rate = invoice.Rate.ToString("C", GetCurrencyProvider(invoice.ProductInformation.Currency)), RedirectUrl = invoice.RedirectURL, StoreName = store.StoreName, TxFees = invoice.TxFee.ToString(), diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 8827b83de..31d15eb08 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -230,7 +230,7 @@ namespace BTCPayServer.Controllers { return View(model); } - + model.Label = model.Label ?? String.Empty; if(storeId == null) // Permissions are not checked by Policy if the storeId is not passed by url { storeId = model.StoreId; diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index 1f19e91c9..f10f39e12 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -11,7 +11,10 @@ namespace BTCPayServer.Models.InvoicingModels { get; set; } - + public string ServerUrl + { + get; set; + } public string OrderId { get; set; diff --git a/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs b/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs index 8788d1ad2..f5dd739dc 100644 --- a/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs @@ -15,7 +15,7 @@ namespace BTCPayServer.Models.StoreViewModels { get; set; } - [Required] + public string Label { get; set; diff --git a/BTCPayServer/Views/Invoice/Checkout.cshtml b/BTCPayServer/Views/Invoice/Checkout.cshtml index 9a68d39a6..07993d88a 100644 --- a/BTCPayServer/Views/Invoice/Checkout.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout.cshtml @@ -27,6 +27,7 @@ crossorigin="anonymous">