Exemplo n.º 1
0
        public ThreeDSAuthorization0Response ThreeDSAuthorize0(ThreeDSAuthorization0Request request)
        {
            // Validate request
            RequestValidator.ValidateThreeDSAuthorize0Request(request);
            // Map input request in the XML Request
            var requestXML = RequestMapper.MapThreeDSAuthorization0Request(request, _shopId, _apiResultKey);

            // Calculate and set MAC
            requestXML.Request.MAC = _encoder.GetMac(RequestHandler.GetMacDictionary(requestXML), _apiResultKey);
            // Url Encode ThreeDSData to correctly send it
            requestXML.Data.RequestTag.ThreeDSData = HttpUtility.UrlEncode(requestXML.Data.RequestTag.ThreeDSData);
            var xmlBody = XmlTool.Serialize(requestXML);
            // Do call
            var xmlResponse = _restClient.CallApi(_urlAPI, xmlBody);
            // Map response
            var objectResponse = XmlTool.Deserialize <BPWXmlResponse <Data3DSResponse> >(xmlResponse);

            // Verify Response MAC
            VerifyMacResponse(objectResponse);
            VerifyAuthorization(objectResponse.Data.Authorization);
            VerifyPanAliasData(objectResponse.Data.PanAliasData);
            VerifyThreeDSChallenge(objectResponse.Data.ThreeDSChallenge);
            VerifyThreeDSMethod(objectResponse.Data.ThreeDSMethod);
            return(ResponseMapper.MapThreeDSAuthorization0(objectResponse));
        }
Exemplo n.º 2
0
        public void Point3D_SerializableTest()
        {
            Point3D p = new Point3D()
            {
                X = 1, Y = 2, Z = 3
            };
            string xmlText = XmlTool.Serialize(typeof(Point3D), p);

            Assert.IsNotNull(xmlText);
            Point3D pd = XmlTool.Deserialize(typeof(Point3D), xmlText) as Point3D;

            Assert.IsTrue(p.Equals(pd));
        }
