2021-10-18 15:00:38 +09:00
@using BTCPayServer.Client.Models
2021-10-18 05:37:59 +02:00
@using BTCPayServer.Payments
2021-10-22 04:17:40 +02:00
@using BTCPayServer.Views.Stores
@using BTCPayServer.Abstractions.Extensions
2021-12-07 16:40:24 +01:00
@using BTCPayServer.Client
2022-04-24 05:19:34 +02:00
@using BTCPayServer.PayoutProcessors
2021-10-22 04:17:40 +02:00
@model BTCPayServer.Models.WalletViewModels.PayoutsModel
2021-04-13 10:36:49 +02:00
@inject IEnumerable<IPayoutHandler> PayoutHandlers;
2022-04-24 05:19:34 +02:00
@inject PayoutProcessorService _payoutProcessorService;
@inject IEnumerable<IPayoutProcessorFactory> _payoutProcessorFactories;
2020-06-24 10:34:09 +09:00
@{
2022-04-24 05:19:34 +02:00
var storeId = Context.GetRouteValue("storeId") as string;
2021-12-31 08:36:38 +01:00
ViewData.SetActivePage(StoreNavPages.Payouts, $"Payouts{(string.IsNullOrEmpty(Model.PullPaymentName) ? string.Empty : " for pull payment " + Model.PullPaymentName)}", Context.GetStoreData().Id);
2021-11-08 08:21:07 +01:00
Model.PaginationQuery ??= new Dictionary<string, object>();
Model.PaginationQuery.Add("pullPaymentId", Model.PullPaymentId);
Model.PaginationQuery.Add("paymentMethodId", Model.PaymentMethodId);
Model.PaginationQuery.Add("payoutState", Model.PayoutState);
2021-06-30 08:59:01 +01:00
var stateActions = new List<(string Action, string Text)>();
2021-10-22 04:17:40 +02:00
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));
}
2021-06-30 08:59:01 +01:00
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;
}
2020-06-24 10:34:09 +09:00
}
2021-05-19 04:39:27 +02:00
@section PageFootContent {
<script>
2021-10-05 08:52:14 +02:00
delegate('click', '.selectAll', e => {
const { payoutState } = e.target.dataset;
document.querySelectorAll(`.selection-item-${payoutState}`).forEach(checkbox => {
checkbox.checked = e.target.checked;
});
});
2021-05-19 04:39:27 +02:00
</script>
}
2021-04-13 10:36:49 +02:00
2022-04-24 05:19:34 +02:00
<partial name="_StatusMessage"/>
@{
}
2021-12-16 14:43:29 +01:00
2022-04-24 05:19:34 +02:00
@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>
}
2021-12-16 11:04:04 +01:00
<h2 class="mt-1 mb-4">@ViewData["Title"]</h2>
2020-06-24 10:34:09 +09:00
<form method="post">
2022-04-24 05:19:34 +02:00
<input type="hidden" asp-for="PaymentMethodId"/>
<input type="hidden" asp-for="PayoutState"/>
2022-01-11 00:15:23 -08:00
<div class="d-flex justify-content-between mb-4">
2022-01-24 18:07:52 -08:00
<ul class="nav mb-1">
2022-01-11 00:15:23 -08:00
@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"
2022-01-24 18:07:52 -08:00
class="btcpay-pill @(state.ToString() == Model.PaymentMethodId ? "active" : "")"
2022-01-11 00:15:23 -08:00
id="@state.ToString()-view"
2022-04-24 05:19:34 +02:00
role="tab">
@state.ToPrettyString()
@if (Model.PaymentMethodCount.TryGetValue(state.ToString(), out var count) && count > 0)
{
<span>(@count)</span>
}
</a>
2022-01-11 00:15:23 -08:00
</li>
}
</ul>
2021-12-16 15:17:51 +01:00
@if (Model.Payouts.Any() && stateActions.Any())
2021-06-30 08:59:01 +01:00
{
2022-01-11 00:15:23 -08:00
<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>
2021-06-30 08:59:01 +01:00
</div>
}
</div>
2022-01-21 02:35:12 +01:00
<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"
2022-04-24 05:19:34 +02:00
class="nav-link @(state.Key == Model.PayoutState ? "active" : "")" role="tab">
@state.Key.GetStateString() (@state.Value)
</a>
2022-01-21 02:35:12 +01:00
}
</div>
2022-01-11 00:15:23 -08:00
</nav>
2022-04-24 05:19:34 +02:00
2022-01-11 00:15:23 -08:00
@if (Model.Payouts.Any())
{
<div class="table-responsive">
<table class="table table-hover">
<thead class="thead-inverse">
2022-04-24 05:19:34 +02:00
<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>
2021-06-30 08:59:01 +01:00
@if (Model.PayoutState != PayoutState.AwaitingApproval)
2021-05-19 04:39:27 +02:00
{
2022-04-24 05:19:34 +02:00
<td class="text-end">
@if (!(pp.ProofLink is null))
{
<a class="transaction-link" href="@pp.ProofLink" rel="noreferrer noopener">Link</a>
}
</td>
2021-06-30 08:59:01 +01:00
}
</tr>
2022-04-24 05:19:34 +02:00
}
2022-01-11 00:15:23 -08:00
</tbody>
</table>
</div>
2022-04-24 05:19:34 +02:00
<vc:pager view-model="Model"/>
2022-01-11 00:15:23 -08:00
}
else
{
<p class="text-muted mb-0" id="@Model.PayoutState-no-payouts">There are no payouts matching this criteria.</p>
}
2020-06-24 10:34:09 +09:00
</form>