Exemple #1
0
        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);
        }
Exemple #2
0
        private void ValidateWinningsToDepositPercentageIncrease(OfflineWithdraw withdrawal, Guid playerId)
        {
            if (!_configuration.HasWinningsToDepositPercentageIncreaseCheck)
            {
                return;
            }

            var playersApprovedWithdraws = _paymentRepository.OfflineWithdraws
                                           .Where(o => o != null)
                                           .Where(o => o.PlayerBankAccount.Player.Id == playerId && o.Status == WithdrawalStatus.Approved)
                                           .ToList();

            var playersApprovedDeposits = _paymentRepository.OfflineDeposits
                                          .Where(o => o.PlayerId == playerId && o.Status == OfflineDepositStatus.Approved);

            var totalWithdrawal = playersApprovedWithdraws.Sum(o => o.Amount);
            var totalDeposit    = playersApprovedDeposits.Sum(o => o.Amount);
            var currentBalance  = _gameRepository.Wallets.Where(o => o.PlayerId == playerId)
                                  .Sum(o => o.Balance); // Clarify waht should be added here Main or Total from the wallets
            var currentWinnings           = totalDeposit - (totalWithdrawal + currentBalance + withdrawal.Amount);
            var winningsToDepositIncrease = (currentWinnings * 100 / totalDeposit);

            var isSuccess = IsRulePassed(_configuration.WinningsToDepositPercentageIncreaseOperator,
                                         _configuration.WinningsToDepositPercentageIncrease, winningsToDepositIncrease);

            var metadataForRule = GenerateFullRuleDescriptionAndValue(
                VerificationStep.WinningsToDepositPercentageIncrease,
                _configuration.WinningsToDepositPercentageIncreaseOperator,
                _configuration.WinningsToDepositPercentageIncrease.ToString(CultureInfo.InvariantCulture),
                winningsToDepositIncrease.ToString(CultureInfo.InvariantCulture));

            OnRuleFinish(isSuccess, withdrawal.Id, VerificationStep.WinningsToDepositPercentageIncrease, metadataForRule);
        }
Exemple #3
0
        private void SetWithdrawalProperties(OfflineWithdraw withdrawal, WithdrawalStatus status)
        {
            _paymentRepository.OfflineWithdraws.Add(withdrawal);

            withdrawal.Amount            = 1000;
            withdrawal.Id                = _observedWithdrawalId;
            withdrawal.PlayerBankAccount =
                _paymentRepository.PlayerBankAccounts
                .Include(x => x.Player)
                .First(x => x.Player.Id == _player.Id);

            withdrawal.Status = status;
            _paymentRepository.SaveChanges();
        }
Exemple #4
0
        public void Reverted_withdrawal_goes_from_AQ_to_VQ()
        {
            //Create a withdrawal to go to the "On Acceptance queue"
            var withdrawal = new OfflineWithdraw();

            SetWithdrawalProperties(withdrawal, WithdrawalStatus.Verified);

            _withdrawalService.Revert(_observedWithdrawalId, "Revert withdrawal request.");

            var withdrawalsInTheVerificationQueue = _withdrawalService.GetWithdrawalsForVerificationQueue();

            //Assert that the withdrawal request was moved to the "On Hold Queue"
            Assert.IsTrue(withdrawalsInTheVerificationQueue.Any(wd => wd.Id == _observedWithdrawalId));
        }
Exemple #5
0
        public void Withdrawal_goes_from_VQ_to_OHQ_after_investigation()
        {
            //Create a withdrawal in the "Verification Queue"
            var withdrawal = new OfflineWithdraw();

            SetWithdrawalProperties(withdrawal, WithdrawalStatus.AutoVerificationFailed);

            //Move withdrawal to the "On Hold Queue"
            _withdrawalService.SetInvestigateState(_observedWithdrawalId, "Investigate withdrawal request.");

            //Assert that the withdrawal request was moved to the "On Hold Queue"
            var withdrawalsInTheOnHoldQueue = _withdrawalService.GetWithdrawalsOnHold();

            Assert.IsTrue(withdrawalsInTheOnHoldQueue.Any(wd => wd.Id == _observedWithdrawalId));
        }
