예제 #1
0
        /// <summary>
        /// Generates the XML required for a GenerateRequest call
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private string GenerateRequestXml(RequestInput input)
        {
            StringWriter sw = new StringWriter();

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent = true;
            settings.NewLineOnAttributes = false;
            settings.OmitXmlDeclaration  = true;

            using (XmlWriter writer = XmlWriter.Create(sw, settings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("GenerateRequest");
                writer.WriteElementString("PxPayUserId", _PxPayUserId);
                writer.WriteElementString("PxPayKey", _PxPayKey);

                PropertyInfo[] properties = input.GetType().GetProperties();

                foreach (PropertyInfo prop in properties)
                {
                    if (prop.CanWrite)
                    {
                        string val = (string)prop.GetValue(input, null);

                        if (val != null || val != string.Empty)
                        {
                            writer.WriteElementString(prop.Name, val);
                        }
                    }
                }
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
            }

            return(sw.ToString());
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public RequestOutput GenerateRequest(RequestInput input)
        {
            RequestOutput result = new RequestOutput(SubmitXml(GenerateRequestXml(input)));

            return(result);
        }