Exemple #1
0
        /// <summary>
        /// Paso 1 emisión de un nuevo giro => Constitución del giro
        /// </summary>
        /// <param name="request">Objeto que contiene la información del giro</param>
        /// <param name="sessionId">ID de sesión para poner en los mensajes de log</param>
        /// <param name="exc">Excepción generada al llamar el servicio</param>
        /// <returns>Respuesta de la constitución del giro</returns>
        private MultiPay472.RespuestaValidacionConstitucionGiro EmitirPaso1Cash472(EmitirRequest request, string sessionId, out Exception exc)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            exc = null;

            MultiPay472.RespuestaValidacionConstitucionGiro resp = null;
            MultiPay472.Service1SoapClient client = this.GetSoapClient();
            string endpointName = "ValidacionConstitucionGiro";

            try
            {
                MultiPay472.ValidacionConstitucionGiro peticion = new MultiPay472.ValidacionConstitucionGiro();
                peticion.NitRed            = this.multipayNitRed;
                peticion.CodigoTerminal    = this.multipayTerminal;
                peticion.CodigoTransaccion = this.GenerarCodigoTransaccion(sessionId);

                peticion.CodigoPuntoVenta             = request.Pdv;
                peticion.ValorRecibido                = request.ValorRecibido;
                peticion.IncluyeFlete                 = request.IncluyeFlete;
                peticion.CodigoDaneCiudadPuntoVenta   = request.CiudadPdv;
                peticion.CodigoDaneCiudadPagoSugerido = request.CiudadDestino;

                peticion.Originador = new MultiPay472.Originador();
                this.EstablecerValoresCliente472(request.Emisor, peticion.Originador, null);

                peticion.Destinatario = new MultiPay472.Destinatario();
                this.EstablecerValoresCliente472(request.Receptor, null, peticion.Destinatario);

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Llamando servicio \"" + endpointName + "\" ..."));

                resp = client.ValidacionConstitucionGiro(peticion, this.multipayUsuario);

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Respuesta servicio \"" + endpointName + "\"")
                                            .Tag("Respuesta").Value(resp != null ? resp.CodigoRespuesta : "NULL"));

                if (resp == null || resp.CodigoRespuesta != CashProvider.CodigoRespuestaExitoso)
                {
                    this.errorMessage = resp == null ? ErrorMessagesMnemonics.WebServiceDoesNotRespond : ErrorMessagesMnemonics.Cash472WsError;
                }
            }
            catch (Exception ex)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New()
                                                 .MethodName(methodName)
                                                 .Message("[" + sessionId + "] " + "Error llamando servicio \"" + endpointName + "\"")
                                                 .Exception(ex));
                this.errorMessage = ErrorMessagesMnemonics.WebServiceException;
                exc = ex;
            }

            return(resp);
        }
Exemple #2
0
        /// <summary>
        /// Obtiene una nueva instancia del cliente SOAP de MultiPay 472
        /// </summary>
        /// <returns>Una nueva instancia del objeto <c>MultiPay472.Service1SoapClient</c></returns>
        private MultiPay472.Service1SoapClient GetSoapClient()
        {
            MultiPay472.Service1SoapClient client = new MultiPay472.Service1SoapClient();

            int timeout = 60;

            try
            {
                timeout = Convert.ToInt32(ConfigurationManager.AppSettings["MultiPayTimeout"]);
            }
            catch (Exception)
            {
            }

            client.InnerChannel.OperationTimeout = TimeSpan.FromSeconds(timeout);
            return(client);
        }
