コード例 #1
0
        /// <summary>
        /// Initialized Transaction.
        /// </summary>
        /// <param name="ParamList">Parameter List</param>
        /// <param name="RequestId">Request Id</param>
        public void InitTrans(String ParamList, String RequestId)
        {
            Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.InitTrans(String): Entered.",
                                PayflowConstants.SEVERITY_DEBUG);

            try
            {
                this.mConnection.RequestId = RequestId;
                this.mPaymentState         = new SendInitState(this.mConnection, ParamList, ref psmContext);
            }
            catch (Exception Ex)
            {
                ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_CONTXT_INIT_FAILED, Ex,
                                                                   PayflowConstants.SEVERITY_ERROR, mPaymentState.IsXmlPayRequest,
                                                                   null);
                if (!PsmContext.IsCommunicationErrorContained(Err))
                {
                    PsmContext.AddError(Err);
                }
            }
            finally
            {
                Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.InitTrans(String): Exiting.",
                                    PayflowConstants.SEVERITY_DEBUG);
            }
        }
コード例 #2
0
        /// <summary>
        /// Executes the transaction.
        /// </summary>
        public void Execute()
        {
            Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.Execute(): Entered.",
                                PayflowConstants.SEVERITY_DEBUG);

            try
            {
                if (PsmContext.HighestErrorLvl == PayflowConstants.SEVERITY_FATAL)
                {
                    String TrxResponse = mPaymentState.TransactionResponse;
                    String Message;
                    if (TrxResponse != null && TrxResponse.Length > 0)
                    {
                        Message = TrxResponse;
                    }
                    else
                    {
                        ArrayList   ErrorList       = psmContext.GetErrors(PayflowConstants.SEVERITY_FATAL);
                        ErrorObject FirstFatalError = (ErrorObject)ErrorList[0];
                        Message = FirstFatalError.ToString();
                    }
                    mPaymentState.SetTransactionFail = Message;
                }
                else
                {
                    Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.Execute(): Current State = " + mPaymentState,
                                        PayflowConstants.SEVERITY_DEBUG);
                    mPaymentState.Execute();
                }
            }
            catch (Exception Ex)
            {
                ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE, Ex, PayflowConstants.SEVERITY_ERROR,
                                                                   mPaymentState.IsXmlPayRequest,
                                                                   null);
                if (!PsmContext.IsCommunicationErrorContained(Err))
                {
                    PsmContext.AddError(Err);
                }
            }
            finally
            {
                // perform state transition
                mPaymentState = GetNextState(mPaymentState);
                mClientInfo   = mConnection.ClientInfo;
                Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.Execute(): Exiting.  Current State = " + mPaymentState.GetType().ToString(),
                                    PayflowConstants.SEVERITY_DEBUG);
            }
        }
コード例 #3
0
        /// <summary>
        /// Copy Constructor
        /// </summary>
        /// <param name="CurrentPmtState">Current PaymentState Object.</param>
        /// <remarks>This is an abstract class, creating an object of PaymentState directly is not possible.</remarks>
        public PaymentState(PaymentState CurrentPmtState)
        {
            Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.PaymentState(PaymentState CurrentPmtState): Entered.", PayflowConstants.SEVERITY_DEBUG);

            mDefaultXmlNameSpace             = PayflowConstants.XMLPAY_NAMESPACE;
            this.mConnection                 = CurrentPmtState.Connection;
            this.mParameterList              = CurrentPmtState.ParameterList;
            this.mTransactionRequest         = CurrentPmtState.TransactionRequest;
            this.mTransactionResponse        = CurrentPmtState.TransactionResponse;
            this.mConnection.RequestId       = CurrentPmtState.mConnection.RequestId;
            this.mConnection.IsXmlPayRequest = CurrentPmtState.mConnection.IsXmlPayRequest;
            this.mAttemptNo           = CurrentPmtState.AttemptNo;
            this.mDefaultXmlNameSpace = CurrentPmtState.mDefaultXmlNameSpace;
            this.PFProXmlNameSpace    = CurrentPmtState.XmlNameSpace;
            this.mContentType         = CurrentPmtState.ContentType;
            this.mContext             = CurrentPmtState.CommContext;
            Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.PaymentState(PaymentState CurrentPmtState): Exiting.", PayflowConstants.SEVERITY_DEBUG);
        }
