Пример #1
0
        internal static ChangePinResponseInternal ChangePinInternal(ChangePinRequestInternal internalRequest)
        {
            UMarketSCClient           utibaClient      = new UMarketSCClient();
            ChangePinResponseInternal internalResponse = null;

            using (OperationContextScope scope = new OperationContextScope(utibaClient.InnerChannel))
            {
                HttpRequestMessageProperty messageProperty = new HttpRequestMessageProperty();
                messageProperty.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
                OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, messageProperty);

                //throw new Exception("Exception fuerte");
                string      passwordHash   = GenerateHash(internalRequest.SessionID, internalRequest.Initiator, internalRequest.CurrentPin);
                pinResponse pinChangeUtiba = utibaClient.pin(new pin()
                {
                    pinRequest = new pinRequestType()
                    {
                        sessionid = internalRequest.SessionID, device_type = internalRequest.DeviceType, new_pin = internalRequest.NewPin, pin = passwordHash, initiator = internalRequest.Initiator
                    }
                });

                internalResponse = new ChangePinResponseInternal()
                {
                    ResponseCode    = pinChangeUtiba.pinReturn.result,
                    ResponseMessage = pinChangeUtiba.pinReturn.result_message,
                    TransactionID   = pinChangeUtiba.pinReturn.transid
                };
            }
            return(internalResponse);
        }
Пример #2
0
        private PayStockResponseInternal PayStockInternal(PayStockRequestInternal internalRequest)
        {
            Log(Logger.LogMessageType.Info, "->   -------------------- Comienza la ejecución del método Stock.PayStockInternal", Logger.LoggingLevelType.Medium);
            PayStockResponseInternal internalResponse = null;

            try
            {
                UMarketSCClient  utibaClient           = new UMarketSCClient();
                payStockResponse utibaPayStockResponse = null;
                using (OperationContextScope scope = new OperationContextScope(utibaClient.InnerChannel))
                {
                    HttpRequestMessageProperty messageProperty = new HttpRequestMessageProperty();
                    messageProperty.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
                    OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, messageProperty);
                    Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Parámetros Recibidos Stock.PayStockInternal: " +
                                                                                                 "SessionID={0}, DeviceType={1}, Amount={2}, Bank={3}, Account={4}, Voucher={5}", internalRequest.SessionID, internalRequest.DeviceType,
                                                                                                 internalRequest.Amount, internalRequest.Bank, internalRequest.Account, internalRequest.Voucher), Logger.LoggingLevelType.Low);
                    Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Parámetros Enviados Stock.PayStockInternal: " +
                                                                                                 "SessionID={0}, DeviceType={1}, Amount={2}, Bank={3}, Account={4}, Voucher={5}", internalRequest.SessionID, internalRequest.DeviceType,
                                                                                                 internalRequest.Amount, internalRequest.Bank, internalRequest.Account, internalRequest.Voucher), Logger.LoggingLevelType.Low);
                    utibaPayStockResponse = utibaClient.payStock(new payStock()
                    {
                        payStockRequest = new payStockRequestType()
                        {
                            sessionid     = internalRequest.SessionID,
                            device_type   = internalRequest.DeviceType,
                            wait          = false,
                            waitSpecified = true,
                            amount        = internalRequest.Amount,
                            details       = " Banco: " + internalRequest.Bank +
                                            " Cuenta: " + internalRequest.Account +
                                            " N°Depósito: " + internalRequest.Voucher
                        }
                    });
                }
                if (utibaPayStockResponse != null)
                {
                    internalResponse = new PayStockResponseInternal()
                    {
                        ResponseCode    = utibaPayStockResponse.payStockReturn.result,
                        ResponseMessage = utibaPayStockResponse.payStockReturn.result_message,
                        Fee             = utibaPayStockResponse.payStockReturn.fee,
                        TransactionID   = utibaPayStockResponse.payStockReturn.transid
                    };
                }
                Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Resultado Obtenido Stock.PayStockInternal: ResponseCode={0}, ResponseMessage={1}, TransactionID={2}, " +
                                                                                             "Fee={3}", internalResponse.ResponseCode, internalResponse.ResponseMessage, internalResponse.TransactionID,
                                                                                             internalResponse.Fee), Logger.LoggingLevelType.Low);
            }
            catch (Exception ex)
            {
                Log(Logger.LogMessageType.Error, "Ocurrio una exception procesando el metodo Stock.PayStockInternal, los detalles son: " + ex.ToString(), Logger.LoggingLevelType.Low);
                return(null);
            }
            Log(Logger.LogMessageType.Info, "->   -------------------- Termina la ejecución del método Stock.PayStockInternal", Logger.LoggingLevelType.Medium);
            return(internalResponse);
        }
Пример #3
0
        internal static LoginResponseInternal LoginInternal(LoginRequestInternal loginRequest)
        {
            LogUtils.LogMethodInvocationStart(true, loginRequest);


            UMarketSCClient       utibaClient = new UMarketSCClient();
            loginResponse         loginInfo;
            createsessionResponse newSession;
            LoginResponseInternal loginResponse = null;

            try
            {
                using (OperationContextScope scope = new OperationContextScope(utibaClient.InnerChannel))
                {
                    HttpRequestMessageProperty messageProperty = new HttpRequestMessageProperty();
                    messageProperty.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
                    OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, messageProperty);

                    newSession = utibaClient.createsession(new createsession());
                    String passwordHash           = GetSHA1(loginRequest.User.ToLower() + loginRequest.Password);
                    String passwordAndSessionHash = GetSHA1(newSession.createsessionReturn.sessionid + passwordHash.ToLower()).ToUpper();

                    login loginObject = new login();
                    loginObject.loginRequest = new loginRequestType()
                    {
                        sessionid   = newSession.createsessionReturn.sessionid,
                        device_type = loginRequest.DeviceType,
                        initiator   = loginRequest.User,
                        pin         = passwordAndSessionHash
                    };
                    loginInfo = utibaClient.login(loginObject);
                }
                loginResponse = new LoginResponseInternal()
                {
                    ResponseCode    = loginInfo.loginReturn.result,
                    ResponseMessage = loginInfo.loginReturn.result_message,
                    TransactionID   = loginInfo.loginReturn.transid,
                    SessionID       = newSession.createsessionReturn.sessionid
                };

                if (loginResponse.ResponseCode != 0)
                {
                    loginResponse.SetResponseNamespace(ApiResponseInternal.ResponseNamespace.BAC);
                }
            }
            catch (Exception e)
            {
                if (loginResponse == null)
                {
                    loginResponse = new LoginResponseInternal();
                }
                loginResponse.SetThrowedException(e);
            }
            return(loginResponse);
        }