Exemple #3
0
        /// <summary>
        /// Paso 2 emisión de un nuevo giro => Confirmación del giro
        /// </summary>
        /// <param name="request">Objeto que contiene la información del giro</param>
        /// <param name="sessionId">ID de sesión para poner en los mensajes de log</param>
        /// <param name="constitution">Mensaje de respuesta de la constitución del giro</param>
        /// <param name="exc">Excepción generada al llamar el servicio</param>
        /// <returns>Respuesta de la constitución del giro</returns>
        private MultiPay472.RespuestaEmisionGiro EmitirPaso2Cash472(EmitirRequest request, string sessionId, MultiPay472.RespuestaValidacionConstitucionGiro constitution, out Exception exc)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            exc = null;

            MultiPay472.RespuestaEmisionGiro resp   = null;
            MultiPay472.Service1SoapClient   client = this.GetSoapClient();
            string endpointName = "EmisionGiro";

            try
            {
                MultiPay472.EmisionGiro peticion = new MultiPay472.EmisionGiro();
                peticion.Token             = constitution.Token;
                peticion.CodigoTransaccion = this.GenerarCodigoTransaccion(sessionId);

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Llamando servicio \"" + endpointName + "\" ..."));

                resp = client.EmisionGiro(peticion, this.multipayUsuario);

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Respuesta servicio \"" + endpointName + "\"")
                                            .Tag("Respuesta").Value(resp != null ? resp.CodigoRespuesta : "NULL"));

                if (resp == null || resp.CodigoRespuesta != CashProvider.CodigoRespuestaExitoso)
                {
                    this.errorMessage = resp == null ? ErrorMessagesMnemonics.WebServiceDoesNotRespond : ErrorMessagesMnemonics.Cash472WsError;
                }
            }
            catch (Exception ex)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New()
                                                 .MethodName(methodName)
                                                 .Message("[" + sessionId + "] " + "Error llamando servicio \"" + endpointName + "\"")
                                                 .Exception(ex));
                this.errorMessage = ErrorMessagesMnemonics.WebServiceException;
                exc = ex;
            }

            return(resp);
        }
Exemple #4
0
        /// <summary>
        /// Realiza el proceso de reverso de pago para un giro
        /// </summary>
        /// <param name="request">Objeto que contiene todos los datos de autenticacion del usuario e información del reverso de pago</param>
        /// <returns>Respuesta del pago</returns>
        public ReversoPagoResponse ReversoPago(ReversoPagoRequest request)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            this.LogRequest(request);

            ReversoPagoResponse response = new ReversoPagoResponse();
            string sessionId             = this.GetSessionId(request, response, out this.errorMessage);

            if (this.errorMessage != ErrorMessagesMnemonics.None)
            {
                this.LogResponse(response);
                return(response);
            }

            if (!request.IsValidRequest())
            {
                this.SetResponseErrorCode(response, ErrorMessagesMnemonics.InvalidRequiredFields);
                this.LogResponse(response);
                return(response);
            }

            DwhModel.Cliente infoCliente = this.GetInfoCliente(sessionId, request.TipoIdentificacion, request.NumeroIdentificacion, out this.errorMessage);
            if (this.errorMessage != ErrorMessagesMnemonics.None)
            {
                this.SetResponseErrorCode(response, this.errorMessage);
                this.LogResponse(response);
                return(response);
            }

            MultiPay472.Service1SoapClient client = this.GetSoapClient();
            string endpointName = "ReversoPagoGiro";

            try
            {
                MultiPay472.PagoGiro peticion = new MultiPay472.PagoGiro();
                peticion.NitRed            = this.multipayNitRed;
                peticion.CodigoTerminal    = this.multipayTerminal;
                peticion.CodigoTransaccion = this.GenerarCodigoTransaccion(sessionId);
                peticion.ConHuella         = false;

                peticion.IdGiro = request.Id;
                peticion.NumeroComprobantePago      = request.NumeroComprobantePago;
                peticion.CodigoPuntoVenta           = request.Pdv;
                peticion.CodigoDaneCiudadPuntoVenta = request.CiudadPdv;
                peticion.Valor = request.Valor;
                peticion.OIdentificacionCliente = new MultiPay472.IdentificacionCliente();
                peticion.OIdentificacionCliente.TipoIdentificacion   = Cash472.CashProvider.ObtenerCodigoTipoIdentificacion(request.TipoIdentificacion);
                peticion.OIdentificacionCliente.NumeroIdentificacion = request.NumeroIdentificacion;

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Llamando servicio \"" + endpointName + "\" ..."));

                MultiPay472.RespuestaPagoGiro resp = client.ReversoPagoGiro(peticion, this.multipayUsuario);

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Respuesta servicio \"" + endpointName + "\"")
                                            .Tag("Respuesta").Value(resp != null ? resp.CodigoRespuesta : "NULL"));

                if (resp != null && resp.CodigoRespuesta == CashProvider.CodigoRespuestaExitoso)
                {
                    response.ResponseCode          = 0;
                    response.NumeroFactura         = resp.NumeroFactura;
                    response.CodigoTransaccion     = !string.IsNullOrEmpty(resp.CodigoTransaccion) ? resp.CodigoTransaccion : string.Empty;
                    response.CodigoAutorizacion    = resp.CodigoAutorizacion;
                    response.NumeroComprobantePago = resp.NumeroComprobantePago;
                    response.NumeroReferencia      = resp.NumeroReferencia;
                    response.Valor = resp.ValorPago;
                    response.Fecha = CashProvider.ObtenerFechaDesdeString(resp.Fecha);
                }
                else
                {
                    if (resp == null)
                    {
                        this.errorMessage        = ErrorMessagesMnemonics.WebServiceDoesNotRespond;
                        response.ResponseCode    = (int)this.errorMessage;
                        response.ResponseMessage = this.errorMessage.ToDescription();
                    }
                    else
                    {
                        response.ResponseMessage = CashProvider.ObtenerMensajeCodigoRespuesta(resp.CodigoRespuesta);
                    }
                }
            }
            catch (Exception ex)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New()
                                                 .MethodName(methodName)
                                                 .Message("[" + sessionId + "] " + "Error llamando servicio \"" + endpointName + "\"")
                                                 .Exception(ex));
            }

            this.LogResponse(response);
            return(response);
        }