コード例 #4
0

        
コード例 #5
0
ファイル: SendState.cs プロジェクト: saint771/payflow-gateway
 /// <summary>
 /// Copy constructor for SendState.
 /// </summary>
 /// <param name="CurrentPaymentState">Current Payment State object.</param>
 public SendState(PaymentState CurrentPaymentState) : base(CurrentPaymentState)
 {
 }
コード例 #6
0
 /// <summary>
 /// Copy Constructor for ReconnectState.
 /// </summary>
 /// <param name="CurrentPmtState">Current Payment State.</param>
 public ReconnectState(PaymentState CurrentPmtState) : base(CurrentPmtState)
 {
 }
コード例 #7
0
 /// <summary>
 /// Copy constructor for TransactionSendState.
 /// </summary>
 /// <param name="CurrentPaymentState">Current Payment State object.</param>
 public TransactionSendState(PaymentState CurrentPaymentState) : base(CurrentPaymentState)
 {
 }
コード例 #8
0

        
コード例 #9
0
 /// <summary>
 /// Copy constructor for TransactionReceiveState.
 /// </summary>
 /// <param name="CurrentPaymentState">Current Payment State object.</param>
 public TransactionReceiveState(PaymentState CurrentPaymentState) : base(CurrentPaymentState)
 {
 }
