public string Save(SaveTransferSettingsCommand model)
        {
            model.TimezoneId = _brandQueries.GetBrandOrNull(model.Brand).TimezoneId;

            try
            {
                string message;

                Guid transferSettingsId = model.Id;
                if (model.Id == Guid.Empty)
                {
                    transferSettingsId = _settingsCommands.AddSettings(model);
                    message            = "CreatedSuccessfully";
                }
                else
                {
                    _settingsCommands.UpdateSettings(model);
                    message = "UpdatedSuccessfully";
                }

                return(SerializeJson(new { Result = "success", Data = message, Id = transferSettingsId }));
            }
            catch (RegoException regoEx)
            {
                return(SerializeJson(new { Result = "failed", Data = regoEx.Message }));
            }
            catch (ValidationError e)
            {
                return(SerializeJson(new { Result = "failed", Data = e.ErrorMessage }));
            }
        }
        public void UpdateSettings(SaveTransferSettingsCommand model)
        {
            var validationResult = new SaveTransferSettingsValidator().Validate(model);

            if (!validationResult.IsValid)
            {
                throw new RegoException(validationResult.Errors.First().ErrorMessage);
            }

            var transferSettings = _repository.TransferSettings.SingleOrDefault(x => x.Id == model.Id);

            if (transferSettings == null)
            {
                throw new RegoException(string.Format("Unable to find Transfer Settings with Id '{0}'", model.Id));
            }

            transferSettings.MinAmountPerTransaction = model.MinAmountPerTransaction;
            transferSettings.MaxAmountPerTransaction = model.MaxAmountPerTransaction;
            transferSettings.MaxAmountPerDay         = model.MaxAmountPerDay;
            transferSettings.MaxTransactionPerDay    = model.MaxTransactionPerDay;
            transferSettings.MaxTransactionPerWeek   = model.MaxTransactionPerWeek;
            transferSettings.MaxTransactionPerMonth  = model.MaxTransactionPerMonth;
            transferSettings.UpdatedDate             = DateTimeOffset.Now.ToBrandOffset(model.TimezoneId);
            transferSettings.UpdatedBy = _actorInfoProvider.Actor.UserName;
            _repository.SaveChanges();

            _eventBus.Publish(new TransferFundSettingsUpdated
            {
                TransferSettingsId = transferSettings.Id,
                UpdatedBy          = transferSettings.UpdatedBy,
                Updated            = transferSettings.UpdatedDate
            });
        }
        public async void Validate_if_transfer_quantity_perWeek_less_than_MaxTransactionPerWeek()
        {
            // Arrange
            _paymentTestHelper.MakeDeposit(_playerId, 10);
            _previousTransferDaysShift = -8;

            _transferFundTestHelper.AddTransfer(_brand, _playerId, _walletTemplateId, _repository, _previousTransferDaysShift);
            var transferSettings = new SaveTransferSettingsCommand {
                MaxTransactionPerWeek = 1, Wallet = _walletTemplateId.ToString()
            };

            _transferFundTestHelper.CreateTransferSettings(_brand, transferSettings, _walletTemplateId);

            var transferFundRequest = new TransferFundRequest
            {
                Amount       = 1,
                PlayerId     = _playerId,
                TransferType = TransferFundType.FundIn,
                WalletId     = _walletTemplateId.ToString()
            };

            //Act
            (await _validationService.Validate(transferFundRequest)).IsValid
            .Should().BeTrue();
        }
        public async void Not_validate_if_transfer_quantity_perMonth_greater_than_MaxTransactionPerMonth()
        {
            // Arrange
            _paymentTestHelper.MakeDeposit(_playerId, 10);
            _previousTransferDaysShift = -29;

            _transferFundTestHelper.AddTransfer(_brand, _playerId, _walletTemplateId, _repository, _previousTransferDaysShift);
            var transferSettings = new SaveTransferSettingsCommand {
                MaxTransactionPerMonth = 1, Wallet = _walletTemplateId.ToString()
            };

            _transferFundTestHelper.CreateTransferSettings(_brand, transferSettings, _walletTemplateId);

            var transferFundRequest = new TransferFundRequest
            {
                Amount       = 1,
                PlayerId     = _playerId,
                TransferType = TransferFundType.FundIn,
                WalletId     = _walletTemplateId.ToString()
            };

            //Act
            (await _validationService.Validate(transferFundRequest)).ErrorMessage
            .Should().Contain("transfers per day exceed monthly limit");
        }