Пример #4
0
        internal static BalanceResponseInternal BalanceInternal(BalanceRequestInternal balanceRequest)
        {
            UMarketSCClient         utibaClient   = new UMarketSCClient();
            BalanceResponseInternal balanceResult = null;

            try
            {
                utibaClient.InnerChannel.OperationTimeout = new TimeSpan(0, 0, _balanceTimeout);
                using (OperationContextScope scope = new OperationContextScope(utibaClient.InnerChannel))
                {
                    HttpRequestMessageProperty messageProperty = new HttpRequestMessageProperty();
                    messageProperty.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
                    OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, messageProperty);

                    Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Parámetros Recibidos BalanceProvider.BalanceInternal: SessionID={0}, DeviceType={1}", balanceRequest.SessionID, balanceRequest.DeviceType), Logger.LoggingLevelType.Low);

                    balanceResponse utibaBalanceResponse = utibaClient.balance(new Utiba.balance()
                    {
                        balanceRequest = new Utiba.balanceRequestType()
                        {
                            sessionid   = balanceRequest.SessionID,
                            device_type = balanceRequest.DeviceType
                        }
                    });

                    balanceResult = new BalanceResponseInternal()
                    {
                        ResponseCode    = utibaBalanceResponse.balanceReturn.result,
                        ResponseMessage = utibaBalanceResponse.balanceReturn.result_message,
                        TransactionID   = utibaBalanceResponse.balanceReturn.transid,
                        WalletBalance   = utibaBalanceResponse.balanceReturn.avail_1,
                        StockBalance    = utibaBalanceResponse.balanceReturn.avail_2,
                        PointsBalance   = utibaBalanceResponse.balanceReturn.avail_3,
                        DebtBalance     = utibaBalanceResponse.balanceReturn.avail_5
                    };
                }
                if (balanceResult.ResponseCode != 0)
                {
                    balanceResult.SetResponseNamespace(ApiResponseInternal.ResponseNamespace.BAC);
                }
            }
            catch (Exception e)
            {
                if (balanceResult == null)
                {
                    balanceResult = new BalanceResponseInternal();
                }
                balanceResult.SetThrowedException(e);
            }
            Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Resultado Obtenido BalanceProvider.BalanceInternal: ResponseCode={0}, ResponseMessage={1}, TransactionID={2}, " +
                                                                                         "WalletBalance={3}, PointsBalance={4}, PointsBalance={5}, DebtBalance={6}", balanceResult.ResponseCode, balanceResult.ResponseMessage, balanceResult.TransactionID,
                                                                                         balanceResult.WalletBalance, balanceResult.StockBalance, balanceResult.PointsBalance, balanceResult.DebtBalance), Logger.LoggingLevelType.Low);
            return(balanceResult);
        }
Пример #5
0
        private BuyStockResponseInternal BuyStockInternal(BuyStockRequestInternal internalRequest)
        {
            Log(Logger.LogMessageType.Info, "->   -------------------- Comienza la ejecución del método Stock.BuyStockInternal", Logger.LoggingLevelType.Medium);
            BuyStockResponseInternal internalResponse = null;

            try
            {
                UMarketSCClient  utibaClient           = new UMarketSCClient();
                buyStockResponse utibaBuyStockResponse = null;
                using (OperationContextScope scope = new OperationContextScope(utibaClient.InnerChannel))
                {
                    HttpRequestMessageProperty messageProperty = new HttpRequestMessageProperty();
                    messageProperty.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
                    OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, messageProperty);
                    Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Parámetros Recibidos Stock.BuyStockInternal: " +
                                                                                                 "SessionID={0}, DeviceType={1}, Amount={2}", internalRequest.SessionID, internalRequest.DeviceType, internalRequest.Amount), Logger.LoggingLevelType.Low);

                    utibaBuyStockResponse = utibaClient.buyStock(new buyStock()
                    {
                        buyStockRequest = new buyStockRequestType()
                        {
                            sessionid   = internalRequest.SessionID,
                            amount      = internalRequest.Amount,
                            device_type = internalRequest.DeviceType
                        }
                    });
                }
                if (utibaBuyStockResponse != null)
                {
                    internalResponse = new BuyStockResponseInternal()
                    {
                        ResponseCode    = utibaBuyStockResponse.buyStockReturn.result,
                        ResponseMessage = utibaBuyStockResponse.buyStockReturn.result_message,
                        Fee             = utibaBuyStockResponse.buyStockReturn.fee,
                        TransactionID   = utibaBuyStockResponse.buyStockReturn.transid
                    };
                }
                Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Resultado Obtenido Stock.BuyStockInternal: ResponseCode={0}, ResponseMessage={1}, TransactionID={2}, " +
                                                                                             "Fee={3}", internalResponse.ResponseCode, internalResponse.ResponseMessage, internalResponse.TransactionID, internalResponse.Fee), Logger.LoggingLevelType.Low);
            }
            catch (Exception ex)
            {
                Log(Logger.LogMessageType.Error, "Ocurrio una exception procesando el metodo Stock.BuyStockInternal, los detalles son: " + ex.ToString(), Logger.LoggingLevelType.Low);
                return(null);
            }
            Log(Logger.LogMessageType.Info, "->   -------------------- Termina la ejecución del método Stock.BuyStockInternal", Logger.LoggingLevelType.Medium);
            return(internalResponse);
        }
Пример #6
0
        public IMovilwayApiResponse PerformOperation(IMovilwayApiRequest request)
        {
            try
            {
                LOG_PREFIX = HttpContext.Current.Session["LOG_PREFIX"].ToString() + "[" + new Random(DateTime.Now.Millisecond * 5).Next(100000000, 999999999) + "] ";
            }
            catch (Exception)
            {
                LOG_PREFIX = "";
            }

            UMarketSCClient      utibaClient = new UMarketSCClient();
            IMovilwayApiResponse response    = null;

            try
            {
                try
                {
                    logger.InfoLow("[API] " + LOG_PREFIX + "[UtibaProvider] [INPUT] UserInfo {IP=" + HttpContext.Current.Request.UserHostAddress + ",Username="******"} " + request.ToString());
                }
                catch (Exception)
                {
                    logger.InfoLow("[API] " + LOG_PREFIX + "[UtibaProvider] [INPUT] UserInfo {IP=" + "NULL" + ",Username="******"} " + request.ToString());
                }

                int timeOutSeconds = int.Parse(ConfigurationManager.AppSettings["DefaultTimeout"]);
                utibaClient.InnerChannel.OperationTimeout = new TimeSpan(0, 0, timeOutSeconds);

                String sessionID = null;
                if (!(request is GetSessionRequestBody))
                {
                    sessionID = GetSessionID(request);
                }

                response = PerformUtibaOperation(request, utibaClient, sessionID);

                logger.InfoLow("[API] " + LOG_PREFIX + "[UtibaProvider] [OUTPUT] " + response.ToString());
            }
            catch (Exception e)
            {
                logger.ErrorLow("[API] " + LOG_PREFIX + "[UtibaProvider] [EXCEPTION] Exception trying to serve UTIBA Operation {message=" + e.Message + ",stackTrace=" + e.StackTrace + "}");
            }

            return(response);
        }
Пример #7
0
        private TransferStockResponseInternal TransferStockInternal(TransferStockRequestInternal internalRequest)
        {
            TransferStockResponseInternal internalResponse = null;

            try
            {
                UMarketSCClient       utibaClient = new UMarketSCClient();
                transferStockResponse utibaTransferStockResponse = null;
                using (OperationContextScope scope = new OperationContextScope(utibaClient.InnerChannel))
                {
                    HttpRequestMessageProperty messageProperty = new HttpRequestMessageProperty();
                    messageProperty.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
                    OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, messageProperty);

                    utibaTransferStockResponse = utibaClient.transferStock(new transferStock()
                    {
                        transferStockRequest = new transferStockRequestType()
                        {
                            sessionid   = internalRequest.SessionID,
                            amount      = internalRequest.Amount.ToString(),
                            device_type = internalRequest.DeviceType,
                            to          = internalRequest.Agent
                        }
                    });
                }
                if (utibaTransferStockResponse != null)
                {
                    internalResponse = new TransferStockResponseInternal()
                    {
                        ResponseCode    = utibaTransferStockResponse.transferStockReturn.result,
                        ResponseMessage = utibaTransferStockResponse.transferStockReturn.result_message,
                        Fee             = utibaTransferStockResponse.transferStockReturn.fee,
                        TransactionID   = utibaTransferStockResponse.transferStockReturn.transid
                    };
                }
            }
            catch (Exception ex)
            {
                Log(Logger.LogMessageType.Error, "Ocurrio una exception procesando el metodo Stock.TransferStockInternal, los detalles son: " + ex.ToString(), Logger.LoggingLevelType.Low);
                return(null);
            }
            return(internalResponse);
        }