コード例 #10
0
        /// <summary>
        /// Changes the Payment States depending upon
        /// the current state status.
        /// </summary>
        /// <param name="CurrentPmtState">Current Payment State.</param>
        /// <returns>Next Payment State</returns>
        private PaymentState GetNextState(PaymentState CurrentPmtState)
        {
            Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState): Entered.",
                                PayflowConstants.SEVERITY_DEBUG);

            if (CurrentPmtState.Success && CurrentPmtState.InProgress)
            {
                if (CurrentPmtState is TransactionReceiveState)
                {
                    // exit state
                    CurrentPmtState.SetTransactionSuccess();
                }
                else if (CurrentPmtState is SendInitState)
                {
                    Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState.Success): SentInitState Entered.",
                                        PayflowConstants.SEVERITY_DEBUG);

                    CurrentPmtState = new TransactionSendState(CurrentPmtState);
                }
                else if (CurrentPmtState is TransactionSendState)
                {
                    Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState.Success): TransactionSentState Entered.",
                                        PayflowConstants.SEVERITY_DEBUG);
                    CurrentPmtState = new TransactionReceiveState(CurrentPmtState);
                }
                else if (CurrentPmtState is SendRetryState)
                {
                    Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState.Success): SendRetryState Entered.",
                                        PayflowConstants.SEVERITY_DEBUG);
                    CurrentPmtState = new SendReconnectState(CurrentPmtState);
                }
                else if (CurrentPmtState is SendReconnectState)
                {
                    Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState.Success): SendReconnectState Entered.",
                                        PayflowConstants.SEVERITY_DEBUG);
                    CurrentPmtState = new SendInitState(CurrentPmtState);
                }
                // unknown state
                else
                {
                    String      AddlMessage = "Unknown State, Current State = " + mPaymentState.ToString();
                    ErrorObject Err         = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE, null,
                                                                               PayflowConstants.SEVERITY_FATAL, mPaymentState.IsXmlPayRequest,
                                                                               AddlMessage);
                    if (!PsmContext.IsCommunicationErrorContained(Err))
                    {
                        PsmContext.AddError(Err);
                    }
                }
            }
            else if (CurrentPmtState.Failed && CurrentPmtState.InProgress)
            {
                Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState): Current Payment State Failed.  Current State = " + mPaymentState.ToString(),
                                    PayflowConstants.SEVERITY_DEBUG);
                if (CurrentPmtState is ReconnectState)
                {
                    // exit state
                    if (!PsmContext.IsErrorContained())
                    {
                        String      AddlMessage = "Exceeded Reconnect attempts, check context for error, Current reconnect attempt = " + mPaymentState.AttemptNo.ToString();
                        ErrorObject Err         = PayflowUtility.PopulateCommError(PayflowConstants.E_TIMEOUT_WAIT_RESP, null,
                                                                                   PayflowConstants.SEVERITY_FATAL, mPaymentState.IsXmlPayRequest,
                                                                                   AddlMessage);
                        if (!PsmContext.IsCommunicationErrorContained(Err))
                        {
                            PsmContext.AddError(Err);
                        }
                    }
                    else
                    {
                        ArrayList ErrList = new ArrayList();
                        ErrList.AddRange(PsmContext.GetErrors());
                        int HighestSevLevel = PsmContext.HighestErrorLvl;

                        int ErrorListIndex;
                        int ErrorListSize = ErrList.Count;
                        for (ErrorListIndex = 0; ErrorListIndex < ErrorListSize; ErrorListIndex++)
                        {
                            ErrorObject Err = (ErrorObject)ErrList[ErrorListIndex];
                            if (Err.SeverityLevel == HighestSevLevel)
                            {
                                int      index;
                                int      size          = Err.MessageParams.Count;
                                string[] MsgCodeParams = new string[size];
                                for (index = 0; index < size; index++)
                                {
                                    MsgCodeParams[index] = (string)Err.MessageParams[index];
                                }

                                ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, Err.MessageCode, MsgCodeParams);
                                ErrList[ErrorListIndex] = Error;
                                break;
                            }
                        }

                        PsmContext.ClearErrors();
                        PsmContext.AddErrors(ErrList);
                    }
                }
                else if (CurrentPmtState is SendInitState)
                {
                    Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState.Failed): SendInitState Entered.",
                                        PayflowConstants.SEVERITY_DEBUG);
                    CurrentPmtState = new SendReconnectState(CurrentPmtState);
                }
                else if (CurrentPmtState is TransactionSendState)
                {
                    Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState.Failed): TransactionSendState Entered.",
                                        PayflowConstants.SEVERITY_DEBUG);
                    CurrentPmtState = new SendRetryState(CurrentPmtState);
                }
                else if (CurrentPmtState is TransactionReceiveState)
                {
                    Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState.Failed): TransactionReceiveState Entered.",
                                        PayflowConstants.SEVERITY_DEBUG);
                    CurrentPmtState = new SendRetryState(CurrentPmtState);
                }
                // unknown state
                else
                {
                    String      AddlMessage = "Current State = " + mPaymentState.ToString();
                    ErrorObject Err         = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE, null,
                                                                               PayflowConstants.SEVERITY_FATAL, mPaymentState.
                                                                               IsXmlPayRequest, AddlMessage);
                    if (!PsmContext.IsCommunicationErrorContained(Err))
                    {
                        PsmContext.AddError(Err);
                    }
                }
            }

            Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState): Obtained State = "
                                + mPaymentState.GetType().ToString(),
                                PayflowConstants.SEVERITY_INFO);
            Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState): Exiting.",
                                PayflowConstants.SEVERITY_DEBUG);
            return(CurrentPmtState);
        }
コード例 #11
0
ファイル: InitState.cs プロジェクト: saint771/payflow-gateway
 /// <summary>
 /// Copy Constructor for InitState.
 /// </summary>
 /// <param name="CurrentPaymentState">PaymentState Object.</param>
 public InitState(PaymentState CurrentPaymentState) : base(CurrentPaymentState)
 {
 }