mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
enhance opensats integration
This commit is contained in:
@@ -23,13 +23,13 @@ public class OpenSatsDestinationValidator : IPluginHookFilter
|
|||||||
public async Task<object> Execute(object args)
|
public async Task<object> Execute(object args)
|
||||||
{
|
{
|
||||||
var result = new PrismDestinationValidationResult();
|
var result = new PrismDestinationValidationResult();
|
||||||
if (args is not string args1 || !args1.StartsWith("opensats")) return args;
|
if (args is not string args1 || !args1.StartsWith("opensats", StringComparison.InvariantCultureIgnoreCase)) return args;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var parts = args1.Split(":", StringSplitOptions.RemoveEmptyEntries);
|
var parts = args1.ToLowerInvariant().Split(":", StringSplitOptions.RemoveEmptyEntries);
|
||||||
var project = "opensats";
|
var project = "general_fund";
|
||||||
var paymentMethod = new PaymentMethodId("BTC", PaymentTypes.LightningLike);
|
var paymentMethod = new PaymentMethodId("BTC", PaymentTypes.LightningLike);
|
||||||
if (parts.Length > 1)
|
if (parts.Length > 1)
|
||||||
{
|
{
|
||||||
@@ -69,7 +69,7 @@ public class OpenSatsDestinationValidator : IPluginHookFilter
|
|||||||
|
|
||||||
result.Success = false;
|
result.Success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
result.Success = true;
|
result.Success = true;
|
||||||
result.PaymentMethod = paymentMethod;
|
result.PaymentMethod = paymentMethod;
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ public class OpenSatsPrismClaimCreate : IPluginHookFilter
|
|||||||
var invoiceUrl = $"{rawInvoice.Value<string>("checkoutLink").TrimEnd('/')}/{paymentMethod}/status";
|
var invoiceUrl = $"{rawInvoice.Value<string>("checkoutLink").TrimEnd('/')}/{paymentMethod}/status";
|
||||||
var invoiceBtcpayModel = JObject.Parse(await httpClient.GetStringAsync(invoiceUrl).ConfigureAwait(false));
|
var invoiceBtcpayModel = JObject.Parse(await httpClient.GetStringAsync(invoiceUrl).ConfigureAwait(false));
|
||||||
var destination = invoiceBtcpayModel.Value<string>("btcAddress");
|
var destination = invoiceBtcpayModel.Value<string>("btcAddress");
|
||||||
|
var receiptLink = invoiceBtcpayModel.Value<string>("receiptLink");
|
||||||
|
|
||||||
var claimDestination = await handler.ParseClaimDestination(paymentMethod,destination, CancellationToken.None);
|
var claimDestination = await handler.ParseClaimDestination(paymentMethod,destination, CancellationToken.None);
|
||||||
if (claimDestination.destination is null)
|
if (claimDestination.destination is null)
|
||||||
@@ -81,7 +82,11 @@ public class OpenSatsPrismClaimCreate : IPluginHookFilter
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
claimRequest.Metadata = JObject.FromObject(new
|
||||||
|
{
|
||||||
|
Source = $"Prism->OpenSats ({project}",
|
||||||
|
SourceLink = receiptLink
|
||||||
|
});
|
||||||
|
|
||||||
claimRequest.Destination = claimDestination.destination;
|
claimRequest.Destination = claimDestination.destination;
|
||||||
claimRequest.PaymentMethodId = paymentMethod;
|
claimRequest.PaymentMethodId = paymentMethod;
|
||||||
|
|||||||
Reference in New Issue
Block a user