Пример #1
0
        public TopUpResponse TopUp(TopUpRequest topUpRequest)
        {
            Log(Logger.LogMessageType.Info, "->   -------------------- Comienza la ejecución del método Stock.TopUp", Logger.LoggingLevelType.Medium);
            TopUpRequestInternal internalObject = new TopUpRequestInternal()
            {
                Amount       = topUpRequest.Request.Amount,
                DeviceType   = topUpRequest.Request.DeviceType,
                HostTransRef = topUpRequest.Request.HostTransRef,
                MNO          = topUpRequest.Request.MNO,
                MNODefinedID = topUpRequest.Request.MNODefinedID,
                Recipient    = topUpRequest.Request.Recipient,
                SessionID    = topUpRequest.Request.SessionID
            };
            TopUpResponseInternal internalResponse = TopUpProvider.TopUpInternal(internalObject);
            TopUpResponse         response         = new TopUpResponse();
            TopUpResponseBody     responseBody     = new TopUpResponseBody()
            {
                ResponseCode    = internalResponse.ResponseCode,
                ResponseMessage = internalResponse.ResponseMessage,
                TransactionID   = internalResponse.TransactionID,
                HostTransRef    = internalResponse.HostTransRef,
                Fee             = internalResponse.Fee,
                BalanceStock    = internalResponse.BalanceStock
            };

            response.Response = responseBody;
            Log(Logger.LogMessageType.Info, "->   -------------------- Termina la ejecución del método Stock.TopUp", Logger.LoggingLevelType.Medium);
            return(response);
        }
Пример #2
0
        public NewSaleWithExternalIDExtendedResponse NewSaleWithExternalIDExtended(NewSaleWithExternalIDExtendedRequest externalRequest)
        {
            Log(Logger.LogMessageType.Info, "->   -------------------- Comienza la ejecución del método Sales.NewSaleWithExternalID", Logger.LoggingLevelType.Medium);
            LoginRequestInternal loginRequest = new LoginRequestInternal()
            {
                DeviceType = externalRequest.Request.AccessType,
                Password   = externalRequest.Request.Password,
                User       = externalRequest.Request.AccessId
            };
            LoginResponseInternal loginResponse   = AuthenticationProvider.LoginInternal(loginRequest);
            TopUpRequestInternal  internalRequest = new TopUpRequestInternal()
            {
                SessionID    = loginResponse.SessionID,
                Recipient    = externalRequest.Request.Customer,
                MNODefinedID = externalRequest.Request.ExternalId,
                MNO          = externalRequest.Request.IdProduct,
                HostTransRef = externalRequest.Request.ExternalId,
                DeviceType   = _deciveTypeForNewSaleWithExternalID,
                Amount       = externalRequest.Request.Amount
            };
            TopUpResponseInternal internalResponse = TopUpProvider.TopUpInternal(internalRequest);
            NewSaleWithExternalIDExtendedResponse externalResponse = new NewSaleWithExternalIDExtendedResponse()
            {
                Response = new NewSaleWithExternalIDExtendedResponseBody()
                {
                    Result        = internalResponse.ResponseCode.ToString() == "0" ? "true" : "false",
                    Message       = internalResponse.ResponseCode.ToString() == "0" ? "Recarga Exitosa" : "Recarga Fallida",
                    IdTransaction = internalResponse.TransactionID,
                    SaleData      = internalResponse.ResponseMessage
                }
            };

            Log(Logger.LogMessageType.Info, "->   -------------------- Termina la ejecución del método Sales.NewSaleWithExternalID", Logger.LoggingLevelType.Medium);
            return(externalResponse);
        }
Пример #3
0
        public TopUpExtendedResponse TopUpExtended(TopUpExtendedRequest externalRequest)
        {
            Log(Logger.LogMessageType.Info, "->   -------------------- Comienza la ejecución del método Stock.TopUp", Logger.LoggingLevelType.Medium);
            LoginRequestInternal loginRequest = new LoginRequestInternal()
            {
                DeviceType = externalRequest.Request.DeviceType,
                Password   = externalRequest.Request.Password,
                User       = externalRequest.Request.Username
            };
            LoginResponseInternal loginResponse  = AuthenticationProvider.LoginInternal(loginRequest);
            TopUpRequestInternal  internalObject = new TopUpRequestInternal()
            {
                Amount       = externalRequest.Request.Amount,
                DeviceType   = externalRequest.Request.DeviceType,
                HostTransRef = externalRequest.Request.HostTransRef,
                MNO          = externalRequest.Request.MNO,
                MNODefinedID = externalRequest.Request.MNODefinedID,
                Recipient    = externalRequest.Request.Recipient,
                SessionID    = loginResponse.SessionID
            };
            TopUpResponseInternal internalResponse = TopUpProvider.TopUpInternal(internalObject);
            TopUpExtendedResponse response         = new TopUpExtendedResponse()
            {
                Response = new TopUpExtendedResponseBody()
                {
                    ResponseCode    = internalResponse.ResponseCode,
                    ResponseMessage = internalResponse.ResponseMessage,
                    TransactionID   = internalResponse.TransactionID,
                    HostTransRef    = internalResponse.HostTransRef,
                    Fee             = internalResponse.Fee,
                    BalanceStock    = internalResponse.BalanceStock
                }
            };

            Log(Logger.LogMessageType.Info, "->   -------------------- Termina la ejecución del método Stock.TopUp", Logger.LoggingLevelType.Medium);
            return(response);
        }
Пример #4
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);
        }