btcpayserver/BTCPayServer/Views/Shared/Zcash/ViewZcashLikePaymentData.cshtml

68 lines
2.8 KiB
Text

@using System.Globalization
@using BTCPayServer.Plugins.Altcoins;
@using BTCPayServer.Components.TruncateCenter
@using BTCPayServer.Services
@using BTCPayServer.Services.Altcoins.Zcash.Payments
@using BTCPayServer.Services.Altcoins.Zcash.Services
@using BTCPayServer.Services.Altcoins.Zcash.UI
@using BTCPayServer.Services.Invoices
@inject DisplayFormatter DisplayFormatter
@model IEnumerable<BTCPayServer.Services.Invoices.PaymentEntity>
@inject TransactionLinkProviders TransactionLinkProviders
@inject PaymentMethodHandlerDictionary handlers
@{
var payments = Model.Select(payment =>
{
if (!handlers.TryGetValue(payment.PaymentMethodId, out var h) || h is not ZcashLikePaymentMethodHandler handler)
return null;
var m = new ZcashPaymentViewModel();
var onChainPaymentData = handler.ParsePaymentDetails(payment.Details);
m.PaymentMethodId = handler.PaymentMethodId;
m.DepositAddress = payment.Destination;
m.Amount = payment.Value.ToString(CultureInfo.InvariantCulture);
var confReq = ZcashListener.ConfirmationsRequired(payment.InvoiceEntity.SpeedPolicy);
var confCount = onChainPaymentData.ConfirmationCount;
confCount = Math.Min(confReq, confCount);
m.Confirmations = $"{confCount} / {confReq}";
m.TransactionId = onChainPaymentData.TransactionId;
m.ReceivedTime = payment.ReceivedTime;
m.TransactionLink = TransactionLinkProviders.GetTransactionLink(m.PaymentMethodId, onChainPaymentData.TransactionId);
m.Currency = payment.Currency;
return m;
}).Where(c => c != null).ToList();
}
@if (payments.Any())
{
<section>
<h5>Zcash Payments</h5>
<table class="table table-hover">
<thead>
<tr>
<th class="w-75px">Payment Method</th>
<th class="w-175px">Destination</th>
<th class="text-nowrap">Payment Proof</th>
<th class="text-end">Confirmations</th>
<th class="w-150px text-end">Paid</th>
</tr>
</thead>
<tbody>
@foreach (var payment in payments)
{
<tr >
<td>@payment.PaymentMethodId</td>
<td><vc:truncate-center text="@payment.DepositAddress" classes="truncate-center-id" /></td>
<td><vc:truncate-center text="@payment.TransactionId" link="@payment.TransactionLink" classes="truncate-center-id" /></td>
<td class="text-end">@payment.Confirmations</td>
<td class="payment-value text-end text-nowrap">
<span data-sensitive class="text-success">@DisplayFormatter.Currency(payment.Amount, payment.Currency)</span>
</td>
</tr>
}
</tbody>
</table>
</section>
}