Пример #8
0
        internal MoviPaymentResponseInternal MoviPaymentInternal(MoviPaymentRequestInternal request)
        {
            Log(Logger.LogMessageType.Info, "->   -------------------- Comienza la ejecución del método MoviPin.MoviPaymentInternal", Logger.LoggingLevelType.Medium);
            UMarketSCClient             utibaClient = new UMarketSCClient();
            MoviPaymentResponseInternal movipaymentResult;

            using (OperationContextScope scope = new OperationContextScope(utibaClient.InnerChannel))
            {
                HttpRequestMessageProperty messageProperty = new HttpRequestMessageProperty();
                messageProperty.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
                OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, messageProperty);
                Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Parámetros Recibidos MoviPin.MoviPaymentInternal: SessionID={0}, DeviceType={1}, Amount={2}, " +
                                                                                             "CouponID={3}, Type={4}", request.SessionID, request.DeviceType, request.Amount, request.CouponID, request.Type), Logger.LoggingLevelType.Low);
                Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Parámetros Enviados MoviPin.MoviPaymentInternal: SessionID={0}, DeviceType={1}, Amount={2}, " +
                                                                                             "CouponID={3}, Type={4}", request.SessionID, request.DeviceType, request.Amount, request.CouponID, request.Type), Logger.LoggingLevelType.Low);
                coupontransferResponse myMoviPayment = utibaClient.coupontransfer(new Utiba.coupontransfer()
                {
                    coupontransferRequestType = new coupontransferRequestType()
                    {
                        sessionid = request.SessionID, device_type = request.DeviceType, amount = request.Amount, couponid = request.CouponID, type = request.Type, typeSpecified = true
                    }
                });
                movipaymentResult = new MoviPaymentResponseInternal()
                {
                    ResponseCode      = myMoviPayment.coupontransferReturn.result,
                    ResponseMessage   = myMoviPayment.coupontransferReturn.result_message,
                    TransactionID     = myMoviPayment.coupontransferReturn.transid,
                    Fee               = myMoviPayment.coupontransferReturn.fee,
                    ResultNameSpace   = myMoviPayment.coupontransferReturn.result_namespace,
                    ScheduleID        = myMoviPayment.coupontransferReturn.schedule_id,
                    TransExtReference = myMoviPayment.coupontransferReturn.trans_ext_reference
                };
                Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Resultado Obtenido MoviPin.MoviPaymentInternal: ResponseCode={0}, ResponseMessage={1}, TransactionID={2}, " +
                                                                                             "Fee={3}, ResultNameSpace={4}, ScheduleID={5}, TransExtReference={6}", movipaymentResult.ResponseCode, movipaymentResult.ResponseMessage, movipaymentResult.TransactionID,
                                                                                             movipaymentResult.Fee, movipaymentResult.ResultNameSpace, movipaymentResult.ScheduleID, movipaymentResult.TransExtReference), Logger.LoggingLevelType.Low);
            }
            Log(Logger.LogMessageType.Info, "->   -------------------- Termina la ejecución del método MoviPin.MoviPaymentInternal", Logger.LoggingLevelType.Medium);
            return(movipaymentResult);
        }
Пример #9
0
 public abstract IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID);
Пример #10
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            GetBankListRequestBody  request  = requestObject as GetBankListRequestBody;
            GetBankListResponseBody response = null;

            getBankListResponse utibaGetBankListResponse = utibaClientProxy.getBankList(new getBankList()
            {
                getBankListRequest = new getBankListRequestType()
                {
                    sessionid       = sessionID,
                    device_type     = request.DeviceType,
                    agent_reference = request.Agent
                }
            });

            if (utibaGetBankListResponse != null)
            {
                response = new GetBankListResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaGetBankListResponse.getBankListReturn.result, utibaGetBankListResponse.getBankListReturn.result_namespace),
                    ResponseMessage = utibaGetBankListResponse.getBankListReturn.result_message,
                    TransactionID   = utibaGetBankListResponse.getBankListReturn.transid
                };

                if (utibaGetBankListResponse.getBankListReturn.banks.Length > 0)
                {
                    response.BankList = new BankList();
                    foreach (KeyValuePair1 kvp in utibaGetBankListResponse.getBankListReturn.banks)
                    {
                        response.BankList.Add(int.Parse(kvp.key), kvp.value);
                    }
                }
            }
            return(response);
        }
Пример #11
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            var request = requestObject as UnBlockAgentRequestBody;
            UnBlockAgentResponseBody response = null;


            var utibaModifyAgentResponse = utibaClientProxy.modify(new modify()
            {
                modifyRequest = new modifyRequestType()
                {
                    sessionid   = sessionID,
                    device_type = request.DeviceType,
                    agent       = request.Agent,
                    status      = new modifyRequestTypeStatus()
                    {
                        Suspended          = false,
                        SuspendedSpecified = true
                    }
                }
            });

            if (utibaModifyAgentResponse != null)
            {
                response = new UnBlockAgentResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaModifyAgentResponse.modifyReturn.result, utibaModifyAgentResponse.modifyReturn.result_namespace),
                    ResponseMessage = utibaModifyAgentResponse.modifyReturn.result_message,
                    TransactionID   = utibaModifyAgentResponse.modifyReturn.transid
                };
            }
            return(response);
        }
Пример #12
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            RegisterAgentBulkRequestBody  request  = requestObject as RegisterAgentBulkRequestBody;
            RegisterAgentBulkResponseBody response = new RegisterAgentBulkResponseBody();

            if (request.Agents != null && request.Agents.Count > 0)
            {
                int     counter = 1;
                Boolean failed  = false;
                foreach (AgentDetails agentInfo in request.Agents)
                {
                    if (!AgentRegistrationUtils.AddAgentToFile(agentInfo, request.Agents.Count))
                    {
                        failed = true;
                    }
                    counter++;
                }

                RegisterAgentBulkResponseBody responseBody = new RegisterAgentBulkResponseBody();
                if (failed)
                {
                    responseBody.ResponseCode    = 1;
                    responseBody.ResponseMessage = "Algunos de los registros en el archivo fallaron, por favor contacte a soporte";
                }
                else
                {
                    responseBody.ResponseCode    = 0;
                    responseBody.ResponseMessage = "Su peticion ha sido procesada";
                }
            }
            else
            {
                response = new RegisterAgentBulkResponseBody()
                {
                    ResponseCode    = 1,
                    ResponseMessage = "Su peticion falló por no contener agentes, por favor verifique los datos e intente de nuevo",
                    TransactionID   = 0
                };
            }
            return(response);
        }
