Esempio n. 1
0
        public decimal[] HandlerCache(AuthenticationData cascadeAuth, TopUpRequestBody request)
        {
            //se inicializa con valores por defecto
            List <decimal> lista = new List <decimal>(3)
            {
                0m, 0m, 0m
            };

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

            if (balanceResponse.StockBalance.HasValue)
            {
                lista[0] = balanceResponse.StockBalance.Value;
            }


            if (balanceResponse.WalletBalance.HasValue)
            {
                lista[1] = balanceResponse.WalletBalance.Value;
            }


            if (balanceResponse.PointsBalance.HasValue)
            {
                lista[2] = balanceResponse.PointsBalance.Value;
            }


            return(lista.ToArray <decimal>());
        }
Esempio n. 2
0
        public override IMovilwayApiResponse PerformKinacuOperation(IMovilwayApiRequest requestObject, SaleInterface kinacuWS, String sessionID)
        {
            //if (sessionID.Equals("0"))
            //    return new TopUpResponseBody()
            //    {
            //        ResponseCode = 90,
            //        ResponseMessage = "error session",
            //        TransactionID = 0,
            //        ExternalTransactionReference = "",
            //        PointBalance = 0m,
            //        StockBalance = 0m,
            //        WalletBalance = 0m
            //    };

            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()]);
            }

            kinacuWS.Timeout = timeOutSeconds * 1000;

            int    transactionId;
            string saleData = "";
            string message  = "";

            logger.InfoLow("[KIN] " + base.LOG_PREFIX + "[TopUpProvider] [SEND-DATA] newSaleWithExternalIdParameters {UserId=" + sessionID + ",IdProduct=" + MapMNOtoProductId(request.MNO) + ",Customer=" + request.Recipient +
                           ",Amount=" + (request.Amount * 100) + ",CommitSale=" + "1" + ",ExternalId=" + request.ExternalTransactionReference + ",PdvRepresented=" + (request.TerminalID ?? "") + "}");

            TopUpResponseBody response = null;
            bool kinacuTopUpResponse   = false;

            int _Amount = (int)(request.Amount * 100);

            if (_cacheSession.IsActiveCache())
            {
                //logger.ErrorHigh(String.Concat("[API] ", LOG_PREFIX, "[KinacuProvider] [EXCEPTION] [", ex.GetType().Name.ToUpper(), "] ACCEDIENDO AL CACHE VALIDANDO SECURITY {message=", ex.Message, ",stackTrace=", ex.StackTrace, "}"));

                logger.InfoLow(String.Concat("[KIN] ", base.LOG_PREFIX, "CACHE ACTIVO TOPUP"));
                ///
                kinacuTopUpResponse = kinacuWS.NewSaleWithExternalId(int.Parse(sessionID), int.Parse(MapMNOtoProductId(request.MNO)), request.Recipient,
                                                                     //(int)(request.Amount * 100)
                                                                     _Amount
                                                                     , 1, request.ExternalTransactionReference, (request.TerminalID ?? ""), out transactionId, out saleData, out message);

                saleData = Movilway.API.Utils.ApiTicket.FormatSaledataTopUp(logger, this.GetType().Name, base.LOG_PREFIX, request, kinacuTopUpResponse, transactionId, saleData);


                response = new TopUpResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(kinacuTopUpResponse, message),
                    ResponseMessage = kinacuTopUpResponse ? saleData : message,
                    TransactionID   = transactionId,
                    ExternalTransactionReference = request.ExternalTransactionReference,
                    Fee = 0
                };


                //CODIGO REPETIDO
                logger.InfoLow("[KIN] " + base.LOG_PREFIX + "[TopUpProvider] [RECV-DATA] newSaleWithExternalIdResult {response=" + kinacuTopUpResponse + ",IdTransaction=" + transactionId + ",SaleData=" + saleData + ",message=" + message + "}");

                bool errorSession = GetResponseCode(message) == 21;



                if (errorSession)
                {
                    logger.InfoLow(String.Concat("[KIN] ", base.LOG_PREFIX, " TOP UP ID DE SESSION INVALIDO RECALCULAR SESSION"));
                    //solicitar de nuevo session



                    var sessionRequest = new GetSessionRequestBody()
                    {
                        Username   = request.AuthenticationData.Username,
                        Password   = request.AuthenticationData.Password,
                        DeviceType = request.DeviceType
                    };

                    var getSessionResponse = new ServiceExecutionDelegator
                                             <GetSessionResponseBody, GetSessionRequestBody>().ResolveRequest(
                        sessionRequest
                        , ApiTargetPlatform.Kinacu, ApiServiceName.GetSession);

                    sessionID = getSessionResponse.SessionID;
                    logger.InfoLow(String.Concat("[KIN] ", base.LOG_PREFIX, " NUEVO ID ", IsValidId(sessionID)));

                    //String llave = String.Concat(cons.CACHE_SESSION_PREFIX, request.AuthenticationData.Username);
                    String llave = String.Concat(request.AuthenticationData.Username, " ", request.AuthenticationData.Password);

                    _cacheSession.AddOrUpdate <String>(llave, sessionID);

                    kinacuTopUpResponse = kinacuWS.NewSaleWithExternalId(int.Parse(sessionID), int.Parse(MapMNOtoProductId(request.MNO)), request.Recipient,
                                                                         //(int)(request.Amount * 100)
                                                                         _Amount
                                                                         , 1, request.ExternalTransactionReference, (request.TerminalID ?? ""), out transactionId, out saleData, out message);

                    saleData = Movilway.API.Utils.ApiTicket.FormatSaledataTopUp(logger, this.GetType().Name, base.LOG_PREFIX, request, kinacuTopUpResponse, transactionId, saleData);



                    response = new TopUpResponseBody()
                    {
                        ResponseCode    = Utils.BuildResponseCode(kinacuTopUpResponse, message),
                        ResponseMessage = kinacuTopUpResponse ? saleData : message,
                        TransactionID   = transactionId,
                        ExternalTransactionReference = request.ExternalTransactionReference,
                        Fee = 0
                    };
                }
            }
            else
            {
                kinacuTopUpResponse = kinacuWS.NewSaleWithExternalId(int.Parse(sessionID), int.Parse(MapMNOtoProductId(request.MNO)), request.Recipient,
                                                                     //(int)(request.Amount * 100)
                                                                     _Amount
                                                                     , 1, request.ExternalTransactionReference, (request.TerminalID ?? ""), out transactionId, out saleData, out message);


                saleData = Movilway.API.Utils.ApiTicket.FormatSaledataTopUp(logger, this.GetType().Name, base.LOG_PREFIX, request, kinacuTopUpResponse, transactionId, saleData);


                response = new TopUpResponseBody()
                {
                    ResponseCode    = Utils.BuildResponseCode(kinacuTopUpResponse, message),
                    ResponseMessage = kinacuTopUpResponse ? saleData : message,
                    TransactionID   = transactionId,
                    ExternalTransactionReference = request.ExternalTransactionReference,
                    Fee = 0
                };


                //CODIGO REPETIDO
                logger.InfoLow("[KIN] " + base.LOG_PREFIX + "[TopUpProvider] [RECV-DATA] newSaleWithExternalIdResult {response=" + kinacuTopUpResponse + ",IdTransaction=" + transactionId + ",SaleData=" + saleData + ",message=" + message + "}");
            }


            if (request.DeviceType == cons.ACCESS_H2H)
            {
                string    llave  = String.Concat(request.AuthenticationData.Username);
                decimal[] result = { 0.0m, 0.0m, 0.0m };

                //try
                //{
                //    Func<decimal[]> callback = delegate()//null;
                //    {
                //        logger.InfoLow("[KIN] " + base.LOG_PREFIX + "[TopUpProvider] CALLBACK SALDO");
                //        List<decimal> lista = new List<decimal>();
                //        AuthenticationData cascadeAuth = new AuthenticationData()
                //        {
                //            SessionID = sessionID
                //        };
                //        GetBalanceResponseBody balanceResponse = new ServiceExecutionDelegator<GetBalanceResponseBody, GetBalanceRequestBody>().ResolveRequest(new GetBalanceRequestBody()
                //        {
                //            AuthenticationData = cascadeAuth,
                //            DeviceType = request.DeviceType
                //        }, ApiTargetPlatform.Kinacu, ApiServiceName.GetBalance);
                //        lista.Add(balanceResponse.StockBalance.Value);
                //        lista.Add(response.WalletBalance = balanceResponse.WalletBalance.Value);
                //        lista.Add(response.PointBalance = balanceResponse.PointsBalance.Value);
                //        return lista.ToArray<decimal>();
                //    };
                //    //    ()=>{
                //    //  new int[]{0,0,0};
                //    //};
                //     result = _cacheSaldo.GetValue<decimal[]>(llave, callback);
                //}
                //catch (Exception ex)
                //{
                //    logger.InfoLow("[KIN] " + base.LOG_PREFIX + "[TopUpProvider] ERROR AL CONSULTAR CHACHE SALDO 1");
                //   // throw;
                //}

                try
                {
                    //CUANDO SE RECARGA EL SALDO
                    Func <decimal[]> callback = delegate()
                    {
                        logger.InfoLow(String.Concat("[KIN] ", base.LOG_PREFIX, "[TopUpProvider] SALDO NOT FOUND CACHE "));
                        return(new HandlerCacheSaldo().HandlerCache(new AuthenticationData()
                        {
                            SessionID = sessionID
                        }, request));
                    };

                    bool inCache = false;
                    //CUANDO SE ENCUENTRA EL SALDO EN CACHE
                    //TODO plantear un accion por referencia
                    //TODO se puede lanzar la actualizacion en cache asincrona
                    Action <Object, Object> accion = delegate(Object key2, Object value)
                    {
                        inCache = true;
                        logger.InfoLow(String.Concat("[KIN] ", base.LOG_PREFIX, "[TopUpProvider] SALDO FOUND CACHE [", key2, "]"));
                    };

                    result = _cacheSaldo.GetValue <decimal[]>(llave, callback, accion);

                    //si la respuesta es valid
                    //if (inCache && response.ResponseCode == 0)
                    //{
                    //    result[0] -= _Amount;
                    //    logger.InfoLow(String.Concat("[KIN] ", base.LOG_PREFIX, "[TopUpProvider] ACTUALIZANDO STOCKBALANCE EN CACHE [", result[0], "]"));
                    //    _cacheSaldo.AddOrUpdate(llave, result);
                    //}
                }
                catch (Exception ex)
                {
                    logger.InfoLow("[KIN] " + base.LOG_PREFIX + "[TopUpProvider] ERROR AL CONSULTAR CHACHE SALDO ");
                    throw;
                }



                //AuthenticationData cascadeAuth = new AuthenticationData()
                //{
                //    SessionID = sessionID
                //};

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

                //if (response != null)
                //{
                //    response.StockBalance = balanceResponse.StockBalance.Value;
                //    response.WalletBalance = balanceResponse.WalletBalance.Value;
                //    response.PointBalance = balanceResponse.PointsBalance.Value;
                //}


                if (result.Length == 3)
                {
                    response.StockBalance  = result[0];
                    response.WalletBalance = result[1];
                    response.PointBalance  = result[2];
                }
            }
            else
            {
                AuthenticationData cascadeAuth = new AuthenticationData()
                {
                    SessionID = sessionID
                };

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

                if (response != null)
                {
                    response.StockBalance  = balanceResponse.StockBalance.Value;
                    response.WalletBalance = balanceResponse.WalletBalance.Value;
                    response.PointBalance  = balanceResponse.PointsBalance.Value;
                }
            }

            if (response.ResponseCode.Equals(0) && (ConfigurationManager.AppSettings["IncludeTopupMessageExtended"] ?? "").ToLower().Equals("true"))
            {
                // Acá concatenar el mensaje del macroproducto en caso de ser necesario
                response.ResponseMessage = String.Concat(response.ResponseMessage, new MacroProductDataManager().GetMacroProductMessage(int.Parse(ConfigurationManager.AppSettings["CountryID"]), int.Parse(MapMNOtoProductId(request.MNO))));
            }

            return(response);
        }