Exemplo n.º 3
0
        public void DeserializeTest()
        {
            //Test1
            string     xmlText = XmlTool.Serialize(typeof(TestObject), this.Test);
            TestObject getTest = XmlTool.Deserialize(typeof(TestObject), xmlText) as TestObject;

            Assert.AreEqual(getTest.id, Test.id);
            Assert.AreEqual(getTest.Name, Test.Name);
            Assert.AreEqual(getTest.Count, Test.Count);
            Assert.AreEqual(getTest.Sub.SubName, Test.Sub.SubName);
            //Test2
            TestObject getTest2 = XmlTool.Deserialize(typeof(TestObject), null) as TestObject;

            Assert.IsNull(getTest2);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 역직렬화를 통해, 객체를 반환한다.
        /// </summary>
        /// <returns></returns>
        public override object GetDeserializedObject()
        {
            if (SerializedValue == null)
            {
                return(null);
            }

            if (log.IsDebugEnabled)
            {
                log.Debug("직렬화 객체 (수형[{0}])에 대해 [{1}] 역직렬화를 수행합니다... ", ObjectTypeName, Method);
            }

            var objectType = Type.GetType(ObjectTypeName, true, true);

            return(XmlTool.Deserialize(objectType, SerializedValue));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create a new instance of <see cref="XdsRequestDocument"/> from the specified xml string.
        /// </summary>
        /// <param name="xml">xml string</param>
        /// <returns>instance of <see cref="XdsRequestDocument"/></returns>
        public static XdsRequestDocument Load(string xml)
        {
            xml.ShouldNotBeWhiteSpace("xml");

            if (IsDebugEnabled)
            {
                log.Debug("Build XdsRequestDocument with the specified xml string. xml=[{0}]", xml.EllipsisChar(80));
            }

            XdsRequestDocument result = null;

            var data = xml.ToBytes(XmlTool.XmlEncoding);

            result = XmlTool.Deserialize <XdsRequestDocument>(data);

            return(result);
        }
Exemplo n.º 6
0
        public void LineSegment_Serializable()
        {
            Point3D start = new Point3D()
            {
                X = 1, Y = 2, Z = 3
            };
            Point3D end = new Point3D()
            {
                X = 4, Y = 5, Z = 6
            };
            LineSegment line    = new LineSegment(start, end);
            string      xmlText = XmlTool.Serialize(typeof(LineSegment), line);

            Assert.IsNotNull(xmlText);
            LineSegment ld = XmlTool.Deserialize(typeof(LineSegment), xmlText) as LineSegment;

            Assert.IsTrue(line.Equals(ld));
        }
Exemplo n.º 7
0
        public RefundResponse Refund(RefundRequest request)
        {
            // Validate Request
            RequestValidator.ValidateRefundRequest(request);
            // Map input request in the XML Request
            var requestXML = RequestMapper.MapRefundRequest(request, _shopId);

            //calculate MAC
            requestXML.Request.MAC = _encoder.GetMac(RequestHandler.GetMacDictionary(requestXML), _apiResultKey);
            // Do call to VPOS
            var xmlBody        = XmlTool.Serialize(requestXML);
            var xmlResponse    = _restClient.CallApi(_urlAPI, xmlBody);
            var objectResponse = XmlTool.Deserialize <BPWXmlResponse <DataManageOperation> >(xmlResponse);

            // Verify Mac Response
            VerifyMacResponse(objectResponse);
            VerifyOperation(objectResponse.Data.Operation);
            return(ResponseMapper.MapRefundResponse(objectResponse));
        }
Exemplo n.º 8
0
        public ThreeDSAuthorization2Response ThreeDSAuthorize2(ThreeDSAuthorization2Request request)
        {
            // Validate request
            RequestValidator.ValidateThreeDSAuthorize2Request(request);
            // Map input request in the XML Request
            var requestXML = RequestMapper.MapThreeDSAuthorization2Request(request, _shopId);

            // Calculate and set MAC
            requestXML.Request.MAC = _encoder.GetMac(RequestHandler.GetMacDictionary(requestXML), _apiResultKey);
            var xmlBody = XmlTool.Serialize(requestXML);
            // Do call to VPOS
            var xmlResponse    = _restClient.CallApi(_urlAPI, xmlBody);
            var objectResponse = XmlTool.Deserialize <BPWXmlResponse <Data3DSResponse> >(xmlResponse);

            // Verify Mac Response
            VerifyMacResponse(objectResponse);
            VerifyAuthorization(objectResponse.Data.Authorization);
            VerifyPanAliasData(objectResponse.Data.PanAliasData);
            return(ResponseMapper.MapThreeDSAuthorization2(objectResponse));
        }
Exemplo n.º 9
0
        public void CurveSegment_Serializable()
        {
            List <CurveSegment> list = new List <CurveSegment>();

            Point3D center = new Point3D()
            {
                X = 0, Y = 0, Z = 0
            };
            Point3D start = new Point3D()
            {
                X = 0, Y = 1, Z = 0
            };
            Point3D end = new Point3D()
            {
                X = 1, Y = 0, Z = 0
            };
            ArcSegment arc = new ArcSegment(center, start, end, ArcDirctionType.CLOCK_WISE);

            Point3D startL = new Point3D()
            {
                X = 1, Y = 2, Z = 3
            };
            Point3D endL = new Point3D()
            {
                X = 4, Y = 5, Z = 6
            };
            LineSegment line = new LineSegment(startL, endL);

            list.Add(arc);
            list.Add(line);

            string xmlText = XmlTool.Serialize(typeof(List <CurveSegment>), list);

            Assert.IsNotNull(xmlText);
            List <CurveSegment> cd = XmlTool.Deserialize(typeof(List <CurveSegment>), xmlText) as List <CurveSegment>;

            for (int i = 0; i < cd.Count; i++)
            {
                Assert.IsTrue(list[i].Equals(cd[i]));
            }
        }
Exemplo n.º 10
0
        public void DeserializeTest1()
        {
            //Test1
            string xmlText = XmlTool.Serialize(typeof(TestObject), this.Test);

            byte[]       array   = Encoding.ASCII.GetBytes(xmlText);
            MemoryStream stream  = new MemoryStream(array);
            TestObject   getTest = XmlTool.Deserialize <TestObject>(stream);

            Assert.AreEqual(getTest.id, Test.id);
            Assert.AreEqual(getTest.Name, Test.Name);
            Assert.AreEqual(getTest.Count, Test.Count);
            Assert.AreEqual(getTest.Sub.SubName, Test.Sub.SubName);
            //Test2
            string xmlText2 = "123";

            byte[]       array2   = Encoding.ASCII.GetBytes(xmlText2);
            MemoryStream stream2  = new MemoryStream(array2);
            TestObject   getTest2 = XmlTool.Deserialize <TestObject>(stream2);

            Assert.IsNull(getTest2);
        }
Exemplo n.º 11
0
        public void ReadXml(XmlReader reader)
        {
            Position = new Position();
            Position.ReadXml(reader);

            if (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    XmlRootAttribute root = new XmlRootAttribute()
                    {
                        ElementName = reader.Name,
                        IsNullable  = true
                    };
                    var obj = Reflection.CreateObject(reader.Name);
                    Item = (T)XmlTool.Deserialize(obj.GetType(), reader, root);
                    (Item as UIObject).Initialize();
                    (Item as UIObject).Setup();
                    reader.ReadEndElement();
                }
            }
        }
Exemplo n.º 12
0
        public AuthorizeResponse Authorize(AuthorizeRequest authorize)
        {
            // Validate request
            RequestValidator.ValidateAuthorizeRequest(authorize);
            // Map input request in the XML Request
            var request = RequestMapper.MapAuthorizeRequest(authorize, _shopId);

            // Calculate and set MAC
            request.Request.MAC = _encoder.GetMac(RequestHandler.GetMacDictionary(request), _apiResultKey);
            var xmlBody = XmlTool.Serialize(request);
            // Do call to VPOS
            var xmlResponse = _restClient.CallApi(_urlAPI, xmlBody);
            // Map response
            var objectResponse = XmlTool.Deserialize <BPWXmlResponse <DataAuthorize> >(xmlResponse);

            // Verify Response MAC
            VerifyMacResponse(objectResponse);
            VerifyAuthorization(objectResponse.Data.Authorization);
            VerifyPanAliasData(objectResponse.Data.PanAliasData);
            //Response Mapping
            return(ResponseMapper.MapAuthorize(objectResponse));;
        }
Exemplo n.º 13
0
        public void ArcSegment_Serializable()
        {
            Point3D center = new Point3D()
            {
                X = 0, Y = 0, Z = 0
            };
            Point3D start = new Point3D()
            {
                X = 0, Y = 1, Z = 0
            };
            Point3D end = new Point3D()
            {
                X = 1, Y = 0, Z = 0
            };
            ArcSegment arc     = new ArcSegment(center, start, end, ArcDirctionType.CLOCK_WISE);
            string     xmlText = XmlTool.Serialize(typeof(ArcSegment), arc);

            Assert.IsNotNull(xmlText);
            ArcSegment ad = XmlTool.Deserialize(typeof(ArcSegment), xmlText) as ArcSegment;

            Assert.IsTrue(arc.Equals(ad));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Create a new instance of <see cref="XdsRequestDocument"/> from the specified file.
        /// </summary>
        /// <param name="filename">full file path</param>
        /// <returns>instance of <see cref="XdsRequestDocument"/></returns>
        public static XdsRequestDocument LoadFromFile(string filename)
        {
            if (IsDebugEnabled)
            {
                log.Debug("Load from file to build request document. filename=[{0}]", filename);
            }

            if (File.Exists(filename) == false)
            {
                throw new FileNotFoundException("File not found.", filename);
            }

            XdsRequestDocument result = null;

            using (var stream = FileTool.GetBufferedFileStream(filename, FileOpenMode.Read)) {
                result = XmlTool.Deserialize <XdsRequestDocument>(stream);
            }
            if (IsDebugEnabled)
            {
                log.Debug("Load from file and build XdsRequestDocument is finished.");
            }

            return(result);
        }
Exemplo n.º 15
0
        public OrderStatusResponse GetOrderStatus(OrderStatusRequest orderStatusRequest)
        {
            // Validate Request
            RequestValidator.ValidateOrderStatusRequest(orderStatusRequest);
            // Build Request object
            var request = RequestMapper.MapOrderStatusRequest(orderStatusRequest, _shopId);

            request.Request.MAC = _encoder.GetMac(RequestHandler.GetMacDictionary(request), _apiResultKey);
            var xmlBody = XmlTool.Serialize(request);
            // Do call to VPOS
            var xmlResponse = _restClient.CallApi(_urlAPI, xmlBody);
            // Map response
            var objectResponse = XmlTool.Deserialize <BPWXmlResponse <DataOrderStatus> >(xmlResponse);

            // Verify Mac Response
            VerifyMacResponse(objectResponse);
            VerifyPanAliasData(objectResponse.Data.PanAliasData);
            foreach (var authorization in objectResponse.Data.Authorizations)
            {
                VerifyAuthorization(authorization);
            }

            return(ResponseMapper.MapOrderStatusResponse(objectResponse));
        }
 /// <summary>
 /// byte array 정보를 Xml Deserialize를 수행하여 <see cref="XdsResponseDocument"/>로 빌드한다.
 /// </summary>
 /// <param name="inBytes"></param>
 /// <param name="enc"></param>
 /// <returns></returns>
 public static XdsResponseDocument ConvertToXdsResponseDocument(this byte[] inBytes, Encoding enc)
 {
     inBytes.ShouldNotBeNull("inBytes");
     return(XmlTool.Deserialize <XdsResponseDocument>(inBytes, enc));
 }
Exemplo n.º 17
0
        public override XdsResponseDocument ExecuteXmlDataManager(XdsRequestDocument requestDocument)
        {
            var responseXml = XmlHttpTool.PostXml(ScriptPath, requestDocument.ToXmlDocument(XmlTool.XmlEncoding));

            return(XmlTool.Deserialize <XdsResponseDocument>(responseXml));
        }
Exemplo n.º 18
0
 /// <summary>
 /// Serialized 된 정보를 Deserialize 를 수행해서 객체로 반환한다.
 /// </summary>
 /// <param name="data">serialized data to be deserialized.</param>
 /// <returns>deserialized object</returns>
 public T Deserialize(byte[] data)
 {
     return(XmlTool.Deserialize <T>(data));
 }
 /// <summary>
 /// Stream을 Xml Deserialize를 통해 <see cref="XdsResponseDocument"/>로 빌드한다.
 /// </summary>
 /// <param name="stream">Stream</param>
 /// <param name="enc">Encoding 방식</param>
 /// <returns>역직렬화된 <see cref="XdsResponseDocument"/> 인스턴스</returns>
 public static XdsResponseDocument ToResponseDocument(this Stream stream, Encoding enc)
 {
     stream.ShouldNotBeNull("stream");
     return(XmlTool.Deserialize <XdsResponseDocument>(stream, enc));
 }