示例#1
0
        /// <summary>
        /// Sets the appropriate server file path for the connection
        /// and initializes the connection uri.
        /// </summary>
        public override void Execute()
        {
            bool IsConnected = false;

            Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Entered.", PayflowConstants.SEVERITY_DEBUG);
            if (!InProgress)
            {
                return;
            }
            try
            {
                Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Initializing Connection.", PayflowConstants.SEVERITY_INFO);
                //Begin Payflow Timeout Check Point 2
                long TimeRemainingMsec;
                bool TimedOut = PayflowUtility.IsTimedOut(mConnection.TimeOut, mConnection.StartTime, out TimeRemainingMsec);
                if (TimedOut)
                {
                    String      AddlMessage = "Input timeout value in millisec : " + Connection.TimeOut.ToString();
                    ErrorObject Err         = PayflowUtility.PopulateCommError(PayflowConstants.E_TIMEOUT_WAIT_RESP, null, PayflowConstants.SEVERITY_FATAL, IsXmlPayRequest, AddlMessage);
                    if (!CommContext.IsCommunicationErrorContained(Err))
                    {
                        CommContext.AddError(Err);
                    }
                }
                else
                {
                    mConnection.TimeOut = TimeRemainingMsec;
                }
                //End Payflow Timeout Check Point 2
                IsConnected = mConnection.ConnectToServer();
            }
            catch (Exception Ex)
            {
                Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Error occurred While Initializing Connection.", PayflowConstants.SEVERITY_ERROR);
                Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Exception " + Ex.ToString(), PayflowConstants.SEVERITY_ERROR);
                IsConnected = false;
            }
            //catch
            //{
            //    IsConnected = false;
            //}
            finally
            {
                if (IsConnected)
                {
                    Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Connection Initialization =  Success", PayflowConstants.SEVERITY_INFO);
                    SetStateSuccess();
                }
                else
                {
                    Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Initialized Connection = Failure", PayflowConstants.SEVERITY_INFO);
                    SetStateFail();
                }
            }

            Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Exiting.", PayflowConstants.SEVERITY_DEBUG);
        }
示例#2
0
        /// <summary>
        ///     Validates Request Id.
        /// </summary>
        /// <returns>True if valid, false otherwise.</returns>
        private bool ValidateRequestId()
        {
            var retValue = false;

            if (!HaveRequestId)
            {
                var err = PayflowUtility.PopulateCommError(PayflowConstants.EMissingRequestId, null,
                                                           PayflowConstants.SeverityFatal, IsXmlPayRequest,
                                                           null);
                if (!CommContext.IsCommunicationErrorContained(err))
                {
                    CommContext.AddError(err);
                }
            }
            else
            {
                retValue = true;
            }

            return(retValue);
        }
示例#3
0
        /// <summary>
        /// Validates Request Id.
        /// </summary>
        /// <returns>True if valid, false otherwise.</returns>
        private bool ValidateRequestId()
        {
            bool RetValue = false;

            if (!HaveRequestId)
            {
                ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_MISSING_REQUEST_ID, null,
                                                                   PayflowConstants.SEVERITY_FATAL, IsXmlPayRequest,
                                                                   null);
                if (!mContext.IsCommunicationErrorContained(Err))
                {
                    CommContext.AddError(Err);
                }
            }
            else
            {
                RetValue = true;
            }

            return(RetValue);
        }