Пример #13
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            GetAgentInfoRequestBody  request  = requestObject as GetAgentInfoRequestBody;
            GetAgentInfoResponseBody response = null;

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetAgentInfoProvider] [SEND-DATA] getAgentByReferenceRequest {sessionid=" + sessionID + ",device_type=" + request.DeviceType + ",reference=" + request.Agent + ",category=agent}");

            AgentResponse utibaGetAgentResponse = utibaClientProxy.getAgentByReference(new getAgentByReference()
            {
                getAgentByReferenceRequest = new getAgentByReferenceRequest()
                {
                    sessionid   = sessionID,
                    device_type = request.DeviceType,
                    reference   = request.Agent,
                    category    = "agent"
                }
            });

            StringBuilder sb = new StringBuilder();

            foreach (var agentData in utibaGetAgentResponse.AgentReturn.agent.agentData)
            {
                sb.Append("agentData={key=" + agentData.key + ",value=" + agentData.value + "},");
            }
            if (sb.Length > 0)
            {
                sb.Remove(sb.Length - 1, 1);
            }

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetAgentInfoProvider] [RECV-DATA] agentResponse {transid=" + utibaGetAgentResponse.AgentReturn.transid + ",result=" + utibaGetAgentResponse.AgentReturn.result +
                           ",result_namespace=" + utibaGetAgentResponse.AgentReturn.result_namespace + ",agent={ID=" + utibaGetAgentResponse.AgentReturn.agent.ID + ",referenceID=" + utibaGetAgentResponse.AgentReturn.agent.referenceID +
                           ",agentID=" + utibaGetAgentResponse.AgentReturn.agent.agentID + ",ownerID=" + utibaGetAgentResponse.AgentReturn.agent.ownerID + ",name=" + utibaGetAgentResponse.AgentReturn.agent.name +
                           ",MSISDN=" + utibaGetAgentResponse.AgentReturn.agent.MSISDN + ",reference=" + utibaGetAgentResponse.AgentReturn.agent.reference + ",entityReference={reference=" + utibaGetAgentResponse.AgentReturn.agent.entityReference.reference + "}" +
                           ",salt=" + utibaGetAgentResponse.AgentReturn.agent.salt + ",emailAddress=" + utibaGetAgentResponse.AgentReturn.agent.emailAddress + ",SMSAddress=" + utibaGetAgentResponse.AgentReturn.agent.SMSAddress +
                           ",Language=" + utibaGetAgentResponse.AgentReturn.agent.Language + ",upstream=" + utibaGetAgentResponse.AgentReturn.agent.upstream + ",status=" + utibaGetAgentResponse.AgentReturn.agent.status +
                           ",agentType=" + utibaGetAgentResponse.AgentReturn.agent.agentType + ",primaryGroup=" + utibaGetAgentResponse.AgentReturn.agent.primaryGroup + ",depth=" + utibaGetAgentResponse.AgentReturn.agent.depth + "," + sb.ToString() +
                           ",createdDate=" + utibaGetAgentResponse.AgentReturn.agent.createdDate + ",organisation=" + utibaGetAgentResponse.AgentReturn.agent.organisation + ",DSComission=" + utibaGetAgentResponse.AgentReturn.agent.DSComission +
                           ",POSComission=" + utibaGetAgentResponse.AgentReturn.agent.POSComission + ",category=" + utibaGetAgentResponse.AgentReturn.agent.category + "}}");

            Func <String, KeyValuePair[], String> findItem = (k, a) =>
            {
                if (a != null)
                {
                    var node = a.FirstOrDefault(kvp => kvp.key.Equals(k));
                    if (node != null)
                    {
                        return(node.value);
                    }
                }
                return(null);
            };


            if (utibaGetAgentResponse != null && utibaGetAgentResponse.AgentReturn.result == 0)
            {
                response = new GetAgentInfoResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaGetAgentResponse.AgentReturn.result, utibaGetAgentResponse.AgentReturn.result_namespace),
                    ResponseMessage = utibaGetAgentResponse.AgentReturn.result_namespace,
                    TransactionID   = utibaGetAgentResponse.AgentReturn.transid,
                    AgentInfo       = new AgentInfo()
                    {
                        Agent          = request.Agent,
                        NationalIDType = findItem("nat_id_type", utibaGetAgentResponse.AgentReturn.agent.agentData),
                        NationalID     = findItem("nat_id", utibaGetAgentResponse.AgentReturn.agent.agentData),
                        Address        = utibaGetAgentResponse.AgentReturn.agent.address ?? findItem("address", utibaGetAgentResponse.AgentReturn.agent.agentData),
                        Email          = utibaGetAgentResponse.AgentReturn.agent.emailAddress,
                        Name           = utibaGetAgentResponse.AgentReturn.agent.name,
                        Depth          = utibaGetAgentResponse.AgentReturn.agent.depth,
                        BirthDate      = findItem("dob", utibaGetAgentResponse.AgentReturn.agent.agentData),
                        Gender         = findItem("gender", utibaGetAgentResponse.AgentReturn.agent.agentData),
                        LegalName      = findItem("legal_name", utibaGetAgentResponse.AgentReturn.agent.agentData),

                        //Elementos privados
                        AgentID     = utibaGetAgentResponse.AgentReturn.agent.agentID,
                        ReferenceID = utibaGetAgentResponse.AgentReturn.agent.referenceID,
                        OwnerID     = utibaGetAgentResponse.AgentReturn.agent.ownerID,
                        BranchID    = utibaGetAgentResponse.AgentReturn.agent.agentID
                    }
                };
            }
            else
            {
                response = new GetAgentInfoResponseBody
                {
                    ResponseCode    = 99,
                    ResponseMessage = "Ocurrio un problema procesando su solicitud"
                };
            }
            return(response);
        }
Пример #14
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            PayStockRequestBody  request  = requestObject as PayStockRequestBody;
            PayStockResponseBody response = null;

            payStockResponse utibaPayStockResponse = utibaClientProxy.payStock(new payStock()
            {
                payStockRequest = new payStockRequestType()
                {
                    sessionid     = sessionID,
                    wait          = false,
                    waitSpecified = true,
                    device_type   = request.DeviceType,
                    amount        = request.Amount,
                    details       = ("Bank: " + request.BankName ?? "NULL") + " - Description: " + (request.Description ?? "NULL") + " - REF.: " + (request.TransactionReference ?? "NULL")
                }
            });

            if (utibaPayStockResponse != null)
            {
                response = new PayStockResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaPayStockResponse.payStockReturn.result, utibaPayStockResponse.payStockReturn.result_namespace),
                    ResponseMessage = utibaPayStockResponse.payStockReturn.result_message,
                    Fee             = utibaPayStockResponse.payStockReturn.fee,
                    TransactionID   = utibaPayStockResponse.payStockReturn.transid
                };
            }
            return(response);
        }
Пример #15
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            GetSessionRequestBody  request  = requestObject as GetSessionRequestBody;
            GetSessionResponseBody response = null;

            createsessionResponse newSessionResponse = utibaClientProxy.createsession(new createsession());
            String PIN = Utils.GenerateHash(newSessionResponse.createsessionReturn.sessionid, request.Username, request.Password);

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetSessionProvider] [SEND-DATA] loginRequest {sessionid=" + newSessionResponse.createsessionReturn.sessionid + ",device_type=" + request.DeviceType + ",initiator=" + request.Username + ",pin=" + PIN + "}");

            loginResponse loginResponse = utibaClientProxy.login(new login()
            {
                loginRequest = new loginRequestType()
                {
                    sessionid   = newSessionResponse.createsessionReturn.sessionid,
                    device_type = request.DeviceType,
                    initiator   = request.Username,
                    pin         = PIN
                }
            });

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetSessionProvider] [RECV-DATA] loginResponse {result=" + loginResponse.loginReturn.result + ",result_namespace=" + loginResponse.loginReturn.result_namespace + "}");

            response = new GetSessionResponseBody()
            {
                ResponseCode    = Utils.BuildResponseCode(loginResponse.loginReturn.result, loginResponse.loginReturn.result_namespace),
                ResponseMessage = loginResponse.loginReturn.result_message,
                TransactionID   = loginResponse.loginReturn.transid,
                SessionID       = newSessionResponse.createsessionReturn.sessionid
            };

            if (response.ResponseCode == 0)
            {
                if (ConfigurationManager.AppSettings["ProcessMigration"].ToLower() == "true")
                {
                    //logger.InfoHigh("Comienza la migración del usuario: " + request.AuthenticationData.Username);
                    bool migrateAgent = MigrateAgent(request.AuthenticationData.Username);
                    int  deviceType   = GetDeviceType(request.AuthenticationData.Username);
                    if (migrateAgent)
                    {
                        // Cambio de password Kinacu
                        var changePinResponse = new ServiceExecutionDelegator <ChangePinResponseBody, ChangePinRequestBody>().ResolveRequest(
                            new ChangePinRequestBody()
                        {
                            AuthenticationData = new AuthenticationData()
                            {
                                Username = request.AuthenticationData.Username,
                                Password = ConfigurationManager.AppSettings["StandardOldPin"]
                            },
                            DeviceType = deviceType,                                     /*int.Parse(ConfigurationManager.AppSettings["StandardNewDeviceType"]),*/
                            Agent      = request.AuthenticationData.Username,
                            OldPin     = ConfigurationManager.AppSettings["StandardOldPin"],
                            NewPin     = request.AuthenticationData.Password
                        }, ApiTargetPlatform.Kinacu, ApiServiceName.ChangePin);

                        // Login con Kinacu - NOT NOW - La proxima vez que entre va por Kinacu de una

                        //logger.InfoHigh("Resultado del cambio de clave del usuario: " + changePinResponse.ResponseCode);

                        // Save in DB
                        if (changePinResponse.ResponseCode == 0)
                        {
                            //logger.InfoHigh("Se migró exitosamente la clave del usuario: " + request.AuthenticationData.Username);
                            SaveAgentMigrated(request.AuthenticationData.Username);
                        }
                    }
                }

                // REPG2013 - esto queda deshabilitado por ahora

                // For speeding up, I'm caching the session value:
                //-var couchBaseClient = new CouchbaseClient();
                //-couchBaseClient.Store(StoreMode.Set, Utils.GetSessionForUserKey(request.Username, request.Password), response.SessionID, new TimeSpan(0, UtibaUtils.SessionTTL, 0));
                // Also caching the
                //-couchBaseClient.Store(StoreMode.Set, Utils.GetUserForSessionKey(response.SessionID), request.Username, new TimeSpan(0, UtibaUtils.SessionTTL, 0));
            }
            return(response);
        }
