mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-19 06:54:19 +01:00
Payouts: Unify confirm external payment and manually mark as paid actions (#2751)
This commit is contained in:
@@ -1081,7 +1081,7 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Contains(PayoutState.AwaitingPayment.GetStateString(), s.Driver.PageSource);
|
Assert.Contains(PayoutState.AwaitingPayment.GetStateString(), s.Driver.PageSource);
|
||||||
s.Driver.FindElement(By.Id($"{PayoutState.AwaitingPayment}-selectAllCheckbox")).Click();
|
s.Driver.FindElement(By.Id($"{PayoutState.AwaitingPayment}-selectAllCheckbox")).Click();
|
||||||
s.Driver.FindElement(By.Id($"{PayoutState.AwaitingPayment}-actions")).Click();
|
s.Driver.FindElement(By.Id($"{PayoutState.AwaitingPayment}-actions")).Click();
|
||||||
s.Driver.FindElement(By.Id($"{PayoutState.AwaitingPayment}-confirm-payment")).Click();
|
s.Driver.FindElement(By.Id($"{PayoutState.AwaitingPayment}-mark-paid")).Click();
|
||||||
s.FindAlertMessage();
|
s.FindAlertMessage();
|
||||||
|
|
||||||
s.Driver.FindElement(By.Id("InProgress-view")).Click();
|
s.Driver.FindElement(By.Id("InProgress-view")).Click();
|
||||||
|
|||||||
@@ -204,10 +204,18 @@ namespace BTCPayServer.Controllers
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
var command = vm.Command.Substring(vm.Command.IndexOf('-', StringComparison.InvariantCulture) + 1);
|
var command = vm.Command.Substring(vm.Command.IndexOf('-', StringComparison.InvariantCulture) + 1);
|
||||||
|
var handler = _payoutHandlers
|
||||||
|
.FirstOrDefault(handler => handler.CanHandle(paymentMethodId));
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
var result = await handler.DoSpecificAction(command, payoutIds, walletId.StoreId);
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
TempData.SetStatusMessageModel(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
switch (command)
|
switch (command)
|
||||||
{
|
{
|
||||||
|
|
||||||
case "approve-pay":
|
case "approve-pay":
|
||||||
case "approve":
|
case "approve":
|
||||||
{
|
{
|
||||||
@@ -264,8 +272,7 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
Message = "Payouts approved", Severity = StatusMessageModel.StatusSeverity.Success
|
Message = "Payouts approved", Severity = StatusMessageModel.StatusSeverity.Success
|
||||||
});
|
});
|
||||||
return RedirectToAction(nameof(Payouts),
|
break;
|
||||||
new {walletId = walletId.ToString(), pullPaymentId = vm.PullPaymentId});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "pay":
|
case "pay":
|
||||||
@@ -337,8 +344,7 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
Message = "Payouts marked as paid", Severity = StatusMessageModel.StatusSeverity.Success
|
Message = "Payouts marked as paid", Severity = StatusMessageModel.StatusSeverity.Success
|
||||||
});
|
});
|
||||||
return RedirectToAction(nameof(Payouts),
|
break;
|
||||||
new {walletId = walletId.ToString(), pullPaymentId = vm.PullPaymentId});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "cancel":
|
case "cancel":
|
||||||
@@ -348,25 +354,10 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
Message = "Payouts archived", Severity = StatusMessageModel.StatusSeverity.Success
|
Message = "Payouts archived", Severity = StatusMessageModel.StatusSeverity.Success
|
||||||
});
|
});
|
||||||
return RedirectToAction(nameof(Payouts),
|
break;
|
||||||
new {walletId = walletId.ToString(), pullPaymentId = vm.PullPaymentId});
|
|
||||||
}
|
}
|
||||||
|
return RedirectToAction(nameof(Payouts),
|
||||||
var handler = _payoutHandlers
|
new {walletId = walletId.ToString(), pullPaymentId = vm.PullPaymentId});
|
||||||
.FirstOrDefault(handler => handler.CanHandle(paymentMethodId));
|
|
||||||
|
|
||||||
if (handler != null)
|
|
||||||
{
|
|
||||||
var result = await handler.DoSpecificAction(command, payoutIds, walletId.StoreId);
|
|
||||||
TempData.SetStatusMessageModel(result);
|
|
||||||
return RedirectToAction(nameof(Payouts), new
|
|
||||||
{
|
|
||||||
walletId = walletId.ToString(),
|
|
||||||
pullPaymentId = vm.PullPaymentId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return NotFound();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<List<PayoutData>> GetPayoutsForPaymentMethod(PaymentMethodId paymentMethodId,
|
private static async Task<List<PayoutData>> GetPayoutsForPaymentMethod(PaymentMethodId paymentMethodId,
|
||||||
|
|||||||
@@ -143,7 +143,6 @@ public class BitcoinLikePayoutHandler : IPayoutHandler
|
|||||||
{
|
{
|
||||||
{PayoutState.AwaitingPayment, new List<(string Action, string Text)>()
|
{PayoutState.AwaitingPayment, new List<(string Action, string Text)>()
|
||||||
{
|
{
|
||||||
("confirm-payment", "Confirm payouts as paid"),
|
|
||||||
("reject-payment", "Reject payout transaction")
|
("reject-payment", "Reject payout transaction")
|
||||||
}}
|
}}
|
||||||
};
|
};
|
||||||
@@ -153,7 +152,7 @@ public class BitcoinLikePayoutHandler : IPayoutHandler
|
|||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case "confirm-payment":
|
case "mark-paid":
|
||||||
await using (var context = _dbContextFactory.CreateContext())
|
await using (var context = _dbContextFactory.CreateContext())
|
||||||
{
|
{
|
||||||
var payouts = (await context.Payouts
|
var payouts = (await context.Payouts
|
||||||
|
|||||||
Reference in New Issue
Block a user