diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index f5b61c412..905a6099a 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -871,9 +871,8 @@ namespace BTCPayServer.Tests var viewUrl = s.Driver.Url; Assert.Equal("Amount due", s.Driver.FindElement(By.CssSelector("[data-test='amount-due-title']")).Text); - Assert.Equal("Pay Invoice", - s.Driver.FindElement(By.CssSelector("[data-test='pay-button']")).Text.Trim()); - + Assert.Equal("Pay Invoice", s.Driver.FindElement(By.CssSelector("[data-test='pay-button']")).Text.Trim()); + // expire s.GoToUrl(editUrl); s.Driver.ExecuteJavaScript("document.getElementById('ExpiryDate').value = '2021-01-21T21:00:00.000Z'"); @@ -891,8 +890,13 @@ namespace BTCPayServer.Tests s.GoToUrl(viewUrl); s.Driver.AssertElementNotFound(By.CssSelector("[data-test='status']")); - Assert.Equal("Pay Invoice", - s.Driver.FindElement(By.CssSelector("[data-test='pay-button']")).Text.Trim()); + Assert.Equal("Pay Invoice", s.Driver.FindElement(By.CssSelector("[data-test='pay-button']")).Text.Trim()); + + // test invoice creation, click with JS, because the button is inside a sticky header + s.Driver.ExecuteJavaScript("document.querySelector('[data-test=\"pay-button\"]').click()"); + // checkout v1 + s.Driver.WaitForElement(By.CssSelector("invoice")); + Assert.Contains("Awaiting Payment", s.Driver.PageSource); // archive (from details page) s.GoToUrl(editUrl); diff --git a/BTCPayServer/Controllers/UIPaymentRequestController.cs b/BTCPayServer/Controllers/UIPaymentRequestController.cs index 0d89db423..e0e359815 100644 --- a/BTCPayServer/Controllers/UIPaymentRequestController.cs +++ b/BTCPayServer/Controllers/UIPaymentRequestController.cs @@ -35,6 +35,7 @@ namespace BTCPayServer.Controllers private readonly EventAggregator _EventAggregator; private readonly CurrencyNameTable _Currencies; private readonly InvoiceRepository _InvoiceRepository; + private readonly StoreRepository _storeRepository; public UIPaymentRequestController( UIInvoiceController invoiceController, @@ -43,6 +44,7 @@ namespace BTCPayServer.Controllers PaymentRequestService paymentRequestService, EventAggregator eventAggregator, CurrencyNameTable currencies, + StoreRepository storeRepository, InvoiceRepository invoiceRepository) { _InvoiceController = invoiceController; @@ -51,6 +53,7 @@ namespace BTCPayServer.Controllers _PaymentRequestService = paymentRequestService; _EventAggregator = eventAggregator; _Currencies = currencies; + _storeRepository = storeRepository; _InvoiceRepository = invoiceRepository; } @@ -223,7 +226,8 @@ namespace BTCPayServer.Controllers try { - var newInvoice = await _InvoiceController.CreatePaymentRequestInvoice(result, amount, this.GetCurrentStore(), Request, cancellationToken); + var store = await _storeRepository.FindStore(result.StoreId); + var newInvoice = await _InvoiceController.CreatePaymentRequestInvoice(result, amount, store, Request, cancellationToken); if (redirectToInvoice) { return RedirectToAction("Checkout", "UIInvoice", new { invoiceId = newInvoice.Id });