Пример #16
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            TransferStockRequestBody  request  = requestObject as TransferStockRequestBody;
            TransferStockResponseBody response = null;

            transferStockResponse utibaTransferStockResponse = utibaClientProxy.transferStock(new transferStock()
            {
                transferStockRequest = new transferStockRequestType()
                {
                    sessionid   = sessionID,
                    amount      = request.Amount.ToString(),
                    device_type = request.DeviceType,
                    to          = request.Agent
                }
            });

            if (utibaTransferStockResponse != null)
            {
                response = new TransferStockResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaTransferStockResponse.transferStockReturn.result, utibaTransferStockResponse.transferStockReturn.result_namespace),
                    ResponseMessage = utibaTransferStockResponse.transferStockReturn.result_message,
                    Fee             = utibaTransferStockResponse.transferStockReturn.fee,
                    TransactionID   = utibaTransferStockResponse.transferStockReturn.transid
                };
            }
            return(response);
        }
Пример #17
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            ChangePinRequestBody  request  = requestObject as ChangePinRequestBody;
            ChangePinResponseBody response = null;

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[ChangePinProvider] [SEND-DATA] pinRequest {sessionId=" + sessionID + ",device_type=" + request.DeviceType +
                           ",new_pin=******,pin=******,initiator=" + request.Agent + "}");

            string currentPinHash = Utils.GenerateHash(sessionID, request.Agent, request.OldPin);
            //string newPinHash = Utils.GenerateHash(sessionID, internalRequest.Initiator, internalRequest.CurrentPin);
            pinResponse pinChangeUtiba = utibaClientProxy.pin(new pin()
            {
                pinRequest = new pinRequestType()
                {
                    sessionid   = sessionID,
                    device_type = request.DeviceType,
                    new_pin     = request.NewPin,
                    pin         = currentPinHash,
                    initiator   = request.Agent
                }
            });

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[ChangePinProvider] [RECV-DATA] pinResponse {transid=" + pinChangeUtiba.pinReturn.transid +
                           ",result=" + pinChangeUtiba.pinReturn.result +
                           ",result_namespace=" + pinChangeUtiba.pinReturn.result_namespace +
                           ",result_message=" + pinChangeUtiba.pinReturn.result_message + "}");

            if (pinChangeUtiba != null)
            {
                response = new ChangePinResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(pinChangeUtiba.pinReturn.result, pinChangeUtiba.pinReturn.result_namespace),
                    ResponseMessage = pinChangeUtiba.pinReturn.result_message,
                    TransactionID   = pinChangeUtiba.pinReturn.transid
                };
            }
            return(response);
        }
Пример #18
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            RegisterAgentRequestBody  request  = requestObject as RegisterAgentRequestBody;
            RegisterAgentResponseBody response = new RegisterAgentResponseBody();

            if (AgentRegistrationUtils.AddAgentToFile(request.Agent, 1))
            {
                response.ResponseCode    = 0;
                response.ResponseMessage = "Agente agregado satisfactoriamente al archivo de carga";
            }
            else
            {
                response.ResponseCode    = 1;
                response.ResponseMessage = "Ocurrio un error tratando de agregar el agente al archivo de carga";
            }
            return(response);
        }
Пример #19
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            GetAgentGroupsRequestBody  request  = requestObject as GetAgentGroupsRequestBody;
            GetAgentGroupsResponseBody response = null;

            GetAgentInfoResponseBody agentInfo = new ServiceExecutionDelegator <GetAgentInfoResponseBody, GetAgentInfoRequestBody>().ResolveRequest(
                new GetAgentInfoRequestBody()
            {
                AuthenticationData = new AuthenticationData()
                {
                    SessionID = sessionID
                },
                Agent      = request.Agent,
                DeviceType = request.DeviceType
            }, ApiTargetPlatform.Utiba, ApiServiceName.GetAgentInfo);

            AgentGroupsResponse utibaAgentGroupsResponse = utibaClientProxy.getAgentGroupByAgentID(new getAgentGroupByAgentID()
            {
                getAgentGroupByAgentIDRequest = new getAgentGroupByAgentIDRequest()
                {
                    sessionid   = sessionID,
                    device_type = request.DeviceType,
                    agentID     = agentInfo.AgentInfo.AgentID
                }
            });

            if (utibaAgentGroupsResponse != null)
            {
                response = new GetAgentGroupsResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaAgentGroupsResponse.AgentGroupsReturn.result, utibaAgentGroupsResponse.AgentGroupsReturn.result_namespace),
                    ResponseMessage = utibaAgentGroupsResponse.AgentGroupsReturn.result_namespace,
                    TransactionID   = utibaAgentGroupsResponse.AgentGroupsReturn.transid
                };

                if (utibaAgentGroupsResponse.AgentGroupsReturn.agentGroups != null &&
                    utibaAgentGroupsResponse.AgentGroupsReturn.agentGroups.Length > 0)
                {
                    response.GroupList = new GroupList();
                    foreach (AgentGroup agentGroup in utibaAgentGroupsResponse.AgentGroupsReturn.agentGroups)
                    {
                        response.GroupList.Add(new GroupInfo()
                        {
                            GroupID  = agentGroup.ID,
                            Name     = agentGroup.name,
                            Category = agentGroup.category,
                            Type     = agentGroup.type
                        });
                    }
                }
            }
            return(response);
        }
