diff --git a/BTCPayServer.Tests/ApiKeysTests.cs b/BTCPayServer.Tests/ApiKeysTests.cs index 7f9a7243a..e19771b11 100644 --- a/BTCPayServer.Tests/ApiKeysTests.cs +++ b/BTCPayServer.Tests/ApiKeysTests.cs @@ -189,6 +189,7 @@ namespace BTCPayServer.Tests (await apiKeyRepo.GetKey(accessToken)).GetBlob().Permissions); //let's test the app identifier system + TestLogs.LogInformation("Checking app identifier system"); authUrl = BTCPayServerClient.GenerateAuthorizeUri(s.ServerUri, new[] { Policies.CanModifyStoreSettings, Policies.CanModifyServerSettings }, false, true, (appidentifier, new Uri(callbackUrl))).ToString(); diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index 26ea7a794..3c3523f22 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -751,7 +751,12 @@ namespace BTCPayServer.Tests s.Driver.FindElement(By.Id("CreatePaymentRequest")).Click(); s.Driver.FindElement(By.Id("Title")).SendKeys("Pay123"); s.Driver.FindElement(By.Id("Amount")).SendKeys("700"); - s.Driver.FindElement(By.Id("Currency")).SendKeys("BTC"); + + var currencyInput = s.Driver.FindElement(By.Id("Currency")); + Assert.Equal("USD", currencyInput.GetAttribute("value")); + currencyInput.Clear(); + currencyInput.SendKeys("BTC"); + s.Driver.FindElement(By.Id("SaveButton")).Click(); s.Driver.FindElement(By.Id("ViewPaymentRequest")).Click(); s.Driver.SwitchTo().Window(s.Driver.WindowHandles.Last()); @@ -1615,6 +1620,12 @@ namespace BTCPayServer.Tests s.Driver.FindElement(By.Id("Name")).SendKeys("PP1"); s.Driver.FindElement(By.Id("Amount")).Clear(); s.Driver.FindElement(By.Id("Amount")).SendKeys("0.0000001"); + + var currencyInput = s.Driver.FindElement(By.Id("Currency")); + Assert.Equal("USD", currencyInput.GetAttribute("value")); + currencyInput.Clear(); + currencyInput.SendKeys("BTC"); + s.Driver.FindElement(By.Id("Create")).Click(); s.Driver.FindElement(By.LinkText("View")).Click(); s.Driver.FindElement(By.Id("Destination")).SendKeys(lnurl); diff --git a/BTCPayServer/Controllers/UIInvoiceController.UI.cs b/BTCPayServer/Controllers/UIInvoiceController.UI.cs index c431898dc..4c68e454a 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.UI.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.UI.cs @@ -914,18 +914,6 @@ namespace BTCPayServer.Controllers [BitpayAPIConstraint(false)] public async Task CreateInvoice(InvoicesModel? model = null) { - var stores = new SelectList( - await _StoreRepository.GetStoresByUserId(GetUserId()), - nameof(StoreData.Id), - nameof(StoreData.StoreName), - new SearchString(model?.SearchTerm).GetFilterArray("storeid")?.ToArray().FirstOrDefault() - ); - if (!stores.Any()) - { - TempData[WellKnownTempData.ErrorMessage] = "You need to create at least one store before creating a transaction"; - return RedirectToAction(nameof(UIHomeController.Index), "UIHome"); - } - if (model?.StoreId != null) { var store = await _StoreRepository.FindStore(model.StoreId, GetUserId()); @@ -944,11 +932,16 @@ namespace BTCPayServer.Controllers HttpContext.SetStoreData(store); } + else + { + TempData[WellKnownTempData.ErrorMessage] = "You need to select a store before creating an invoice."; + return RedirectToAction(nameof(UIHomeController.Index), "UIHome"); + } var vm = new CreateInvoiceModel { - Stores = stores, - StoreId = model?.StoreId, + StoreId = model.StoreId, + Currency = HttpContext.GetStoreData()?.GetStoreBlob().DefaultCurrency, AvailablePaymentMethods = GetPaymentMethodsSelectList() }; @@ -961,8 +954,6 @@ namespace BTCPayServer.Controllers [BitpayAPIConstraint(false)] public async Task CreateInvoice(CreateInvoiceModel model, CancellationToken cancellationToken) { - var stores = await _StoreRepository.GetStoresByUserId(GetUserId()); - model.Stores = new SelectList(stores, nameof(StoreData.Id), nameof(StoreData.StoreName), model.StoreId); model.AvailablePaymentMethods = GetPaymentMethodsSelectList(); var store = HttpContext.GetStoreData(); if (!ModelState.IsValid) diff --git a/BTCPayServer/Controllers/UIPaymentRequestController.cs b/BTCPayServer/Controllers/UIPaymentRequestController.cs index bd99ee03c..459949fe8 100644 --- a/BTCPayServer/Controllers/UIPaymentRequestController.cs +++ b/BTCPayServer/Controllers/UIPaymentRequestController.cs @@ -89,10 +89,14 @@ namespace BTCPayServer.Controllers return NotFound(); } - return View(nameof(EditPaymentRequest), new UpdatePaymentRequestViewModel(paymentRequest) + var vm = new UpdatePaymentRequestViewModel(paymentRequest) { StoreId = store.Id - }); + }; + + vm.Currency ??= store.GetStoreBlob().DefaultCurrency; + + return View(nameof(EditPaymentRequest), vm); } [HttpPost("/stores/{storeId}/payment-requests/edit/{payReqId?}")] diff --git a/BTCPayServer/Controllers/UIStorePullPaymentsController.PullPayments.cs b/BTCPayServer/Controllers/UIStorePullPaymentsController.PullPayments.cs index f5564abe8..fcd18be48 100644 --- a/BTCPayServer/Controllers/UIStorePullPaymentsController.PullPayments.cs +++ b/BTCPayServer/Controllers/UIStorePullPaymentsController.PullPayments.cs @@ -76,10 +76,11 @@ namespace BTCPayServer.Controllers }); return RedirectToAction(nameof(UIStoresController.GeneralSettings), "UIStores", new { storeId }); } + return View(new NewPullPaymentModel { Name = "", - Currency = "BTC", + Currency = CurrentStore.GetStoreBlob().DefaultCurrency, CustomCSSLink = "", EmbeddedCSS = "", PaymentMethodItems = paymentMethods.Select(id => new SelectListItem(id.ToPrettyString(), id.ToString(), true)) diff --git a/BTCPayServer/Models/InvoicingModels/CreateInvoiceModel.cs b/BTCPayServer/Models/InvoicingModels/CreateInvoiceModel.cs index a7c01b98e..7306bd156 100644 --- a/BTCPayServer/Models/InvoicingModels/CreateInvoiceModel.cs +++ b/BTCPayServer/Models/InvoicingModels/CreateInvoiceModel.cs @@ -64,12 +64,6 @@ namespace BTCPayServer.Models.InvoicingModels get; set; } - [DisplayName("Store")] - public SelectList Stores - { - get; set; - } - [DisplayName("Supported Transaction Currencies")] public List SupportedTransactionCurrencies { diff --git a/BTCPayServer/Views/UIInvoice/CreateInvoice.cshtml b/BTCPayServer/Views/UIInvoice/CreateInvoice.cshtml index c9edc6e83..7c59182bb 100644 --- a/BTCPayServer/Views/UIInvoice/CreateInvoice.cshtml +++ b/BTCPayServer/Views/UIInvoice/CreateInvoice.cshtml @@ -25,7 +25,6 @@ } -