Esempio n. 3
0
 public HandlerCacheSaldo(AuthenticationData cascadeAuth, TopUpRequestBody request)
 {
     _cascadeAuth = cascadeAuth;
     _request     = request;
 }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public static string FormatSaledataTopUp(ILogger logger, string Provider, string LOG_PREFIX, TopUpRequestBody request, bool kinacuTopUpResponse, int transactionId, string saleData)
        {
            var _saleData = saleData;

            try
            {
                if (IsApiTicketEnabled() && kinacuTopUpResponse)
                {
                    // andres vargas
                    //TODO LOGICA QUEMADA :-/
                    //COMO HACERLO POR PRODUCTO SIENDO QUE LOS CODIGOS DE LOS PRODUCTOS CAMBIAN 0_o
                    //HACER UN HANDLER POR PRODUCTO Y ASOCIARLO POR CONFIGURACION ^_^a

                    var keyticket = ConfigurationManager.AppSettings[prefix + request.DeviceType + "_" + request.MNO] ?? string.Empty;

                    if (!string.IsNullOrEmpty(keyticket))
                    {
                        Dictionary <string, string> _dicc = new Dictionary <string, string>();

                        _dicc = new Dictionary <string, string>();
                        var arr = (request.TerminalID ?? "").Split(' ');

                        //DVLP: Se cambia el limite inferior debido a que los nombres de los convenios
                        // pueden estar compuestos por mas de una palabra y al momento de generar el ticket se recorta
                        // el nombre Impreso
                        //if (arr.Length > 2)
                        if (arr.Length > 1)
                        {
                            // DVLP: Validar que el ultimo campo no sea numerico, Intento para soportar los valores seleccionados en tipos ListStrings para POS
                            int  auxValue = 0;
                            bool isNumber = Int32.TryParse(arr[arr.Length - 1].ToString(), out auxValue);
                            var  _arrlist = arr.ToList();
                            if (isNumber)
                            {   //QUITAL EL ULTIMO
                                _arrlist.RemoveAt(_arrlist.Count - 1);
                            }

                            _dicc.Add("convenio", String.Join(" ", _arrlist.ToArray()));
                        }
                        //SEVE
                        else if (arr.Length > 0)
                        {
                            _dicc.Add("convenio", arr[0]);
                        }
                        else
                        {
                            _dicc.Add("convenio", "");
                        }
                        //_dicc.Add("6", "POS");

                        var lines = saleData.Split(';');
                        if (lines.Length > 1)
                        {
                            foreach (var line in lines)
                            {
                                var lineparts = line.Split(':');
                                if (lineparts.Length == 2)
                                {
                                    var key = lineparts[0].ToLower().TrimStart().TrimEnd();
                                    if (!string.IsNullOrEmpty(key) && !_dicc.Keys.Contains(key))
                                    {
                                        _dicc.Add(key, lineparts[1].TrimStart().TrimEnd());
                                    }
                                }
                                else if (lineparts.Length > 2)
                                {
                                    // si el split tiene mas de dos partes
                                    var key = lineparts[0].ToLower().TrimStart().TrimEnd();

                                    if (!string.IsNullOrEmpty(key) && !_dicc.Keys.Contains(key))
                                    {
                                        var laux = lineparts.ToList();
                                        //quitar la parte de llave para luego poner juntas las partes nuevametne
                                        laux.RemoveAt(0);



                                        var valueaux = String.Join(":", laux.ToArray());
                                        _dicc.Add(key, valueaux);
                                    }
                                }
                                else if (lineparts.Length == 1)
                                {
                                    // si el split tiene mas de dos partes
                                    var key = lineparts[0].ToLower().TrimStart().TrimEnd();
                                    if (!string.IsNullOrEmpty(key) && !_dicc.Keys.Contains(key))
                                    {
                                        _dicc.Add(key, "");
                                    }
                                }
                            }
                        }


                        return(_FormatSaledataTopUp(logger, Provider, LOG_PREFIX, request, kinacuTopUpResponse, transactionId, saleData, _dicc));
                    }
                }
            }
            catch (Exception ex)
            {
                logger.ErrorLow("[API] " + LOG_PREFIX + "[" + Provider + "] ERROR FormatSaledataTopUp [" + ex.Message + "] [" + ex.GetType().Name + "] [" + ex.StackTrace + "]");
                _saleData = saleData;
            }
            return(_saleData);
        }
