Payment Settled Webhook event (#2944)

* Payment Settled Webhook event

resolves #2691

* Move payment methods to payment services
This commit is contained in:
Andrew Camilleri
2021-10-05 11:10:41 +02:00
committed by GitHub
parent 143d5f69c1
commit 6e3d6125c2
20 changed files with 401 additions and 224 deletions

View File

@@ -91,6 +91,7 @@ namespace BTCPayServer.Payments.PayJoin
private readonly BTCPayServerEnvironment _env;
private readonly WalletReceiveService _walletReceiveService;
private readonly StoreRepository _storeRepository;
private readonly PaymentService _paymentService;
public PayJoinEndpointController(BTCPayNetworkProvider btcPayNetworkProvider,
InvoiceRepository invoiceRepository, ExplorerClientProvider explorerClientProvider,
@@ -101,7 +102,8 @@ namespace BTCPayServer.Payments.PayJoin
DelayedTransactionBroadcaster broadcaster,
BTCPayServerEnvironment env,
WalletReceiveService walletReceiveService,
StoreRepository storeRepository)
StoreRepository storeRepository,
PaymentService paymentService)
{
_btcPayNetworkProvider = btcPayNetworkProvider;
_invoiceRepository = invoiceRepository;
@@ -114,6 +116,7 @@ namespace BTCPayServer.Payments.PayJoin
_env = env;
_walletReceiveService = walletReceiveService;
_storeRepository = storeRepository;
_paymentService = paymentService;
}
[HttpPost("")]
@@ -487,7 +490,7 @@ namespace BTCPayServer.Payments.PayJoin
};
if (invoice != null)
{
var payment = await _invoiceRepository.AddPayment(invoice.Id, DateTimeOffset.UtcNow, originalPaymentData, network, true);
var payment = await _paymentService.AddPayment(invoice.Id, DateTimeOffset.UtcNow, originalPaymentData, network, true);
if (payment is null)
{
return UnprocessableEntity(CreatePayjoinError("already-paid",