mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
Payouts: Unify confirm external payment and manually mark as paid actions (#2751)
This commit is contained in:
parent
f84b2c5160
commit
060f30d0bf
@ -1081,7 +1081,7 @@ namespace BTCPayServer.Tests
|
||||
Assert.Contains(PayoutState.AwaitingPayment.GetStateString(), s.Driver.PageSource);
|
||||
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}-confirm-payment")).Click();
|
||||
s.Driver.FindElement(By.Id($"{PayoutState.AwaitingPayment}-mark-paid")).Click();
|
||||
s.FindAlertMessage();
|
||||
|
||||
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 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)
|
||||
{
|
||||
|
||||
case "approve-pay":
|
||||
case "approve":
|
||||
{
|
||||
@ -264,8 +272,7 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
Message = "Payouts approved", Severity = StatusMessageModel.StatusSeverity.Success
|
||||
});
|
||||
return RedirectToAction(nameof(Payouts),
|
||||
new {walletId = walletId.ToString(), pullPaymentId = vm.PullPaymentId});
|
||||
break;
|
||||
}
|
||||
|
||||
case "pay":
|
||||
@ -337,8 +344,7 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
Message = "Payouts marked as paid", Severity = StatusMessageModel.StatusSeverity.Success
|
||||
});
|
||||
return RedirectToAction(nameof(Payouts),
|
||||
new {walletId = walletId.ToString(), pullPaymentId = vm.PullPaymentId});
|
||||
break;
|
||||
}
|
||||
|
||||
case "cancel":
|
||||
@ -348,27 +354,12 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
Message = "Payouts archived", Severity = StatusMessageModel.StatusSeverity.Success
|
||||
});
|
||||
break;
|
||||
}
|
||||
return RedirectToAction(nameof(Payouts),
|
||||
new {walletId = walletId.ToString(), pullPaymentId = vm.PullPaymentId});
|
||||
}
|
||||
|
||||
var handler = _payoutHandlers
|
||||
.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,
|
||||
ApplicationDbContext ctx, string[] payoutIds,
|
||||
string storeId, CancellationToken cancellationToken)
|
||||
|
@ -143,7 +143,6 @@ public class BitcoinLikePayoutHandler : IPayoutHandler
|
||||
{
|
||||
{PayoutState.AwaitingPayment, new List<(string Action, string Text)>()
|
||||
{
|
||||
("confirm-payment", "Confirm payouts as paid"),
|
||||
("reject-payment", "Reject payout transaction")
|
||||
}}
|
||||
};
|
||||
@ -153,7 +152,7 @@ public class BitcoinLikePayoutHandler : IPayoutHandler
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case "confirm-payment":
|
||||
case "mark-paid":
|
||||
await using (var context = _dbContextFactory.CreateContext())
|
||||
{
|
||||
var payouts = (await context.Payouts
|
||||
|
Loading…
Reference in New Issue
Block a user