Example #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="GCheckoutResponse"/> class.
        /// </summary>
        /// <param name="ResponseXml">The XML returned from Google.</param>
        public GCheckoutResponse(string ResponseXml)
        {
            _Xml = ResponseXml;

            //to cut down on the number or exceptions, we are going to try to
            //predetermine the type of message being returned this will allow for
            //a greater experience on the dev side. If you are not using debug
            //symbols, it is very difficult to determine if the error is real
            //or not if you are breaking on all thrown exceptions.
            bool parsed = false;

            try {
                if (ResponseXml.IndexOf("<checkout-redirect") > -1)
                {
                    _CheckoutRedirectResponse = (AutoGen.CheckoutRedirect)
                                                EncodeHelper.Deserialize(ResponseXml,
                                                                         typeof(AutoGen.CheckoutRedirect));
                    parsed = true;
                }
                else if (ResponseXml.IndexOf("<request-received") > -1)
                {
                    _GoodResponse = (AutoGen.RequestReceivedResponse)
                                    EncodeHelper.Deserialize(ResponseXml,
                                                             typeof(AutoGen.RequestReceivedResponse));
                    parsed = true;
                }
                else if (ResponseXml.IndexOf("<error") > -1)
                {
                    _ErrorResponse = (AutoGen.ErrorResponse)
                                     EncodeHelper.Deserialize(ResponseXml,
                                                              typeof(AutoGen.ErrorResponse));
                    parsed = true;
                }
            }
            catch {
                //let it continue
            }


            if (!parsed)
            {
                try {
                    _GoodResponse = (AutoGen.RequestReceivedResponse)
                                    EncodeHelper.Deserialize(ResponseXml,
                                                             typeof(AutoGen.RequestReceivedResponse));
                }
                catch {
                    try {
                        _ErrorResponse = (AutoGen.ErrorResponse)
                                         EncodeHelper.Deserialize(ResponseXml,
                                                                  typeof(AutoGen.ErrorResponse));
                    }
                    catch {
                        _CheckoutRedirectResponse = (AutoGen.CheckoutRedirect)
                                                    EncodeHelper.Deserialize(ResponseXml,
                                                                             typeof(AutoGen.CheckoutRedirect));
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Create a new instance of the Response parser
        /// </summary>
        /// <param name="responseXml"></param>
        public GCheckoutResponse(string responseXml)
        {
            //to cut down on the number or exceptions, we are going to try to
            //predetermine the type of message being returned this will allow for
            //a greater experience on the dev side. If you are not using debug
            //symbols, it is very difficult to determine if the error is real
            //or not if you are breaking on all thrown exceptions.

            _responseXml = responseXml;

            if (ResponseXml.IndexOf("<request-received") > -1)
            {
                _GoodResponse = (AutoGen.RequestReceivedResponse)
                                EncodeHelper.Deserialize(ResponseXml,
                                                         typeof(AutoGen.RequestReceivedResponse));
                Log.Xml(_GoodResponse.serialnumber, ResponseXml);
                //_parsed = true;
            }
            else if (ResponseXml.IndexOf("<error") > -1)
            {
                _ErrorResponse = (AutoGen.ErrorResponse)
                                 EncodeHelper.Deserialize(ResponseXml,
                                                          typeof(AutoGen.ErrorResponse));
                Log.Xml(_ErrorResponse.serialnumber, ResponseXml);
                //_parsed = true;
            }
            else if (ParseMessage())
            {
                //_parsed = true;
            }
            else
            {
                //What we want to do is determine if there is a type so we
                //can report it to the user so they can report the error
                string messageTypeFound = string.Empty;
                try {
                    var theType = EncodeHelper.Deserialize(ResponseXml);
                    if (theType != null)
                    {
                        messageTypeFound = theType.GetType().Name;
                    }
                    else
                    {
                        messageTypeFound = "Unknown Message Type";
                    }
                    Log.Xml(Guid.NewGuid().ToString(), ResponseXml);
                }
                catch (Exception ex) {
                    Log.Xml(Guid.NewGuid().ToString(), ResponseXml);
                    Log.Err("GCheckoutResponse else check failed:" + ex.Message);
                }

                _ErrorResponse = new GCheckout.AutoGen.ErrorResponse();
                _ErrorResponse.errormessage
                    = string.Format("Couldn't parse ResponseXml. "
                                    + "Message type found was {0}. Please See ResponseXml",
                                    messageTypeFound);
            }
        }
        /// <summary>
        /// Create a new instance of the Response parser
        /// </summary>
        /// <param name="responseXml"></param>
        public GCheckoutResponse(string responseXml)
        {
            //to cut down on the number or exceptions, we are going to try to
              //predetermine the type of message being returned this will allow for
              //a greater experience on the dev side. If you are not using debug
              //symbols, it is very difficult to determine if the error is real
              //or not if you are breaking on all thrown exceptions.

              _responseXml = responseXml;

              if (ResponseXml.IndexOf("<request-received") > -1) {
            _GoodResponse = (AutoGen.RequestReceivedResponse)
              EncodeHelper.Deserialize(ResponseXml,
              typeof(AutoGen.RequestReceivedResponse));
            Log.Xml(_GoodResponse.serialnumber, ResponseXml);
            //_parsed = true;
              }
              else if (ResponseXml.IndexOf("<error") > -1) {
            _ErrorResponse = (AutoGen.ErrorResponse)
              EncodeHelper.Deserialize(ResponseXml,
              typeof(AutoGen.ErrorResponse));
            Log.Xml(_ErrorResponse.serialnumber, ResponseXml);
            //_parsed = true;
              }
              else if (ParseMessage()) {
            //_parsed = true;
              }
              else {
            //What we want to do is determine if there is a type so we
            //can report it to the user so they can report the error
            string messageTypeFound = string.Empty;
            try {
              var theType = EncodeHelper.Deserialize(ResponseXml);
              if (theType != null) {
            messageTypeFound = theType.GetType().Name;
              }
              else {
            messageTypeFound = "Unknown Message Type";
              }
              Log.Xml(Guid.NewGuid().ToString(), ResponseXml);
            }
            catch (Exception ex) {
              Log.Xml(Guid.NewGuid().ToString(), ResponseXml);
              Log.Err("GCheckoutResponse else check failed:" + ex.Message);
            }

            _ErrorResponse = new GCheckout.AutoGen.ErrorResponse();
            _ErrorResponse.errormessage
              = string.Format("Couldn't parse ResponseXml. "
              + "Message type found was {0}. Please See ResponseXml",
              messageTypeFound);
              }
        }
 /// <summary>
 /// Creates a new instance of the <see cref="GCheckoutResponse"/> class.
 /// </summary>
 /// <param name="ResponseXml">The XML returned from Google.</param>
 public GCheckoutResponse(string ResponseXml) {
   _Xml = ResponseXml;
   try {
     _GoodResponse = (AutoGen.RequestReceivedResponse) 
       EncodeHelper.Deserialize(ResponseXml, 
       typeof(AutoGen.RequestReceivedResponse));
   }
   catch {
     try {
       _ErrorResponse = (AutoGen.ErrorResponse) 
         EncodeHelper.Deserialize(ResponseXml, 
         typeof(AutoGen.ErrorResponse));
     }
     catch {
       _CheckoutRedirectResponse = (AutoGen.CheckoutRedirect) 
         EncodeHelper.Deserialize(ResponseXml, 
         typeof(AutoGen.CheckoutRedirect));
     }
   }
 }
 /// <summary>
 /// Creates a new instance of the <see cref="GCheckoutResponse"/> class.
 /// </summary>
 /// <param name="ResponseXml">The XML returned from Google.</param>
 public GCheckoutResponse(string ResponseXml)
 {
     _Xml = ResponseXml;
     try {
         _GoodResponse = (AutoGen.RequestReceivedResponse)
                         EncodeHelper.Deserialize(ResponseXml,
                                                  typeof(AutoGen.RequestReceivedResponse));
     }
     catch {
         try {
             _ErrorResponse = (AutoGen.ErrorResponse)
                              EncodeHelper.Deserialize(ResponseXml,
                                                       typeof(AutoGen.ErrorResponse));
         }
         catch {
             _CheckoutRedirectResponse = (AutoGen.CheckoutRedirect)
                                         EncodeHelper.Deserialize(ResponseXml,
                                                                  typeof(AutoGen.CheckoutRedirect));
         }
     }
 }