mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-06 18:41:12 +01:00
* Automated Transfer processors This PR introduces a few things: * Payouts can now be directly nested under a store instead of through a pull payment. * The Wallet Send screen now has an option to "schedule" instead of simply creating a transaction. When you click on schedule, all transaction destinations are converted into approved payouts. Any options relating to fees or coin selection are discarded. * There is a new concept introduced, called "Transfer Processors". Transfer Processors are services for stores that process payouts that are awaiting payment. Each processor specifies which payment methods it can handle. BTCPay Server will have some forms of transfer processors baked in but it has been designed to allow the Plugin System to provide additional processors. * The initial transfer processors provided are "automated processors", for on chain and lightning payment methods. They can be configured to process payouts every X amount of minutes. For on-chain, this means payments are batched into one transaction, resulting in more efficient and cheaper fees for processing. * * fix build * extract * remove magic string stuff * fix error message when scheduling * Paginate migration * add payout count to payment method tab * remove unused var * add protip * optimzie payout migration dramatically * Remove useless double condition * Fix bunch of warnings * Remove warning * Remove warnigns * Rename to Payout processors * fix typo Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com>
191 lines
8.6 KiB
Text
191 lines
8.6 KiB
Text
@using BTCPayServer.Client.Models
|
|
@using BTCPayServer.Payments
|
|
@using BTCPayServer.Views.Stores
|
|
@using BTCPayServer.Abstractions.Extensions
|
|
@using BTCPayServer.Client
|
|
@using BTCPayServer.PayoutProcessors
|
|
@model BTCPayServer.Models.WalletViewModels.PayoutsModel
|
|
|
|
@inject IEnumerable<IPayoutHandler> PayoutHandlers;
|
|
@inject PayoutProcessorService _payoutProcessorService;
|
|
@inject IEnumerable<IPayoutProcessorFactory> _payoutProcessorFactories;
|
|
@{
|
|
var storeId = Context.GetRouteValue("storeId") as string;
|
|
ViewData.SetActivePage(StoreNavPages.Payouts, $"Payouts{(string.IsNullOrEmpty(Model.PullPaymentName) ? string.Empty : " for pull payment " + Model.PullPaymentName)}", Context.GetStoreData().Id);
|
|
Model.PaginationQuery ??= new Dictionary<string, object>();
|
|
Model.PaginationQuery.Add("pullPaymentId", Model.PullPaymentId);
|
|
Model.PaginationQuery.Add("paymentMethodId", Model.PaymentMethodId);
|
|
Model.PaginationQuery.Add("payoutState", Model.PayoutState);
|
|
var stateActions = new List<(string Action, string Text)>();
|
|
if (PaymentMethodId.TryParse(Model.PaymentMethodId, out var paymentMethodId))
|
|
{
|
|
var payoutHandler = PayoutHandlers.FindPayoutHandler(paymentMethodId);
|
|
if (payoutHandler is null)
|
|
return;
|
|
stateActions.AddRange(payoutHandler.GetPayoutSpecificActions().Where(pair => pair.Key == Model.PayoutState).SelectMany(pair => pair.Value));
|
|
}
|
|
switch (Model.PayoutState)
|
|
{
|
|
case PayoutState.AwaitingApproval:
|
|
stateActions.Add(("approve", "Approve selected payouts"));
|
|
stateActions.Add(("approve-pay", "Approve & Send selected payouts"));
|
|
stateActions.Add(("cancel", "Cancel selected payouts"));
|
|
break;
|
|
case PayoutState.AwaitingPayment:
|
|
stateActions.Add(("pay", "Send selected payouts"));
|
|
stateActions.Add(("cancel", "Cancel selected payouts"));
|
|
stateActions.Add(("mark-paid", "Mark selected payouts as already paid"));
|
|
break;
|
|
}
|
|
}
|
|
|
|
@section PageFootContent {
|
|
<script>
|
|
delegate('click', '.selectAll', e => {
|
|
const { payoutState } = e.target.dataset;
|
|
document.querySelectorAll(`.selection-item-${payoutState}`).forEach(checkbox => {
|
|
checkbox.checked = e.target.checked;
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
|
|
<partial name="_StatusMessage"/>
|
|
|
|
@{
|
|
|
|
}
|
|
|
|
@if (_payoutProcessorFactories.Any(factory => factory.GetSupportedPaymentMethods().Contains(paymentMethodId)) && !(await _payoutProcessorService.GetProcessors(new PayoutProcessorService.PayoutProcessorQuery()
|
|
{
|
|
Stores = new[] {storeId},
|
|
PaymentMethods = new[] {Model.PaymentMethodId}
|
|
})).Any())
|
|
{
|
|
<div class="alert alert-info text-break" role="alert">
|
|
protip: BTCPay Server has detected that there are supported but unconfigured Payout Processors for this payout payment method. Payout processors can potentially help automate the the workflow of these payouts so that you do not need to manually handle them.
|
|
<a class="alert-link p-0" asp-action="ConfigureStorePayoutProcessors" asp-controller="UIPayoutProcessors" asp-route-storeId="@storeId">Configure now</a>
|
|
</div>
|
|
}
|
|
<h2 class="mt-1 mb-4">@ViewData["Title"]</h2>
|
|
|
|
<form method="post">
|
|
<input type="hidden" asp-for="PaymentMethodId"/>
|
|
<input type="hidden" asp-for="PayoutState"/>
|
|
<div class="d-flex justify-content-between mb-4">
|
|
<ul class="nav mb-1">
|
|
@foreach (var state in Model.PaymentMethods)
|
|
{
|
|
<li class="nav-item py-0">
|
|
<a asp-action="Payouts" asp-route-storeId="@Context.GetRouteValue("storeId")"
|
|
asp-route-payoutState="@Model.PayoutState"
|
|
asp-route-paymentMethodId="@state.ToString()"
|
|
asp-route-pullPaymentId="@Model.PullPaymentId"
|
|
class="btcpay-pill @(state.ToString() == Model.PaymentMethodId ? "active" : "")"
|
|
id="@state.ToString()-view"
|
|
role="tab">
|
|
@state.ToPrettyString()
|
|
@if (Model.PaymentMethodCount.TryGetValue(state.ToString(), out var count) && count > 0)
|
|
{
|
|
<span>(@count)</span>
|
|
}
|
|
</a>
|
|
</li>
|
|
}
|
|
</ul>
|
|
@if (Model.Payouts.Any() && stateActions.Any())
|
|
{
|
|
<div class="dropdown ms-xl-auto mt-xl-0" permission="@Policies.CanModifyStoreSettings">
|
|
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" id="@Model.PayoutState-actions">Actions</button>
|
|
<div class="dropdown-menu" aria-labelledby="@Model.PayoutState-actions">
|
|
@foreach (var action in stateActions)
|
|
{
|
|
<button type="submit" id="@Model.PayoutState-@action.Action" name="Command" class="dropdown-item" role="button" value="@Model.PayoutState-@action.Action">@action.Text</button>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
<nav id="SectionNav" class="mb-3">
|
|
<div class="nav">
|
|
@foreach (var state in Model.PayoutStateCount)
|
|
{
|
|
<a id="@state.Key-view"
|
|
asp-action="Payouts"
|
|
asp-route-storeId="@Context.GetRouteValue("storeId")"
|
|
asp-route-payoutState="@state.Key"
|
|
asp-route-pullPaymentId="@Model.PullPaymentId"
|
|
asp-route-paymentMethodId="@Model.PaymentMethodId"
|
|
class="nav-link @(state.Key == Model.PayoutState ? "active" : "")" role="tab">
|
|
@state.Key.GetStateString() (@state.Value)
|
|
</a>
|
|
}
|
|
</div>
|
|
</nav>
|
|
|
|
@if (Model.Payouts.Any())
|
|
{
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead class="thead-inverse">
|
|
<tr>
|
|
<th permission="@Policies.CanModifyStoreSettings">
|
|
<input id="@Model.PayoutState-selectAllCheckbox" type="checkbox" class="form-check-input selectAll" data-payout-state="@Model.PayoutState.ToString()"/>
|
|
</th>
|
|
<th style="min-width: 90px;" class="col-md-auto">
|
|
Date
|
|
</th>
|
|
<th class="text-start">Source</th>
|
|
<th class="text-start">Destination</th>
|
|
<th class="text-end">Amount</th>
|
|
@if (Model.PayoutState != PayoutState.AwaitingApproval)
|
|
{
|
|
<th class="text-end">Transaction</th>
|
|
}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@for (int i = 0; i < Model.Payouts.Count; i++)
|
|
{
|
|
var pp = Model.Payouts[i];
|
|
<tr class="payout">
|
|
<td permission="@Policies.CanModifyStoreSettings">
|
|
<span>
|
|
<input type="checkbox" class="selection-item-@Model.PayoutState.ToString() form-check-input" asp-for="Payouts[i].Selected"/>
|
|
<input type="hidden" asp-for="Payouts[i].PayoutId"/>
|
|
</span>
|
|
</td>
|
|
<td>
|
|
<span>@pp.Date.ToBrowserDate()</span>
|
|
</td>
|
|
<td class="mw-100">
|
|
<span>@pp.PullPaymentName</span>
|
|
</td>
|
|
<td title="@pp.Destination">
|
|
<span class="text-break">@pp.Destination</span>
|
|
</td>
|
|
<td class="text-end text-nowrap">
|
|
<span>@pp.Amount</span>
|
|
</td>
|
|
@if (Model.PayoutState != PayoutState.AwaitingApproval)
|
|
{
|
|
<td class="text-end">
|
|
@if (!(pp.ProofLink is null))
|
|
{
|
|
<a class="transaction-link" href="@pp.ProofLink" rel="noreferrer noopener">Link</a>
|
|
}
|
|
</td>
|
|
}
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<vc:pager view-model="Model"/>
|
|
}
|
|
else
|
|
{
|
|
<p class="text-muted mb-0" id="@Model.PayoutState-no-payouts">There are no payouts matching this criteria.</p>
|
|
}
|
|
</form>
|