2022-04-24 05:19:34 +02:00
|
|
|
#nullable enable
|
2021-04-13 10:36:49 +02:00
|
|
|
using System;
|
2021-07-16 09:57:37 +02:00
|
|
|
using System.Collections.Generic;
|
2022-11-22 20:17:29 +09:00
|
|
|
using System.Threading;
|
2021-04-13 10:36:49 +02:00
|
|
|
using System.Threading.Tasks;
|
2021-07-16 09:57:37 +02:00
|
|
|
using BTCPayServer.Abstractions.Models;
|
|
|
|
using BTCPayServer.Client.Models;
|
2021-04-13 10:36:49 +02:00
|
|
|
using BTCPayServer.Data;
|
|
|
|
using BTCPayServer.Payments;
|
2021-10-18 05:37:59 +02:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2021-12-31 16:59:02 +09:00
|
|
|
using PayoutData = BTCPayServer.Data.PayoutData;
|
2021-11-04 08:21:01 +01:00
|
|
|
using StoreData = BTCPayServer.Data.StoreData;
|
2021-04-13 10:36:49 +02:00
|
|
|
|
|
|
|
public interface IPayoutHandler
|
|
|
|
{
|
|
|
|
public bool CanHandle(PaymentMethodId paymentMethod);
|
2021-07-16 09:57:37 +02:00
|
|
|
public Task TrackClaim(PaymentMethodId paymentMethodId, IClaimDestination claimDestination);
|
2021-04-13 10:36:49 +02:00
|
|
|
//Allows payout handler to parse payout destinations on its own
|
2022-11-22 20:17:29 +09:00
|
|
|
public Task<(IClaimDestination destination, string error)> ParseClaimDestination(PaymentMethodId paymentMethodId, string destination, CancellationToken cancellationToken);
|
2022-04-24 05:19:34 +02:00
|
|
|
public (bool valid, string? error) ValidateClaimDestination(IClaimDestination claimDestination, PullPaymentBlob? pullPaymentBlob);
|
2022-11-22 20:17:29 +09:00
|
|
|
public async Task<(IClaimDestination? destination, string? error)> ParseAndValidateClaimDestination(PaymentMethodId paymentMethodId, string destination, PullPaymentBlob? pullPaymentBlob, CancellationToken cancellationToken)
|
2022-01-24 20:17:09 +09:00
|
|
|
{
|
2022-11-22 20:17:29 +09:00
|
|
|
var res = await ParseClaimDestination(paymentMethodId, destination, cancellationToken);
|
2022-01-24 20:17:09 +09:00
|
|
|
if (res.destination is null)
|
|
|
|
return res;
|
|
|
|
var res2 = ValidateClaimDestination(res.destination, pullPaymentBlob);
|
|
|
|
if (!res2.valid)
|
|
|
|
return (null, res2.error);
|
|
|
|
return res;
|
|
|
|
}
|
2021-04-13 10:36:49 +02:00
|
|
|
public IPayoutProof ParseProof(PayoutData payout);
|
|
|
|
//Allows you to subscribe the main pull payment hosted service to events and prepare the handler
|
|
|
|
void StartBackgroundCheck(Action<Type[]> subscribe);
|
|
|
|
//allows you to process events that the main pull payment hosted service is subscribed to
|
|
|
|
Task BackgroundCheck(object o);
|
|
|
|
Task<decimal> GetMinimumPayoutAmount(PaymentMethodId paymentMethod, IClaimDestination claimDestination);
|
2021-07-16 09:57:37 +02:00
|
|
|
Dictionary<PayoutState, List<(string Action, string Text)>> GetPayoutSpecificActions();
|
|
|
|
Task<StatusMessageModel> DoSpecificAction(string action, string[] payoutIds, string storeId);
|
2021-11-04 08:21:01 +01:00
|
|
|
Task<IEnumerable<PaymentMethodId>> GetSupportedPaymentMethods(StoreData storeData);
|
2021-10-18 05:37:59 +02:00
|
|
|
Task<IActionResult> InitiatePayment(PaymentMethodId paymentMethodId, string[] payoutIds);
|
2021-04-13 10:36:49 +02:00
|
|
|
}
|