Пример #20
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            TopUpRequestBody request = requestObject as TopUpRequestBody;

            int timeOutSeconds = int.Parse(ConfigurationManager.AppSettings["DefaultTimeout"]);

            if (ConfigurationManager.AppSettings["TopUp_Timeout_" + request.MNO.ToLower()] != null)
            {
                timeOutSeconds = int.Parse(ConfigurationManager.AppSettings["TopUp_Timeout_" + request.MNO.ToLower()]);
            }

            utibaClientProxy.InnerChannel.OperationTimeout = new TimeSpan(0, 0, timeOutSeconds);


            TopUpResponseBody response = null;

            if (request.WalletType == WalletType.NotSpecified || request.WalletType == WalletType.Stock)
            {
                logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[TopUpProvider] [SEND-DATA] topupRequest {sessionid=" + sessionID + ",device_type=" + request.DeviceType + ",mno=" + request.MNO + ",amount=" + request.Amount +
                               ",recipient=" + request.Recipient + ",mno_defined_id=" + request.TerminalID + ",host_trans_ref=" + request.ExternalTransactionReference + "}");

                topupResponse utibaTopUpResponse = utibaClientProxy.topup(new topup()
                {
                    topupRequest = new topupRequestType()
                    {
                        sessionid      = sessionID,
                        device_type    = request.DeviceType,
                        mno            = request.MNO,
                        amount         = request.Amount,
                        recipient      = request.Recipient,
                        host_trans_ref = request.ExternalTransactionReference,
                        mno_defined_id = request.TerminalID
                    }
                });

                logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[TopUpProvider] [RECV-DATA] topupResponse {transid=" + utibaTopUpResponse.topupReturn.transid + ",result=" + utibaTopUpResponse.topupReturn.result +
                               ",result_namespace=" + utibaTopUpResponse.topupReturn.result_namespace + ",result_message=" + utibaTopUpResponse.topupReturn.result_message + "}");

                response = new TopUpResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaTopUpResponse.topupReturn.result, utibaTopUpResponse.topupReturn.result_namespace),
                    ResponseMessage = utibaTopUpResponse.topupReturn.result_message,
                    TransactionID   = utibaTopUpResponse.topupReturn.transid,
                    ExternalTransactionReference = request.ExternalTransactionReference, //utibaTopUpResponse.topupReturn.trans_ext_reference,
                    Fee = utibaTopUpResponse.topupReturn.fee
                };
            }
            else if (request.WalletType == WalletType.eWallet)
            {
                logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[TopUpProvider] [SEND-DATA] buyRequest {sessionid=" + sessionID + ",device_type=" + request.DeviceType +
                               ",mno=" + request.MNO + ",amount=" + request.Amount + ",recipient=" + request.Recipient + "}");

                buyResponse buyResponse = utibaClientProxy.buy(new buy()
                {
                    buyRequest = new buyRequestType()
                    {
                        sessionid   = sessionID,
                        device_type = request.DeviceType,
                        target      = request.MNO,
                        amount      = request.Amount,
                        recipient   = request.Recipient
                    }
                });

                logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[TopUpProvider] [RECV-DATA] buyResponse {transid=" + buyResponse.buyReturn.transid + ",result=" + buyResponse.buyReturn.result +
                               ",result_namespace=" + buyResponse.buyReturn.result_namespace + ",result_message=" + buyResponse.buyReturn.result_message + "}");

                response = new TopUpResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(buyResponse.buyReturn.result, buyResponse.buyReturn.result_namespace),
                    ResponseMessage = buyResponse.buyReturn.result_message,
                    TransactionID   = buyResponse.buyReturn.transid,
                    ExternalTransactionReference = request.ExternalTransactionReference,
                    Fee = buyResponse.buyReturn.fee
                };
            }
            AuthenticationData cascadeAuth = new AuthenticationData()
            {
                SessionID = sessionID
            };

            GetBalanceResponseBody balanceResponse = new ServiceExecutionDelegator <GetBalanceResponseBody, GetBalanceRequestBody>().ResolveRequest(new GetBalanceRequestBody()
            {
                AuthenticationData = cascadeAuth,
                DeviceType         = request.DeviceType
            }, ApiTargetPlatform.Utiba, ApiServiceName.GetBalance);

            if (response != null)
            {
                response.StockBalance  = balanceResponse.StockBalance.Value;
                response.WalletBalance = balanceResponse.WalletBalance.Value;
                response.PointBalance  = balanceResponse.PointsBalance.Value;
            }
            return(response);
        }
Пример #21
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            GetProvinceListRequestBody  request  = requestObject as GetProvinceListRequestBody;
            GetProvinceListResponseBody response = null;

            UtibaRegistrationDataContext utibaRegistration = new UtibaRegistrationDataContext();
            List <Province> provinces = utibaRegistration.Provinces.Where(p => p.CountryId == _countryID).ToList();

            if (provinces != null && provinces.Count > 0)
            {
                response = new GetProvinceListResponseBody()
                {
                    ResponseCode = 0,
                    ProvinceList = new ProvinceList()
                };
                foreach (Province province in provinces)
                {
                    response.ProvinceList.Add(province.ProvinceId, province.ProvinceName);
                }
            }
            else
            {
                response = new GetProvinceListResponseBody()
                {
                    ResponseCode    = 1,
                    ResponseMessage = "No se encuentran registradas provincias para el pais donde se encuentra"
                };
            }
            return(response);
        }
Пример #22
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            GetGroupListRequestBody  request  = requestObject as GetGroupListRequestBody;
            GetGroupListResponseBody response = null;

            AgentGroupsResponse utibaGetAllAgentGroupsResponse = utibaClientProxy.getAllAgentGroups(new getAllAgentGroups()
            {
                getAllAgentGroupsRequest = new getAllGroupsRequestType()
                {
                    sessionid   = sessionID,
                    device_type = request.DeviceType,
                    filter      = new getAllGroupsRequestTypeFilter()
                    {
                        category             = "agent",
                        includeUncategorised = true
                    }
                }
            });

            if (utibaGetAllAgentGroupsResponse != null)
            {
                response = new GetGroupListResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaGetAllAgentGroupsResponse.AgentGroupsReturn.result, utibaGetAllAgentGroupsResponse.AgentGroupsReturn.result_namespace),
                    ResponseMessage = utibaGetAllAgentGroupsResponse.AgentGroupsReturn.result_namespace,
                    TransactionID   = utibaGetAllAgentGroupsResponse.AgentGroupsReturn.transid
                };

                if (utibaGetAllAgentGroupsResponse.AgentGroupsReturn.agentGroups != null &&
                    utibaGetAllAgentGroupsResponse.AgentGroupsReturn.agentGroups.Length > 0)
                {
                    response.GroupList = new GroupList();
                    foreach (AgentGroup agentGroup in utibaGetAllAgentGroupsResponse.AgentGroupsReturn.agentGroups)
                    {
                        response.GroupList.Add(new GroupInfo()
                        {
                            GroupID  = agentGroup.ID,
                            Name     = agentGroup.name,
                            Category = agentGroup.category,
                            Type     = agentGroup.type
                        });
                    }
                }
            }
            return(response);
        }
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            GetLastTransactionsRequestBody  request  = requestObject as GetLastTransactionsRequestBody;
            GetLastTransactionsResponseBody response = null;

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetLastTransactionsProvider] [SEND-DATA] lastTransactionsRequest {sessionid=" + sessionID + ",device_type=" + request.DeviceType + ",transCount=" + request.Count + ",agent=" + request.Agent + "}");

            lastTransactionsResponse utibaGetLastTransactionsResponse = utibaClientProxy.lastTransactions(new lastTransactionsRequest()
            {
                lastTransactionsRequestType = new lastTransactionsRequestType()
                {
                    sessionid   = sessionID,
                    device_type = request.DeviceType,
                    agent       = request.Agent,
                    transCount  = request.Count
                }
            });

            StringBuilder sb = new StringBuilder(), sb2;

            foreach (var transaction in utibaGetLastTransactionsResponse.lastTransactionsReturn.transactionsList)
            {
                sb2 = new StringBuilder();
                foreach (var party in transaction.partiesReferenceIdList)
                {
                    sb2.Append("partiesReferenceIdList=" + party + ",");
                }
                if (sb2.Length > 0)
                {
                    sb2.Remove(sb2.Length - 1, 1);
                }

                sb.Append("transactionsList={transactionId=" + transaction.transactionId + ",transactionType=" + transaction.transactionType +
                          ",lastModified=" + transaction.lastModified + ",amount=" + transaction.amount + "," + sb2.ToString() + "},");
            }
            if (sb.Length > 0)
            {
                sb.Remove(sb.Length - 1, 1);
            }

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetLastTransactionsProvider] [RECV-DATA] lastTransactionsResponse " +
                           "{transid=" + utibaGetLastTransactionsResponse.lastTransactionsReturn.transid +
                           ",result=" + utibaGetLastTransactionsResponse.lastTransactionsReturn.result +
                           ",result_namespace=" + utibaGetLastTransactionsResponse.lastTransactionsReturn.result_namespace +
                           "," + sb.ToString() + "}");

            if (utibaGetLastTransactionsResponse != null)
            {
                response = new GetLastTransactionsResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaGetLastTransactionsResponse.lastTransactionsReturn.result, utibaGetLastTransactionsResponse.lastTransactionsReturn.result_namespace),
                    ResponseMessage = utibaGetLastTransactionsResponse.lastTransactionsReturn.result_namespace,
                    TransactionID   = utibaGetLastTransactionsResponse.lastTransactionsReturn.transid
                };

                if (utibaGetLastTransactionsResponse.lastTransactionsReturn.transactionsList != null &&
                    utibaGetLastTransactionsResponse.lastTransactionsReturn.transactionsList.Length > 0)
                {
                    response.Transactions = new TransactionList();
                    foreach (Movilway.API.Utiba.TransactionSummary transaction in utibaGetLastTransactionsResponse.lastTransactionsReturn.transactionsList)
                    {
                        DataContract.TransactionSummary currentTransactionSummary = new DataContract.TransactionSummary()
                        {
                            TransactionType       = Utils.GetTransactionTypeName(transaction.transactionType),
                            Amount                = transaction.amount,
                            LastTimeModified      = transaction.lastModified,
                            OriginalTransactionID = transaction.transactionId
                        };

                        if (transaction.partiesReferenceIdList != null && transaction.partiesReferenceIdList.Length > 0)
                        {
                            currentTransactionSummary.RelatedParties = new RelatedParties();
                            currentTransactionSummary.RelatedParties.AddRange(transaction.partiesReferenceIdList);
                        }
                        response.Transactions.Add(currentTransactionSummary);
                    }
                }
            }
            return(response);
        }