Ejemplo n.º 5
0
        public void Update_transfer_settgins_limits_test()
        {
            // Arrange
            var transferSettings = new TransferSettings();

            transferSettings.Id = new Guid("84c60b9f-16ad-49e0-bb9a-0e7670054dd5");
            _paymentRepository.TransferSettings.Add(transferSettings);

            var saveTransferSettingsCommand = new SaveTransferSettingsCommand();

            saveTransferSettingsCommand.Id = transferSettings.Id;
            saveTransferSettingsCommand.MinAmountPerTransaction = 10;
            saveTransferSettingsCommand.MaxAmountPerTransaction = 20;
            saveTransferSettingsCommand.MaxAmountPerDay         = 30;
            saveTransferSettingsCommand.MaxTransactionPerDay    = 40;
            saveTransferSettingsCommand.MaxTransactionPerWeek   = 50;
            saveTransferSettingsCommand.MaxTransactionPerMonth  = 60;
            saveTransferSettingsCommand.TimezoneId = TestDataGenerator.GetRandomTimeZone().Id;

            // Act
            _commands.UpdateSettings(saveTransferSettingsCommand);

            //Assert
            var settings = _paymentRepository.TransferSettings.Single(x => x.Id == transferSettings.Id);

            settings.MinAmountPerTransaction.ShouldBeEquivalentTo(10);
            settings.MaxAmountPerTransaction.ShouldBeEquivalentTo(20);
            settings.MaxAmountPerDay.ShouldBeEquivalentTo(30);
            settings.MaxTransactionPerDay.ShouldBeEquivalentTo(40);
            settings.MaxTransactionPerWeek.ShouldBeEquivalentTo(50);
            settings.MaxTransactionPerMonth.ShouldBeEquivalentTo(60);
            settings.UpdatedBy.ShouldBeEquivalentTo(_securityProvider.Actor.UserName);
            settings.UpdatedDate.Should().BeCloseTo(DateTime.Now, 5000);
        }
        public void CreateTransferSettings(
            Core.Brand.Interface.Data.Brand brand,
            SaveTransferSettingsCommand saveTransferSettingsCommand,
            Guid walletTemplateId,
            TransferFundType transferType,
            string currencyCode,
            Guid vipLevel)
        {
            var transferSettings = new SaveTransferSettingsCommand
            {
                Brand        = brand.Id,
                Licensee     = brand.Licensee.Id,
                TimezoneId   = brand.TimezoneId,
                TransferType = transferType,
                Currency     = currencyCode,
                //VipLevel = vipLevel.ToString(),
                VipLevel = vipLevel,
                Wallet   = walletTemplateId.ToString(),
                MinAmountPerTransaction = saveTransferSettingsCommand.MinAmountPerTransaction,
                MaxAmountPerTransaction = saveTransferSettingsCommand.MaxAmountPerTransaction,
                MaxAmountPerDay         = saveTransferSettingsCommand.MaxAmountPerDay,
                MaxTransactionPerDay    = saveTransferSettingsCommand.MaxTransactionPerDay,
                MaxTransactionPerWeek   = saveTransferSettingsCommand.MaxTransactionPerWeek,
                MaxTransactionPerMonth  = saveTransferSettingsCommand.MaxTransactionPerMonth
            };

            var transferSettingsId = _transferSettingsCommands.AddSettings(transferSettings);

            _transferSettingsCommands.Enable(transferSettingsId, brand.TimezoneId, "remark");
        }
        public Guid AddSettings(SaveTransferSettingsCommand model)
        {
            var validationResult = new SaveTransferSettingsValidator().Validate(model);

            if (!validationResult.IsValid)
            {
                throw new RegoException(validationResult.Errors.First().ErrorMessage);
            }

            if (_repository.TransferSettings.Any(x => x.Id == model.Id))
            {
                throw new RegoException(TransferFundSettingsErrors.AlreadyExistsError.ToString());
            }

            if (_repository.TransferSettings.Any(
                    x => x.BrandId == model.Brand &&
                    x.VipLevelId == model.VipLevel &&
                    x.TransferType == model.TransferType &&
                    x.CurrencyCode == model.Currency &&
                    x.WalletId == model.Wallet))
            {
                throw new RegoException(TransferFundSettingsErrors.AlreadyExistsError.ToString());
            }

            var transferSettings = new AFT.RegoV2.Core.Payment.Data.TransferSettings();

            transferSettings.Id                      = model.Id == Guid.Empty ? Guid.NewGuid() : model.Id;
            transferSettings.BrandId                 = model.Brand;
            transferSettings.CurrencyCode            = model.Currency;
            transferSettings.VipLevelId              = model.VipLevel;
            transferSettings.TransferType            = model.TransferType;
            transferSettings.WalletId                = model.Wallet;
            transferSettings.CreatedDate             = DateTimeOffset.Now.ToBrandOffset(model.TimezoneId);
            transferSettings.CreatedBy               = _actorInfoProvider.Actor.UserName;
            transferSettings.MinAmountPerTransaction = model.MinAmountPerTransaction;
            transferSettings.MaxAmountPerTransaction = model.MaxAmountPerTransaction;
            transferSettings.MaxAmountPerDay         = model.MaxAmountPerDay;
            transferSettings.MaxTransactionPerDay    = model.MaxTransactionPerDay;
            transferSettings.MaxTransactionPerWeek   = model.MaxTransactionPerWeek;
            transferSettings.MaxTransactionPerMonth  = model.MaxTransactionPerMonth;
            _repository.TransferSettings.Add(transferSettings);
            _repository.SaveChanges();

            _eventBus.Publish(new TransferFundSettingsCreated
            {
                TransferSettingsId = transferSettings.Id,
                CreatedBy          = transferSettings.CreatedBy,
                Created            = transferSettings.CreatedDate
            });

            return(transferSettings.Id);
        }