示例#4
0
        /// <summary>
        ///     Execute function.
        /// </summary>
        public override async Task ExecuteAsync()
        {
            var isReceiveSuccess = false;

            Logger.Instance.Log("PayPal.Payments.Communication.ReceiveState.Execute(): Entered.",
                                PayflowConstants.SeverityDebug);
            if (!InProgress)
            {
                return;
            }
            try
            {
                //Begin Payflow Timeout Check Point 4
                long timeRemainingMsec;
                if (PayflowUtility.IsTimedOut(Connection.TimeOut, Connection.StartTime, out timeRemainingMsec))
                {
                    var addlMessage = "Input timeout value in millisec = " + Connection.TimeOut;
                    var err         = PayflowUtility.PopulateCommError(PayflowConstants.ETimeoutWaitResp, null,
                                                                       PayflowConstants.SeverityFatal, IsXmlPayRequest, addlMessage);
                    if (!CommContext.IsCommunicationErrorContained(err))
                    {
                        CommContext.AddError(err);
                    }
                }
                else
                {
                    Connection.TimeOut = timeRemainingMsec;
                }

                //End Payflow Timeout Check Point 4
                var responseValue = await Connection.ReceiveResponseAsync();

                isReceiveSuccess = SetReceiveResponse(responseValue);
            }
            catch (Exception ex)
            {
                Logger.Instance.Log(
                    "PayPal.Payments.Communication.ReceiveState.Execute(): Error occurred While Receiving Response.",
                    PayflowConstants.SeverityError);
                Logger.Instance.Log("PayPal.Payments.Communication.ReceiveState.Execute(): Exception " + ex,
                                    PayflowConstants.SeverityError);
                isReceiveSuccess = false;
            }
            //catch
            //{
            //    IsReceiveSuccess = false;
            //}
            finally
            {
                if (isReceiveSuccess)
                {
                    Logger.Instance.Log(
                        "PayPal.Payments.Communication.ReceiveState.Execute(): Receive Response = Success ",
                        PayflowConstants.SeverityInfo);
                    SetStateSuccess();
                }
                else
                {
                    Logger.Instance.Log(
                        "PayPal.Payments.Communication.ReceiveState.Execute(): Receive Response = Failure ",
                        PayflowConstants.SeverityInfo);
                    SetStateFail();
                }
            }

            Logger.Instance.Log("PayPal.Payments.Communication.ReceiveState.Execute(): Exiting.",
                                PayflowConstants.SeverityDebug);
        }
        /// <summary>
        ///     Sets the appropriate server file path for the connection
        ///     and initializes the connection uri.
        /// </summary>
        public override Task ExecuteAsync()
        {
            var isConnected = false;

            Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Entered.",
                                PayflowConstants.SeverityDebug);
            if (!InProgress)
            {
                return(Task.CompletedTask);
            }
            try
            {
                Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Initializing Connection.",
                                    PayflowConstants.SeverityInfo);
                //Begin Payflow Timeout Check Point 2
                long timeRemainingMsec;
                var  timedOut =
                    PayflowUtility.IsTimedOut(Connection.TimeOut, Connection.StartTime, out timeRemainingMsec);
                if (timedOut)
                {
                    var addlMessage = "Input timeout value in millisec : " + Connection.TimeOut;
                    var err         = PayflowUtility.PopulateCommError(PayflowConstants.ETimeoutWaitResp, null,
                                                                       PayflowConstants.SeverityFatal, IsXmlPayRequest, addlMessage);
                    if (!CommContext.IsCommunicationErrorContained(err))
                    {
                        CommContext.AddError(err);
                    }
                }
                else
                {
                    Connection.TimeOut = timeRemainingMsec;
                }

                //End Payflow Timeout Check Point 2
                isConnected = Connection.ConnectToServer();
            }
            catch (Exception ex)
            {
                Logger.Instance.Log(
                    "PayPal.Payments.Communication.InitState.Execute(): Error occurred While Initializing Connection.",
                    PayflowConstants.SeverityError);
                Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Exception " + ex,
                                    PayflowConstants.SeverityError);
                isConnected = false;
            }
            //catch
            //{
            //    IsConnected = false;
            //}
            finally
            {
                if (isConnected)
                {
                    Logger.Instance.Log(
                        "PayPal.Payments.Communication.InitState.Execute(): Connection Initialization =  Success",
                        PayflowConstants.SeverityInfo);
                    SetStateSuccess();
                }
                else
                {
                    Logger.Instance.Log(
                        "PayPal.Payments.Communication.InitState.Execute(): Initialized Connection = Failure",
                        PayflowConstants.SeverityInfo);
                    SetStateFail();
                }
            }

            Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Exiting.",
                                PayflowConstants.SeverityDebug);
            return(Task.CompletedTask);
        }