Пример #24
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            GetProductListRequestBody  request  = requestObject as GetProductListRequestBody;
            GetProductListResponseBody response = null;

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetProductListProvider] [SEND-DATA] getProductListRequest {sessionId=" + sessionID + ",device_type=" + request.DeviceType + ",agent_reference=" + request.Agent + "}");

            getProductListResponse utibaGetProductListResponse = utibaClientProxy.getProductList(new getProductList()
            {
                getProductListRequest = new getProductListRequestType()
                {
                    sessionid       = sessionID,
                    device_type     = request.DeviceType,
                    agent_reference = request.Agent
                }
            });

            StringBuilder sb = new StringBuilder("products={");

            foreach (var pair in utibaGetProductListResponse.getProductListReturn.products)
            {
                sb.Append("keyValuePair={key=" + pair.key + ",value=" + pair.value + "},");
            }
            sb.Remove(sb.Length - 1, 1);
            sb.Append("}");

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetProductListProvider] [RECV-DATA] getProductListResponse {transid=" + utibaGetProductListResponse.getProductListReturn.transid +
                           ",result=" + utibaGetProductListResponse.getProductListReturn.result +
                           ",result_namespace=" + utibaGetProductListResponse.getProductListReturn.result_namespace +
                           "," + sb.ToString() + "}");

            if (utibaGetProductListResponse != null)
            {
                response = new GetProductListResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaGetProductListResponse.getProductListReturn.result, utibaGetProductListResponse.getProductListReturn.result_namespace),
                    ResponseMessage = utibaGetProductListResponse.getProductListReturn.result_message,
                    TransactionID   = utibaGetProductListResponse.getProductListReturn.transid
                };
                if (utibaGetProductListResponse.getProductListReturn.products != null &&
                    utibaGetProductListResponse.getProductListReturn.products.Length > 0)
                {
                    response.ProductList = new ProductList();
                    foreach (KeyValuePair1 keyValuePair1 in utibaGetProductListResponse.getProductListReturn.products)
                    {
                        response.ProductList.Add(keyValuePair1.key, keyValuePair1.value);
                    }
                }
            }
            return(response);
        }
Пример #25
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            GetSalesSummaryRequestBody  request  = requestObject as GetSalesSummaryRequestBody;
            GetSalesSummaryResponseBody response = null;

            //int startEpochTime = Utils.FromDateTimeToEpoch(request.StartDate);
            //int endEpochTime = Utils.FromDateTimeToEpoch(request.EndDate);

            response = new GetSalesSummaryResponseBody()
            {
                ResponseCode    = 0,
                ResponseMessage = "OK",
                Summaries       = Utils.SalesSummary(request.AuthenticationData.Username, request.Date, (int)request.WalletType),
                SummaryDate     = request.Date,
                TransactionID   = new Random().Next(100000, 999999)
            };

            //salesResponse utibaSalesResponse = utibaClientProxy.sales(new sales()
            //{
            //    salesRequest = new salesRequestType()
            //    {
            //        sessionid = sessionID,
            //        device_type = request.DeviceType,
            //        start = (startEpochTime * 1000L),
            //        startSpecified = true,
            //        end = (endEpochTime * 1000L),
            //        endSpecified = true,
            //        type = (int)request.WalletType,
            //        target = request.Product
            //    }
            //});

            //if (utibaSalesResponse != null)
            //{
            //    response = new GetSalesSummaryResponseBody()
            //    {
            //        ResponseCode = utibaSalesResponse.salesReturn.result,
            //        ResponseMessage = utibaSalesResponse.salesReturn.result_message,
            //        TransactionID = utibaSalesResponse.salesReturn.transid,
            //        TransactionCount = utibaSalesResponse.salesReturn.count,
            //        TotalAmount = utibaSalesResponse.salesReturn.sum
            //    };
            //}
            return(response);
        }
Пример #26
0
        public static TopUpResponseInternal TopUpInternal(TopUpRequestInternal request)
        {
            UMarketSCClient       utibaClient = new UMarketSCClient();
            TopUpResponseInternal topUpResult = null;

            try
            {
                int timeOutSeconds = int.Parse(ConfigurationManager.AppSettings["DefaultTimeout"]);
                if (ConfigurationManager.AppSettings["TopUp_Timeout_" + request.MNO.ToLower()] != null)
                {
                    timeOutSeconds = int.Parse(ConfigurationManager.AppSettings["TopUp_Timeout_" + request.MNO.ToLower()]);
                }

                Log(Logger.LogMessageType.Info, "-> TimeOut: " + timeOutSeconds + ", mno: " + request.MNO.ToLower(), Logger.LoggingLevelType.Low);

                utibaClient.InnerChannel.OperationTimeout = new TimeSpan(0, 10, timeOutSeconds);
                using (OperationContextScope scope = new OperationContextScope(utibaClient.InnerChannel))
                {
                    HttpRequestMessageProperty messageProperty = new HttpRequestMessageProperty();
                    messageProperty.Headers.Add(HttpRequestHeader.UserAgent, ApiServiceBase.UserAgent);
                    OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, messageProperty);

                    topupResponse myTopUp = utibaClient.topup(new Utiba.topup()
                    {
                        topupRequest = new Utiba.topupRequestType()
                        {
                            sessionid = request.SessionID, device_type = request.DeviceType, mno = request.MNO, amount = request.Amount, recipient = request.Recipient, host_trans_ref = request.HostTransRef, mno_defined_id = request.MNODefinedID
                        }
                    });


                    BalanceResponseInternal balanceResponse = BalanceProvider.BalanceInternal(new BalanceRequestInternal()
                    {
                        DeviceType = request.DeviceType,
                        SessionID  = request.SessionID
                    });

                    // Remuevo el codigo de respuesta del protocolo en caso de que este disponible
                    String modifiedResultMessage = null;
                    String backendResponseCode   = null;
                    if (myTopUp.topupReturn.result_message != null)
                    {
                        int namespaceIndex = myTopUp.topupReturn.result_message.IndexOf("IPR:");
                        namespaceIndex = namespaceIndex > 0 ? namespaceIndex : myTopUp.topupReturn.result_message.IndexOf("MNO:");
                        if (namespaceIndex > 0)
                        {
                            backendResponseCode = myTopUp.topupReturn.result_message.Substring(namespaceIndex + 4,
                                                                                               myTopUp.topupReturn.result_message.IndexOf(":", namespaceIndex + 5) - (namespaceIndex + 4));
                        }
                        else
                        {
                            modifiedResultMessage = myTopUp.topupReturn.result_message;
                        }
                    }

                    topUpResult = new TopUpResponseInternal()
                    {
                        ResponseCode    = myTopUp.topupReturn.result,
                        ResponseMessage = modifiedResultMessage,
                        TransactionID   = myTopUp.topupReturn.transid,
                        HostTransRef    = request.HostTransRef,
                        Fee             = myTopUp.topupReturn.fee,
                        BalanceStock    = balanceResponse.StockBalance
                    };
                    Log(Logger.LogMessageType.Info, "-> HostTransRef: " + topUpResult.HostTransRef + "; Resultado Obtenido (TopUp): Result: " + topUpResult.ResponseCode + "; ResultMessage: " + topUpResult.ResponseMessage + "; TransId: " + topUpResult.TransactionID + "; HostTransRef: " + topUpResult.HostTransRef + "; Fee: " + topUpResult.Fee + ", BalanceStock: " + topUpResult.BalanceStock, Logger.LoggingLevelType.Low);
                    Log(Logger.LogMessageType.Info, "-> HostTransRef: " + topUpResult.HostTransRef + " -------------------- Termina la ejecución del método TopUp", Logger.LoggingLevelType.Low);
                }

                if (topUpResult.ResponseCode != 0)
                {
                    topUpResult.SetResponseNamespace(ApiResponseInternal.ResponseNamespace.BAC);
                }
            }
            catch (Exception e)
            {
                if (topUpResult == null)
                {
                    topUpResult = new TopUpResponseInternal();
                }
                topUpResult.SetThrowedException(e);
            }

            return(topUpResult);
        }
