public async Task <CustomerWalletBlockErrorCode> BlockCustomerWalletAsync(string customerId) { if (string.IsNullOrEmpty(customerId)) { throw new ArgumentNullException(nameof(customerId)); } var customerResponse = await _customerProfileClient.CustomerProfiles.GetByCustomerIdAsync(customerId, true); if (customerResponse.ErrorCode == CustomerProfileErrorCodes.CustomerProfileDoesNotExist) { return(CustomerWalletBlockErrorCode.CustomerNotFound); } var repositoryEntry = await _walletFlagsRepository.GetByCustomerIdAsync(customerId); if (repositoryEntry != null && repositoryEntry.IsBlocked) { return(CustomerWalletBlockErrorCode.CustomerWalletAlreadyBlocked); } await _walletFlagsRepository.CreateOrUpdateAsync(customerId, true); await _walletStatusUpdatePublisher.PublishAsync(new CustomerWalletStatusUpdatedEvent { CustomerId = customerId, WalletBlocked = true, }); return(CustomerWalletBlockErrorCode.None); }
public override async Task <bool> ProcessMessageAsync(EmailVerifiedEvent message) { if (!message.WasEmailEverVerified) { var customer = await _customerProfileClient.CustomerProfiles.GetByCustomerIdAsync(message.CustomerId, true); if (customer.ErrorCode == CustomerProfileErrorCodes.None) { if (_isPhoneVerificationDisabled || (customer.Profile?.IsPhoneVerified ?? false)) { await _bonusTriggerEventPublisher.PublishAsync(new BonusTriggerEvent { CustomerId = message.CustomerId, TimeStamp = message.TimeStamp, Type = BonusTypes.SignUp.EventName, Data = new Dictionary <string, string>() }); } } } await _bonusTriggerEventPublisher.PublishAsync(new BonusTriggerEvent { CustomerId = message.CustomerId, TimeStamp = message.TimeStamp, Type = BonusTypes.EmailVerificationTrigger.EventName, Data = new Dictionary <string, string>() }); return(true); }
public async Task <CustomerProfileErrorCodes> CreateIfNotExistsAsync(ICustomerProfile customerProfile) { var isSocialAccountProfile = customerProfile.LoginProviders.Any(p => p != LoginProvider.Standard); if (isSocialAccountProfile) { customerProfile.IsEmailVerified = true; } if (customerProfile.CountryOfNationalityId.HasValue) { var countryResult = await _dictionariesClient.Salesforce.GetCountryOfResidenceByIdAsync( customerProfile.CountryOfNationalityId.Value); if (countryResult == null) { return(CustomerProfileErrorCodes.InvalidCountryOfNationalityId); } } var creationResult = await _customerProfileRepository.CreateIfNotExistAsync(customerProfile); switch (creationResult) { case CustomerProfileErrorCodes.CustomerProfileAlreadyExistsWithDifferentProvider: _log.Warning("Customer Profile already exists but with different login provider", context: customerProfile.CustomerId); return(creationResult); case CustomerProfileErrorCodes.CustomerProfileAlreadyExists: _log.Warning("Customer Profile already exists", context: customerProfile.CustomerId); return(creationResult); } _log.Info("Customer profile is created", context: customerProfile.CustomerId); if (isSocialAccountProfile) { Task.Run(async() => { try { await _emailVerifiedPublisher.PublishAsync(new EmailVerifiedEvent { CustomerId = customerProfile.CustomerId, TimeStamp = DateTime.UtcNow }); } catch (Exception e) { _log.Error(e); } }); } return(creationResult); }
private Task ProcessWalletLinkingOperationFailure(IOperation operation) { var operationContext = JsonConvert.DeserializeObject <WalletLinkingContext>(operation.ContextJson); return(_walletStatusChangeFailedPublisher.PublishAsync(new WalletStatusChangeFailedEvent { PublicWalletAddress = operationContext.PublicWalletAddress, InternalWalletAddress = operationContext.InternalWalletAddress, })); }
private Task ProcessPublicAccountLinkedEvent(IEnumerable <string> topics, string data) { var eventData = DecodeEvent <PublicAccountLinkedEventDTO>(topics, data); var evt = new EthereumWalletLinkingStatusChangeCompletedEvent { PrivateAddress = eventData.InternalAccount, PublicAddress = eventData.PublicAccount }; return(_walletLinkingStatusChangeCompletedPublisher.PublishAsync(evt)); }
private Task PublishUnlinkCommandAsync(string customerId, string privateAddress) { return(_requestedPublisher.PublishAsync(new WalletLinkingStatusChangeRequestedEvent { Direction = LinkingDirection.Unlink, CustomerId = customerId, PrivateAddress = privateAddress, PublicAddress = null, Fee = 0, MasterWalletAddress = _settingsService.GetMasterWalletAddress(), EventId = Guid.NewGuid().ToString() })); }
public async Task HandleSucceededTransferAsync(Guid transferId) { var operation = await _operationsRepository.GetByTransferIdAsync(transferId, OperationType.Accept); if (operation == null) { return; } await _operationsRepository.UpdateAsync(operation.Id, OperationStatus.Succeeded); var transfer = await _transfersRepository.GetByIdAsync(operation.TransferId); if (transfer == null) { throw new TransferNotFoundException(); } var evt = new VoucherTokensUsedEvent { TransferId = operation.TransferId, CustomerId = transfer.CustomerId, SpendRuleId = transfer.SpendRuleId, Amount = transfer.Amount, Timestamp = transfer.Created, VoucherId = transfer.VoucherId, }; await _voucherTokensUsedEventPublisher.PublishAsync(evt); _log.Info("Operation completed.", context: $"transferId: {operation.Id}; type: {operation.Type}; transferId: {operation.TransferId}"); }
public async Task <ReferralLead> ApproveReferralLeadAsync(Guid referralId, DateTime timestamp) { var referralLeadEncrypted = await _referralLeadRepository.GetAsync(referralId); if (referralLeadEncrypted == null) { throw new ReferralDoesNotExistException($"Referral Lead with Id '{referralId}' does not exist."); } if (referralLeadEncrypted.State != ReferralLeadState.Confirmed) { throw new InvalidOperationException("Referral should be in status Confirmed."); } referralLeadEncrypted.State = ReferralLeadState.Approved; referralLeadEncrypted = await _referralLeadRepository.UpdateAsync(referralLeadEncrypted); await _propertyLeadApprovedReferralPublisher.PublishAsync(new PropertyLeadApprovedReferralEvent { ReferrerId = referralLeadEncrypted.AgentId.ToString(), TimeStamp = timestamp, StakedCampaignId = referralLeadEncrypted.CampaignId, ReferralId = referralLeadEncrypted.Id.ToString() }); await PublishLeadChangeStateEvent(referralLeadEncrypted.Id.ToString(), _mapper.Map <Contract.Enums.ReferralLeadState>(referralLeadEncrypted.State)); return(await DecryptAsync(referralLeadEncrypted)); }
private async Task ProcessTransferOperationFailure(IOperation operation) { var operationContext = JsonConvert.DeserializeObject <TokensTransferContext>(operation.ContextJson); var senderWalletOwner = await _walletOwnersRepository.GetByWalletAddressAsync(operationContext.SenderWalletAddress); //If sender is not a customer this is not a P2P transaction and we shouldn't raise an event if (senderWalletOwner == null) { return; } var receiverWalletOwner = await _walletOwnersRepository.GetByWalletAddressAsync(operationContext.RecipientWalletAddress); //If receiver is not a customer this is not a P2P transaction and we shouldn't raise an event if (receiverWalletOwner == null) { return; } await _p2PFailedPublisher.PublishAsync(new P2PTransferFailedEvent { TransactionHash = operation.TransactionHash, RequestId = operationContext.RequestId, Timestamp = operation.Timestamp, Amount = operationContext.Amount, SenderCustomerId = senderWalletOwner.OwnerId, ReceiverCustomerId = receiverWalletOwner.OwnerId }); }
private async Task ProcessCompletedTransactionAsync(TransactionReceipt transactionReceipt) { try { var evt = new TransactionCompletedInBlockchainEvent { TransactionHash = transactionReceipt.TransactionHash, ObservedAt = DateTime.UtcNow, }; await _transactionCompletedInBlockchainEventPublishingService.PublishAsync(evt); _log.Info($"{nameof(TransactionCompletedInBlockchainEvent)} has been published", evt); } catch (Exception e) { #region Logging _log.Error ( e, $"Failed to process completed transaction [{transactionReceipt.TransactionHash}].", new { transactionHash = transactionReceipt.TransactionHash } ); #endregion throw; } }
private async Task HandleTransferToInternalAsync(string[] topics, string data, string operationId) { var transferToInternalData = _blockchainEventDecoder.DecodeTransferToInternalEvent(topics, data); var customerResponse = await _pbfClient.CustomersApi.GetCustomerIdByWalletAddress(transferToInternalData.InternalAddress); if (customerResponse.Error != CustomerWalletAddressError.None) { _log.Error( message: "No customer with that internal wallet address during decoding of TransferToInternal", context: new { customerResponse.Error, transferToInternalData.InternalAddress }); return; } await _transferToInternalCompletedPublisher.PublishAsync(new TransferToInternalCompletedEvent { CustomerId = customerResponse.CustomerId, Amount = transferToInternalData.Amount, PrivateAddress = transferToInternalData.InternalAddress, PublicAddress = transferToInternalData.PublicAddress, OperationId = operationId }); await _pushNotificationsPublisher.PublishTransferToInternalSucceededAsync(customerResponse.CustomerId, transferToInternalData.Amount); }
public override async Task <bool> ProcessMessageAsync(BonusCustomerTriggerEvent message) { var response = await _currencyConverterClient.Converter .ConvertAsync(message.Currency, _assetName, message.Amount); if (response.ErrorCode != ConverterErrorCode.None) { _log.Error(message: "An error occured while converting currency amount", context: $"from: {message.Currency}; to: {_assetName}; error: {response.ErrorCode}"); return(false); } await _bonusTriggerEventPublisher.PublishAsync(new BonusTriggerEvent { CustomerId = message.CustomerId, TimeStamp = DateTime.UtcNow, Type = BonusTypes.HotelCheckout.EventName, PartnerId = message.PartnerId, LocationId = message.LocationId, Data = new Dictionary <string, string> { { "Amount", response.Amount.ToString("G") } } }); _log.Info("Hotel stay bonus event published", context: $"CustomerId: {message.CustomerId}"); return(true); }
public async Task <CustomerProfileErrorCodes> RequestCustomerProfileDeactivation(string customerId) { return(await _transactionRunner.RunWithTransactionAsync(async txContext => { var customerProfile = await _customerProfileRepository.GetByCustomerIdAsync(customerId, includeNotVerified: true, includeNotActive: true, txContext); if (customerProfile == null) { return CustomerProfileErrorCodes.CustomerProfileDoesNotExist; } if (customerProfile.Status != CustomerProfileStatus.Active) { return CustomerProfileErrorCodes.CustomerIsNotActive; } await _customerProfileRepository.ChangeProfileStatus(customerId, CustomerProfileStatus.PendingDeactivation, txContext); await _deactivationRequestedPublisher.PublishAsync(new CustomerProfileDeactivationRequestedEvent { CustomerId = customerId }); return CustomerProfileErrorCodes.None; })); }
public async Task ProcessWarningsForReferralStakes() { var referralStakesForWarning = await _referralStakesRepository.GetStakesForWarningAsync(); foreach (var stake in referralStakesForWarning) { var campaignResult = await _campaignClient.History.GetEarnRuleByIdAsync(Guid.Parse(stake.CampaignId)); if (campaignResult.ErrorCode != CampaignServiceErrorCodes.None) { _log.Error(message: "Cannot find campaign for existing stake", context: stake); } var evt = new PushNotificationEvent { CustomerId = stake.CustomerId, MessageTemplateId = _pushNotificationsSettingsService.ReferralStakeWarningTemplateId, Source = _componentSourceName, TemplateParameters = new Dictionary <string, string> { { "Amount", _moneyFormatter.FormatAmountToDisplayString(stake.Amount) }, { "Offer", campaignResult.Name } }, }; await _pushNotificationsPublisher.PublishAsync(evt); await _referralStakesRepository.SetWarningSentAsync(stake.ReferralId); } }
public async Task <(bool isSuccessful, string errorMessage)> ProcessOfferToPurchaseAsync( OfferToPurchase offerToPurchase) { if (!await _referralLeadRepository.DoesExistAsync(offerToPurchase.ReferId)) { return(false, $"Referral lead with id '{offerToPurchase.ReferId} does not exist.'"); } await _offerToPurchasePurchaseRepository.InsertAsync(offerToPurchase); var lead = await _referralLeadRepository.GetAsync(offerToPurchase.ReferId); await _offerToPurchasePublisher.PublishAsync(new OfferToPurchaseByLeadEvent { AgentId = lead.AgentId.ToString(), TimeStamp = offerToPurchase.Timestamp, CurrencyCode = offerToPurchase.CurrencyCode, VatAmount = offerToPurchase.VatAmount, DiscountAmount = offerToPurchase.DiscountAmount, NetPropertyPrice = offerToPurchase.NetPropertyPrice, SellingPropertyPrice = offerToPurchase.SellingPropertyPrice, CampaignId = lead.CampaignId.Value, UnitLocationCode = offerToPurchase.UnitLocationCode, ReferralId = lead.Id.ToString() }); return(true, string.Empty); }
public async Task <(bool isSuccessful, string errorMessage)> AcceptAsync(Guid customerId) { var friendReferral = await _friendReferralHistoryRepository.GetAcceptedAsync(customerId); if (friendReferral == null) { _log.Info($"No accepted friend referral for customer '{customerId}'"); return(true, string.Empty); } friendReferral.State = ReferralFriendState.Confirmed; await _friendReferralHistoryRepository.UpdateAsync(friendReferral); await _friendReferralPublisher.PublishAsync(new FriendReferralEvent { ReferredId = friendReferral.ReferredId.ToString("D"), ReferrerId = friendReferral.ReferrerId.ToString("D"), ReferralId = friendReferral.Id.ToString("D"), Timestamp = DateTime.UtcNow }); _log.Info("Referral friend accepted", context: $"referralFriendId: {friendReferral.Id}"); return(true, string.Empty); }
public Task <ReferralStakesStatusUpdateErrorCode> TokensBurnAndReleaseSucceedAsync(string referralId) { return(SetStatusAsync(referralId, StakeStatus.TokensBurnAndReleaseStarted, StakeStatus.TokensBurnAndReleaseSucceeded, async stake => { var burnRatio = stake.ReleaseBurnRatio ?? stake.ExpirationBurnRatio; var(amountToBurn, amountToRelease) = CalculateAmountToBurnAndRelease(stake.Amount, burnRatio); if (amountToRelease > 0) { await _stakeReleasedPublisher.PublishAsync(new ReferralStakeReleasedEvent { CustomerId = stake.CustomerId, ReferralId = stake.ReferralId, CampaignId = stake.CampaignId, Amount = amountToRelease, Timestamp = DateTime.UtcNow }); } if (amountToBurn > 0) { await _stakeBurntPublisher.PublishAsync(new ReferralStakeBurntEvent { CustomerId = stake.CustomerId, ReferralId = stake.ReferralId, CampaignId = stake.CampaignId, Amount = amountToBurn, Timestamp = DateTime.UtcNow }); } })); }
public async Task AddBonusOperationAsync(BonusOperation bonusOperation) { var campaignId = bonusOperation.CampaignId.ToGuid(); var bonusIssuedEvent = new BonusIssuedEvent { OperationId = Guid.NewGuid(), Amount = bonusOperation.Reward, CampaignId = campaignId, ConditionId = bonusOperation.BonusOperationType == Domain.Enums.BonusOperationType.CampaignReward ? Guid.Empty : bonusOperation.ConditionId.ToGuid(), PartnerId = bonusOperation.PartnerId, LocationId = bonusOperation.LocationId, UnitLocationCode = bonusOperation.UnitLocationCode, CustomerId = bonusOperation.CustomerId, BonusOperationType = _mapper.Map <BonusOperationType>(bonusOperation.BonusOperationType), TimeStamp = bonusOperation.TimeStamp, ReferralId = bonusOperation.ReferralId }; // Zero reward operations are not accepted by blockchain facade if (bonusIssuedEvent.Amount > 0) { await _bonusIssuedPublisher.PublishAsync(bonusIssuedEvent); _log.Info( $"Bonus issued: {bonusIssuedEvent.ToJson()}", bonusIssuedEvent.BonusOperationType, process: nameof(AddBonusOperationAsync)); } }
private async Task PublishOTP(ReferralLead createdReferralLead) { var offerToPurchase = new OfferToPurchase { CurrencyCode = "AED", DiscountAmount = 1, NetPropertyPrice = 1, ReferId = createdReferralLead.Id, SellingPropertyPrice = 1, Timestamp = DateTime.UtcNow, VatAmount = 1 }; await _offerToPurchasePurchaseRepository.InsertAsync(offerToPurchase); var lead = await _referralLeadRepository.GetAsync(offerToPurchase.ReferId); await _offerToPurchasePublisher.PublishAsync(new OfferToPurchaseByLeadEvent { AgentId = lead.AgentId.ToString(), TimeStamp = offerToPurchase.Timestamp, CurrencyCode = offerToPurchase.CurrencyCode, VatAmount = offerToPurchase.VatAmount, DiscountAmount = offerToPurchase.DiscountAmount, NetPropertyPrice = offerToPurchase.NetPropertyPrice, SellingPropertyPrice = offerToPurchase.SellingPropertyPrice, ReferralId = lead.Id.ToString() }); }
public override async Task <bool> ProcessMessageAsync(MAVNPropertyPurchaseFirstRewardEvent message) { // Having customer id null here is valid case if (string.IsNullOrEmpty(message.BuyerCustomerId)) { return(true); } var amount = message.NetPropertyPrice ?? 0M; if (amount < 0) { Log.Error(null, "Amount has invalid value in Purchase Referral Event", context: message, process: nameof(ProcessMessageAsync)); return(false); } await _bonusTriggerEventPublisher.PublishAsync(new BonusTriggerEvent { CustomerId = message.BuyerCustomerId, TimeStamp = message.Timestamp, Type = BonusTypes.PropertyPurchaseFirstReward.EventName, Data = new Dictionary <string, string>() { { "Amount", amount.ToString("G") }, { "UnitLocationCode", message.UnitLocationCode } } }); return(true); }
public async Task HandleAsync(string customerId) { var customerBalance = await _balanceService.GetAsync(customerId); if (customerBalance.Error != CustomerBalanceError.None) { _log.Error(message: "Cannot seize balance of a customer because of error", context: customerBalance.Error); return; } if (customerBalance.Total == 0) { await _seizeBalanceFromCustomerCompletedPublisher.PublishAsync( new SeizeBalanceFromCustomerCompletedEvent { CustomerId = customerId }); return; } var walletResult = await _walletOwnersRepository.GetByOwnerIdAsync(customerId); if (walletResult == null) { _log.Error(message: "Cannot seize balance of a customer because the wallet is missing", context: customerId); return; } await _operationRequestsProducer.AddAsync(customerId, OperationType.SeizeToInternal, new SeizeToInternalContext { Account = walletResult.WalletId, Amount = customerBalance.Total, Reason = BalanceSeizeReason, }); }
private async Task ThreadCustomerVerificationAsync(int threadNumber, List <string> customerIds) { var phoneNumberGen = new Random((int)DateTime.UtcNow.Ticks); foreach (var customerId in customerIds) { try { await _emailVerifiedPublisher.PublishAsync( new EmailCodeVerifiedEvent { CustomerId = customerId, TimeStamp = DateTime.UtcNow, }); await Task.Delay(100); while (true) { var phoneNumerStr = (10000000000 * phoneNumberGen.NextDouble()).ToString().Substring(0, 10); var dotIndex = phoneNumerStr.IndexOfAny(new[] { '.', ',' }); if (dotIndex != -1) { phoneNumerStr = phoneNumerStr.Substring(0, dotIndex); } try { await _customerProfileClient.CustomerPhones.SetCustomerPhoneInfoAsync( new SetCustomerPhoneInfoRequestModel { CustomerId = customerId, PhoneNumber = phoneNumerStr, CountryPhoneCodeId = 1, }); } catch (Exception e) { _log.Error(e, context: phoneNumerStr); continue; } var verificationResult = await _customerProfileClient.CustomerPhones.SetCustomerPhoneAsVerifiedAsync( new SetPhoneAsVerifiedRequestModel { CustomerId = customerId }); if (verificationResult.ErrorCode == CustomerProfileErrorCodes.None) { break; } } } catch (Exception e) { _log.Error(e); } } }
public async Task HandlePartnersPaymentProcessedAsync(PartnerPaymentDto partnerPayment) { if (partnerPayment.Status == PartnerPaymentStatus.Accepted) { await _successfulPartnersPaymentPublisher.PublishAsync(new SuccessfulPartnersPaymentEvent { CustomerId = partnerPayment.CustomerId, Amount = partnerPayment.Amount, Timestamp = partnerPayment.Timestamp, PartnerId = partnerPayment.PartnerId, PaymentRequestId = partnerPayment.PaymentRequestId, LocationId = partnerPayment.LocationId, }); _log.Info("Published SuccessfulPartnersPaymentEvent", context: partnerPayment.PaymentRequestId); } if (partnerPayment.Status == PartnerPaymentStatus.Rejected) { await _refundPartnersPaymentPublisher.PublishAsync(new RefundPartnersPaymentEvent { CustomerId = partnerPayment.CustomerId, Amount = partnerPayment.Amount, Timestamp = partnerPayment.Timestamp, PartnerId = partnerPayment.PartnerId, PaymentRequestId = partnerPayment.PaymentRequestId, LocationId = partnerPayment.LocationId, }); _log.Info("Published RefundPartnersPaymentEvent", context: partnerPayment.PaymentRequestId); } }
private async Task HandleWalletUnlinkedAsync(string[] topics, string data) { var publicAccountUnlinkedDto = _blockchainEventDecoder.DecodePublicAccountUnlinkedEvent(topics, data); var linkRequest = await _requestsRepository.GetByPrivateAddressAsync(publicAccountUnlinkedDto.PrivateAddress); if (linkRequest != null) { await _pushNotificationsPublisher.PublishWalletUnlinkingSuccessfulAsync(linkRequest.CustomerId); await _requestsRepository.DeleteByIdAsync(linkRequest.CustomerId); } else { _log.Error(message: "Wallet linking request has not been deleted upon confirmation from blockchain", context: new { publicAccountUnlinkedDto.PrivateAddress, publicAccountUnlinkedDto.PublicAddress }); } await _statusChangeCompletedPublisher.PublishAsync(new WalletLinkingStatusChangeCompletedEvent { CustomerId = linkRequest?.CustomerId, PrivateAddress = publicAccountUnlinkedDto.PrivateAddress, PublicAddress = null, EventId = Guid.NewGuid().ToString(), Fee = linkRequest?.Fee ?? 0 }); _log.Info("Wallet has been unlinked and confirmed in private blockchain", context: publicAccountUnlinkedDto.ToJson()); }
public async Task ProcessP2PTransferDetectedEventAsync( string contextId, string transactionHash, string senderCustomerId, string receiverCustomerId, Money18 amount, DateTime timestamp) { var transferContext = await _transfersRepository.GetAsync(contextId); if (transferContext == null) { _log.Error(message: ContextNotFoundMsg, context: new { requestId = contextId, transactionHash, senderCustomerId, receiverCustomerId }); throw new InvalidOperationException(ContextNotFoundMsg); } await _p2PTransferEventPublisher.PublishAsync(new P2PTransferEvent { Amount = amount, Timestamp = timestamp, SenderCustomerId = senderCustomerId, ReceiverCustomerId = receiverCustomerId, AssetSymbol = transferContext.AssetSymbol, TransactionId = transferContext.OperationId, ExternalOperationId = transferContext.ExternalOperationId }); var senderCurrentBalance = await GetCustomerCurrentBalance(senderCustomerId); var receiverCurrentBalance = await GetCustomerCurrentBalance(receiverCustomerId); var senderCustomerEmail = await GetCustomerEmail(senderCustomerId); var receiverCustomerEmail = await GetCustomerEmail(receiverCustomerId); var senderEmailNotificationTask = _emailsPublisher.SendP2PSucceededForSenderAsync(senderCustomerId, contextId, amount, timestamp, senderCurrentBalance, receiverCustomerEmail); var receiverEmailNotificationTask = _emailsPublisher.SendP2PSucceededForReceiverAsync(receiverCustomerId, contextId, amount, timestamp, receiverCurrentBalance, senderCustomerEmail); var senderPushNotificationTask = _pushNotificationsPublisher.PublishP2PSucceededForSenderAsync(senderCustomerId); var receiverPushNotificationTask = _pushNotificationsPublisher.PublishP2PSucceededForReceiverAsync(receiverCustomerId, amount, senderCustomerEmail); await Task.WhenAll( senderEmailNotificationTask, receiverEmailNotificationTask, senderPushNotificationTask, receiverPushNotificationTask); await _transfersRepository.DeleteAsync(contextId); }
public async Task HandlePaymentTransferProcessed(IPaymentTransfer paymentTransfer) { if (paymentTransfer.Status == PaymentTransferStatus.Accepted) { await _successfulPaymentTransferPublisher.PublishAsync(new SuccessfulPaymentTransferEvent { CustomerId = paymentTransfer.CustomerId, Amount = paymentTransfer.Amount, CampaignId = paymentTransfer.CampaignId, TransferId = paymentTransfer.TransferId, Timestamp = paymentTransfer.Timestamp, InvoiceId = paymentTransfer.InvoiceId, InstalmentName = paymentTransfer.InstalmentName, LocationCode = paymentTransfer.LocationCode, }); _log.Info("Published SuccessfulPaymentTransferEvent", context: paymentTransfer.TransferId); var balanceResponse = await _pbfClient.CustomersApi.GetBalanceAsync(Guid.Parse(paymentTransfer.CustomerId)); if (balanceResponse.Error != CustomerBalanceError.None) { _log.Error(message: "Customer balance response error", context: new { paymentTransfer.CustomerId, error = balanceResponse.Error.ToString() }); } var balance = balanceResponse.Error == CustomerBalanceError.None ? balanceResponse.Total : 0; await _pushNotificationsPublisher.PublishPaymentTransferAcceptedAsync( paymentTransfer.CustomerId, paymentTransfer.InvoiceId, balance); await _emailsPublisher.SendPaymentTransferAcceptedAsync( paymentTransfer.CustomerId, paymentTransfer.InvoiceId, balance); } if (paymentTransfer.Status == PaymentTransferStatus.Rejected) { await _refundPaymentTransferPublisher.PublishAsync(new RefundPaymentTransferEvent { CustomerId = paymentTransfer.CustomerId, Amount = paymentTransfer.Amount, CampaignId = paymentTransfer.CampaignId, TransferId = paymentTransfer.TransferId, Timestamp = paymentTransfer.Timestamp, InvoiceId = paymentTransfer.InvoiceId, InstalmentName = paymentTransfer.InstalmentName, LocationCode = paymentTransfer.LocationCode, }); _log.Info("Published RefundPaymentTransferEvent", context: paymentTransfer.TransferId); await _pushNotificationsPublisher.PublishPaymentTransferRejectedAsync( paymentTransfer.CustomerId, paymentTransfer.InvoiceId); await _emailsPublisher.SendPaymentTransferRejectedAsync( paymentTransfer.CustomerId, paymentTransfer.InvoiceId); } }
private async Task SendCustomerBlockedEmailAsync(string customerId) { await _emailEventPublisher.PublishAsync(new EmailMessageEvent { CustomerId = customerId, MessageTemplateId = _customerBlockEmailTemplateId, SubjectTemplateId = _customerBlockSubjectTemplateId, TemplateParameters = new Dictionary <string, string> { { SupportPhoneNumberKey, _customerSupportPhoneNumber } }, Source = $"{AppEnvironment.Name} - {AppEnvironment.Version}" }); }
private Task PublishStatusUpdatedEvent(string referralId, StakeStatus status) { return(_statusUpdatedPublisher.PublishAsync(new ReferralStakeStatusUpdatedEvent { ReferralId = referralId, Status = (Contract.StakeStatus)status })); }
private async Task PublishParticipationEventAsync(string campaignId, string customerId) { await _rabbitParticipatedInCampaignEventPublisher.PublishAsync(new ParticipatedInCampaignEvent { CampaignId = campaignId, CustomerId = customerId }); }
public async Task HandleAsync(string privateAddress, string publicAddress) { if (string.IsNullOrEmpty(publicAddress)) { // it is unlink completion await _publisher.PublishAsync(new WalletLinkingStatusChangeFinalizedEvent { PrivateAddress = privateAddress, PublicAddress = publicAddress }); _log.Info("Unlink request has been confirmed in public blockchain", new { privateAddress, publicAddress }); return; } var linkingRequest = await _walletLinker.GetByPrivateAddressAsync(privateAddress); if (linkingRequest == null) { _log.Error(message: "The wallet linking request was not found", context: new { privateAddress, publicAddress }); return; } // it is link completion var confirmationResult = await _walletLinker.ConfirmInPublicAsync(privateAddress); if (confirmationResult.Error != ConfirmationError.None) { _log.Error(message: "Couldn't mark link request as confirmed in public blockchain", context: new { privateAddress, publicAddress, confirmationResult.Error }); return; } await _pushNotificationsPublisher.PublishWalletLinkingSuccessfulAsync(linkingRequest.CustomerId); await _publisher.PublishAsync(new WalletLinkingStatusChangeFinalizedEvent { PrivateAddress = privateAddress, PublicAddress = publicAddress }); }