Ejemplo n.º 8
0
        public void Should_not_throw_exception_with_zero_values_in_add_transferSettings()
        {
            // Arrange
            var saveSettingsCommand = new SaveTransferSettingsCommand();

            saveSettingsCommand.TimezoneId = TestDataGenerator.GetRandomTimeZone().Id;

            // Act
            Action action = () => _commands.AddSettings(saveSettingsCommand);

            //Assert
            action.ShouldNotThrow();
        }
Ejemplo n.º 9
0
        public void Should_throw_exception_if_negative_values_in_MaxTransactionPerDay()
        {
            // Arrange
            var saveSettingsCommand = new SaveTransferSettingsCommand();

            saveSettingsCommand.MaxTransactionPerDay = -1;
            saveSettingsCommand.TimezoneId           = TestDataGenerator.GetRandomTimeZone().Id;

            // Act
            Action action = () => _commands.AddSettings(saveSettingsCommand);

            //Assert
            action.ShouldThrow <RegoException>().WithMessage("MaxTransactionPerDayError");
        }
Ejemplo n.º 10
0
        public void Should_throw_exception_if_MaxTransactionsPerDay_greater_than_MaxTransactionsPerMonth_in_add_transferSettings()
        {
            // Arrange
            var saveSettingsCommand = new SaveTransferSettingsCommand();

            saveSettingsCommand.MaxTransactionPerDay   = 2;
            saveSettingsCommand.MaxTransactionPerMonth = 1;
            saveSettingsCommand.TimezoneId             = TestDataGenerator.GetRandomTimeZone().Id;

            // Act
            Action action = () => _commands.AddSettings(saveSettingsCommand);

            //Assert
            action.ShouldThrow <RegoException>().WithMessage("MaxTransactionPerMonthErrorPerDay");
        }