Exemple #5
0
        /// <summary>
        /// Consulta de giros
        /// </summary>
        /// <param name="request">Objeto que contiene todos los datos de autenticacion del usuario e información de la consulta</param>
        /// <returns>Respuesta de la consulta</returns>
        public ConsultaResponse Consulta(ConsultaRequest request)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            this.LogRequest(request);

            ConsultaResponse response = new ConsultaResponse();

            string sessionId = this.GetSessionId(request, response, out this.errorMessage);

            if (this.errorMessage != ErrorMessagesMnemonics.None)
            {
                this.LogResponse(response);
                return(response);
            }

            if (!request.IsValidRequest())
            {
                this.SetResponseErrorCode(response, ErrorMessagesMnemonics.InvalidRequiredFields);
                this.LogResponse(response);
                return(response);
            }

            MultiPay472.Service1SoapClient client = this.GetSoapClient();
            string endpointName = "ConsultaGiros";

            try
            {
                MultiPay472.ConsultaGiro peticion = new MultiPay472.ConsultaGiro();
                peticion.NitRed            = this.multipayNitRed;
                peticion.CodigoTerminal    = this.multipayTerminal;
                peticion.CodigoTransaccion = this.GenerarCodigoTransaccion(sessionId);

                peticion.CodigoPuntoVenta       = request.Pdv;
                peticion.TipoCliente            = Cash472.CashProvider.ObtenerCodigoTipoCliente(request.TipoCliente);
                peticion.OIdentificacionCliente = new MultiPay472.IdentificacionCliente();
                peticion.OIdentificacionCliente.TipoIdentificacion   = Cash472.CashProvider.ObtenerCodigoTipoIdentificacion(request.TipoIdentificacion);
                peticion.OIdentificacionCliente.NumeroIdentificacion = request.NumeroIdentificacion;

                if (!string.IsNullOrEmpty(request.Pin))
                {
                    peticion.PIN = Multipay472TripleDes.Encrypt(this.multipayTripleDesKey, request.Pin);
                }

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Llamando servicio \"" + endpointName + "\" ..."));

                MultiPay472.RespuestaConsultaGiro[] resp    = client.ConsultaGiros(peticion, this.multipayUsuario);
                MultiPay472.RespuestaConsultaGiro   primero = resp != null && resp.Length > 0 ? resp[0] : null;

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Respuesta servicio \"" + endpointName + "\"")
                                            .Tag("Respuesta").Value(resp != null && primero != null ? resp[0].CodigoRespuesta : "NULL"));

                if (resp != null && primero != null && primero.CodigoRespuesta == CashProvider.CodigoRespuestaExitoso)
                {
                    response.ResponseCode = 0;
                    response.Giros        = new List <Giro>();
                    foreach (MultiPay472.RespuestaConsultaGiro it in resp)
                    {
                        DataContract.Cash472.Giro giro = new DataContract.Cash472.Giro();
                        this.EstablecerValoresGiro(giro, it);
                        response.Giros.Add(giro);
                    }

                    response.Quantity = response.Giros.Count;
                }
                else
                {
                    if (resp == null || primero == null)
                    {
                        this.errorMessage        = ErrorMessagesMnemonics.WebServiceDoesNotRespond;
                        response.ResponseCode    = (int)this.errorMessage;
                        response.ResponseMessage = this.errorMessage.ToDescription();
                    }
                    else
                    {
                        response.ResponseMessage = CashProvider.ObtenerMensajeCodigoRespuesta(primero.CodigoRespuesta);
                    }
                }
            }
            catch (Exception ex)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New()
                                                 .MethodName(methodName)
                                                 .Message("[" + sessionId + "] " + "Error llamando servicio \"" + endpointName + "\"")
                                                 .Exception(ex));
            }

            this.LogResponse(response);
            return(response);
        }
