-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathReconciliationConsumer.cs
More file actions
35 lines (30 loc) · 1.48 KB
/
ReconciliationConsumer.cs
File metadata and controls
35 lines (30 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Threading.Tasks;
using Unity.Modules.Shared.MessageBrokers.RabbitMQ.Interfaces;
using Unity.Payments.RabbitMQ.QueueMessages;
using System;
using Unity.Payments.PaymentRequests;
using Unity.Payments.Integrations.Cas;
namespace Unity.Payments.Integrations.RabbitMQ;
public class ReconciliationConsumer(
CasPaymentRequestCoordinator casPaymentRequestCoordinator,
InvoiceService invoiceService
) : IQueueConsumer<ReconcilePaymentMessages>
{
public async Task ConsumeAsync(ReconcilePaymentMessages reconcilePaymentMessage)
{
if (reconcilePaymentMessage != null && !reconcilePaymentMessage.InvoiceNumber.IsNullOrEmpty() && reconcilePaymentMessage.TenantId != Guid.Empty)
{
// string invoiceNumber, string supplierNumber, string siteNumber)
// Go to CAS retrieve the status of the payment
CasPaymentSearchResult result = await invoiceService.GetCasPaymentAsync(
reconcilePaymentMessage.TenantId,
reconcilePaymentMessage.InvoiceNumber,
reconcilePaymentMessage.SupplierNumber,
reconcilePaymentMessage.SiteNumber);
if (result != null && result.InvoiceStatus != null && result.InvoiceStatus != "")
{
await casPaymentRequestCoordinator.UpdatePaymentRequestStatus(reconcilePaymentMessage.TenantId, reconcilePaymentMessage.PaymentRequestId, result);
}
}
}
}