From 9b0d1a23dcf943965d50a1532a2792ce8049a04d Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Fri, 22 Oct 2021 04:17:40 +0200 Subject: [PATCH] Decouple Pull payment from wallets (#2987) * Decouple Pull payments from wallet * Update _Nav.cshtml * Fixes --- BTCPayServer.Tests/SeleniumTester.cs | 3 +- BTCPayServer.Tests/SeleniumTests.cs | 25 ++-- BTCPayServer/BTCPayServer.csproj | 18 +-- ...orePullPaymentsController.PullPayments.cs} | 128 ++++++++++-------- .../Extensions/UrlHelperExtensions.cs | 9 +- .../WalletViewModels/PullPaymentsModel.cs | 2 - .../ExternalPayoutTransactionNotification.cs | 8 +- .../Notifications/Blobs/PayoutNotification.cs | 6 +- .../NewPullPayment.cshtml | 7 +- .../Payouts.cshtml | 24 ++-- .../PullPayments.cshtml | 20 +-- BTCPayServer/Views/Stores/StoreNavPages.cs | 4 +- BTCPayServer/Views/Stores/_Nav.cshtml | 2 + BTCPayServer/Views/Wallets/WalletsNavPages.cs | 2 - BTCPayServer/Views/Wallets/_Nav.cshtml | 4 +- 15 files changed, 147 insertions(+), 115 deletions(-) rename BTCPayServer/Controllers/{WalletsController.PullPayments.cs => StorePullPaymentsController.PullPayments.cs} (83%) rename BTCPayServer/Views/{Wallets => StorePullPayments}/NewPullPayment.cshtml (91%) rename BTCPayServer/Views/{Wallets => StorePullPayments}/Payouts.cshtml (87%) rename BTCPayServer/Views/{Wallets => StorePullPayments}/PullPayments.cshtml (87%) diff --git a/BTCPayServer.Tests/SeleniumTester.cs b/BTCPayServer.Tests/SeleniumTester.cs index 8b0dd664f..08a3b58fd 100644 --- a/BTCPayServer.Tests/SeleniumTester.cs +++ b/BTCPayServer.Tests/SeleniumTester.cs @@ -313,7 +313,8 @@ namespace BTCPayServer.Tests public void GoToStore(string storeId, StoreNavPages storeNavPage = StoreNavPages.Index) { - Driver.FindElement(By.Id("Stores")).Click(); + GoToHome(); + Driver.WaitForAndClick(By.Id("Stores")); Driver.FindElement(By.Id($"update-store-{storeId}")).Click(); if (storeNavPage != StoreNavPages.Index) diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index 3417379f7..f302caa7e 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -995,7 +995,7 @@ namespace BTCPayServer.Tests await s.Server.ExplorerNode.GenerateAsync(1); await s.FundStoreWallet(denomination: 50.0m); - s.GoToWallet(navPages: WalletsNavPages.PullPayments); + s.GoToStore(s.StoreId, StoreNavPages.PullPayments); s.Driver.FindElement(By.Id("NewPullPayment")).Click(); s.Driver.FindElement(By.Id("Name")).SendKeys("PP1"); s.Driver.FindElement(By.Id("Amount")).Clear(); @@ -1003,7 +1003,7 @@ namespace BTCPayServer.Tests s.Driver.FindElement(By.Id("Create")).Click(); s.Driver.FindElement(By.LinkText("View")).Click(); - s.GoToWallet(navPages: WalletsNavPages.PullPayments); + s.GoToStore(s.StoreId, StoreNavPages.PullPayments); s.Driver.FindElement(By.Id("NewPullPayment")).Click(); s.Driver.FindElement(By.Id("Name")).SendKeys("PP2"); @@ -1035,13 +1035,13 @@ namespace BTCPayServer.Tests var viewPullPaymentUrl = s.Driver.Url; // This one should have nothing - s.GoToWallet(navPages: WalletsNavPages.PullPayments); + s.GoToStore(s.StoreId, StoreNavPages.PullPayments); var payouts = s.Driver.FindElements(By.ClassName("pp-payout")); Assert.Equal(2, payouts.Count); payouts[1].Click(); Assert.Empty(s.Driver.FindElements(By.ClassName("payout"))); // PP2 should have payouts - s.GoToWallet(navPages: WalletsNavPages.PullPayments); + s.GoToStore(s.StoreId, StoreNavPages.PullPayments); payouts = s.Driver.FindElements(By.ClassName("pp-payout")); payouts[0].Click(); @@ -1061,7 +1061,7 @@ namespace BTCPayServer.Tests }); Assert.Equal("payout", s.Driver.FindElement(By.ClassName("transactionLabel")).Text); - s.GoToWallet(navPages: WalletsNavPages.Payouts); + s.GoToStore(s.StoreId, StoreNavPages.Payouts); var x = s.Driver.PageSource; s.Driver.FindElement(By.Id($"{PayoutState.InProgress}-view")).Click(); ReadOnlyCollection txs; @@ -1103,7 +1103,7 @@ namespace BTCPayServer.Tests var newStore = s.CreateNewStore(); s.GenerateWallet("BTC", "", true, true); var newWalletId = new WalletId(newStore.storeId, "BTC"); - s.GoToWallet(newWalletId, WalletsNavPages.PullPayments); + s.GoToStore(s.StoreId, StoreNavPages.PullPayments); s.Driver.FindElement(By.Id("NewPullPayment")).Click(); s.Driver.FindElement(By.Id("Name")).SendKeys("External Test"); @@ -1120,7 +1120,7 @@ namespace BTCPayServer.Tests s.FindAlertMessage(); Assert.Contains(PayoutState.AwaitingApproval.GetStateString(), s.Driver.PageSource); - s.GoToWallet(newWalletId, WalletsNavPages.Payouts); + s.GoToStore(s.StoreId, StoreNavPages.Payouts); s.Driver.FindElement(By.Id($"{PayoutState.AwaitingApproval}-view")).Click(); s.Driver.FindElement(By.Id($"{PayoutState.AwaitingApproval}-selectAllCheckbox")).Click(); s.Driver.FindElement(By.Id($"{PayoutState.AwaitingApproval}-actions")).Click(); @@ -1128,7 +1128,7 @@ namespace BTCPayServer.Tests s.FindAlertMessage(); var tx =await s.Server.ExplorerNode.SendToAddressAsync(address, Money.FromUnit(0.001m, MoneyUnit.BTC)); - s.GoToWallet(newWalletId, WalletsNavPages.Payouts); + s.GoToStore(s.StoreId, StoreNavPages.Payouts); s.Driver.FindElement(By.Id($"{PayoutState.AwaitingPayment}-view")).Click(); Assert.Contains(PayoutState.AwaitingPayment.GetStateString(), s.Driver.PageSource); @@ -1146,8 +1146,8 @@ namespace BTCPayServer.Tests s.AddLightningNode("BTC"); //Currently an onchain wallet is required to use the Lightning payouts feature.. s.GenerateWallet("BTC", "", true, true); - newWalletId = new WalletId(newStore.storeId, "BTC"); - s.GoToWallet(newWalletId, WalletsNavPages.PullPayments); + + s.GoToStore(newStore.storeId, StoreNavPages.PullPayments); s.Driver.FindElement(By.Id("NewPullPayment")).Click(); @@ -1188,7 +1188,8 @@ namespace BTCPayServer.Tests s.FindAlertMessage(); Assert.Contains(PayoutState.AwaitingApproval.GetStateString(), s.Driver.PageSource); - s.GoToWallet(newWalletId, WalletsNavPages.Payouts); + + s.GoToStore(newStore.storeId, StoreNavPages.Payouts); s.Driver.FindElement(By.Id($"{new PaymentMethodId("BTC", PaymentTypes.LightningLike )}-view")).Click(); s.Driver.FindElement(By.Id($"{PayoutState.AwaitingApproval}-view")).Click(); s.Driver.FindElement(By.Id($"{PayoutState.AwaitingApproval}-selectAllCheckbox")).Click(); @@ -1200,7 +1201,7 @@ namespace BTCPayServer.Tests s.Driver.FindElement(By.CssSelector("#pay-invoices-form")).Submit(); //lightning config in tests is very unstable so we can just go ahead and handle it as both s.FindAlertMessage(new []{StatusMessageModel.StatusSeverity.Error, StatusMessageModel.StatusSeverity.Success}); - s.GoToWallet(newWalletId, WalletsNavPages.Payouts); + s.GoToStore(newStore.storeId, StoreNavPages.Payouts); s.Driver.FindElement(By.Id($"{new PaymentMethodId("BTC", PaymentTypes.LightningLike )}-view")).Click(); diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 22f338163..c0b538c06 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -21,6 +21,15 @@ + + false + + + false + + + false + @@ -197,12 +206,6 @@ $(IncludeRazorContentInPack) - - $(IncludeRazorContentInPack) - - - $(IncludeRazorContentInPack) - $(IncludeRazorContentInPack) @@ -218,9 +221,6 @@ $(IncludeRazorContentInPack) - - $(IncludeRazorContentInPack) - $(IncludeRazorContentInPack) diff --git a/BTCPayServer/Controllers/WalletsController.PullPayments.cs b/BTCPayServer/Controllers/StorePullPaymentsController.PullPayments.cs similarity index 83% rename from BTCPayServer/Controllers/WalletsController.PullPayments.cs rename to BTCPayServer/Controllers/StorePullPaymentsController.PullPayments.cs index dfe2cff20..4d18567bc 100644 --- a/BTCPayServer/Controllers/WalletsController.PullPayments.cs +++ b/BTCPayServer/Controllers/StorePullPaymentsController.PullPayments.cs @@ -1,39 +1,70 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Abstractions.Models; +using BTCPayServer.Client; using BTCPayServer.Client.Models; -using BTCPayServer.Common; using BTCPayServer.Data; using BTCPayServer.HostedServices; -using BTCPayServer.ModelBinders; using BTCPayServer.Models; using BTCPayServer.Models.WalletViewModels; using BTCPayServer.Payments; using BTCPayServer.Rating; -using BTCPayServer.Views; +using BTCPayServer.Services; +using BTCPayServer.Services.Rates; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.EntityFrameworkCore; -using NBitcoin; using PayoutData = BTCPayServer.Data.PayoutData; +using StoreData = BTCPayServer.Data.StoreData; namespace BTCPayServer.Controllers { - public partial class WalletsController + [Route("stores/{storeId}/pull-payments")] + [Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)] + [AutoValidateAntiforgeryToken] + public class StorePullPaymentsController: Controller { - [HttpGet("{walletId}/pull-payments/new")] - public IActionResult NewPullPayment([ModelBinder(typeof(WalletIdModelBinder))] - WalletId walletId) + private readonly BTCPayNetworkProvider _btcPayNetworkProvider; + private readonly IEnumerable _payoutHandlers; + private readonly CurrencyNameTable _currencyNameTable; + private readonly PullPaymentHostedService _pullPaymentService; + private readonly ApplicationDbContextFactory _dbContextFactory; + private readonly BTCPayNetworkJsonSerializerSettings _jsonSerializerSettings; + + public StoreData CurrentStore { - - if (GetDerivationSchemeSettings(walletId) == null) + get + { + return HttpContext.GetStoreData(); + } + } + public StorePullPaymentsController(BTCPayNetworkProvider btcPayNetworkProvider, + IEnumerable payoutHandlers, + CurrencyNameTable currencyNameTable, + PullPaymentHostedService pullPaymentHostedService, + ApplicationDbContextFactory dbContextFactory, + BTCPayNetworkJsonSerializerSettings jsonSerializerSettings) + { + _btcPayNetworkProvider = btcPayNetworkProvider; + _payoutHandlers = payoutHandlers; + _currencyNameTable = currencyNameTable; + _pullPaymentService = pullPaymentHostedService; + _dbContextFactory = dbContextFactory; + _jsonSerializerSettings = jsonSerializerSettings; + } + + [HttpGet("new")] + public IActionResult NewPullPayment(string storeId) + { + if (CurrentStore is null) return NotFound(); - var storeMethods = CurrentStore.GetSupportedPaymentMethods(NetworkProvider).Select(method => method.PaymentId).ToList(); + var storeMethods = CurrentStore.GetSupportedPaymentMethods(_btcPayNetworkProvider).Select(method => method.PaymentId).ToList(); var paymentMethodOptions = _payoutHandlers.GetSupportedPaymentMethods(storeMethods); return View(new NewPullPaymentModel { @@ -45,14 +76,13 @@ namespace BTCPayServer.Controllers }); } - [HttpPost("{walletId}/pull-payments/new")] - public async Task NewPullPayment([ModelBinder(typeof(WalletIdModelBinder))] - WalletId walletId, NewPullPaymentModel model) + [HttpPost("new")] + public async Task NewPullPayment(string storeId, NewPullPaymentModel model) { - if (GetDerivationSchemeSettings(walletId) == null) + if (CurrentStore is null) return NotFound(); - var storeMethods = CurrentStore.GetSupportedPaymentMethods(NetworkProvider).Select(method => method.PaymentId).ToList(); + var storeMethods = CurrentStore.GetSupportedPaymentMethods(_btcPayNetworkProvider).Select(method => method.PaymentId).ToList(); var paymentMethodOptions = _payoutHandlers.GetSupportedPaymentMethods(storeMethods); model.PaymentMethodItems = paymentMethodOptions.Select(id => new SelectListItem(id.ToPrettyString(), id.ToString(), true)); @@ -62,7 +92,7 @@ namespace BTCPayServer.Controllers { ModelState.AddModelError(nameof(model.PaymentMethods), "You need at least one payment method"); } - if (_currencyTable.GetCurrencyData(model.Currency, false) is null) + if (_currencyNameTable.GetCurrencyData(model.Currency, false) is null) { ModelState.AddModelError(nameof(model.Currency), "Invalid currency"); } @@ -87,7 +117,7 @@ namespace BTCPayServer.Controllers Name = model.Name, Amount = model.Amount, Currency = model.Currency, - StoreId = walletId.StoreId, + StoreId = storeId, PaymentMethodIds = selectedPaymentMethodIds, EmbeddedCSS = model.EmbeddedCSS, CustomCSSLink = model.CustomCSSLink @@ -97,17 +127,14 @@ namespace BTCPayServer.Controllers Message = "Pull payment request created", Severity = StatusMessageModel.StatusSeverity.Success }); - return RedirectToAction(nameof(PullPayments), new { walletId = walletId.ToString() }); + return RedirectToAction(nameof(PullPayments), new { storeId = storeId }); } - [HttpGet("{walletId}/pull-payments")] - public async Task PullPayments( - [ModelBinder(typeof(WalletIdModelBinder))] - WalletId walletId) + [HttpGet("")] + public async Task PullPayments(string storeId) { using var ctx = this._dbContextFactory.CreateContext(); var now = DateTimeOffset.UtcNow; - var storeId = walletId.StoreId; var pps = await ctx.PullPayments.Where(p => p.StoreId == storeId && !p.Archived) .OrderByDescending(p => p.StartDate) .Select(o => new @@ -120,8 +147,7 @@ namespace BTCPayServer.Controllers }) .ToListAsync(); - var vm = new PullPaymentsModel - { HasDerivationSchemeSettings = GetDerivationSchemeSettings(walletId) != null }; + var vm = new PullPaymentsModel(); foreach (var o in pps) { @@ -131,8 +157,8 @@ namespace BTCPayServer.Controllers var totalAwaiting = o.Awaiting.Where(o => o.IsInPeriod(pp, now)) .Select(o => o.GetBlob(_jsonSerializerSettings).Amount).Sum(); var ppBlob = pp.GetBlob(); - var ni = _currencyTable.GetCurrencyData(ppBlob.Currency, true); - var nfi = _currencyTable.GetNumberFormatInfo(ppBlob.Currency, true); + var ni = _currencyNameTable.GetCurrencyData(ppBlob.Currency, true); + var nfi = _currencyNameTable.GetNumberFormatInfo(ppBlob.Currency, true); var period = pp.GetPeriod(now); vm.PullPayments.Add(new PullPaymentsModel.PullPaymentModel() { @@ -146,7 +172,7 @@ namespace BTCPayServer.Controllers AwaitingPercent = (int)(totalAwaiting / ppBlob.Limit * 100m), Awaiting = totalAwaiting.RoundToSignificant(ni.Divisibility).ToString("C", nfi), Completed = totalCompleted.RoundToSignificant(ni.Divisibility).ToString("C", nfi), - Limit = _currencyTable.DisplayFormatCurrency(ppBlob.Limit, ppBlob.Currency), + Limit = _currencyNameTable.DisplayFormatCurrency(ppBlob.Limit, ppBlob.Currency), ResetIn = period?.End is DateTimeOffset nr ? ZeroIfNegative(nr - now).TimeString() : null, EndIn = pp.EndDate is DateTimeOffset end ? ZeroIfNegative(end - now).TimeString() : null } @@ -161,19 +187,15 @@ namespace BTCPayServer.Controllers return time; } - [HttpGet("{walletId}/pull-payments/{pullPaymentId}/archive")] - public IActionResult ArchivePullPayment( - [ModelBinder(typeof(WalletIdModelBinder))] - WalletId walletId, + [HttpGet("{pullPaymentId}/archive")] + public IActionResult ArchivePullPayment(string storeId, string pullPaymentId) { return View("Confirm", new ConfirmModel("Archive pull payment", "Do you really want to archive the pull payment?", "Archive")); } - [HttpPost("{walletId}/pull-payments/{pullPaymentId}/archive")] - public async Task ArchivePullPaymentPost( - [ModelBinder(typeof(WalletIdModelBinder))] - WalletId walletId, + [HttpPost("{pullPaymentId}/archive")] + public async Task ArchivePullPaymentPost(string storeId, string pullPaymentId) { await _pullPaymentService.Cancel(new HostedServices.PullPaymentHostedService.CancelRequest(pullPaymentId)); @@ -182,18 +204,15 @@ namespace BTCPayServer.Controllers Message = "Pull payment archived", Severity = StatusMessageModel.StatusSeverity.Success }); - return RedirectToAction(nameof(PullPayments), new { walletId = walletId.ToString() }); + return RedirectToAction(nameof(PullPayments), new { storeId = storeId }); } - [HttpPost("{walletId}/payouts")] + [HttpPost("payouts")] public async Task PayoutsPost( - [ModelBinder(typeof(WalletIdModelBinder))] - WalletId walletId, PayoutsModel vm, CancellationToken cancellationToken) + string storeId, PayoutsModel vm, CancellationToken cancellationToken) { - if (vm is null || GetDerivationSchemeSettings(walletId) == null) + if (vm is null) return NotFound(); - - var storeId = walletId.StoreId; var paymentMethodId = PaymentMethodId.Parse(vm.PaymentMethodId); var handler = _payoutHandlers .FindPayoutHandler(paymentMethodId); @@ -208,7 +227,7 @@ namespace BTCPayServer.Controllers }); return RedirectToAction(nameof(Payouts), new { - walletId = walletId.ToString(), + storeId = storeId, pullPaymentId = vm.PullPaymentId, paymentMethodId = paymentMethodId.ToString() }); @@ -216,7 +235,7 @@ namespace BTCPayServer.Controllers var command = vm.Command.Substring(vm.Command.IndexOf('-', StringComparison.InvariantCulture) + 1); if (handler != null) { - var result = await handler.DoSpecificAction(command, payoutIds, walletId.StoreId); + var result = await handler.DoSpecificAction(command, payoutIds, storeId); if (result != null) { TempData.SetStatusMessageModel(result); @@ -315,7 +334,7 @@ namespace BTCPayServer.Controllers }); return RedirectToAction(nameof(Payouts), new { - walletId = walletId.ToString(), + storeId = storeId, pullPaymentId = vm.PullPaymentId, paymentMethodId = paymentMethodId.ToString() }); @@ -342,7 +361,7 @@ namespace BTCPayServer.Controllers return RedirectToAction(nameof(Payouts), new { - walletId = walletId.ToString(), + storeId = storeId, pullPaymentId = vm.PullPaymentId, paymentMethodId = paymentMethodId.ToString() }); @@ -363,15 +382,14 @@ namespace BTCPayServer.Controllers return payouts; } - [HttpGet("{walletId}/payouts")] + [HttpGet("payouts")] public async Task Payouts( - [ModelBinder(typeof(WalletIdModelBinder))] - WalletId walletId, string pullPaymentId, string paymentMethodId, PayoutState payoutState, + string storeId, string pullPaymentId, string paymentMethodId, PayoutState payoutState, int skip = 0, int count = 50) { var vm = this.ParseListQuery(new PayoutsModel { - PaymentMethodId = paymentMethodId?? new PaymentMethodId(walletId.CryptoCode, PaymentTypes.BTCLike).ToString(), + PaymentMethodId = paymentMethodId?? _payoutHandlers.GetSupportedPaymentMethods().First().ToString(), PullPaymentId = pullPaymentId, PayoutState = payoutState, Skip = skip, @@ -379,13 +397,13 @@ namespace BTCPayServer.Controllers }); vm.Payouts = new List(); await using var ctx = _dbContextFactory.CreateContext(); - var storeId = walletId.StoreId; var payoutRequest = ctx.Payouts.Where(p => p.PullPaymentData.StoreId == storeId && !p.PullPaymentData.Archived); if (pullPaymentId != null) { payoutRequest = payoutRequest.Where(p => p.PullPaymentDataId == vm.PullPaymentId); vm.PullPaymentName = (await ctx.PullPayments.FindAsync(pullPaymentId)).GetBlob().Name; } + if (vm.PaymentMethodId != null) { var pmiStr = vm.PaymentMethodId; @@ -425,7 +443,7 @@ namespace BTCPayServer.Controllers PullPaymentName = ppBlob.Name ?? item.PullPayment.Id, Date = item.Payout.Date, PayoutId = item.Payout.Id, - Amount = _currencyTable.DisplayFormatCurrency(payoutBlob.Amount, ppBlob.Currency), + Amount = _currencyNameTable.DisplayFormatCurrency(payoutBlob.Amount, ppBlob.Currency), Destination = payoutBlob.Destination }; var handler = _payoutHandlers diff --git a/BTCPayServer/Extensions/UrlHelperExtensions.cs b/BTCPayServer/Extensions/UrlHelperExtensions.cs index f0d8fc08a..4168fff18 100644 --- a/BTCPayServer/Extensions/UrlHelperExtensions.cs +++ b/BTCPayServer/Extensions/UrlHelperExtensions.cs @@ -63,12 +63,13 @@ namespace Microsoft.AspNetCore.Mvc scheme, host, pathbase); } - public static string PayoutLink(this LinkGenerator urlHelper, string walletId,string pullPaymentId, string scheme, HostString host, string pathbase) + public static string PayoutLink(this LinkGenerator urlHelper, string walletIdOrStoreId,string pullPaymentId, string scheme, HostString host, string pathbase) { + WalletId.TryParse(walletIdOrStoreId, out var wallet); return urlHelper.GetUriByAction( - action: nameof(WalletsController.Payouts), - controller: "Wallets", - values: new {walletId, pullPaymentId}, + action: nameof(StorePullPaymentsController.Payouts), + controller: "StorePullPayments", + values: new {storeId= wallet?.StoreId?? walletIdOrStoreId , pullPaymentId}, scheme, host, pathbase); } } diff --git a/BTCPayServer/Models/WalletViewModels/PullPaymentsModel.cs b/BTCPayServer/Models/WalletViewModels/PullPaymentsModel.cs index 7b722c1f9..2ebaf59e8 100644 --- a/BTCPayServer/Models/WalletViewModels/PullPaymentsModel.cs +++ b/BTCPayServer/Models/WalletViewModels/PullPaymentsModel.cs @@ -29,8 +29,6 @@ namespace BTCPayServer.Models.WalletViewModels } public List PullPayments { get; set; } = new List(); - - public bool HasDerivationSchemeSettings { get; set; } } public class NewPullPaymentModel diff --git a/BTCPayServer/Services/Notifications/Blobs/ExternalPayoutTransactionNotification.cs b/BTCPayServer/Services/Notifications/Blobs/ExternalPayoutTransactionNotification.cs index 52125eb71..0e529e4b4 100644 --- a/BTCPayServer/Services/Notifications/Blobs/ExternalPayoutTransactionNotification.cs +++ b/BTCPayServer/Services/Notifications/Blobs/ExternalPayoutTransactionNotification.cs @@ -2,6 +2,7 @@ using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Client.Models; using BTCPayServer.Configuration; using BTCPayServer.Controllers; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing; namespace BTCPayServer.Services.Notifications.Blobs @@ -36,11 +37,12 @@ namespace BTCPayServer.Services.Notifications.Blobs { vm.Body = "A payment that was made to an approved payout by an external wallet is waiting for your confirmation."; - vm.ActionLink = _linkGenerator.GetPathByAction(nameof(WalletsController.Payouts), - "Wallets", + vm.ActionLink = _linkGenerator.GetPathByAction(nameof(StorePullPaymentsController.Payouts), + "StorePullPayments", new { - walletId = new WalletId(notification.StoreId, notification.PaymentMethod), + storeId = notification.StoreId, + paymentMethodId = notification.PaymentMethod, payoutState = PayoutState.AwaitingPayment }, _options.RootPath); } diff --git a/BTCPayServer/Services/Notifications/Blobs/PayoutNotification.cs b/BTCPayServer/Services/Notifications/Blobs/PayoutNotification.cs index 3bb47bd9f..eee394185 100644 --- a/BTCPayServer/Services/Notifications/Blobs/PayoutNotification.cs +++ b/BTCPayServer/Services/Notifications/Blobs/PayoutNotification.cs @@ -33,9 +33,9 @@ namespace BTCPayServer.Services.Notifications.Blobs protected override void FillViewModel(PayoutNotification notification, NotificationViewModel vm) { vm.Body = "A new payout is awaiting for approval"; - vm.ActionLink = _linkGenerator.GetPathByAction(nameof(WalletsController.Payouts), - "Wallets", - new {walletId = new WalletId(notification.StoreId, notification.PaymentMethod)}, _options.RootPath); + vm.ActionLink = _linkGenerator.GetPathByAction(nameof(StorePullPaymentsController.Payouts), + "StorePullPayments", + new {storeId = notification.StoreId, paymentMethodId = notification.PaymentMethod }, _options.RootPath); } } diff --git a/BTCPayServer/Views/Wallets/NewPullPayment.cshtml b/BTCPayServer/Views/StorePullPayments/NewPullPayment.cshtml similarity index 91% rename from BTCPayServer/Views/Wallets/NewPullPayment.cshtml rename to BTCPayServer/Views/StorePullPayments/NewPullPayment.cshtml index 4aac79b28..c07437f74 100644 --- a/BTCPayServer/Views/Wallets/NewPullPayment.cshtml +++ b/BTCPayServer/Views/StorePullPayments/NewPullPayment.cshtml @@ -1,7 +1,10 @@ -@model NewPullPaymentModel +@using BTCPayServer.Abstractions.Extensions +@using BTCPayServer.Views.Stores +@model BTCPayServer.Models.WalletViewModels.NewPullPaymentModel @{ Layout = "../Shared/_NavLayout.cshtml"; - ViewData.SetActivePageAndTitle(WalletsNavPages.PullPayments, "New pull payment", Context.GetStoreData().StoreName); + ViewData["NavPartialName"] = "../Stores/_Nav"; + ViewData.SetActivePageAndTitle(StoreNavPages.PullPayments, "New pull payment", Context.GetStoreData().StoreName); }