Ejemplo n.º 11
0
        public void Should_throw_exception_if_MaxAmountPerTransaction_equal_MinAmountPerTransaction_in_add_transferSettings()
        {
            // Arrange
            var saveSettingsCommand = new SaveTransferSettingsCommand();

            saveSettingsCommand.MinAmountPerTransaction = 1;
            saveSettingsCommand.MaxAmountPerTransaction = 1;
            saveSettingsCommand.TimezoneId = TestDataGenerator.GetRandomTimeZone().Id;

            // Act
            Action action = () => _commands.AddSettings(saveSettingsCommand);

            //Assert
            action.ShouldThrow <RegoException>().WithMessage("MaxminAmountPerTransactionError");
        }
        public override void BeforeAll()
        {
            base.BeforeAll();
            var brandTestHelper    = _container.Resolve <BrandTestHelper>();
            var transferTestHelper = _container.Resolve <TransferFundTestHelper>();
            var paymentTestHelper  = _container.Resolve <PaymentTestHelper>();
            var playerTestHelper   = _container.Resolve <PlayerTestHelper>();
            var playerQueries      = _container.Resolve <PlayerQueries>();
            var playerCommands     = _container.Resolve <PlayerCommands>();
            var brandQueries       = _container.Resolve <BrandQueries>();

            //create vip level for a brand
            //TODO: Igor  -  needs to generate new vip level for a brand here
            //change default VIP Level for Brand
            //TODO: Igor  -  change default VIP Level for Brand 138

            _brand = brandQueries.GetBrand(DefaultBrandId);

            var vipLevel = _brand.DefaultVipLevel; //needs to be changed for multiple times run

            //create fund-in transfer settings for the brand and vip level
            var transferSettings = new SaveTransferSettingsCommand
            {
                MinAmountPerTransaction = MinAmountPerTransaction,
                MaxAmountPerTransaction = MaxAmountPerTransaction
            };

            var walletTemplateId = _brand.WalletTemplates.Single(x => x.IsMain).Id;

            transferTestHelper.CreateTransferSettings(_brand, transferSettings, walletTemplateId, TransferFundType.FundIn, "CAD", vipLevel.Id);

            //create a player
            _player = playerTestHelper.CreatePlayerForMemberWebsite(currencyCode: "CAD", password: "******");

            //deposit money to the player's main balance
            paymentTestHelper.MakeDeposit(_player.Username, 200);
            var playerId = playerQueries.GetPlayerByUsername(_player.Username).Id;

            //change the vip level of the player
            playerCommands.ChangeVipLevel(playerId, vipLevel.Id, "changed vip level");
        }
        private SaveTransferSettingsCommand CreateNewTransferSettingsData()
        {
            var brandTestHelper = Container.Resolve <BrandTestHelper>();

            var licensee = brandTestHelper.CreateLicensee();
            var brand    = brandTestHelper.CreateBrand(licensee, isActive: true);

            var saveSettingsCommand = new SaveTransferSettingsCommand
            {
                Licensee = licensee.Id,
                Brand    = brand.Id,
                MinAmountPerTransaction = 1,
                MaxAmountPerTransaction = 100,
                MaxAmountPerDay         = 500,
                MaxTransactionPerDay    = 1,
                MaxTransactionPerWeek   = 5,
                MaxTransactionPerMonth  = 10,
                TimezoneId = TestDataGenerator.GetRandomTimeZone().Id
            };

            return(saveSettingsCommand);
        }
        public async void Not_validate_if_Amount_greater_than_MaxAmountPerDay()
        {
            // Arrange
            _paymentTestHelper.MakeDeposit(_playerId, 10);
            var transferSettings = new SaveTransferSettingsCommand {
                MaxAmountPerDay = 1, Wallet = _walletTemplateId.ToString()
            };

            _transferFundTestHelper.CreateTransferSettings(_brand, transferSettings, _walletTemplateId);

            var transferFundRequest = new TransferFundRequest
            {
                Amount       = 2,
                PlayerId     = _playerId,
                TransferType = TransferFundType.FundIn,
                WalletId     = _walletTemplateId.ToString()
            };

            //Act
            (await _validationService.Validate(transferFundRequest)).ErrorMessage
            .Should().Contain("amounts exceed the daily limit");
        }
        public async void Not_validate_if_Amount_less_than_MinAmountPerTransaction()
        {
            // Arrange
            _paymentTestHelper.MakeDeposit(_playerId, 10);
            var transferSettings = new SaveTransferSettingsCommand {
                MinAmountPerTransaction = 2, Wallet = _walletTemplateId.ToString()
            };

            _transferFundTestHelper.CreateTransferSettings(_brand, transferSettings, _walletTemplateId);

            var transferFundRequest = new TransferFundRequest
            {
                Amount       = 1,
                PlayerId     = _playerId,
                TransferType = TransferFundType.FundIn,
                WalletId     = _walletTemplateId.ToString()
            };

            //Act
            (await _validationService.Validate(transferFundRequest)).ErrorMessage
            .Should().Contain("amount is below the allowed value");
        }
Ejemplo n.º 16
0
        public void Should_throw_exception_if_try_to_add_same_settings()
        {
            // Arrange

            var timeZoneId = TestDataGenerator.GetRandomTimeZone().Id;

            var savePaymentSettingsCommand1 = new SaveTransferSettingsCommand();

            //required field
            savePaymentSettingsCommand1.TimezoneId = timeZoneId;
            _commands.AddSettings(savePaymentSettingsCommand1);

            var savePaymentSettingsCommand2 = new SaveTransferSettingsCommand();

            //required field
            savePaymentSettingsCommand1.TimezoneId = timeZoneId;

            // Act
            Action action = () => _commands.AddSettings(savePaymentSettingsCommand2);

            //Assert
            action.ShouldThrow <RegoException>().WithMessage("AlreadyExistsError");
        }