private void ValidateHasCompleteDocuments(Guid withdrawalId, Payment.Data.Player player, Guid brandId) { if (!_configuration.HasCompleteDocuments) { return; } var ruleResult = true; //Kristian: I leave it like this because the validation doesn't have a return code or value //but it directly throws an exception if one of the needed documents is not present for that player. try { _identityValidator.Validate(player.Id, Common.Data.Player.TransactionType.Withdraw); } catch { ruleResult = false; } var metadataForRule = GenerateFullRuleDescriptionAndValue( VerificationStep.HasDocuments, ComparisonEnum.Is, _configuration.HasCompleteDocuments.ToString(), ruleResult.ToString()); OnRuleFinish(ruleResult, withdrawalId, VerificationStep.HasDocuments, metadataForRule); }
private void ValidatePaymentLevel(Guid withdrawalId, Payment.Data.Player player) { var playerPaymentLevel = _paymentRepository .PlayerPaymentLevels .Include(x => x.PaymentLevel) .FirstOrDefault(elem => elem.PlayerId == player.Id); if (!_configuration.HasPaymentLevel || playerPaymentLevel == null) { return; } var avcAllowedPaymentLevels = string.Join(",", _configuration .PaymentLevels.Select(pl => pl.Name).ToArray()); var metadataForRule = GenerateFullRuleDescriptionAndValue( VerificationStep.PaymentLevel, ComparisonEnum.Of, avcAllowedPaymentLevels, playerPaymentLevel.PaymentLevel.Name); var avcContainsPlayersPaymentLevel = _configuration .PaymentLevels .Any(x => x.Id == playerPaymentLevel.PaymentLevel.Id); if (!avcContainsPlayersPaymentLevel) { OnRuleFinish(false, withdrawalId, VerificationStep.PaymentLevel, metadataForRule); } else { OnRuleFinish(true, withdrawalId, VerificationStep.PaymentLevel, metadataForRule); } }
private bool PlayerIsAllowedForExemption(Payment.Data.Player player, DateTimeOffset?autoVerificationCheckDate) { return(player.ExemptWithdrawalFrom <= autoVerificationCheckDate && player.ExemptWithdrawalTo >= autoVerificationCheckDate && player.ExemptLimit > 0 && player.ExemptWithdrawalVerification == true); }
private async void ValidateBonus(OfflineWithdraw withdrawal, Payment.Data.Player player) { if (!_configuration.HasBonusCheck) { return; } var latestDeposit = _paymentRepository.OfflineDeposits .Where(o => o.Status == OfflineDepositStatus.Approved && o.PlayerId == player.Id) .OrderByDescending(o => o.Approved.Value) .First(); var allowedBonuses = _configuration.AllowedBonuses.Select(o => o.Name); var bonusName = latestDeposit.BonusRedemptionId.HasValue ? (await _bonusApiProxy.GetBonusRedemptionAsync(latestDeposit.PlayerId, latestDeposit.BonusRedemptionId.Value)).Bonus.Name : string.Empty; var isSuccess = !string.IsNullOrEmpty(bonusName) && allowedBonuses.Contains(bonusName); var metadataForRule = GenerateFullRuleDescriptionAndValue( VerificationStep.RecentBonus, ComparisonEnum.Of, string.Join(",", allowedBonuses.ToArray()), bonusName); OnRuleFinish(isSuccess, withdrawal.Id, VerificationStep.RecentBonus, metadataForRule); }
private void ValidateHasOfflineWithdrawalExeption(Guid withdrawalId, Payment.Data.Player player, DateTimeOffset?autoVerificationCheckDate) { if (!_configuration.HasWithdrawalExemption) { return; } var ruleResult = PlayerIsAllowedForExemption(player, autoVerificationCheckDate); var metadataForRule = GenerateFullRuleDescriptionAndValue( VerificationStep.WithdrawalExemption, ComparisonEnum.Is, _configuration.HasCompleteDocuments.ToString(), ruleResult.ToString()); OnRuleFinish(true, withdrawalId, VerificationStep.HasDocuments, metadataForRule); }
private void ValidateAccountAge(Guid withdrawalId, Payment.Data.Player player) { if (!_configuration.HasAccountAge) { return; } var isSuccess = true; var daysFromRegistration = (player.DateRegistered - DateTimeOffset.Now).Days * -1; isSuccess = IsRulePassed(_configuration.AccountAgeOperator, _configuration.AccountAge, daysFromRegistration); var metadataForRule = this.GenerateFullRuleDescriptionAndValue( VerificationStep.AccountAge, _configuration.AccountAgeOperator, _configuration.AccountAge.ToString(), daysFromRegistration.ToString()); OnRuleFinish(isSuccess, withdrawalId, VerificationStep.AccountAge, metadataForRule); }
private void ApplyExemptionForThatWithdrawalRequest(Payment.Data.Player player, Guid withdrawalId, OfflineWithdraw withdrawal) { withdrawal.AutoVerificationCheckStatus = CommonVerificationStatus.Passed; withdrawal.Status = WithdrawalStatus.Verified; try { using (var scope = CustomTransactionScope.GetTransactionScope()) { var playerToBeUpdated = _paymentRepository.Players.FirstOrDefault(pl => pl.Id == player.Id); if (playerToBeUpdated != null) { playerToBeUpdated.ExemptLimit -= 1; } _paymentRepository.SaveChanges(); scope.Complete(); } } catch (Exception ex) { throw new ArgumentException(string.Format("There was a problem while decresing player's exemtion limit. For more information:{0}", ex.Message)); } _eventBus.Publish(new WithdrawalVerified( withdrawalId, withdrawal.Amount, DateTime.Now, withdrawal.PlayerBankAccount.Player.Id, withdrawal.PlayerBankAccount.Player.Id, WithdrawalStatus.Verified, string.Format("Withdrawal exemption was applied for:{0}!", withdrawal.PlayerBankAccount.Player.GetFullName()), withdrawal.TransactionNumber, "System")); }