private void UpdateWinningRules(AutoVerificationCheckConfiguration entity, AVCConfigurationDTO data)
        {
            foreach (var rule in entity.WinningRules.ToList())
            {
                _fraudRepository.WinningRules.Remove(rule);
            }

            foreach (var rule in data.WinningRules)
            {
                _fraudRepository.WinningRules.Add(CreateWinningRuleEntity(rule, entity));
            }

            _fraudRepository.SaveChanges();
        }
Ejemplo n.º 2
0
        private string GetCriteriasString(AutoVerificationCheckConfiguration autoVerificationCheckConfiguration)
        {
            //TODO: I think next query has to be refactored. It doesn't seem to be consistent. Plus, it sets a constraint over the namings
            //TODO: and this is not something well known by all the developers.

            var type           = autoVerificationCheckConfiguration.GetType();
            var criteriasCount =
                type
                .GetProperties()
                .Where(x => x.Name.StartsWith("has", StringComparison.InvariantCultureIgnoreCase))
                .Count(x => (bool)x.GetValue(autoVerificationCheckConfiguration));

            return(string.Format("Criterias count: {0}", criteriasCount));
        }
Ejemplo n.º 3
0
        public override void BeforeAll()
        {
            base.BeforeAll();

            _paymentTestHelper = _container.Resolve <PaymentTestHelper>();
            _playerCommands    = _container.Resolve <PlayerCommands>();
            _brandTestHelper   = _container.Resolve <BrandTestHelper>();
            _playerTestHelper  = _container.Resolve <PlayerTestHelper>();
            _autoVerificationConfigurationTestHelper = _container.Resolve <AutoVerificationConfigurationTestHelper>();
            _riskProfileCheckTestHelper = _container.Resolve <RiskProfileCheckTestHelper>();

            //create a not default VIP Level for Brand
            _vipLevel = _brandTestHelper.CreateNotDefaultVipLevel(DefaultBrandId);

            //create a player for the DefaultBrandId
            var player   = _playerTestHelper.CreatePlayer(isActive: true, brandId: DefaultBrandId);
            var playerId = player.Id;

            _player         = _container.Resolve <PlayerQueries>().GetPlayer(playerId);
            _playerUsername = _player.Username;

            _paymentTestHelper.CreatePlayerBankAccount(playerId, DefaultBrandId, true);

            //change the VIP Level for Player
            _playerCommands.ChangeVipLevel(playerId, _vipLevel.Id, "changed vip level");

            //deposit
            _paymentTestHelper.MakeDeposit(_playerUsername, 100);
            _paymentTestHelper.MakeDeposit(_playerUsername, 200);
            _paymentTestHelper.MakeDeposit(_playerUsername, 300);

            //create Auto Verification configuration which expected to be failed
            _avcConfigurationBuilder = new AvcConfigurationBuilder(DefaultBrandId, new [] { _vipLevel.Id }, "CAD");
            _avcConfigurationBuilder.SetupTotalDepositAmount(1500, ComparisonEnum.GreaterOrEqual);
            _avcDTO = _avcConfigurationBuilder.Configuration;

            _avc = _autoVerificationConfigurationTestHelper.CreateConfiguration(_avcDTO);
            _autoVerificationConfigurationTestHelper.Activate(_avc.Id);

            //create Risk Profile Check configuration
            _riskProfileCheckConfigurationBuilder = new RiskProfileCheckConfigurationBuilder(DefaultBrandId, _avcDTO.Licensee, "CAD", new List <Guid> {
                _vipLevel.Id
            });
            _rpcDTO = _riskProfileCheckConfigurationBuilder.Configuration;
            var createdConfigurationEntity = _riskProfileCheckTestHelper.CreateConfiguration(_rpcDTO);

            _rpcDTO.Id = createdConfigurationEntity.Id;
        }
        public override void BeforeAll()
        {
            base.BeforeAll();

            _paymentTestHelper = _container.Resolve <PaymentTestHelper>();
            _playerCommands    = _container.Resolve <PlayerCommands>();
            _brandTestHelper   = _container.Resolve <BrandTestHelper>();
            _playerTestHelper  = _container.Resolve <PlayerTestHelper>();
            _autoVerificationConfigurationTestHelper = _container.Resolve <AutoVerificationConfigurationTestHelper>();


            //create a not default VIP Level for Brand
            _vipLevel = _brandTestHelper.CreateNotDefaultVipLevel(DefaultBrandId);

            //create a player for the DefaultBrandId
            var player   = _playerTestHelper.CreatePlayer(isActive: true, brandId: DefaultBrandId);
            var playerId = player.Id;

            _player         = _container.Resolve <PlayerQueries>().GetPlayer(playerId);
            _playerUsername = _player.Username;

            _paymentTestHelper.CreatePlayerBankAccount(playerId, DefaultBrandId, true);

            //change the VIP Level for Player
            _playerCommands.ChangeVipLevel(playerId, _vipLevel.Id, "changed vip level");

            //deposit
            _paymentTestHelper.MakeDeposit(_playerUsername, 100);
            _paymentTestHelper.MakeDeposit(_playerUsername, 200);
            _paymentTestHelper.MakeDeposit(_playerUsername, 300);


            _avcConfigurationBuilder = new AvcConfigurationBuilder(DefaultBrandId, new[] { _vipLevel.Id }, "CAD");

            _avcDTO = _avcConfigurationBuilder.Configuration;

            _avc = _autoVerificationConfigurationTestHelper.CreateConfiguration(_avcDTO);
            _autoVerificationConfigurationTestHelper.Activate(_avc.Id);
        }
