protected override async Task ProcessEvent(object evt, CancellationToken cancellationToken) { if (evt is InvoiceEvent invoiceEvent && invoiceEvent.Name == InvoiceEvent.ReceivedPayment && invoiceEvent.Payment.GetPaymentMethodId()?.PaymentType == BitcoinPaymentType.Instance && invoiceEvent.Payment.GetCryptoPaymentData() is BitcoinLikePaymentData bitcoinLikePaymentData) { var walletId = new WalletId(invoiceEvent.Invoice.StoreId, invoiceEvent.Payment.GetCryptoCode()); var transactionId = bitcoinLikePaymentData.Outpoint.Hash; var labels = new List <(string color, Label label)> { UpdateTransactionLabel.InvoiceLabelTemplate(invoiceEvent.Invoice.Id) }; if (invoiceEvent.Invoice.GetPayments(invoiceEvent.Payment.GetCryptoCode(), false).Any(entity => entity.GetCryptoPaymentData() is BitcoinLikePaymentData pData && pData.PayjoinInformation?.CoinjoinTransactionHash == transactionId)) { labels.Add(UpdateTransactionLabel.PayjoinLabelTemplate()); } foreach (var paymentId in PaymentRequestRepository.GetPaymentIdsFromInternalTags(invoiceEvent.Invoice)) { labels.Add(UpdateTransactionLabel.PaymentRequestLabelTemplate(paymentId)); } foreach (var appId in AppService.GetAppInternalTags(invoiceEvent.Invoice)) { labels.Add(UpdateTransactionLabel.AppLabelTemplate(appId)); } _eventAggregator.Publish(new UpdateTransactionLabel(walletId, transactionId, labels)); }
protected override async Task ProcessEvent(object evt, CancellationToken cancellationToken) { if (evt is InvoiceEvent invoiceEvent) { foreach (var paymentId in PaymentRequestRepository.GetPaymentIdsFromInternalTags(invoiceEvent.Invoice)) { if (invoiceEvent.Name == InvoiceEvent.ReceivedPayment || invoiceEvent.Name == InvoiceEvent.MarkedCompleted || invoiceEvent.Name == InvoiceEvent.MarkedInvalid) { await _PaymentRequestService.UpdatePaymentRequestStateIfNeeded(paymentId); var data = invoiceEvent.Payment?.GetCryptoPaymentData(); if (data != null) { await _HubContext.Clients.Group(paymentId).SendCoreAsync(PaymentRequestHub.PaymentReceived, new object[] { data.GetValue(), invoiceEvent.Payment.GetCryptoCode(), invoiceEvent.Payment.GetPaymentMethodId()?.PaymentType?.ToString() }, cancellationToken); } } await InfoUpdated(paymentId); } } else if (evt is PaymentRequestUpdated updated) { await _PaymentRequestService.UpdatePaymentRequestStateIfNeeded(updated.PaymentRequestId); await InfoUpdated(updated.PaymentRequestId); var expiry = updated.Data.GetBlob().ExpiryDate; if (updated.Data.Status == PaymentRequestData.PaymentRequestStatus.Pending && expiry.HasValue) { QueueExpiryTask( updated.PaymentRequestId, expiry.Value.UtcDateTime, cancellationToken); } } }