diff --git a/BTCPayServer/Controllers/UIPullPaymentController.cs b/BTCPayServer/Controllers/UIPullPaymentController.cs index 40c6fde52..abecc873d 100644 --- a/BTCPayServer/Controllers/UIPullPaymentController.cs +++ b/BTCPayServer/Controllers/UIPullPaymentController.cs @@ -21,21 +21,18 @@ namespace BTCPayServer.Controllers public class UIPullPaymentController : Controller { private readonly ApplicationDbContextFactory _dbContextFactory; - private readonly BTCPayNetworkProvider _networkProvider; private readonly CurrencyNameTable _currencyNameTable; private readonly PullPaymentHostedService _pullPaymentHostedService; private readonly BTCPayNetworkJsonSerializerSettings _serializerSettings; private readonly IEnumerable _payoutHandlers; public UIPullPaymentController(ApplicationDbContextFactory dbContextFactory, - BTCPayNetworkProvider networkProvider, CurrencyNameTable currencyNameTable, PullPaymentHostedService pullPaymentHostedService, BTCPayNetworkJsonSerializerSettings serializerSettings, IEnumerable payoutHandlers) { _dbContextFactory = dbContextFactory; - _networkProvider = networkProvider; _currencyNameTable = currencyNameTable; _pullPaymentHostedService = pullPaymentHostedService; _serializerSettings = serializerSettings; @@ -64,7 +61,7 @@ namespace BTCPayServer.Controllers var totalPaid = payouts.Where(p => p.Entity.State != PayoutState.Cancelled).Select(p => p.Blob.Amount).Sum(); var amountDue = blob.Limit - totalPaid; - ViewPullPaymentModel vm = new ViewPullPaymentModel(pp, DateTimeOffset.UtcNow) + ViewPullPaymentModel vm = new (pp, DateTimeOffset.UtcNow) { AmountFormatted = _currencyNameTable.FormatCurrency(blob.Limit, blob.Currency), AmountCollected = totalPaid, @@ -85,8 +82,8 @@ namespace BTCPayServer.Controllers Status = entity.Entity.State, Destination = entity.Blob.Destination, PaymentMethod = PaymentMethodId.Parse(entity.Entity.PaymentMethodId), - Link = entity.ProofBlob?.Link, - TransactionId = entity.ProofBlob?.Id + Link = entity.ProofBlob.Link, + TransactionId = entity.ProofBlob.Id }).ToList() }; vm.IsPending &= vm.AmountDue > 0.0m; @@ -111,10 +108,10 @@ namespace BTCPayServer.Controllers var payoutHandler = paymentMethodId is null ? null : _payoutHandlers.FindPayoutHandler(paymentMethodId); if (payoutHandler is null) { - ModelState.AddModelError(nameof(vm.SelectedPaymentMethod), $"Invalid destination with selected payment method"); + ModelState.AddModelError(nameof(vm.SelectedPaymentMethod), "Invalid destination with selected payment method"); return await ViewPullPayment(pullPaymentId); } - var destination = await payoutHandler?.ParseAndValidateClaimDestination(paymentMethodId, vm.Destination, ppBlob); + var destination = await payoutHandler.ParseAndValidateClaimDestination(paymentMethodId, vm.Destination, ppBlob); if (destination.destination is null) { ModelState.AddModelError(nameof(vm.Destination), destination.error ?? "Invalid destination with selected payment method"); @@ -123,8 +120,7 @@ namespace BTCPayServer.Controllers if (vm.ClaimedAmount == 0) { - ModelState.AddModelError(nameof(vm.ClaimedAmount), - $"Amount is required"); + ModelState.AddModelError(nameof(vm.ClaimedAmount), "Amount is required"); } else if (vm.ClaimedAmount != 0 && destination.destination.Amount != null && vm.ClaimedAmount != destination.destination.Amount) { @@ -157,15 +153,14 @@ namespace BTCPayServer.Controllers } return await ViewPullPayment(pullPaymentId); } - else + + TempData.SetStatusMessageModel(new StatusMessageModel { - TempData.SetStatusMessageModel(new StatusMessageModel() - { - Message = $"Your claim request of {_currencyNameTable.DisplayFormatCurrency(vm.ClaimedAmount, ppBlob.Currency)} to {vm.Destination} has been submitted and is awaiting {(result.PayoutData.State == PayoutState.AwaitingApproval? "approval": "payment")}.", - Severity = StatusMessageModel.StatusSeverity.Success - }); - } - return RedirectToAction(nameof(ViewPullPayment), new { pullPaymentId = pullPaymentId }); + Message = $"Your claim request of {_currencyNameTable.DisplayFormatCurrency(vm.ClaimedAmount, ppBlob.Currency)} to {vm.Destination} has been submitted and is awaiting {(result.PayoutData.State == PayoutState.AwaitingApproval? "approval": "payment")}.", + Severity = StatusMessageModel.StatusSeverity.Success + }); + + return RedirectToAction(nameof(ViewPullPayment), new { pullPaymentId }); } } } diff --git a/BTCPayServer/Views/UIStorePullPayments/Payouts.cshtml b/BTCPayServer/Views/UIStorePullPayments/Payouts.cshtml index 65c4f2f90..e285440e4 100644 --- a/BTCPayServer/Views/UIStorePullPayments/Payouts.cshtml +++ b/BTCPayServer/Views/UIStorePullPayments/Payouts.cshtml @@ -62,8 +62,9 @@ PaymentMethods = new[] {Model.PaymentMethodId} })).Any()) { -