Exemple #6
0
        /// <summary>
        /// Cotizador de giros
        /// </summary>
        /// <param name="request">Objeto que contiene todos los datos de autenticacion del usuario e información de la cotización</param>
        /// <returns>Respuesta de la cotización</returns>
        public CotizarResponse Cotizar(CotizarRequest request)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            this.LogRequest(request);

            CotizarResponse response  = new CotizarResponse();
            string          sessionId = this.GetSessionId(request, response, out this.errorMessage);

            if (this.errorMessage != ErrorMessagesMnemonics.None)
            {
                this.LogResponse(response);
                return(response);
            }

            MultiPay472.Service1SoapClient client = this.GetSoapClient();
            string endpointName = "CotizadorGiro";

            try
            {
                MultiPay472.CotizadorGiro peticion = new MultiPay472.CotizadorGiro();
                peticion.NitRed            = this.multipayNitRed;
                peticion.CodigoTerminal    = this.multipayTerminal;
                peticion.CodigoTransaccion = this.GenerarCodigoTransaccion(sessionId);

                peticion.CodigoPuntoVenta = request.Pdv;
                peticion.ValorRecibido    = request.ValorRecibido;
                peticion.IncluyeFlete     = request.IncluyeFlete;

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Llamando servicio \"" + endpointName + "\" ..."));

                MultiPay472.RespuestaCotizadorGiro resp = client.CotizadorGiro(peticion, this.multipayUsuario);

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Respuesta servicio \"" + endpointName + "\"")
                                            .Tag("Respuesta").Value(resp != null ? resp.CodigoRespuesta : "NULL"));

                if (resp != null && resp.CodigoRespuesta == CashProvider.CodigoRespuestaExitoso)
                {
                    response.ResponseCode      = 0;
                    response.TotalARecibir     = resp.ValorTotal;
                    response.TotalAEntregar    = resp.ValorEntregaBeneficiario;
                    response.Flete             = resp.ValorFlete;
                    response.CodigoTransaccion = resp.CodigoTransaccion;
                }
                else
                {
                    if (resp == null)
                    {
                        this.errorMessage        = ErrorMessagesMnemonics.WebServiceDoesNotRespond;
                        response.ResponseCode    = (int)this.errorMessage;
                        response.ResponseMessage = this.errorMessage.ToDescription();
                    }
                    else
                    {
                        response.ResponseMessage = CashProvider.ObtenerMensajeCodigoRespuesta(resp.CodigoRespuesta);
                    }
                }
            }
            catch (Exception ex)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New()
                                                 .MethodName(methodName)
                                                 .Message("[" + sessionId + "] " + "Error llamando servicio \"" + endpointName + "\"")
                                                 .Exception(ex));
            }

            this.LogResponse(response);
            return(response);
        }