mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Providing Payment Request completed webhook
This commit is contained in:
committed by
nicolas.dorier
parent
fdde3096d0
commit
967ec3460e
@@ -17,5 +17,6 @@ public static class WebhookEventType
|
||||
public const string PaymentRequestCreated = nameof(PaymentRequestCreated);
|
||||
public const string PaymentRequestArchived = nameof(PaymentRequestArchived);
|
||||
public const string PaymentRequestStatusChanged = nameof(PaymentRequestStatusChanged);
|
||||
public const string PaymentRequestCompleted = nameof(PaymentRequestCompleted);
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ public class PaymentRequestWebhookDeliveryRequest : WebhookSender.WebhookDeliver
|
||||
.Replace("{PaymentRequest.Currency}", data.Currency)
|
||||
.Replace("{PaymentRequest.Title}", blob.Title)
|
||||
.Replace("{PaymentRequest.Description}", blob.Description)
|
||||
.Replace("{PaymentRequest.Status}", data.Status.ToString());
|
||||
.Replace("{PaymentRequest.ReferenceNumber}", blob.ReferenceNumber)
|
||||
.Replace("{PaymentRequest.Status}", _evt.Data.Status.ToString());
|
||||
|
||||
res = InterpolateJsonField(res, "PaymentRequest.FormResponse", blob.FormResponse);
|
||||
return res;
|
||||
|
||||
@@ -22,6 +22,7 @@ public class PaymentRequestWebhookProvider: WebhookProvider<PaymentRequestEvent>
|
||||
{WebhookEventType.PaymentRequestUpdated, "Payment Request - Updated"},
|
||||
{WebhookEventType.PaymentRequestArchived, "Payment Request - Archived"},
|
||||
{WebhookEventType.PaymentRequestStatusChanged, "Payment Request - Status Changed"},
|
||||
{WebhookEventType.PaymentRequestCompleted, "Payment Request - Completed"},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,6 +43,7 @@ public class PaymentRequestWebhookProvider: WebhookProvider<PaymentRequestEvent>
|
||||
PaymentRequestEvent.Updated => new WebhookPaymentRequestEvent(WebhookEventType.PaymentRequestUpdated, evt.Data.StoreDataId),
|
||||
PaymentRequestEvent.Archived => new WebhookPaymentRequestEvent(WebhookEventType.PaymentRequestArchived, evt.Data.StoreDataId),
|
||||
PaymentRequestEvent.StatusChanged => new WebhookPaymentRequestEvent(WebhookEventType.PaymentRequestStatusChanged, evt.Data.StoreDataId),
|
||||
PaymentRequestEvent.Completed => new WebhookPaymentRequestEvent(WebhookEventType.PaymentRequestCompleted, evt.Data.StoreDataId),
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace BTCPayServer.Services.PaymentRequests
|
||||
public const string Updated = nameof(Updated);
|
||||
public const string Archived = nameof(Archived);
|
||||
public const string StatusChanged = nameof(StatusChanged);
|
||||
public const string Completed = nameof(Completed);
|
||||
public PaymentRequestData Data { get; set; }
|
||||
public string Type { get; set; }
|
||||
}
|
||||
@@ -99,9 +100,7 @@ namespace BTCPayServer.Services.PaymentRequests
|
||||
{
|
||||
await using var context = _ContextFactory.CreateContext();
|
||||
var paymentRequestData = await context.FindAsync<PaymentRequestData>(paymentRequestId);
|
||||
if (paymentRequestData == null)
|
||||
return;
|
||||
if( paymentRequestData.Status == status)
|
||||
if (paymentRequestData == null || paymentRequestData.Status == status)
|
||||
return;
|
||||
paymentRequestData.Status = status;
|
||||
|
||||
@@ -112,6 +111,15 @@ namespace BTCPayServer.Services.PaymentRequests
|
||||
Data = paymentRequestData,
|
||||
Type = PaymentRequestEvent.StatusChanged
|
||||
});
|
||||
|
||||
if (status == Client.Models.PaymentRequestData.PaymentRequestStatus.Completed)
|
||||
{
|
||||
_eventAggregator.Publish(new PaymentRequestEvent()
|
||||
{
|
||||
Data = paymentRequestData,
|
||||
Type = PaymentRequestEvent.Completed
|
||||
});
|
||||
}
|
||||
}
|
||||
public async Task<PaymentRequestData[]> GetExpirablePaymentRequests(CancellationToken cancellationToken = default)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user