Esempio n. 1
0
        /// <summary>
        ///     Parses response
        /// </summary>
        /// <param name="response">Response string</param>
        private void ParseResponse(string response)
        {
            //Pass a new context object to the validator. We do not mean to
            //validate request here. We just need to parse it and populate
            //the response hashtable.
            var respContext = new Context();

            //Check newly created context for fatal error. If the newly created
            //context has fatal error, it means that, there is a problem with the
            //message file. So we'll have manually assign the result,respmsg value.
            //Add following values in hashtable manually
            //RESULT=<Code for E_UNKNOWN_STATE>
            //RESPMSG=<Message for E_UNKNOWN_STATE>, <Response String>
            if (respContext.HighestErrorLvl == PayflowConstants.SeverityFatal)
            {
                var result  = PayflowUtility.LocateValueForName(response, PayflowConstants.ParamResult, false);
                var respMsg = PayflowUtility.LocateValueForName(response, PayflowConstants.ParamRespmsg, false);
                if (_mResponseHashTable == null)
                {
                    _mResponseHashTable = new Hashtable();
                }

                _mResponseHashTable.Add(PayflowConstants.IntlParamFullresponse, _mResponseString);
                _mResponseHashTable.Add(PayflowConstants.ParamResult, result);
                _mResponseHashTable.Add(PayflowConstants.ParamRespmsg, respMsg);
            }
            else
            {
                _mResponseHashTable = ParameterListValidator.ParseNvpList(response, ref respContext, true);
                respContext         = null;
                if (_mResponseHashTable != null)
                {
                    _mResponseHashTable.Add(PayflowConstants.IntlParamFullresponse, response);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Parses response
        /// </summary>
        /// <param name="Response">Response string</param>
        private void ParseResponse(String Response)
        {
            //Pass a new context object to the validator. We do not mean to
            //validate request here. We just need to parse it and populate
            //the response hashtable.
            Context RespContext = new Context();

            //Check newly created context for fatal error. If the newly created
            //context has fatal error, it means that, there is a problem with the
            //message file. So we'll have manually assign the result,respmsg value.
            //Add following values in hashtable manually
            //RESULT=<Code for E_UNKNOWN_STATE>
            //RESPMSG=<Message for E_UNKNOWN_STATE>, <Response String>
            if (RespContext.HighestErrorLvl == PayflowConstants.SEVERITY_FATAL)
            {
                String Result  = PayflowUtility.LocateValueForName(Response, PayflowConstants.PARAM_RESULT, false);
                String RespMsg = PayflowUtility.LocateValueForName(Response, PayflowConstants.PARAM_RESPMSG, false);
                if (mResponseHashTable == null)
                {
                    mResponseHashTable = new Hashtable();
                }

                mResponseHashTable.Add(PayflowConstants.INTL_PARAM_FULLRESPONSE, mResponseString);
                mResponseHashTable.Add(PayflowConstants.PARAM_RESULT, Result);
                mResponseHashTable.Add(PayflowConstants.PARAM_RESPMSG, RespMsg);
            }
            else
            {
                mResponseHashTable = ParameterListValidator.ParseNVPList(Response, ref RespContext, true);
                RespContext        = null;
                if (mResponseHashTable != null)
                {
                    mResponseHashTable.Add(PayflowConstants.INTL_PARAM_FULLRESPONSE, Response);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Sets the response params
        /// </summary>
        /// <param name="response">Response string</param>
        internal void SetParams(string response)
        {
            try
            {
                _mResponseString = response;
                if (response != null)
                {
                    var resultIndex = response.IndexOf(PayflowConstants.ParamResult);
                    if (resultIndex >= 0)
                    {
                        if (resultIndex > 0)
                        {
                            response = response.Substring(resultIndex);
                        }
                        ParseResponse(response);
                        SetResultParams(ref _mResponseHashTable);
                        SetFraudResultParams(ref _mResponseHashTable);
                        SetBuyerAuthResultParams(ref _mResponseHashTable);
                        var trxType = PayflowUtility.LocateValueForName(RequestString,
                                                                        PayflowConstants.ParamTrxtype, false);
                        if (string.Equals(trxType, PayflowConstants.TrxtypeRecurring))
                        {
                            SetRecurringResultParams(ref _mResponseHashTable);
                        }
                        else
                        {
                            SetExpressCheckoutDoResultParams(ref _mResponseHashTable);
                            SetExpressCheckoutGetResultParams(ref _mResponseHashTable);
                            SetExpressCheckoutSetResultParams(ref _mResponseHashTable);
                            SetExpressCheckoutUpdateResultParams(ref _mResponseHashTable);
                        }

                        _mResponseHashTable.Remove(PayflowConstants.IntlParamFullresponse);
                        SetExtDataList();
                        _mResponseHashTable = null;
                    }
                    else
                    {
                        //Append the RESULT and RESPMSG for error code
                        //E_UNKNOWN_STATE and create a message.
                        //Call SetParams again on it.
                        var responseValue = PayflowConstants.ParamResult
                                            + PayflowConstants.SeparatorNvp
                                            + (string)PayflowConstants.CommErrorCodes[PayflowConstants.EUnknownState]
                                            + PayflowConstants.DelimiterNvp
                                            + PayflowConstants.ParamRespmsg
                                            + PayflowConstants.SeparatorNvp
                                            + (string)PayflowConstants.CommErrorMessages[
                            PayflowConstants.EUnknownState]
                                            + ", " + _mResponseString;
                        SetParams(responseValue);
                    }
                }
                else
                {
                    var addlMessage = "Empty response";
                    var err         = PayflowUtility.PopulateCommError(PayflowConstants.EEmptyParamList, null,
                                                                       PayflowConstants.SeverityWarn, false, addlMessage);
                    TransactionContext.AddError(err);
                    err = TransactionContext.GetError(TransactionContext.GetErrorCount() - 1);
                    var responseValue = err.ToString();
                    SetParams(responseValue);
                }
            }
            catch (BaseException baseEx)
            {
                //ErrorObject Error = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE,BaseEx,PayflowConstants.SEVERITY_ERROR,false, null);
                var error = baseEx.GetFirstErrorInExceptionContext();
                TransactionContext.AddError(error);
                var responseValue = error.ToString();
                SetParams(responseValue);
            }
            catch (Exception ex)
            {
                var dEx   = new DataObjectException(ex);
                var error = PayflowUtility.PopulateCommError(PayflowConstants.EUnknownState, dEx,
                                                             PayflowConstants.SeverityError, false, null);
                TransactionContext.AddError(error);
                var responseValue = error.ToString();
                SetParams(responseValue);
            }

            //catch
            //{
            //    ErrorObject Error = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE,null,PayflowConstants.SEVERITY_ERROR,false,null);
            //    mContext.AddError(Error);
            //    String ResponseValue = Error.ToString();
            //    this.SetParams(ResponseValue);
            //}
        }
Esempio n. 4
0
 /// <summary>
 /// Sets the response params
 /// </summary>
 /// <param name="Response">Response string</param>
 internal void SetParams(String Response)
 {
     try
     {
         mResponseString = Response;
         if (Response != null)
         {
             int ResultIndex = Response.IndexOf(PayflowConstants.PARAM_RESULT);
             if (ResultIndex >= 0)
             {
                 if (ResultIndex > 0)
                 {
                     Response = Response.Substring(ResultIndex);
                 }
                 ParseResponse(Response);
                 SetResultParams(ref mResponseHashTable);
                 SetFraudResultParams(ref mResponseHashTable);
                 SetBuyerAuthResultParams(ref mResponseHashTable);
                 String TrxType = PayflowUtility.LocateValueForName(RequestString,
                                                                    PayflowConstants.PARAM_TRXTYPE, false);
                 if (String.Equals(TrxType, PayflowConstants.TRXTYPE_RECURRING))
                 {
                     SetRecurringResultParams(ref mResponseHashTable);
                 }
                 else
                 {
                     SetExpressCheckoutDOResultParams(ref mResponseHashTable);
                     SetExpressCheckoutGETResultParams(ref mResponseHashTable);
                     SetExpressCheckoutSETResultParams(ref mResponseHashTable);
                     SetExpressCheckoutUPDATEResultParams(ref mResponseHashTable);
                 }
                 mResponseHashTable.Remove(PayflowConstants.INTL_PARAM_FULLRESPONSE);
                 SetExtDataList();
                 mResponseHashTable = null;
             }
             else
             {
                 //Append the RESULT and RESPMSG for error code
                 //E_UNKNOWN_STATE and create a message.
                 //Call SetParams again on it.
                 String ResponseValue = PayflowConstants.PARAM_RESULT
                                        + PayflowConstants.SEPARATOR_NVP
                                        + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_UNKNOWN_STATE]
                                        + PayflowConstants.DELIMITER_NVP
                                        + PayflowConstants.PARAM_RESPMSG
                                        + PayflowConstants.SEPARATOR_NVP
                                        + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_UNKNOWN_STATE]
                                        + ", " + mResponseString;
                 this.SetParams(ResponseValue);
             }
         }
         else
         {
             String      AddlMessage = "Empty response";
             ErrorObject Err         = PayflowUtility.PopulateCommError(PayflowConstants.E_EMPTY_PARAM_LIST, null, PayflowConstants.SEVERITY_WARN, false, AddlMessage);
             mContext.AddError(Err);
             Err = mContext.GetError(mContext.getErrorCount() - 1);
             String ResponseValue = Err.ToString();
             this.SetParams(ResponseValue);
         }
     }
     catch (BaseException BaseEx)
     {
         //ErrorObject Error = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE,BaseEx,PayflowConstants.SEVERITY_ERROR,false, null);
         ErrorObject Error = BaseEx.GetFirstErrorInExceptionContext();
         mContext.AddError(Error);
         String ResponseValue = Error.ToString();
         this.SetParams(ResponseValue);
     }
     catch (Exception Ex)
     {
         DataObjectException DEx   = new DataObjectException(Ex);
         ErrorObject         Error = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE, DEx, PayflowConstants.SEVERITY_ERROR, false, null);
         mContext.AddError(Error);
         String ResponseValue = Error.ToString();
         this.SetParams(ResponseValue);
     }
     //catch
     //{
     //    ErrorObject Error = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE,null,PayflowConstants.SEVERITY_ERROR,false,null);
     //    mContext.AddError(Error);
     //    String ResponseValue = Error.ToString();
     //    this.SetParams(ResponseValue);
     //}
 }