Ejemplo n.º 5
0
        public override void BeforeAll()
        {
            base.BeforeAll();

            _paymentTestHelper = _container.Resolve <PaymentTestHelper>();
            _playerCommands    = _container.Resolve <PlayerCommands>();
            _playerTestHelper  = _container.Resolve <PlayerTestHelper>();
            _autoVerificationConfigurationTestHelper = _container.Resolve <AutoVerificationConfigurationTestHelper>();


            var brand = _container.Resolve <BrandQueries>().GetBrand(DefaultBrandId);

            _vipLevel = brand.DefaultVipLevel;
            //create a not default VIP Level for Brand

            //create a player for the DefaultBrandId
            _player = _playerTestHelper.CreatePlayer(isActive: true, brandId: DefaultBrandId);
            var playerId = _player.Id;

            _playerUsername = _player.Username;

            _paymentTestHelper.CreatePlayerBankAccount(playerId, DefaultBrandId, true);

            //change the VIP Level for Player
            _playerCommands.ChangeVipLevel(playerId, _vipLevel.Id, "changed vip level");

            //deposit
            _paymentTestHelper.MakeDeposit(_playerUsername, 200);


            //create Auto Verification configuration which expected to be failed
            _avcConfigurationBuilder = new AvcConfigurationBuilder(DefaultBrandId, new[] { _vipLevel.Id }, "CAD");
            _avcConfigurationBuilder.SetupTotalDepositAmount(1500, ComparisonEnum.GreaterOrEqual);
            _avcDTO = _avcConfigurationBuilder.Configuration;

            _avc = _autoVerificationConfigurationTestHelper.CreateConfiguration(_avcDTO);
            _autoVerificationConfigurationTestHelper.Activate(_avc.Id);
        }
        public AutoVerificationCheckConfiguration Create(AVCConfigurationDTO data)
        {
            ValidateAvcEntity(data, AvcConfigurationDtoQueriesEnum.Create);

            var entity = new AutoVerificationCheckConfiguration
            {
                Id = data.Id,
                HasFraudRiskLevel = data.HasFraudRiskLevel,
                BrandId           = data.Brand,
                Brand             = _fraudRepository.Brands.First(x => x.Id == data.Brand),
                Currency          = data.Currency,
                DateCreated       = DateTimeOffset.UtcNow,

                HasWinLoss      = data.HasWinLoss,
                WinLossAmount   = data.WinLossAmount,
                WinLossOperator = data.WinLossOperator,

                HasCompleteDocuments = data.HasCompleteDocuments,

                HasWithdrawalExemption = data.HasWithdrawalExemption,

                HasTotalDepositAmount      = data.HasTotalDepositAmount,
                TotalDepositAmount         = data.TotalDepositAmount,
                TotalDepositAmountOperator = data.TotalDepositAmountOperator,

                HasDepositCount           = data.HasDepositCount,
                TotalDepositCountAmount   = data.TotalDepositCountAmount,
                TotalDepositCountOperator = data.TotalDepositCountOperator,

                HasAccountAge      = data.HasAccountAge,
                AccountAge         = data.AccountAge,
                AccountAgeOperator = data.AccountAgeOperator,

                HasWithdrawalCount           = data.HasWithdrawalCount,
                TotalWithdrawalCountAmount   = data.TotalWithdrawalCountAmount,
                TotalWithdrawalCountOperator = data.TotalWithdrawalCountOperator,

                HasNoRecentBonus = data.HasNoRecentBonus,
                CreatedBy        = _actorInfoProvider.Actor.Id,

                HasPaymentLevel = data.HasPaymentLevel,
                Status          = data.Status
            };

            //ToDo: Add validation here
            if (entity.Id == Guid.Empty)
            {
                entity.Id = Guid.NewGuid();
            }

            if (data.HasFraudRiskLevel)
            {
                //Let's add all risk levels.
                var brand = _fraudRepository.Brands
                            .Single(x => x.Id == data.Brand);

                _fraudRepository.RiskLevels
                .Where(x => x.BrandId == brand.Id)
                .ForEach(x => entity.AllowedRiskLevels.Add(x));

                //Let's remove all ignored via UI
                foreach (var riskLevelId in data.RiskLevels)
                {
                    var riskLevel = entity.AllowedRiskLevels.FirstOrDefault(x => x.Id == riskLevelId);
                    if (riskLevel != null)
                    {
                        entity.AllowedRiskLevels.Remove(riskLevel);
                    }
                }
            }

            if (data.HasPaymentLevel)
            {
                entity.PaymentLevels.Clear();

                //Let's add all payment levels.
                var currentlySelectedPaymentLevels = _fraudRepository
                                                     .PaymentLevels
                                                     .Where(x => data.PaymentLevels.Contains(x.Id));

                currentlySelectedPaymentLevels.ForEach(x => entity.PaymentLevels.Add(x));
            }

            if (data.HasWinnings)
            {
                entity.HasWinnings = true;
                foreach (var winningRule in data.WinningRules)
                {
                    var rule = CreateWinningRuleEntity(winningRule, entity);

                    if (winningRule.Period == PeriodEnum.CustomDate)
                    {
                        rule.StartDate = winningRule.StartDate;
                        rule.EndDate   = winningRule.EndDate;
                    }

                    entity.WinningRules.Add(rule);
                }
            }

            entity.VipLevels.Clear();
            data.VipLevels
            .ForEach(id =>
            {
                var vipLevel = _fraudRepository.VipLevels
                               .Single(x => x.Id == id);

                entity.VipLevels.Add(vipLevel);
            });

            using (var scope = CustomTransactionScope.GetTransactionScope())
            {
                _fraudRepository.AutoVerificationCheckConfigurations.Add(entity);
                _fraudRepository.SaveChanges();
                scope.Complete();
            }

            _eventBus.Publish(new AutoVerificationCheckCreated()
            {
                CreatedBy   = _actorInfoProvider.Actor.UserName,
                DateCreated = DateTime.UtcNow
            });

            return(entity);
        }
 private static WinningRule CreateWinningRuleEntity(WinningRuleDTO winningRule, AutoVerificationCheckConfiguration entity)
 {
     return(new WinningRule
     {
         Id = Guid.NewGuid(),
         ProductId = winningRule.ProductId,
         Comparison = winningRule.Comparison,
         Amount = winningRule.Amount,
         Period = winningRule.Period,
         AutoVerificationCheckConfigurationId = entity.Id,
         StartDate = winningRule.StartDate,
         EndDate = winningRule.EndDate
     });
 }
