public void Unverify(OfflineWithdrawId id, string remarks) { var withdrawal = _repository.OfflineWithdraws.Include(x => x.PlayerBankAccount.Player).Single(x => x.Id == id); if (withdrawal.Status != WithdrawalStatus.AutoVerificationFailed && withdrawal.Status != WithdrawalStatus.Reverted && withdrawal.Status != WithdrawalStatus.Investigation && withdrawal.Status != WithdrawalStatus.Documents) { ThrowStatusError(withdrawal.Status, WithdrawalStatus.Unverified); } var now = _paymentQueries.GetBrandDateTimeOffset(withdrawal.PlayerBankAccount.Player.BrandId); _serviceBus.PublishMessage(new WithdrawRequestCancel { WithdrawId = id, ActorName = _actorInfoProvider.Actor.UserName, CanceledUserId = _actorInfoProvider.Actor.Id, Status = WithdrawalStatus.Unverified, Remarks = remarks, Canceled = now }); }
public SavePaymentGatewaysSettingsResult Add(SavePaymentGatewaysSettingsData model) { var validationResult = new SavePaymentGatewaySettingsValidator(_repository, true).Validate(model); if (!validationResult.IsValid) { throw new RegoValidationException(validationResult); } var setting = new PaymentGatewaySettings { Id = Guid.NewGuid(), BrandId = model.Brand, OnlinePaymentMethodName = model.OnlinePaymentMethodName, PaymentGatewayName = model.PaymentGatewayName, Channel = model.Channel, EntryPoint = model.EntryPoint, Remarks = model.Remarks, Status = Status.Inactive, DateCreated = _paymentQueries.GetBrandDateTimeOffset(model.Brand), CreatedBy = _actorInfoProvider.Actor.UserName }; _repository.PaymentGatewaySettings.Add(setting); using (var scope = CustomTransactionScope.GetTransactionScope()) { _repository.SaveChanges(); _eventBus.Publish(new PaymentGatewaySettingCreated { Id = setting.Id, CreatedBy = setting.CreatedBy, CreatedDate = setting.DateCreated, OnlinePaymentMethodName = setting.OnlinePaymentMethodName, PaymentGatewayName = setting.PaymentGatewayName, Channel = setting.Channel, EntryPoint = setting.EntryPoint, BrandId = setting.BrandId }); scope.Complete(); } return(new SavePaymentGatewaysSettingsResult { PaymentGatewaySettingsId = setting.Id }); }
public async Task <SubmitOnlineDepositRequestResult> SubmitOnlineDepositRequest(OnlineDepositRequest request) { var validationResult = new OnlineDepositRequestValidator(_repository).Validate(request); if (!validationResult.IsValid) { throw new RegoValidationException(validationResult); } var player = _repository.Players.FirstOrDefault(x => x.Id == request.PlayerId); var paymentGetewaySettings = _paymentGatewaySettingsQueries.GetOnePaymentGatewaySettingsByPlayerId(player.Id); if (paymentGetewaySettings == null) { throw new RegoException("PaymentGatewaySettings not found"); } var method = paymentGetewaySettings.OnlinePaymentMethodName; var channel = paymentGetewaySettings.Channel; var paymentUrl = paymentGetewaySettings.EntryPoint; _validator.ValidatePaymentSetting(request.PlayerId, method, request.Amount, player.CurrencyCode); var number = GenerateOrderId(method, channel); var merchantId = GetDepositMerchantId(); var hashKey = GetDepositHashKey(); var depositParams = new OnlineDepositParams(); depositParams.Method = method; depositParams.Channel = channel; depositParams.Amount = request.Amount; depositParams.MerchantId = merchantId; depositParams.OrderId = number; depositParams.Currency = player.CurrencyCode; depositParams.Language = request.CultureCode; depositParams.ReturnUrl = request.ReturnUrl; depositParams.NotifyUrl = request.NotifyUrl; depositParams.Signature = EncryptHelper.GetMD5HashInHexadecimalFormat(depositParams.SignParams + hashKey); var id = Guid.NewGuid(); var brandId = player.BrandId; var now = _paymentQueries.GetBrandDateTimeOffset(brandId); var onlineDepositEntity = new Entities.OnlineDeposit(id, number, request, depositParams, brandId, now); var submitEvent = onlineDepositEntity.Submit(); using (var scope = CustomTransactionScope.GetTransactionScopeAsync()) { if (!string.IsNullOrWhiteSpace(request.BonusCode) || (request.BonusId.HasValue && request.BonusId != Guid.Empty)) { var bonusRedemptionId = await _bonusApiProxy.ApplyForBonusAsync(new DepositBonusApplication { PlayerId = request.PlayerId, BonusId = request.BonusId, Amount = request.Amount, DepositId = onlineDepositEntity.Data.Id, BonusCode = onlineDepositEntity.Data.BonusCode }); onlineDepositEntity.SetBonusRedemption(bonusRedemptionId); } _repository.OnlineDeposits.Add(onlineDepositEntity.Data); _eventBus.Publish(submitEvent); _repository.SaveChanges(); scope.Complete(); } return(new SubmitOnlineDepositRequestResult { DepositId = id, RedirectUrl = new Uri(paymentUrl), RedirectParams = depositParams }); }