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);
        }
Ejemplo n.º 2
0
        public IActionResult ApproveMatureOrder(ApproveIdRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = new SingleResponse <long>()
                {
                    ResultCode = ResultCodes.normal
                };

                MatureOrder order = _cacheHelper.GetApprovalOrder <MatureOrder>(request.Id);

                ActionResult saveResult = _xbService.ApproveMatureOrder(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));
            }
        }
Ejemplo n.º 3
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            ApproveIdRequest                     request          = null;
            ProductIdApproveRequest              productIdRequest = null;
            ApproveLoanProductOrderRequest       approveLoan      = null;
            ListDocIdRequest                     listRequest      = null;
            Dictionary <long, ApprovalOrderType> Types            = new Dictionary <long, ApprovalOrderType>();
            string sessionId = "";
            string otp       = "";
            byte   language  = 0;
            bool   isSigned  = false;
            string ipAddress = "";
            Dictionary <string, string> signData = null;
            SourceType sourceType = SourceType.NotSpecified;

            // հայտի մուտքագրման աղբյուրի ստացում Header-ից
            if (!string.IsNullOrEmpty(context.HttpContext.Request.Headers["SourceType"]))
            {
                Enum.TryParse(context.HttpContext.Request.Headers["SourceType"], out sourceType);
            }


            // Սեսիայի ստացում Header-ից
            if (!string.IsNullOrEmpty(context.HttpContext.Request.Headers["SessionId"]))
            {
                sessionId = context.HttpContext.Request.Headers["SessionId"];
            }


            // Լեզվի ստացում Header-ից
            if (!string.IsNullOrEmpty(context.HttpContext.Request.Headers["language"]))
            {
                byte.TryParse(context.HttpContext.Request.Headers["language"], out language);
            }

            // IP հասցեի ստացում
            if (!string.IsNullOrEmpty(context.HttpContext.Request.Headers["LocalIPAddress"]))
            {
                ipAddress = context.HttpContext.Request.Headers["LocalIPAddress"];
            }

            // Փոխանցված պարամետրի ստացում
            var argument = context.ActionArguments.Values.First();

            //Approve մեթոդների համար
            if (argument is ApproveIdRequest)
            {
                request = argument as ApproveIdRequest;
                Types.Add(request.Id, _type);
                otp = request.OTP;
            }
            //ApproveOrders մեթոդի համար
            else if (argument is ListDocIdRequest)
            {
                listRequest = argument as ListDocIdRequest;
                foreach (var item in listRequest.ListDocId)
                {
                    Types.Add(item, GetOrderType(_xbService.GetDocumentType(item)));
                }
                otp = listRequest.OTP;
            }
            else if (argument is ProductIdApproveRequest)
            {
                productIdRequest = argument as ProductIdApproveRequest;
                Types.Add((long)productIdRequest.ProductId, _type);
                otp = productIdRequest.OTP;
            }
            else if (argument is ApproveLoanProductOrderRequest)
            {
                approveLoan = argument as ApproveLoanProductOrderRequest;
                Types.Add(approveLoan.Id, _type);
                otp = approveLoan.OTP;
            }

            //Հայտի ստեղծում, քեշավորում, և Sign լինող պարամետրերի փոխանցում
            foreach (var x in Types)
            {
                switch (x.Value)
                {
                case ApprovalOrderType.PaymentOrder:
                {
                    PaymentOrder order = (PaymentOrder)_cacheHelper.SetApprovalOrder(_xbService.GetPaymentOrder(x.Key));
                    CollectParameters(order.Id.ToString(), order.DebitAccount.AccountNumber.ToString(), order.ReceiverAccount.AccountNumber.ToString(),
                                      Math.Truncate(order.Amount).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.PlasticCardOrder:
                {
                    PlasticCardOrder order = (PlasticCardOrder)_cacheHelper.SetApprovalOrder(_xbService.GetPlasticCardOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", order.PlasticCard.Currency, ipAddress);
                }
                break;

                case ApprovalOrderType.UtilityPaymentOrder:
                {
                    UtilityPaymentOrder order = (UtilityPaymentOrder)_cacheHelper.SetApprovalOrder(_xbService.GetUtilityPaymentOrder(x.Key));
                    CollectParameters(order.Id.ToString(), order.DebitAccount.AccountNumber.ToString(), "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.MatureOrder:
                {
                    MatureOrder order = (MatureOrder)_cacheHelper.SetApprovalOrder(_xbService.GetMatureOrder(x.Key));
                    CollectParameters(order.Id.ToString(), order.Account.AccountNumber.ToString(), "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.ReferenceOrder:
                {
                    ReferenceOrder order = (ReferenceOrder)_cacheHelper.SetApprovalOrder(_xbService.GetReferenceOrder(x.Key));
                    if (order.FeeAccount != null)
                    {
                        CollectParameters(order.Id.ToString(), order.FeeAccount.AccountNumber.ToString(), "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                    }
                    else
                    {
                        CollectParameters(order.Id.ToString(), "0", "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                    }
                }
                break;

                case ApprovalOrderType.LoanProductOrder:
                {
                    LoanProductOrder order = null;
                    var type = _xbService.GetDocumentType((int)x.Key);
                    switch (type)
                    {
                    case OrderType.CreditSecureDeposit:
                        order = (LoanProductOrder)_cacheHelper.SetApprovalOrder(_xbService.GetLoanOrder(x.Key));
                        break;

                    default:
                        order = (LoanProductOrder)_cacheHelper.SetApprovalOrder(_xbService.GetCreditLineOrder(x.Key));
                        break;
                    }
                    CollectParameters(order.Id.ToString(), "0", "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.ReceivedFastTransferPaymentOrder:
                {
                    ReceivedFastTransferPaymentOrder order = (ReceivedFastTransferPaymentOrder)_cacheHelper.SetApprovalOrder(_xbService.GetReceivedFastTransferPaymentOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", order.ReceiverAccount.AccountNumber.ToString(), Math.Truncate(order.Amount).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.AccountClosingOrder:
                {
                    AccountClosingOrder order = (AccountClosingOrder)_cacheHelper.SetApprovalOrder(_xbService.GetAccountClosingOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", "0", ipAddress);
                }
                break;

                case ApprovalOrderType.SwiftCopyOrder:
                {
                    SwiftCopyOrder order = (SwiftCopyOrder)_cacheHelper.SetApprovalOrder(_xbService.GetSwiftCopyOrder(x.Key));
                    if (order.FeeAccount != null)
                    {
                        CollectParameters(order.Id.ToString(), order.FeeAccount.AccountNumber.ToString(), "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                    }
                    else
                    {
                        CollectParameters(order.Id.ToString(), "0", "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                    }
                }
                break;

                case ApprovalOrderType.CredentialOrder:
                {
                    CredentialOrder order = (CredentialOrder)_cacheHelper.SetApprovalOrder(_xbService.GetCredentialOrder(x.Key));
                    if (order.Fees != null && order.Fees[0] != null && order.Fees[0].Account != null)
                    {
                        CollectParameters(order.Id.ToString(), order.Fees[0].Account.AccountNumber.ToString(), "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                    }
                    else
                    {
                        CollectParameters(order.Id.ToString(), "0", "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                    }
                }
                break;

                case ApprovalOrderType.DepositOrder:
                {
                    DepositOrder order = (DepositOrder)_cacheHelper.SetApprovalOrder(_xbService.GetDepositorder(x.Key));
                    CollectParameters(order.Id.ToString(), order.DebitAccount.AccountNumber.ToString(), "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.AccountOrder:
                {
                    AccountOrder order = (AccountOrder)_cacheHelper.SetApprovalOrder(_xbService.GetAccountOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", order.Currency, ipAddress);
                }
                break;

                case ApprovalOrderType.CashOrder:
                {
                    CashOrder order = (CashOrder)_cacheHelper.SetApprovalOrder(_xbService.GetCashOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.CreditLineTerminationOrder:
                {
                    CreditLineTerminationOrder order = (CreditLineTerminationOrder)_cacheHelper.SetApprovalOrder(_xbService.GetCreditLineTerminationOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", order.Currency, ipAddress);
                }
                break;

                case ApprovalOrderType.CardClosingOrder:
                {
                    CardClosingOrder order = (CardClosingOrder)_cacheHelper.SetApprovalOrder(_xbService.GetCardClosingOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", order.ProductId.ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.CustomerDataOrder:
                {
                    CustomerDataOrder order = (CustomerDataOrder)_cacheHelper.SetApprovalOrder(_xbService.GetCustomerDataOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", order.Password, ipAddress);
                }
                break;

                case ApprovalOrderType.StatmentByEmailOrder:
                {
                    StatmentByEmailOrder order = (StatmentByEmailOrder)_cacheHelper.SetApprovalOrder(_xbService.GetStatmentByEmailOrder(x.Key));
                }
                break;

                case ApprovalOrderType.DepositTerminationOrder:
                {
                    DepositTerminationOrder order = (DepositTerminationOrder)_cacheHelper.SetApprovalOrder(_xbService.GetDepositTerminationOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", order.ProductId.ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.ReestrTransferOrder:
                {
                    ReestrTransferOrder order = (ReestrTransferOrder)_cacheHelper.SetApprovalOrder(_xbService.GetReestrTransferOrder(x.Key));
                    CollectParameters(order.Id.ToString(), order.DebitAccount.AccountNumber.ToString(), "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.ArcaCardsTransactionOrder:
                {
                    ArcaCardsTransactionOrder order = (ArcaCardsTransactionOrder)_cacheHelper.SetApprovalOrder(_xbService.GetArcaCardsTransactionOrder(x.Key));
                    CollectParameters(order.Id.ToString(), order.CardNumber.Substring(0, 10), "0", "0", ipAddress);
                }
                break;

                case ApprovalOrderType.CardToCardOrder:
                {
                    CardToCardOrder order = (CardToCardOrder)_cacheHelper.SetApprovalOrder(_xbService.GetCardToCardOrder(x.Key));
                    CollectParameters(order.Id.ToString(), order.DebitCardNumber.Substring(0, 10), order.CreditCardNumber, Math.Truncate(order.Amount).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.CardLimitChangeOrder:
                {
                    CardLimitChangeOrder order = (CardLimitChangeOrder)_cacheHelper.SetApprovalOrder(_xbService.GetCardLimitChangeOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", Math.Truncate(order.Limits[0].LimitValue).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.PeriodicPaymentOrder:
                {
                    PaymentOrder order = (PaymentOrder)_cacheHelper.SetApprovalOrder(_xbService.GetPaymentOrder(x.Key));
                    CollectParameters(order.Id.ToString(), order.DebitAccount.AccountNumber.ToString(), "0", Math.Truncate(order.Amount).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.InternationalPaymentOrder:
                {
                    InternationalPaymentOrder order = (InternationalPaymentOrder)_cacheHelper.SetApprovalOrder(_xbService.GetInternationalPaymentOrder(x.Key));
                    CollectParameters(order.Id.ToString(), order.DebitAccount.AccountNumber.ToString(), order.ReceiverAccount.AccountNumber.ToString(),
                                      Math.Truncate(order.Amount).ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.AccountReOpenOrder:
                {
                    AccountReOpenOrder order = (AccountReOpenOrder)_cacheHelper.SetApprovalOrder(_xbService.GetAccountReOpenOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", "0", ipAddress);
                }
                break;

                case ApprovalOrderType.PlasticCardSmsServiceOrder:
                {
                    PlasticCardSMSServiceOrder order = (PlasticCardSMSServiceOrder)_cacheHelper.SetApprovalOrder(_xbService.GetPlasticCardSMSServiceOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", order.ProductID.ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.RemovalOrder:
                {
                    RemovalOrder order = context.ActionArguments.Values.First() as RemovalOrder;
                    CollectParameters("0", order.RemovingOrderId.ToString(), "0", "0", ipAddress);
                }
                break;

                case ApprovalOrderType.PeriodicTerminationOrder:
                {
                    PeriodicTerminationOrder order = (PeriodicTerminationOrder)_cacheHelper.SetApprovalOrder(_xbService.GetPeriodicTerminationOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", order.ProductId.ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.PeriodicDataChangeOrder:
                {
                    PeriodicTransferDataChangeOrder order = (PeriodicTransferDataChangeOrder)_cacheHelper.SetApprovalOrder(_xbService.GetPeriodicDataChangeOrder(x.Key));
                    CollectParameters(order.Id.ToString(), "0", "0", order.ProductId.ToString(), ipAddress);
                }
                break;

                case ApprovalOrderType.CardActivationOrder:
                {
                    CollectParameters(x.Key.ToString(), "0", "0", "0", ipAddress);
                }
                break;

                default:
                    break;
                }
            }
            ;

            //CheckSign Filter-ն անհրաժեշտ է աշխատի միայն sourceType-ը 5-ի՝ MobileBanking-ի դեպքում
            if (sourceType != SourceType.MobileBanking)
            {
                return;
            }
            else
            {
                signData = this.GenerateSignData(TransactionID, SenderAccount, RecepientAccount, Amount, IpAddress);
            }

            isSigned = _xbSecurityService.SingData(sessionId, otp, signData, language);

            //թեստային միջավայրի համար
            if ((sessionId == "ba0f312d-8487-445e-aee2-d5877ac1d4de" || otp == "0123456") && Convert.ToBoolean(_config["TestVersion"]))
            {
                return;
            }
            if (!isSigned)
            {
                Response response = new Response();
                response.ResultCode  = ResultCodes.validationError;
                response.Description = (Languages)language == Languages.hy ? "Սխալ PIN կոդ։" : "Incorrect PIN code.";
                context.Result       = ResponseExtensions.ToHttpResponse(response);
            }
        }
        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);
        }