Exemple #6
0
        public void Withdrawal_goes_from_VQ_to_AQ_after_verification()
        {
            //Create a withdrawal to go to the "Verification Queue"
            var withdrawal = new OfflineWithdraw();

            SetWithdrawalProperties(withdrawal, WithdrawalStatus.AutoVerificationFailed);

            //Move withdrawal to the "Acceptance Queue"
            _withdrawalService.Verify(_observedWithdrawalId, "Verify withdrawal request.");

            //Assert that the withdrawal request was moved to the "Acceptance queue"
            var withdrawalsInTheAcceptanceQueue = _withdrawalService.GetWithdrawalsVerified();

            Assert.IsTrue(withdrawalsInTheAcceptanceQueue.Any(wd => wd.Id == _observedWithdrawalId));
        }
Exemple #7
0
        private void ValidatePaymentMethod(OfflineWithdraw withdrawal)
        {
            if (!_configuration.HasPaymentMethodCheck)
            {
                return;
            }

            var allowedPaymentMethods = _configuration.AllowedPaymentMethods.Select(o => o.Code);

            var isSuccess = allowedPaymentMethods.Contains(withdrawal.PaymentMethod.ToString());

            var metadataForRule = GenerateFullRuleDescriptionAndValue(
                VerificationStep.PaymentMethod,
                ComparisonEnum.Of,
                string.Join(",", allowedPaymentMethods.ToArray()),
                withdrawal.PaymentMethod.ToString());

            OnRuleFinish(isSuccess, withdrawal.Id, VerificationStep.PaymentMethod, metadataForRule);
        }
Exemple #8
0
        private void ValidateWithdrawalAveragePercentageChange(OfflineWithdraw withdrawal, Guid playerId)
        {
            if (!_configuration.HasWithdrawalAveragePercentageCheck)
            {
                return;
            }

            var playersApprovedWithdraws = _paymentRepository.OfflineWithdraws
                                           .Where(o => o.PlayerBankAccount.Player.Id == playerId && o.Status == WithdrawalStatus.Approved).ToList();

            if (!playersApprovedWithdraws.Any())
            {
                var metaForRule = GenerateFullRuleDescriptionAndValue(
                    VerificationStep.WithdrawalAveragePercentageCheck,
                    _configuration.WithdrawalAveragePercentageOperator,
                    _configuration.WithdrawalAveragePercentage.ToString(CultureInfo.InvariantCulture),
                    Convert.ToString(0));

                OnRuleFinish(true, withdrawal.Id, VerificationStep.WithdrawalAveragePercentageCheck, metaForRule);
                return;
            }

            var totalWithdrawalAmount = playersApprovedWithdraws.Sum(o => o.Amount);
            var totalWithdrawalCount  = playersApprovedWithdraws.Count;
            var withdrawalAve         = totalWithdrawalAmount / totalWithdrawalCount;
            var withdrawalDiff        = withdrawal.Amount - withdrawalAve;
            var withdrawalAveChange   = withdrawalDiff * 100 / withdrawalAve;
            var isSuccess             = IsRulePassed(_configuration.WithdrawalAveragePercentageOperator,
                                                     _configuration.WithdrawalAveragePercentage, withdrawalAveChange);


            var metadataForRule = GenerateFullRuleDescriptionAndValue(
                VerificationStep.WithdrawalAveragePercentageCheck,
                _configuration.WithdrawalAveragePercentageOperator,
                _configuration.WithdrawalAveragePercentage.ToString(CultureInfo.InvariantCulture),
                withdrawalAveChange.ToString(CultureInfo.InvariantCulture));

            OnRuleFinish(isSuccess, withdrawal.Id, VerificationStep.WithdrawalAveragePercentageCheck, metadataForRule);
        }
        private object GenerateWithdawalInfoResponse(Guid id,
                                                     OfflineWithdraw withdrawal,
                                                     OfflineWithdrawalHistory verificationQueue,
                                                     OfflineWithdrawalHistory onHoldQueue)
        {
            var response = new
            {
                BaseInfo = new
                {
                    Licensee = withdrawal.PlayerBankAccount.Bank.Brand.LicenseeName,
                    Brand    = withdrawal.PlayerBankAccount.Bank.Brand.Name,
                    withdrawal.PlayerBankAccount.Player.Username,
                    ReferenceCode = withdrawal.TransactionNumber,
                    Status        =
                        withdrawal.Status == WithdrawalStatus.AutoVerificationFailed
                            ? WithdrawalStatus.New.ToString()
                            : withdrawal.Status.ToString(),
                    InternalAccount = "no", //TODO: wtf
                    Currency        = withdrawal.PlayerBankAccount.Player.CurrencyCode,
                    PaymentMethod   = withdrawal.PaymentMethod.ToString(),
                    Amount          = withdrawal.Amount.ToString(CultureInfo.InvariantCulture),
                    Submitted       = withdrawal.CreatedBy,
                    DateSubmitted   = Format.FormatDate(withdrawal.Created)
                },
                BankInformation = new
                {
                    withdrawal.PlayerBankAccount.Bank.BankName,
                    BankAccountName   = withdrawal.PlayerBankAccount.AccountName,
                    BankAccountNumber = withdrawal.PlayerBankAccount.AccountNumber,
                    withdrawal.PlayerBankAccount.Branch,
                    withdrawal.PlayerBankAccount.SwiftCode,
                    withdrawal.PlayerBankAccount.Address,
                    withdrawal.PlayerBankAccount.City,
                    withdrawal.PlayerBankAccount.Province
                },
                ProcessInformation = new
                {
                    AutoVerification = new
                    {
                        HasAutoVerification = withdrawal.AutoVerificationCheckStatus != null,
                        Status =
                            withdrawal.AutoVerificationCheckStatus != null
                                ? withdrawal.AutoVerificationCheckStatus.ToString()
                                : "",
                        Date =
                            withdrawal.AutoVerificationCheckDate != null
                                ? Format.FormatDate(withdrawal.AutoVerificationCheckDate)
                                : ""
                    },
                    RiskLevel = new
                    {
                        HasRiskLevel = withdrawal.RiskLevelStatus != null,
                        Status       =
                            withdrawal.RiskLevelStatus != null
                                ? withdrawal.RiskLevelStatus.ToString()
                                : "",
                        Date =
                            withdrawal.RiskLevelCheckDate != null
                                ? Format.FormatDate(withdrawal.RiskLevelCheckDate)
                                : ""
                    },
                    VerificationQueue = new
                    {
                        HasResult = verificationQueue != null,
                        Result    = verificationQueue != null?verificationQueue.Action.ToString() : null,
                                        HandledBy   = verificationQueue != null ? verificationQueue.Username : null,
                                        DateHandled = verificationQueue != null?Format.FormatDate(verificationQueue.DateCreated) : null
                    },
                    OnHoldQueue = new
                    {
                        HasResult = onHoldQueue != null,
                        Result    = onHoldQueue != null?onHoldQueue.Action.ToString() : null,
                                        HandledBy   = onHoldQueue != null ? onHoldQueue.Username : null,
                                        DateHandled = onHoldQueue != null?Format.FormatDate(onHoldQueue.DateCreated) : null
                    }
                },
                Remarks = new
                {
                    AdminRemarks  = GetWithdrawalHistoryFormattedRemakrs(id, true),
                    PlayerRemarks = GetWithdrawalHistoryFormattedRemakrs(id)
                },
                Officer = _actorInfoProvider.Actor.UserName
            };

            return(response);
        }