Esempio n. 6
0
        private static string _FormatSaledataTopUp(ILogger logger, string Provider, string LOG_PREFIX, TopUpRequestBody request, bool kinacuTopUpResponse, int transactionId, string saleData, Dictionary <string, string> _dicc = null)
        {
            var _saleData = saleData;

            try
            {
                var keyticket = ConfigurationManager.AppSettings[prefix + request.DeviceType + "_" + request.MNO] ?? string.Empty;


                var typerequest     = request.GetType();
                var keyticketresult = keyticket;

                var matches = Regex.Matches(keyticket, @"{([a-zA-Z0-9]+\.[a-zA-Z0-9]+|[a-zA-Z0-9]+)}");
                var bandera = true;

                for (int i = 0; i < matches.Count && bandera; i++) //   foreach (System.Text.RegularExpressions.Match match in matches)
                {
                    var match = matches[i];

                    var auxval = match.Value.Substring(1, match.Value.Length - 2);// .Replace("{", "").Replace("}", "");

                    var parts = auxval.Split('.');


                    string firstpart  = parts[0].ToLower();
                    string secondpart = "";
                    if (parts.Length > 1)
                    {
                        secondpart = parts[1].ToLower();
                    }
                    ;


                    var change = "";

                    /*
                     * DATENOW
                     *      request
                     * transactionId
                     * _dicc
                     */

                    switch (firstpart)
                    {
                    case "datenow":
                        //if (!string.IsNullOrEmpty(secondpart))
                        //{
                        //    try
                        //    {
                        //        change = DateTime.Now.ToString(secondpart, ApiTicket_dateformat);
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        logger.ErrorLow("[API] " + LOG_PREFIX + "[TopUpProvider] ERROR Formatting date [" + secondpart + "] " + ex.Message + " ");
                        //        throw new Exception("ERROR Formatting date [" + secondpart + "]");
                        //    }

                        //}
                        //else
                        change = DateTime.Now.ToString(ApiTicket_dateformat);

                        break;

                    case "request":

                        if (!string.IsNullOrEmpty(secondpart))
                        {
                            var prop = typerequest.GetProperties().FirstOrDefault(p => p.Name.ToLower() == secondpart);

                            if (prop != null)
                            {
                                change = prop.GetValue(request, new object[] { }).ToString();
                            }
                            else
                            {
                                bandera = false;
                                logger.ErrorLow("[API] " + LOG_PREFIX + " No se econtro la propiedad en el request " + match.Value);
                            }
                            // throw new Exception("No se econtro la propiedad en el request " + match.Value);
                        }
                        else
                        {
                            bandera = false;
                            logger.ErrorLow("[API] " + LOG_PREFIX + " No se definio la propiedad para el request " + match.Value);
                        }



                        break;

                    case "transactionid":

                        change = transactionId.ToString();

                        break;

                    case "dictionary":


                        if (!string.IsNullOrEmpty(secondpart))
                        {
                            var auxvalue = string.Empty;

                            if (_dicc.TryGetValue(secondpart, out auxvalue))
                            {
                                change = auxvalue;
                            }
                            else
                            {
                                bandera = false;
                                logger.ErrorLow("[API] " + LOG_PREFIX + " No se econtro el valor en el diccionario " + match.Value);
                                // throw new Exception("No se econtro el valor en el diccionario " + match.Value);
                            }
                        }
                        else
                        {
                            bandera = false;
                            logger.ErrorLow("[API] " + LOG_PREFIX + " No se definio la llave para el diccionario " + match.Value);
                            //   throw new Exception("No se definio la llave para el diccionario " + match.Value);
                        }



                        break;

                    default:

                        bandera = false;
                        logger.ErrorLow("[API] " + LOG_PREFIX + " NO ESTA CONTEMPLADO ESTA LLAVE EN EL TEMPLATE " + match.Value);

                        break;
                    }


                    keyticketresult = keyticketresult.Replace(match.Value, change);
                }



                if (!bandera)
                {
                    _saleData = saleData;
                }
                else
                {
                    logger.InfoLow("[API] " + LOG_PREFIX + "[" + Provider + "]  Kinacuticket" + saleData);//+ " " + (_saleData));
                    _saleData = keyticketresult;
                }

                logger.InfoLow("[API] " + LOG_PREFIX + "[" + Provider + "]  FormatSaledata result " + bandera);//+ " " + (_saleData));
            }
            catch (Exception ex)
            {
                logger.ErrorLow("[API] " + LOG_PREFIX + "[" + Provider + "] ERROR Formating FormatSaledata  [" + ex.Message + "] [" + ex.GetType().Name + "] [" + ex.StackTrace + "]");
                _saleData = saleData;
            }



            return(_saleData);
        }