예제 #1
0
        public IActionResult GetCommunalsByPhoneNumber(SearchCommunalRequest request)
        {
            if (ModelState.IsValid)
            {
                SingleResponse <List <Communal> > response = new SingleResponse <List <Communal> >();
                string validationResult = _xBService.ValidateSearchData(request.SearchCommunal);
                if (validationResult == "")
                {
                    response.Result = _xBService.GetCommunalsByPhoneNumber(request.SearchCommunal);
                }
                else
                {
                    XBS.ActionResult result = new XBS.ActionResult
                    {
                        ResultCode = ResultCode.ValidationError,
                        Errors     = new List <ActionError>()
                    };

                    ActionError actionError = new ActionError();
                    actionError.Description = validationResult;

                    result.Errors.Add(actionError);
                }
                response.ResultCode = ResultCodes.normal;
                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
        public IActionResult SavePeriodicDataChangeOrder(PeriodicTransferDataChangeOrderRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };
                if (request.Order.ChargeType == 1)
                {
                    request.Order.ChargeType = 0;
                }
                else if (request.Order.ChargeType == 2)
                {
                    request.Order.ChargeType = 1;
                }
                ActionResult saveResult = _xbService.SavePeriodicDataChangeOrder(request.Order);

                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Result      = saveResult.Id;
                response.Description = utils.GetActionResultErrors(saveResult.Errors);

                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
        public IActionResult SaveUtilityPeriodicPaymentOrder(PeriodicUtilityPaymentOrderRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };
                ActionResult saveResult = _xbService.SaveUtilityPeriodicPaymentOrder(request.Order);

                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Result      = saveResult.Id;
                response.Description = utils.GetActionResultErrors(saveResult.Errors);

                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                if (request == null)
                {
                    foreach (var item in ModelState.Keys)
                    {
                        if (item.ToString().ToLower() == "order.CheckDaysCount".ToLower())
                        {
                            return(ValidationError.GetTypeValidationErrorResponse(item, _localizer["Սխալ ստուգման օրերի քանակ"]));
                        }
                    }
                }
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
예제 #4
0
        public IActionResult SaveMatureOrder(MatureOrderRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };
                if (request.Order.Type == OrderType.LoanMature)
                {
                    request.Order.Description = _xbInfoService.GetLoanMatureTypesForIBanking()
                                                .Where(x => x.Key == ((int)request.Order.MatureType)
                                                       .ToString())
                                                .First().Value;
                }
                if (request.Order.MatureType == MatureType.PartialRepayment)
                {
                    request.Order.MatureType = MatureType.RepaymentByCreditCode;
                }
                ActionResult saveResult = _xbService.SaveMatureOrder(request.Order);

                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Result      = saveResult.Id;
                response.Description = utils.GetActionResultErrors(saveResult.Errors);

                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
예제 #5
0
        public IActionResult UpdateCustomerAccountRestConfig(RestConfigRequest request)
        {
            if (ModelState.IsValid)
            {
                SingleResponse <long> response = new SingleResponse <long>();
                var authorizedCustomer         = _cacheHelper.GetAuthorizedCustomer();

                request.ConfigurationItems.ForEach(item => {
                    item.CustomerNumber      = authorizedCustomer.CustomerNumber;
                    item.DigitalUserId       = authorizedCustomer.UserId;
                    item.RegistrationDate    = DateTime.Now;
                    item.ConfigurationTypeId = 2;
                });

                ActionResult saveResult = _xbService.UpdateCustomerAccountRestConfig(request.ConfigurationItems);
                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Result      = saveResult.Id;
                response.Description = utils.GetActionResultErrors(saveResult.Errors);
                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
예제 #6
0
        public IActionResult ApprovePlasticCardOrder(ApproveIdRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };

                PlasticCardOrder order = _cacheHelper.GetApprovalOrder <PlasticCardOrder>(request.Id);
                if (order.Attachments != null)
                {
                    foreach (var item in order.Attachments)
                    {
                        item.AttachmentInBase64 = _xbService.GetOrderAttachmentInBase64(item.Id);
                    }
                }
                ActionResult saveResult = _xbService.ApprovePlasticCardOrder(order);

                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Result      = saveResult.Id;
                response.Description = utils.GetActionResultErrors(saveResult.Errors);

                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
        public IActionResult SaveBudgetPaymentOrder(BudgetPaymentOrderRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };
                if (request.Order.ReceiverAccount.AccountNumber.StartsWith("10300"))
                {
                    request.Order.ReceiverBankCode = 10300; // ոստիկանության բանկի կոդ
                    request.Order.ReceiverAccount.AccountNumber = request.Order.ReceiverAccount.AccountNumber.Substring(5);
                }
                ActionResult saveResult = _xBService.SaveBudgetPaymentOrder(request.Order);
                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Result      = saveResult.Id;
                response.Description = utils.GetActionResultErrors(saveResult.Errors);

                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
예제 #8
0
        public IActionResult SaveAndApproveTokenDeactivationOrder([FromBody] TokenOperationRequest request)
        {
            if (ModelState.IsValid)
            {
                SingleResponse <long> response        = new SingleResponse <long>();
                HBToken            hBToken            = new HBToken();
                ActionResult       result             = new ActionResult();
                AuthorizedCustomer authorizedCustomer = _cacheHelper.GetAuthorizedCustomer();
                _xBService.Use(client =>
                {
                    hBToken = client.GetHBTokenWithSerialNumberAsync(request.TokenSerial).Result;
                });
                if (hBToken == null)
                {
                    byte language = 1;

                    //Լեզու
                    if (!string.IsNullOrEmpty(Request.Headers["language"]))
                    {
                        byte.TryParse(Request.Headers["language"], out language);
                    }

                    result.ResultCode    = ResultCode.ValidationError;
                    response.Description = (Languages)language == Languages.hy ? "Տվյալ համարով տոկեն գոյություն չունի։" : "Token not exist.";
                }
                else
                {
                    //string sessionId = Guid.NewGuid().ToString();
                    //AuthorizeAnonymousMethods(hBToken.HBUser.CustomerNumber, sessionId, hBToken.HBUser.ID, hBToken.HBUser.UserName);
                    //Request.Headers.Add("SessionId", sessionId);

                    HBServletRequestOrder hBServletRequestOrder = new HBServletRequestOrder
                    {
                        RegistrationDate = DateTime.Now,
                        OperationDate    = _xBService.GetCurrentOperDay(),
                        ServletAction    = HBServletAction.DeactivateToken,
                        Type             = OrderType.HBServletRequestTokenDeactivationOrder,
                        SubType          = 1,
                        CustomerNumber   = authorizedCustomer.CustomerNumber,
                        ServletRequest   = null,
                        HBtoken          = hBToken,
                        Source           = SourceType.MobileBanking,
                        FilialCode       = 22000
                    };

                    ActionResult saveActionResult = _xBService.SaveAndApproveTokenOrder(hBServletRequestOrder);
                    response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveActionResult.ResultCode);
                    response.Result      = saveActionResult.Id;
                    response.Description = utils.GetActionResultErrors(saveActionResult.Errors);
                }
                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
 public IActionResult SaveLoanMatureOrderTemplate(LoanMatureOrderTemplateRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <long> response = new SingleResponse <long>();
         XBS.ActionResult      result   = _xbService.SaveLoanMatureOrderTemplate(request.Template);
         response.Result      = result.Id;
         response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
         response.Description = utils.GetActionResultErrors(result.Errors);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
예제 #10
0
 public IActionResult SaveProductNote(ProductNoteRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <long> response = new SingleResponse <long>();
         response.ResultCode = ResultCodes.normal;
         XBS.ActionResult result = _xbService.SaveProductNote(request.ProductNote);
         response.Result      = result.Id;
         response.Description = Utils.GetActionResultErrors(result.Errors);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
        private SingleResponse <long> ApproveAttachedCardOrder(AttachCardPaymentApprovalRequest request)
        {
            SingleResponse <long> response = new SingleResponse <long>()
            {
                ResultCode = ResultCodes.normal
            };

            XBS.ActionResult result = new XBS.ActionResult();
            switch (request.Type)
            {
            case OrderType.RATransfer:
            {
                if (request.SubType == 3)
                {
                    PaymentOrder order = _xBService.GetPaymentOrder(request.Id);
                    result = _xBService.ApprovePaymentOrder(order);
                }
                //else if (request.SubType == 6)
                //{
                //    BudgetPaymentOrder order = _xBService.GetBudgetPaymentOrder(request.Id);
                //    result = _xBService.ApprovePaymentOrder(order);
                //}
            }
            break;

            case OrderType.LoanMature:
            {
                MatureOrder order = _xBService.GetMatureOrder(request.Id);
                result = _xBService.ApproveMatureOrder(order);
            }
            break;

            case OrderType.CommunalPayment:
            {
                UtilityPaymentOrder order = _xBService.GetUtilityPaymentOrder(request.Id);
                result = _xBService.ApproveUtilityPaymentOrder(order);
            }
            break;

            default:
                break;
            }
            response.Result      = result.Id;
            response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
            response.Description = Utils.GetActionResultErrors(result.Errors);
            return(response);
        }
예제 #12
0
        public IActionResult DeletePaymentOrder(IdRequest request)
        {
            if (ModelState.IsValid)
            {
                SingleResponse <long> response = new SingleResponse <long>();
                XBS.ActionResult      result   = _xBService.DeletePaymentOrder(request.Id);

                response.Result      = result.Id;
                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
                response.Description = Utils.GetActionResultErrors(result.Errors);
                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
예제 #13
0
 public IActionResult ApproveReceivedFastTransferPaymentOrder(ApproveIdRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <long>            response = new SingleResponse <long>();
         ReceivedFastTransferPaymentOrder order    = _cacheHelper.GetApprovalOrder <ReceivedFastTransferPaymentOrder>(request.Id);
         XBS.ActionResult result = _xBService.ApproveReceivedFastTransferPaymentOrder(order);
         response.Result      = result.Id;
         response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
         response.Description = Utils.GetActionResultErrors(result.Errors);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
예제 #14
0
 public IActionResult SaveCurrencyExchangeOrderTemplate(CurrencyExchangeOrderTemplateRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <long> response = new SingleResponse <long>();
         request.Template.TemplateCustomerNumber = _cacheHelper.GetAuthorizedCustomer().CustomerNumber;
         XBS.ActionResult result = _xbService.SaveCurrencyExchangeOrderTemplate(request.Template);
         response.Result      = result.Id;
         response.Description = utils.GetActionResultErrors(result.Errors);
         response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
예제 #15
0
 public IActionResult ResetCustomerAccountRestConfig()
 {
     if (ModelState.IsValid)
     {
         SingleResponse <long> response  = new SingleResponse <long>();
         var          authorizedCustomer = _cacheHelper.GetAuthorizedCustomer();
         int          onlineUserId       = authorizedCustomer.UserId;
         ActionResult saveResult         = _xbService.ResetCustomerAccountRestConfig(onlineUserId);
         response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
         response.Result      = saveResult.Id;
         response.Description = utils.GetActionResultErrors(saveResult.Errors);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
        public IActionResult ApproveCashOrder(ApproveIdRequest request)
        {
            if (ModelState.IsValid)
            {
                var       response = new SingleResponse <ActionResult>();
                CashOrder order    = _cacheHelper.GetApprovalOrder <CashOrder>(request.Id);

                ActionResult Result = _xbService.ApproveCashOrder(order);

                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(Result.ResultCode);
                response.ResultCode  = ResultCodes.normal;
                response.Description = utils.GetActionResultErrors(Result.Errors);
                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
예제 #17
0
 public IActionResult SaveReceivedFastTransferPaymentOrder(ReceivedFastTransferPaymentOrderRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <long> response = new SingleResponse <long>();
         request.Order.Quality     = OrderQuality.Draft;
         request.Order.FilialCode  = 22000;
         request.Order.Description = "Non-commercial transfer for personal needs";
         XBS.ActionResult result = _xBService.SaveReceivedFastTransferPaymentOrder(request.Order);
         response.Result      = result.Id;
         response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
         response.Description = Utils.GetActionResultErrors(result.Errors);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
        public async Task <IActionResult> AttachCard([FromBody] AttachCardRequest request)
        {
            SingleResponse <CardAttachmentResponse> httpResponse = new SingleResponse <CardAttachmentResponse>();
            var authorizedCustomer = _cacheHelper.GetAuthorizedCustomer();
            var language           = _cacheHelper.GetLanguage();
            var source             = _cacheHelper.GetSourceType();

            XBS.ActionResult actionResult = _xBService.ValidateAttachCard(request.CardNumber.ToString(), authorizedCustomer.CustomerNumber, request.CardHolderName);
            if (actionResult.Errors.Count == 0)
            {
                var response = await _client.AtachCardOrderAsync(new CardAttachmentRequest
                {
                    CustomerNumber = authorizedCustomer.CustomerNumber,
                    UserId         = authorizedCustomer.UserId,
                    CardNumber     = request.CardNumber,
                    CardHolderName = request.CardHolderName,
                    ExpireMonth    = request.ExpireMonth,
                    ExpireYear     = request.ExpireYear,
                    Cvc            = request.Cvv,
                    Language       = language == 1 ? "hy" : "en",
                    PageView       = source == SourceType.AcbaOnline ? "DESKTOP" : "MOBILE"
                });

                if (response != null)
                {
                    httpResponse.ResultCode = ResultCodes.normal;
                    httpResponse.Result     = response;
                }
                else
                {
                    httpResponse.ResultCode  = ResultCodes.failed;
                    httpResponse.Description = "Քարտի կցման ժամանակ տեղի ունեցավ սխալ։";
                }
            }
            else
            {
                httpResponse.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(actionResult.ResultCode);
                httpResponse.Description = _xBService.GetTerm(actionResult?.Errors[0]?.Code ?? 0, null, (Languages)language);
            }
            return(ResponseExtensions.ToHttpResponse(httpResponse));
        }
예제 #19
0
        public IActionResult CheckDepositOrderCondition(CheckDepositOrderConditionRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };

                ActionResult saveResult = _xbService.CheckDepositOrderCondition(request.Order);
                response.Result      = saveResult.Id;
                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Description = utils.GetActionResultErrors(saveResult.Errors);

                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
예제 #20
0
        public IActionResult ActivateAndOpenProductAccounts(ProductIdApproveRequest productID)
        {
            if (ModelState.IsValid)
            {
                var response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };

                ActionResult saveResult = _xbService.ActivateAndOpenProductAccounts(productID.ProductId);

                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Result      = saveResult.Id;
                response.Description = utils.GetActionResultErrors(saveResult.Errors);

                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
예제 #21
0
        public IActionResult ApproveLoanProductOrder(ApproveLoanProductOrderRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };
                LoanProductOrder   order = new LoanProductOrder();
                AuthorizedCustomer authorizedCustomer = _cacheHelper.GetAuthorizedCustomer();

                if (request.ProductType == 1)
                {
                    order = _xbService.GetLoanOrder(request.Id);
                }
                if (request.ProductType == 2)
                {
                    order = _xbService.GetCreditLineOrder(request.Id);
                }
                if (request.ProductType == 3)
                {
                    order = _xbService.GetCreditLineOrder(request.Id);
                }

                ActionResult saveResult = _xbService.ApproveLoanProductOrder(order);

                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Result      = saveResult.Id;
                response.Description = utils.GetActionResultErrors(saveResult.Errors);

                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
        public IActionResult ApprovePeriodicTerminationOrder(ApproveIdRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };

                PeriodicTerminationOrder order = _xbService.GetPeriodicTerminationOrder(request.Id);

                ActionResult saveResult = _xbService.ApprovePeriodicTerminationOrder(order);

                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Result      = saveResult.Id;
                response.Description = utils.GetActionResultErrors(saveResult.Errors);

                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
        public IActionResult SavePeriodicTerminationOrder(PeriodicTerminationOrderRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };

                request.Order.OrderNumber      = "";
                request.Order.RegistrationDate = _xbService.GetNextOperDay();
                ActionResult saveResult = _xbService.SavePeriodicTerminationOrder(request.Order);

                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Result      = saveResult.Id;
                response.Description = utils.GetActionResultErrors(saveResult.Errors);

                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
        private SingleResponse <long> SaveAttachedCardOrder(AttachCardBindingRequest request)
        {
            SingleResponse <long> response = new SingleResponse <long>()
            {
                ResultCode = ResultCodes.normal
            };

            XBS.ActionResult result = new XBS.ActionResult();
            //Տարանցիկ հաշվի ստացում դեբետագրելու համար , կախված հայտի տեսակից
            string accountNumber = _client.GetMerchantAccountNumberByOrderType(new AttachedCardOrderTypeRequest
            {
                Currency     = GetOrderTypeBasedCurrency(request),
                OrderType    = (int)request.Order.Type,
                OrderSubType = request.Order.SubType
            })?.AccountNumber;

            if (string.IsNullOrEmpty(accountNumber))
            {
                response.ResultCode = ResultCodes.failed;
                return(response);
            }
            switch (request.Order.Type)
            {
            case OrderType.RATransfer:
            {
                if (request.Order.SubType == 3)
                {
                    PaymentOrder order = new PaymentOrder
                    {
                        Amount           = request.Order.Amount,
                        Currency         = request.Order.Currency,
                        SubType          = request.Order.SubType,
                        Type             = request.Order.Type,
                        ReceiverBankCode = request.Order.ReceiverBankCode,
                        ReceiverAccount  = new Account
                        {
                            AccountNumber = request.Order.ReceiverAccount.AccountNumber,
                            Currency      = request.Order.ReceiverAccount.Currency
                        },
                        DebitAccount = new Account
                        {
                            AccountNumber  = accountNumber,
                            Currency       = request.Order.DebitAccount.Currency,
                            IsAttachedCard = true
                        }
                    };
                    result = _xBService.SavePaymentOrder(order);
                }
                //else if (request.Order.SubType == 6)
                //{
                //    BudgetPaymentOrder order = new BudgetPaymentOrder
                //    {
                //        Amount = request.Order.Amount,
                //        Currency = request.Order.Currency,
                //        SubType = request.Order.SubType,
                //        Type = request.Order.Type,
                //        ReceiverBankCode = request.Order.ReceiverBankCode,
                //        UseCreditLine = request.Order.UseCreditLine,
                //        Description = request.Order.Description,
                //        TransferFee = request.Order.TransferFee,
                //        Receiver = request.Order.Receiver,
                //        PoliceResponseDetailsId = request.Order.PoliceResponseDetailsId,
                //        LTACode = request.Order.LTACode,
                //        FeeAccount = new Account
                //        {
                //            AccountNumber = request.Order.FeeAccount.AccountNumber,
                //            Currency = request.Order.FeeAccount.Currency
                //        },
                //        ReceiverAccount = new Account
                //        {
                //            AccountNumber = request.Order.ReceiverAccount.AccountNumber
                //        },
                //        DebitAccount = new Account
                //        {
                //            AccountNumber = accountNumber,
                //            Currency = request.Order.DebitAccount.Currency,
                //            IsAttachedCard = true
                //        }
                //    };
                //    result = _xBService.SaveBudgetPaymentOrder(order);
                //}
            }
            break;

            case OrderType.LoanMature:
            {
                string loanAccNumber = _xBService.GetLiabilitiesAccountNumberByAppId(request.Order.ProductId);
                if (string.IsNullOrEmpty(loanAccNumber))
                {
                    response.ResultCode = ResultCodes.failed;
                    return(response);
                }
                PaymentOrder order = new PaymentOrder
                {
                    Amount           = request.Order.Amount,
                    Currency         = request.Order.Currency,
                    SubType          = 3,
                    Type             = OrderType.RATransfer,
                    ReceiverBankCode = request.Order.ReceiverBankCode,
                    ReceiverAccount  = new Account
                    {
                        AccountNumber = loanAccNumber,
                        Currency      = request.Order.Currency
                    },
                    DebitAccount = new Account
                    {
                        AccountNumber  = accountNumber,
                        Currency       = request.Order.Currency,
                        IsAttachedCard = true
                    }
                };
                result = _xBService.SavePaymentOrder(order);
                if (result.ResultCode == ResultCode.Normal)
                {
                    PaymentOrder paymOrder = _xBService.GetPaymentOrder(result.Id);
                    result = _xBService.ApprovePaymentOrder(paymOrder);
                    if (result.ResultCode == ResultCode.Normal)
                    {
                        MatureOrder matureOrder = new MatureOrder
                        {
                            ProductId  = request.Order.ProductId,
                            Amount     = request.Order.Amount,
                            Currency   = request.Order.Currency,
                            SubType    = request.Order.SubType,
                            Type       = request.Order.Type,
                            MatureType = request.Order.MatureType,
                            MatureMode = request.Order.MatureMode,
                            Account    = new Account
                            {
                                AccountNumber  = loanAccNumber,
                                Currency       = request.Order.Currency,
                                IsAttachedCard = true
                            }
                        };
                        result = _xBService.SaveMatureOrder(matureOrder);
                    }
                }
            }
            break;

            case OrderType.CommunalPayment:
            {
                UtilityPaymentOrder order = new UtilityPaymentOrder
                {
                    Amount            = request.Order.Amount,
                    Currency          = request.Order.Currency,
                    Type              = request.Order.Type,
                    Code              = request.Order.Code,
                    AbonentType       = request.Order.AbonentType,
                    CommunalType      = request.Order.CommunalType,
                    Branch            = request.Order.Branch,
                    AbonentFilialCode = request.Order.AbonentFilialCode,
                    PaymentType       = request.Order.PaymentType,
                    DebitAccount      = new Account
                    {
                        AccountNumber  = accountNumber,
                        Currency       = "AMD",
                        IsAttachedCard = true
                    }
                };
                result = _xBService.SaveUtilityPaymentOrder(order);
            }
            break;

            default:
                break;
            }
            response.Result      = result.Id;
            response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
            response.Description = Utils.GetActionResultErrors(result.Errors);
            return(response);
        }
예제 #25
0
        public IActionResult SaveAndApproveUserUnlockOrder([FromBody] TokenOperationRequestWithAuthorization request)
        {
            if (ModelState.IsValid)
            {
                SingleResponse <long> response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };
                XBSecurity.LoginInfo loginInfo = new XBSecurity.LoginInfo()
                {
                    ForUnlocking = true
                };
                byte language = 1;
                //Լեզու
                if (!string.IsNullOrEmpty(Request.Headers["language"]))
                {
                    byte.TryParse(Request.Headers["language"], out language);
                }

                //Օգտագործող
                if (!string.IsNullOrEmpty(request.UserName))
                {
                    loginInfo.UserName = request.UserName;
                }
                else
                {
                    response.ResultCode  = ResultCodes.validationError;
                    response.Description = (Languages)language == Languages.hy ? "Մուտքագրեք ձեր օգտվողի անունը։" : "Please enter your username.";
                }
                //Գաղտնաբառ
                if (!string.IsNullOrEmpty(request.Password))
                {
                    loginInfo.Password = utils.GetSHA1Hash(request.Password);
                }
                else
                {
                    response.ResultCode  = ResultCodes.validationError;
                    response.Description = (Languages)language == Languages.hy ? "Մուտքագրեք ձեր գաղտնաբառը։" : "Please enter your password.";
                }

                if (response.ResultCode == ResultCodes.normal)
                {
                    loginInfo.IpAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();

                    var AuthResponce = _xbSecurity.AuthorizeUserByUserPassword(loginInfo, language);

                    if (AuthResponce.AuthorizationResult.IsAuthorized)
                    {
                        if (AuthResponce.AuthorizationResult.ResultCode == XBSecurity.LoginResultCode.ChangePassword)
                        {
                            response.ResultCode  = ResultCodes.validationError;
                            response.Description = $"{(!string.IsNullOrEmpty(AuthResponce.AuthorizationResult.DescriptionAM) ? AuthResponce.AuthorizationResult.DescriptionAM + " " : "")}{AuthResponce.AuthorizationResult.Description}";
                            return(ResponseExtensions.ToHttpResponse(response));
                        }
                        HBUser hbUser = new HBUser();
                        _xBService.Use(client =>
                        {
                            hbUser = client.GetHBUserByUserNameAsync(request.UserName).Result;
                        });
                        AuthorizeAnonymousMethods(hbUser.CustomerNumber, AuthResponce.AuthorizationResult.SessionID.ToString(), hbUser.ID, hbUser.UserName);
                        if (Request.Headers.ContainsKey("SessionId"))
                        {
                            Request.Headers.Remove("SessionId");
                        }
                        Request.Headers.Add("SessionId", AuthResponce.AuthorizationResult.SessionID.ToString());
                        HBServletRequestOrder hBServletRequestOrder = new HBServletRequestOrder
                        {
                            RegistrationDate = DateTime.Now,
                            OperationDate    = _xBService.GetCurrentOperDay(),
                            ServletAction    = HBServletAction.UnlockUser,
                            Type             = OrderType.HBServletRequestTokenUnBlockOrder,
                            SubType          = 1,
                            ServletRequest   = new TokenOperationsInfo1(),
                            HBtoken          = new HBToken
                            {
                                HBUser = new HBUser
                                {
                                    UserName = hbUser.UserName,
                                    IsCas    = true
                                }
                            },
                            CustomerNumber = hbUser.CustomerNumber,
                            Source         = SourceType.MobileBanking,
                            FilialCode     = 22000,
                            PhoneNumber    = GetCustomerRegPhone(hbUser.CustomerNumber)
                        };
                        ActionResult saveActionResult = _xBService.SaveAndApproveTokenOrder(hBServletRequestOrder);
                        response.ResultCode = ResultCodeFormatter.FromPersonalAccountSecurityService(saveActionResult.ResultCode);
                        response.Result     = saveActionResult.Id;
                        if (response.ResultCode == ResultCodes.normal)
                        {
                            response.Description = (Languages)language == Languages.hy ? "Օգտագործողը ապաբլոկավորված է:" : "User unblocked";
                        }
                        else
                        {
                            response.Description = utils.GetActionResultErrors(saveActionResult.Errors);
                        }
                        return(ResponseExtensions.ToHttpResponse(response));
                    }
                    else
                    {
                        response.ResultCode  = ResultCodes.notAuthorized;
                        response.Description = $"{(!string.IsNullOrEmpty(AuthResponce.AuthorizationResult.DescriptionAM) ? AuthResponce.AuthorizationResult.DescriptionAM + " " : "")}{AuthResponce.AuthorizationResult.Description}";
                    }
                }
                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
예제 #26
0
#pragma warning disable IDE0060 // Remove unused parameter
        public IActionResult SaveAndApproveNewTokenOrder([FromBody] TokenOperationRequest request)
#pragma warning restore IDE0060 // Remove unused parameter
        {
            if (ModelState.IsValid)
            {
                SingleResponse <long> response        = new SingleResponse <long>();
                double             DayLimit           = 400000;
                double             TransLimit         = 400000;
                AuthorizedCustomer authorizedCustomer = _cacheHelper.GetAuthorizedCustomer();
                ulong id = _xBInfoService.GetLastKeyNumber(22000, 74);
                HBApplicationOrder order = new HBApplicationOrder()
                {
                    Source              = SourceType.MobileBanking,
                    HBApplication       = new HBApplication(),
                    HBApplicationUpdate = new HBApplicationUpdate
                    {
                        AddedItems       = new List <object>(),
                        DeactivatedItems = new List <object>(),
                        UpdatedItems     = new List <object>()
                    }
                };
                ActionResult result = _xBService.SaveAndApproveHBApplicationNewOrder(order, out HBToken hBToken, id, authorizedCustomer.UserId, DayLimit, TransLimit);
                if (result.ResultCode == (ResultCode)ResultCodes.normal)
                {
                    HBServletRequestOrder hBServletRequestOrder = new HBServletRequestOrder
                    {
                        RegistrationDate = DateTime.Now,
                        OperationDate    = _xBService.GetCurrentOperDay(),
                        ServletAction    = HBServletAction.ActivateToken,
                        Type             = OrderType.HBServletRequestTokenActivationOrder,
                        SubType          = 1,
                        CustomerNumber   = authorizedCustomer.CustomerNumber,
                        ServletRequest   = null,
                        Source           = SourceType.MobileBanking,
                        PhoneNumber      = GetCustomerRegPhone(authorizedCustomer.CustomerNumber),
                        HBtoken          = new HBToken
                        {
                            TokenNumber  = hBToken.TokenNumber,
                            DayLimit     = 400000,
                            TransLimit   = 400000,
                            ID           = hBToken.ID,
                            GID          = hBToken.GID,
                            TokenType    = hBToken.TokenType,
                            HBUser       = hBToken.HBUser,
                            IsRegistered = true
                        },
                        FilialCode = 22000
                    };

                    ActionResult saveActionResult = _xBService.SaveAndApproveTokenOrder(hBServletRequestOrder);
                    if ((saveActionResult.ResultCode == ResultCode.DoneAndReturnedValues || saveActionResult.ResultCode == ResultCode.Normal) && hBToken?.HBUser?.IsCas == false) //եթե հին մոբայլի user -  ը (iscas == false)  ստանում է նոր տոկեն աֆտոմատ սարքում ենք նոր մոբայլի user
                    {
                        _xBService.MigrateOldUserToCas(hBToken.HBUser.ID);
                    }
                    response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveActionResult.ResultCode);
                    response.Result      = saveActionResult.Id;
                    response.Description = utils.GetActionResultErrors(saveActionResult.Errors);
                }
                else
                {
                    response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
                    response.Result      = result.Id;
                    response.Description = result?.Errors.Count > 0 ? _xBService.GetTerm(result?.Errors[0]?.Code ?? 0, null, Languages.hy) : default;
                }
                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
예제 #27
0
        public async Task <IActionResult> SaveAndApproveTokenReplacementOrder([FromBody] TokenOperationRequest request)
        {
            if (ModelState.IsValid)
            {
                double oldDayLimit   = 400000;
                double oldTransLimit = 400000;
                if (!request.IsNewHbUser)
                {
                    SingleResponse <long> response = new SingleResponse <long>();
                    byte language = 1;
                    if (!string.IsNullOrEmpty(Request.Headers["language"]))
                    {
                        byte.TryParse(Request.Headers["language"], out language);
                    }
                    AuthorizedCustomer authorizedCustomer = _cacheHelper.GetAuthorizedCustomer();
                    ulong              id             = _xBInfoService.GetLastKeyNumber(22000, 74);
                    List <HBToken>     activehBTokens = new List <HBToken>();
                    HBApplicationOrder order          = new HBApplicationOrder()
                    {
                        Source              = SourceType.MobileBanking,
                        HBApplication       = new HBApplication(),
                        HBApplicationUpdate = new HBApplicationUpdate
                        {
                            AddedItems       = new List <object>(),
                            DeactivatedItems = new List <object>(),
                            UpdatedItems     = new List <object>()
                        }
                    };
                    _xBService.Use(client =>
                    {
                        activehBTokens = client.GetFilteredHBTokensAsync(authorizedCustomer.UserId, HBTokenQuality.Active).Result;
                    });
                    oldDayLimit   = (activehBTokens.OrderByDescending(x => x.ActivationDate).FirstOrDefault()?.DayLimit ?? 0) != 0 ? activehBTokens.OrderByDescending(x => x.ActivationDate).FirstOrDefault().DayLimit : 400000;
                    oldTransLimit = (activehBTokens.OrderByDescending(x => x.ActivationDate).FirstOrDefault()?.TransLimit ?? 0) != 0 ? activehBTokens.OrderByDescending(x => x.ActivationDate).FirstOrDefault().TransLimit : 400000;
                    ActionResult result = _xBService.SaveAndApproveHBApplicationNewOrder(order, out HBToken hBToken, id, authorizedCustomer.UserId, oldDayLimit, oldTransLimit);
                    if (result.ResultCode == (ResultCode)ResultCodes.normal)
                    {
                        hBToken.HBUser.IsCas = true;
                        HBServletRequestOrder hBServletRequestOrder = new HBServletRequestOrder
                        {
                            RegistrationDate = DateTime.Now,
                            OperationDate    = _xBService.GetCurrentOperDay(),
                            ServletAction    = HBServletAction.ActivateToken,
                            Type             = OrderType.HBServletRequestTokenActivationOrder,
                            SubType          = 1,
                            CustomerNumber   = authorizedCustomer.CustomerNumber,
                            ServletRequest   = null,
                            Source           = SourceType.MobileBanking,
                            PhoneNumber      = GetCustomerRegPhone(authorizedCustomer.CustomerNumber),
                            HBtoken          = new HBToken
                            {
                                TokenNumber  = hBToken.TokenNumber,
                                DayLimit     = oldDayLimit,
                                TransLimit   = oldTransLimit,
                                ID           = hBToken.ID,
                                GID          = hBToken.GID,
                                TokenType    = hBToken.TokenType,
                                HBUser       = hBToken.HBUser,
                                IsRegistered = true
                            },
                            FilialCode = 22000
                        };
                        ActionResult saveActionResult = _xBService.SaveAndApproveTokenOrder(hBServletRequestOrder);
                        if (saveActionResult.ResultCode == ResultCode.DoneAndReturnedValues || saveActionResult.ResultCode == ResultCode.Normal) //եթե հին մոբայլի user -  ը (iscas == false)  ստանում է նոր տոկեն աֆտոմատ սարքում ենք նոր մոբայլի user
                        {
                            _xBService.MigrateOldUserToCas(hBToken.HBUser.ID);
                            response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveActionResult.ResultCode);
                            response.Result      = saveActionResult.Id;
                            response.Description = (Languages)language == Languages.hy ? "Ակտիվացման կոդը ուղարկվել է Ձեր էլ. փոստին, իսկ PIN կոդը կստանանք SMS-ի տեսքով:" : "The activation code was sent to your email. PIN code was sent by SMS.";
                        }
                        else
                        {
                            response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveActionResult.ResultCode);
                            response.Result      = saveActionResult.Id;
                            response.Description = saveActionResult.Errors[0].Code == 0 ? saveActionResult.Errors[0].Description : _xBService.GetTerm(saveActionResult.Errors[0].Code, null, (Languages)language);
                        }
                    }
                    else
                    {
                        response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
                        response.Result      = result.Id;
                        response.Description = _xBService.GetTerm(result.Errors[0].Code, null, Languages.hy);
                    }
                    return(ResponseExtensions.ToHttpResponse(response));
                }
                else
                {
                    SingleResponse <long>      response     = new SingleResponse <long>();
                    ActionResult               result       = new ActionResult();
                    List <HBActivationRequest> hBActivation = new List <HBActivationRequest>();
                    HBApplicationOrder         order        = new HBApplicationOrder()
                    {
                        Source = SourceType.MobileBanking
                    };
                    HBActivationOrder      hBActivationOrder = new HBActivationOrder();
                    List <HBToken>         hBTokens          = new List <HBToken>();
                    HBToken                hBToken           = new HBToken();
                    HBApplication          hBApplication     = new HBApplication();
                    Task <List <HBToken> > hBTokensTask      = null;
                    Task <HBToken>         hBTokenTask       = null;
                    Task <HBApplication>   hBApplicationTask = null;
                    ulong id = _xBInfoService.GetLastKeyNumber(22000, 74);
                    AuthorizedCustomer authorizedCustomer = _cacheHelper.GetAuthorizedCustomer();
                    byte language = 1;
                    if (!string.IsNullOrEmpty(Request.Headers["language"]))
                    {
                        byte.TryParse(Request.Headers["language"], out language);
                    }

                    _xBService.Use(client =>
                    {
                        hBTokensTask = client.GetFilteredHBTokensAsync(authorizedCustomer.UserId, HBTokenQuality.NotDefined);
                    });
                    _xBService.Use(client =>
                    {
                        hBTokenTask = client.GetHBTokenWithSerialNumberAsync(request.TokenSerial);
                    });
                    _xBService.Use(client =>
                    {
                        hBApplicationTask = client.GetHBApplicationAsync();
                    });
                    hBTokens      = await hBTokensTask;
                    hBApplication = await hBApplicationTask;
                    hBToken       = await hBTokenTask;
                    oldDayLimit   = (hBToken?.DayLimit ?? 0) != 0 ? hBToken.DayLimit : 400000;
                    oldTransLimit = (hBToken?.TransLimit ?? 0) != 0 ? hBToken.TransLimit : 400000;
                    if (authorizedCustomer.TypeOfClient != 6 && hBTokens.All(x => x.TokenType == HBTokenTypes.Token) && hBApplication?.ContractDate < new DateTime(2015, 7, 25)) // Ն-19051
                    {
                        response.ResultCode  = ResultCodes.validationError;
                        response.Description = (Languages)language == Languages.hy ? "Փոխարինման հայտը հնարավոր չէ ուղարկել: Խնդրում ենք դիմել Բանկ:" : "Can't send replacement request. Please contact the Bank.";
                        return(ResponseExtensions.ToHttpResponse(response));
                    }
                    if (hBToken == null)
                    {
                        result.ResultCode    = ResultCode.ValidationError;
                        response.Description = (Languages)language == Languages.hy ? "Տվյալ համարով տոկեն գոյություն չունի։" : "Token not exist.";
                        return(ResponseExtensions.ToHttpResponse(response));
                    }
                    HBServletRequestOrder hBServletRequestOrder = new HBServletRequestOrder
                    {
                        RegistrationDate = DateTime.Now,
                        OperationDate    = _xBService.GetCurrentOperDay(),
                        ServletAction    = HBServletAction.DeactivateToken,
                        Type             = XBS.OrderType.HBServletRequestTokenDeactivationOrder,
                        SubType          = 1,
                        CustomerNumber   = authorizedCustomer.CustomerNumber,
                        ServletRequest   = null,
                        Source           = SourceType.MobileBanking,
                        HBtoken          = hBToken,
                        FilialCode       = 22000
                    };
                    ActionResult saveActionResult = _xBService.SaveAndApproveTokenOrder(hBServletRequestOrder);
                    if (saveActionResult.ResultCode == (ResultCode)ResultCodes.normal)
                    {
                        result = _xBService.SaveAndApproveHBApplicationReplacmentOrder(order, ref hBToken, id, authorizedCustomer.UserId, request.TokenSerial, oldDayLimit, oldTransLimit);
                        if (result.ResultCode == (ResultCode)ResultCodes.normal)
                        {
                            hBServletRequestOrder.RegistrationDate = DateTime.Now;
                            hBServletRequestOrder.OperationDate    = _xBService.GetCurrentOperDay();
                            hBServletRequestOrder.ServletAction    = HBServletAction.ActivateToken;
                            hBServletRequestOrder.Type             = OrderType.HBServletRequestTokenActivationOrder;
                            hBServletRequestOrder.SubType          = 1;
                            hBServletRequestOrder.Source           = SourceType.MobileBanking;
                            hBServletRequestOrder.CustomerNumber   = authorizedCustomer.CustomerNumber;
                            hBServletRequestOrder.PhoneNumber      = GetCustomerRegPhone(authorizedCustomer.CustomerNumber);
                            hBServletRequestOrder.ServletRequest   = null;
                            hBServletRequestOrder.HBtoken          = new HBToken
                            {
                                TokenNumber  = hBToken.TokenNumber,
                                DayLimit     = oldDayLimit,
                                TransLimit   = oldTransLimit,
                                ID           = hBToken.ID,
                                GID          = hBToken.GID,
                                TokenType    = hBToken.TokenType,
                                HBUser       = hBToken.HBUser,
                                IsRegistered = true
                            };
                            hBServletRequestOrder.FilialCode = 22000;

                            ActionResult saveTokenResult = _xBService.SaveAndApproveTokenOrder(hBServletRequestOrder);
                            if ((saveTokenResult.ResultCode == ResultCode.DoneAndReturnedValues || saveTokenResult.ResultCode == ResultCode.Normal)) //եթե հին մոբայլի user -  ը (iscas == false)  ստանում է նոր տոկեն աֆտոմատ սարքում ենք նոր մոբայլի user
                            {
                                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveTokenResult.ResultCode);
                                response.Result      = saveTokenResult.Id;
                                response.Description = (Languages)language == Languages.hy ? "Ակտիվացման կոդը ուղարկվել է Ձեր էլ. փոստին, իսկ PIN կոդը կստանանք SMS-ի տեսքով:" : "The activation code was sent to your email. PIN code was sent by SMS.";
                            }
                            else
                            {
                                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
                                response.Result      = result.Id;
                                response.Description = _xBService.GetTerm(saveTokenResult.Errors[0].Code, null, (Languages)language);
                            }
                        }
                        else
                        {
                            response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
                            response.Result      = result.Id;
                            response.Description = _xBService.GetTerm(result.Errors[0].Code, null, (Languages)language);
                        }
                    }
                    else
                    {
                        response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveActionResult.ResultCode);
                        response.Result      = saveActionResult.Id;
                        response.Description = _xBService.GetTerm(saveActionResult.Errors[0].Code, null, (Languages)language);
                    }
                    return(ResponseExtensions.ToHttpResponse(response));
                }
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }