Esempio n. 1
0
        public SaleStateByExternalIDExtendedResponse SaleStateByExternalIDExtended(SaleStateByExternalIDExtendedRequest externalRequest)
        {
            Log(Logger.LogMessageType.Info, "->   -------------------- Comienza la ejecución del método Sales.SaleStateByExternalID", Logger.LoggingLevelType.Medium);
            LoginRequestInternal loginRequest = new LoginRequestInternal()
            {
                DeviceType = externalRequest.Request.AccessType,
                Password   = externalRequest.Request.Password,
                User       = externalRequest.Request.AccessId
            };
            LoginResponseInternal         loginResponse   = AuthenticationProvider.LoginInternal(loginRequest);
            GetTransactionRequestInternal internalRequest = new GetTransactionRequestInternal()
            {
                SessionID      = loginResponse.SessionID,
                DeviceType     = _deciveTypeForNewSaleWithExternalID,
                ParameterValue = externalRequest.Request.ExternalID,
                ParameterType  = GetTransactionRequestInternalParameterType.HostReference
            };
            GetTransactionResponseInternal        internalResponse = GetTransactionInternal(internalRequest);
            SaleStateByExternalIDExtendedResponse externalResponse = new SaleStateByExternalIDExtendedResponse()
            {
                Response = new SaleStateByExternalIDExtendedResponseBody()
                {
                    Amount          = (int)internalResponse.Amount,
                    Customer        = internalResponse.Recipient,
                    Date            = internalResponse.TransactionDate,
                    ReloadState     = internalResponse.TransactionResult == 0 ? "Recarga Exitosa" : "Recarga Fallida",
                    ReloadStateCode = internalResponse.TransactionResult.ToString(),
                    IdTransaccion   = internalResponse.TransactionID.ToString()
                }
            };

            Log(Logger.LogMessageType.Info, "->   -------------------- Termina la ejecución del método Sales.SaleStateByExternalID", Logger.LoggingLevelType.Medium);
            return(externalResponse);
        }
Esempio n. 2
0
        public GetTransactionResponse GetTransaction(GetTransactionRequest getTransactionRequest)
        {
            Log(Logger.LogMessageType.Info, "->   -------------------- Comienza la ejecución del método Sales.GetTransaction", Logger.LoggingLevelType.Medium);
            GetTransactionRequestInternal getTransactionRequestInternal = new GetTransactionRequestInternal()
            {
                SessionID      = getTransactionRequest.Request.SessionID,
                DeviceType     = getTransactionRequest.Request.DeviceType,
                ParameterType  = (GetTransactionRequestInternalParameterType)getTransactionRequest.Request.ParameterType,
                ParameterValue = getTransactionRequest.Request.Parameter
            };
            GetTransactionResponseInternal internalResponse       = GetTransactionInternal(getTransactionRequestInternal);
            GetTransactionResponse         getTransactionResponse = new GetTransactionResponse();
            GetTransactionResponseBody     responseBody           = new GetTransactionResponseBody()
            {
                Amount            = internalResponse.Amount,
                Recipient         = internalResponse.Recipient,
                ResponseCode      = internalResponse.ResponseCode,
                ResponseMessage   = internalResponse.ResponseMessage,
                TransactionDate   = internalResponse.TransactionDate,
                TransactionID     = internalResponse.TransactionID,
                TransactionResult = internalResponse.TransactionResult,
                TransactionType   = internalResponse.TransactionType,
                Initiator         = internalResponse.Initiator,
                Debtor            = internalResponse.Debtor,
                Creditor          = internalResponse.Creditor
            };

            getTransactionResponse.Response = responseBody;
            Log(Logger.LogMessageType.Info, "->   -------------------- Termina la ejecución del método Sales.GetTransaction", Logger.LoggingLevelType.Medium);
            return(getTransactionResponse);
        }
Esempio n. 3
0
        public GetTransactionExtendedResponse GetTransactionExtended(GetTransactionExtendedRequest getTransactionRequest)
        {
            Log(Logger.LogMessageType.Info, "->   -------------------- Comienza la ejecución del método Sales.GetTransactionExtended", Logger.LoggingLevelType.Medium);
            LoginRequestInternal loginRequest = new LoginRequestInternal()
            {
                DeviceType = getTransactionRequest.Request.DeviceType,
                Password   = getTransactionRequest.Request.Password,
                User       = getTransactionRequest.Request.Username
            };
            LoginResponseInternal loginResponse = AuthenticationProvider.LoginInternal(loginRequest);

            GetTransactionRequestInternal getTransactionRequestInternal = new GetTransactionRequestInternal()
            {
                SessionID      = loginResponse.SessionID,
                DeviceType     = getTransactionRequest.Request.DeviceType,
                ParameterType  = (GetTransactionRequestInternalParameterType)getTransactionRequest.Request.ParameterType,
                ParameterValue = getTransactionRequest.Request.Parameter
            };
            //switch (getTransactionRequest.Request.ParameterType)
            //{
            //    case GetTransactionRequestInternalParameterType.TransID: getTransactionRequestInternal.TransactionID = int.Parse(getTransactionRequest.Request.Parameter); break;
            //    case "HostReference": getTransactionRequestInternal.HostTransRef = getTransactionRequest.Request.Parameter; break;
            //    case "OperatorReference": getTransactionRequestInternal.HostTransRef = getTransactionRequest.Request.Parameter; break;
            //}
            GetTransactionResponseInternal     internalResponse       = GetTransactionInternal(getTransactionRequestInternal);
            GetTransactionExtendedResponse     getTransactionResponse = new GetTransactionExtendedResponse();
            GetTransactionExtendedResponseBody responseBody           = new GetTransactionExtendedResponseBody()
            {
                Amount            = internalResponse.Amount,
                Recipient         = internalResponse.Recipient,
                ResponseCode      = internalResponse.ResponseCode,
                ResponseMessage   = internalResponse.ResponseMessage,
                TransactionDate   = internalResponse.TransactionDate,
                TransactionID     = internalResponse.TransactionID,
                TransactionResult = internalResponse.TransactionResult,
                TransactionType   = internalResponse.TransactionType,
                Initiator         = internalResponse.Initiator,
                Debtor            = internalResponse.Debtor,
                Creditor          = internalResponse.Creditor
            };

            getTransactionResponse.Response = responseBody;
            Log(Logger.LogMessageType.Info, "->   -------------------- Termina la ejecución del método Sales.GetTransactionExtended", Logger.LoggingLevelType.Medium);
            return(getTransactionResponse);
        }
Esempio n. 4
0
        internal GetTransactionResponseInternal GetTransactionInternal(GetTransactionRequestInternal getTransactionRequest)
        {
            Log(Logger.LogMessageType.Info, "->   -------------------- Comienza la ejecución del método Sales.GetTransactionInternal", Logger.LoggingLevelType.Medium);
            GetTransactionResponseInternal responseInternal = null;

            try
            {
                UMarketSCClient          utibaClient = new UMarketSCClient();
                queryTransactionResponse utibaQueryTransactionResponse = 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 Sales.GetTransactionInternal: " +
                                                                                                 "SessionID={0}, DeviceType={1}, ParameterType={2}, ParameterValue={3}", getTransactionRequest.SessionID, getTransactionRequest.DeviceType,
                                                                                                 getTransactionRequest.ParameterType, getTransactionRequest.ParameterValue), Logger.LoggingLevelType.Low);
                    Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Parámetros Enviados Sales.GetTransactionInternal: " +
                                                                                                 "SessionID={0}, DeviceType={1}, ParameterType={2}, ParameterValue={3}", getTransactionRequest.SessionID, getTransactionRequest.DeviceType,
                                                                                                 getTransactionRequest.ParameterType, getTransactionRequest.ParameterValue), Logger.LoggingLevelType.Low);
                    switch (getTransactionRequest.ParameterType)
                    {
                    case GetTransactionRequestInternalParameterType.HostReference:
                        utibaQueryTransactionResponse = utibaClient.queryTransaction(new queryTransaction()
                        {
                            queryTransactionRequest = new queryTransactionRequestType()
                            {
                                sessionid    = getTransactionRequest.SessionID,
                                device_type  = getTransactionRequest.DeviceType,
                                hostTransRef = getTransactionRequest.ParameterValue
                            }
                        });
                        break;

                    case GetTransactionRequestInternalParameterType.OperatorReference:
                        utibaQueryTransactionResponse = utibaClient.queryTransaction(new queryTransaction()
                        {
                            queryTransactionRequest = new queryTransactionRequestType()
                            {
                                sessionid    = getTransactionRequest.SessionID,
                                device_type  = getTransactionRequest.DeviceType,
                                targetMSISDN = getTransactionRequest.ParameterValue
                            }
                        });
                        break;

                    case GetTransactionRequestInternalParameterType.TransID:
                        utibaQueryTransactionResponse = utibaClient.queryTransaction(new queryTransaction()
                        {
                            queryTransactionRequest = new queryTransactionRequestType()
                            {
                                sessionid   = getTransactionRequest.SessionID,
                                device_type = getTransactionRequest.DeviceType,
                                ID          = getTransactionRequest.ParameterValue
                            }
                        });
                        break;
                    }
                }
                if (utibaQueryTransactionResponse != null)
                {
                    responseInternal = new GetTransactionResponseInternal()
                    {
                        Amount            = utibaQueryTransactionResponse.queryTransactionReturn.amount,
                        Recipient         = utibaQueryTransactionResponse.queryTransactionReturn.recipient,
                        ResponseCode      = utibaQueryTransactionResponse.queryTransactionReturn.result,
                        ResponseMessage   = utibaQueryTransactionResponse.queryTransactionReturn.result_message,
                        TransactionDate   = FromEpochToLocalTime(utibaQueryTransactionResponse.queryTransactionReturn.date),
                        TransactionID     = utibaQueryTransactionResponse.queryTransactionReturn.transid,
                        TransactionResult = utibaQueryTransactionResponse.queryTransactionReturn.trans_result,
                        TransactionType   = utibaQueryTransactionResponse.queryTransactionReturn.transaction_type,
                        Initiator         = utibaQueryTransactionResponse.queryTransactionReturn.initiator,
                        Debtor            = utibaQueryTransactionResponse.queryTransactionReturn.debtor,
                        Creditor          = utibaQueryTransactionResponse.queryTransactionReturn.creditor
                    };
                }
                Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Resultado Obtenido Sales.GetTransactionInternal: ResponseCode={0}, ResponseMessage={1}, TransactionID={2}, " +
                                                                                             "Amount={3}, Recipient={4}, TransactionDate={5}, TransactionResult={6}", responseInternal.ResponseCode, responseInternal.ResponseMessage, responseInternal.TransactionID, responseInternal.Amount,
                                                                                             responseInternal.Recipient, responseInternal.TransactionDate, responseInternal.TransactionResult), Logger.LoggingLevelType.Low);
            }
            catch (Exception ex)
            {
                Log(Logger.LogMessageType.Error, "Ocurrio una exception procesando el metodo Sales.GetTransaction, los detalles son: " + ex.ToString(), Logger.LoggingLevelType.Low);
                return(null);
            }
            Log(Logger.LogMessageType.Info, "->   -------------------- Termina la ejecución del método Sales.GetTransactionInternal", Logger.LoggingLevelType.Medium);
            return(responseInternal);
        }