Ejemplo n.º 8
0
        public void Validate(Guid withdrawalId)
        {
            var withdrawal = _paymentRepository
                             .OfflineWithdraws
                             .Include(x => x.PlayerBankAccount)
                             .Single(x => x.Id == withdrawalId);

            var bankAccount =
                _paymentRepository.PlayerBankAccounts
                .Include(x => x.Player)
                .Include(x => x.Player.Brand)
                .FirstOrDefault(x => x.Id == withdrawal.PlayerBankAccount.Id);

            _configuration = _avcConfigurationQueries
                             .GetAutoVerificationCheckConfigurations()
                             .SingleOrDefault(
                x =>
                x.BrandId == bankAccount.Player.BrandId &&
                x.VipLevels.Select(o => o.Id).Contains(bankAccount.Player.VipLevelId) &&
                x.Currency == bankAccount.Player.CurrencyCode &&
                x.Status == AutoVerificationCheckStatus.Active);

            var eventCreated = DateTimeOffset.Now.ToBrandOffset(bankAccount.Player.Brand.TimezoneId);

            if (_configuration == null)
            {
                withdrawal.AutoVerificationCheckDate = DateTimeOffset.UtcNow;
                withdrawal.Status = WithdrawalStatus.Verified;

                _eventBus.Publish(new WithdrawalVerified(
                                      withdrawalId,
                                      withdrawal.Amount,
                                      eventCreated,
                                      withdrawal.PlayerBankAccount.Player.Id,
                                      withdrawal.PlayerBankAccount.Player.Id,
                                      WithdrawalStatus.Verified,
                                      "Automatic auto verification check succeeded!",
                                      withdrawal.TransactionNumber,
                                      "System")
                {
                    EventCreated = eventCreated
                });

                _paymentRepository.SaveChanges();
                return;
            }

            withdrawal.AutoVerificationCheckDate = DateTimeOffset.UtcNow;

            if (_configuration.HasWithdrawalExemption && PlayerIsAllowedForExemption(bankAccount.Player, withdrawal.AutoVerificationCheckDate))
            {
                ApplyExemptionForThatWithdrawalRequest(bankAccount.Player, withdrawalId, withdrawal);
                return;
            }

            base.Validate(_configuration, withdrawalId);

            ValidateTotalDepositAmount(withdrawalId, bankAccount.Player.Id);
            ValidatePlayersWinningsRules(withdrawalId, bankAccount.Player.Id);
            ValidatePaymentLevel(withdrawalId, bankAccount.Player);
            ValidateHasCompleteDocuments(withdrawalId, bankAccount.Player, bankAccount.Player.BrandId);
            ValidateHasOfflineWithdrawalExeption(withdrawalId, bankAccount.Player, withdrawal.AutoVerificationCheckDate);

            if (_withdrawalVerificationLogsQueues.HasFailedCriteras(withdrawalId, VerificationType.AutoVerification))
            {
                withdrawal.AutoVerificationCheckStatus = CommonVerificationStatus.Failed;
                withdrawal.Status = WithdrawalStatus.AutoVerificationFailed;

                eventCreated = DateTimeOffset.Now.ToBrandOffset(bankAccount.Player.Brand.TimezoneId);

                _eventBus.Publish(new WithdrawalUnverified(
                                      withdrawalId,
                                      withdrawal.Amount,
                                      eventCreated,
                                      withdrawal.PlayerBankAccount.Player.Id,
                                      withdrawal.PlayerBankAccount.Player.Id,
                                      WithdrawalStatus.Unverified,
                                      "Automatic auto verification check failed!",
                                      withdrawal.TransactionNumber,
                                      "System")
                {
                    EventCreated = eventCreated
                });
            }
            else
            {
                withdrawal.AutoVerificationCheckStatus = CommonVerificationStatus.Passed;
                withdrawal.Status = WithdrawalStatus.Verified;

                _eventBus.Publish(new WithdrawalVerified(
                                      withdrawalId,
                                      withdrawal.Amount,
                                      eventCreated,
                                      withdrawal.PlayerBankAccount.Player.Id,
                                      withdrawal.PlayerBankAccount.Player.Id,
                                      WithdrawalStatus.Verified,
                                      "Automatic auto verification check succeeded!",
                                      withdrawal.TransactionNumber,
                                      "System")
                {
                    EventCreated = eventCreated
                });
            }

            _paymentRepository.SaveChanges();
        }