mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-27 07:57:33 +01:00
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using BTCPayServer.Payments;
|
||
|
using BTCPayServer.Services.Invoices;
|
||
|
|
||
|
namespace BTCPayServer.Services.Altcoins.Zcash.Payments
|
||
|
{
|
||
|
public class ZcashPaymentModelExtension : IPaymentModelExtension
|
||
|
{
|
||
|
private readonly BTCPayNetworkBase _network;
|
||
|
private readonly IPaymentLinkExtension paymentLinkExtension;
|
||
|
|
||
|
public ZcashPaymentModelExtension(
|
||
|
PaymentMethodId paymentMethodId,
|
||
|
IEnumerable<IPaymentLinkExtension> paymentLinkExtensions,
|
||
|
BTCPayNetworkBase network)
|
||
|
{
|
||
|
PaymentMethodId = paymentMethodId;
|
||
|
_network = network;
|
||
|
paymentLinkExtension = paymentLinkExtensions.Single(p => p.PaymentMethodId == PaymentMethodId);
|
||
|
}
|
||
|
public PaymentMethodId PaymentMethodId { get; }
|
||
|
|
||
|
public string DisplayName => _network.DisplayName;
|
||
|
|
||
|
public string Image => _network.CryptoImagePath;
|
||
|
public string Badge => "";
|
||
|
|
||
|
public void ModifyPaymentModel(PaymentModelContext context)
|
||
|
{
|
||
|
if (context.Model.Activated)
|
||
|
{
|
||
|
context.Model.InvoiceBitcoinUrl = paymentLinkExtension.GetPaymentLink(context.Prompt, context.UrlHelper);
|
||
|
context.Model.InvoiceBitcoinUrlQR = context.Model.InvoiceBitcoinUrl;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
context.Model.InvoiceBitcoinUrl = "";
|
||
|
context.Model.InvoiceBitcoinUrlQR = "";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|