mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 22:46:49 +01:00
40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using BTCPayServer.Models;
|
|
using BTCPayServer.Payments.Bitcoin;
|
|
using BTCPayServer.Payments.Lightning;
|
|
using BTCPayServer.Services.Invoices;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using NBitpayClient;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BTCPayServer.Payments.LNURLPay;
|
|
|
|
public class LNURLPayPaymentMethodBitpayAPIExtension : IPaymentMethodBitpayAPIExtension
|
|
{
|
|
public LNURLPayPaymentMethodBitpayAPIExtension(
|
|
PaymentMethodId paymentMethodId,
|
|
IEnumerable<IPaymentLinkExtension> paymentLinkExtensions)
|
|
{
|
|
PaymentMethodId = paymentMethodId;
|
|
paymentLinkExtension = paymentLinkExtensions.Single(p => p.PaymentMethodId == PaymentMethodId);
|
|
}
|
|
public PaymentMethodId PaymentMethodId { get; }
|
|
|
|
private IPaymentLinkExtension paymentLinkExtension;
|
|
|
|
public void PopulateCryptoInfo(BTCPayServer.Services.Invoices.InvoiceCryptoInfo cryptoInfo, InvoiceResponse dto, PaymentPrompt prompt, IUrlHelper urlHelper)
|
|
{
|
|
var link = paymentLinkExtension.GetPaymentLink(prompt, urlHelper);
|
|
if (link is not null)
|
|
{
|
|
cryptoInfo.PaymentUrls = new BTCPayServer.Services.Invoices.InvoiceCryptoInfo.InvoicePaymentUrls()
|
|
{
|
|
AdditionalData = new Dictionary<string, JToken>()
|
|
{
|
|
{"LNURLP", JToken.FromObject(link)}
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|