Пример #27
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            UnMapAgentToGroupRequestBody  request  = requestObject as UnMapAgentToGroupRequestBody;
            UnMapAgentToGroupResponseBody response = null;

            unmapAgentResponse utibaUnMapAgentResponse = utibaClientProxy.unmapAgent(new unmapAgentRequest()
            {
                unmapAgentRequestType = new unmapAgentRequestType()
                {
                    sessionid   = sessionID,
                    device_type = request.DeviceType,
                    agid        = request.GroupID,
                    agent       = request.Agent
                }
            });

            if (utibaUnMapAgentResponse != null)
            {
                response = new UnMapAgentToGroupResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaUnMapAgentResponse.unmapAgentReturn.result, utibaUnMapAgentResponse.unmapAgentReturn.result_namespace),
                    ResponseMessage = utibaUnMapAgentResponse.unmapAgentReturn.result_message,
                    TransactionID   = utibaUnMapAgentResponse.unmapAgentReturn.transid
                };
            }
            return(response);
        }
Пример #28
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            CreateMoviPinRequestBody  request  = requestObject as CreateMoviPinRequestBody;
            CreateMoviPinResponseBody response = null;

            createcouponRequestType createCouponRequest = new createcouponRequestType()
            {
                sessionid            = sessionID,
                device_type          = request.DeviceType,
                amount               = request.Amount,
                amountSpecified      = true,
                wallet_type          = int.Parse(ConfigurationManager.AppSettings["CouponWalletType"]),
                wallet_typeSpecified = true,
                reserve              = true,
                reserveSpecified     = true,
                wait            = false,
                expiry          = int.Parse(ConfigurationManager.AppSettings["CouponExpiryDays"]),
                expirySpecified = true
            };

            if (!String.IsNullOrEmpty(request.ProductId))
            {
                createCouponRequest.extra_trans_data = new KeyValuePair[] { new KeyValuePair()
                                                                            {
                                                                                key = "product_id", value = request.ProductId
                                                                            } }
            }
            ;

            createcoupon utibaCreateCouponRequest = new createcoupon()
            {
                createcouponRequest = createCouponRequest
            };

            if (request.Recipient != null)
            {
                utibaCreateCouponRequest.createcouponRequest.recipient = request.Recipient;
            }
            createcouponResponse utibaCreateCouponResponse = utibaClientProxy.createcoupon(utibaCreateCouponRequest);

            if (utibaCreateCouponResponse != null)
            {
                response = new CreateMoviPinResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaCreateCouponResponse.createcouponReturn.result, utibaCreateCouponResponse.createcouponReturn.result_namespace),
                    ResponseMessage = utibaCreateCouponResponse.createcouponReturn.result_message,
                    TransactionID   = utibaCreateCouponResponse.createcouponReturn.transid,
                    MoviPin         = utibaCreateCouponResponse.createcouponReturn.couponid,
                    Fee             = utibaCreateCouponResponse.createcouponReturn.fee,
                    ExpiryDate      = DateTime.Now.Date.AddDays(int.Parse(ConfigurationManager.AppSettings["CouponExpiryDays"]))
                };
            }
            return(response);
        }
    }
Пример #29
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            CashOutRequestBody  request  = requestObject as CashOutRequestBody;
            CashOutResponseBody response = null;

            // 5 minutos de timeout para la operacion
            utibaClientProxy.InnerChannel.OperationTimeout = new TimeSpan(0, 5, 0);

            cashoutResponse utibaCashOutResponse = utibaClientProxy.cashout(new cashout()
            {
                cashoutRequest = new cashoutRequestType()
                {
                    sessionid   = sessionID,
                    device_type = request.DeviceType,
                    amount      = request.Amount,
                    to          = request.Agent
                }
            });

            if (utibaCashOutResponse != null)
            {
                response = new CashOutResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaCashOutResponse.cashoutReturn.result, utibaCashOutResponse.cashoutReturn.result_namespace),
                    ResponseMessage = utibaCashOutResponse.cashoutReturn.result_message,
                    TransactionID   = utibaCashOutResponse.cashoutReturn.transid,
                    Fee             = utibaCashOutResponse.cashoutReturn.fee
                };
            }
            return(response);
        }
Пример #30
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID)
        {
            GetParentListRequestBody  request  = requestObject as GetParentListRequestBody;
            GetParentListResponseBody response = null;

            GetAgentInfoResponseBody agentInfo = new ServiceExecutionDelegator <GetAgentInfoResponseBody, GetAgentInfoRequestBody>().ResolveRequest(
                new GetAgentInfoRequestBody()
            {
                AuthenticationData = new AuthenticationData()
                {
                    SessionID = sessionID
                },
                Agent      = request.Agent,
                DeviceType = request.DeviceType
            }, ApiTargetPlatform.Utiba, ApiServiceName.GetAgentInfo);

            getParentListByReferenceIDResponse utibaGetParentListResponse = utibaClientProxy.getParentListByReferenceID(new getParentListByReferenceIDRequest()
            {
                getParentListByReferenceIDRequestType = new getParentListByReferenceIDRequestType()
                {
                    sessionid        = sessionID,
                    device_type      = request.DeviceType,
                    agentReferenceID = agentInfo.AgentInfo.ReferenceID
                }
            });

            //logger.InfoLow("Ajá: " + request.Agent + " vs " + agentInfo.AgentInfo.ReferenceID);

            if (utibaGetParentListResponse != null)
            {
                response = new GetParentListResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(utibaGetParentListResponse.getParentListByReferenceIDResponseType.result, utibaGetParentListResponse.getParentListByReferenceIDResponseType.result_namespace),
                    ResponseMessage = utibaGetParentListResponse.getParentListByReferenceIDResponseType.result_message,
                    TransactionID   = utibaGetParentListResponse.getParentListByReferenceIDResponseType.transid
                };


                if (utibaGetParentListResponse.getParentListByReferenceIDResponseType.agentList != null &&
                    utibaGetParentListResponse.getParentListByReferenceIDResponseType.agentList.Length > 0)
                {
                    response.ParentList = new ParentList();

                    foreach (Agent agent in utibaGetParentListResponse.getParentListByReferenceIDResponseType.agentList)
                    {
                        response.ParentList.Add(new BasicAgentInfo()
                        {
                            Agent = agent.reference,
                            Name  = agent.name
                        });
                    }
                }
            }

            return(response);
        }