示例#1
0
        public void TestPaymentResponseDeserialization()
        {
            String xml = "<saml2:PaymentResponse xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\"><saml2:Attribute Name=\"PaymentResponse.state\" xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\"><saml2:AttributeValue xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\">WAITING_FOR_UPDATE</saml2:AttributeValue></saml2:Attribute><saml2:Attribute Name=\"PaymentResponse.txnId\" xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\"><saml2:AttributeValue xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\">fee3880e-460c-453e-8585-15e2337b03b5</saml2:AttributeValue></saml2:Attribute></saml2:PaymentResponse>";

            //XmlReaderSettings settings = new XmlReaderSettings();
            //settings.ConformanceLevel = ConformanceLevel.Fragment;
            //settings.IgnoreComments = true;
            //settings.IgnoreWhitespace = true;

            //NameTable nt = new NameTable();

            //XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
            //nsmgr.AddNamespace("saml2", Saml2Constants.SAML2_ASSERTION_NAMESPACE);

            //XmlParserContext ctx = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

            //TextReader txReader = new StringReader(xml);
            //XmlReader reader = XmlReader.Create(txReader, settings, ctx);

            XmlRootAttribute xRoot = new XmlRootAttribute();

            xRoot.ElementName = "PaymentResponse";
            xRoot.Namespace   = Saml2Constants.SAML2_ASSERTION_NAMESPACE;

            XmlSerializer       serializer          = new XmlSerializer(typeof(PaymentResponseType), xRoot);
            PaymentResponseType paymentResponseType = (PaymentResponseType)serializer.Deserialize(new XmlTextReader(new StringReader(xml)));
        }
示例#2
0
        private static LinkIDPaymentResponse findPaymentResponse(ResponseType response)
        {
            if (null == response.Extensions || null == response.Extensions.Any)
            {
                return(null);
            }
            if (0 == response.Extensions.Any.Length)
            {
                return(null);
            }

            XmlElement xmlElement = response.Extensions.Any[0];

            if (xmlElement.LocalName.Equals(LinkIDPaymentResponse.LOCAL_NAME))
            {
                PaymentResponseType paymentResponseType = deserializePaymentResponse(xmlElement);
                return(LinkIDPaymentResponse.fromSaml(paymentResponseType));
            }

            return(null);
        }
        public static LinkIDPaymentResponse fromSaml(PaymentResponseType paymentResponseType)
        {
            String orderReference     = null;
            String paymentStateString = null;
            String mandateReference   = null;
            String docdataReference   = null;
            String paymentMenuURL     = null;

            foreach (object item in paymentResponseType.Items)
            {
                AttributeType attributeType = (AttributeType)item;
                if (attributeType.Name.Equals(ORDER_REF_KEY) && null != attributeType.AttributeValue)
                {
                    orderReference = (String)attributeType.AttributeValue[0];
                }
                if (attributeType.Name.Equals(STATE_KEY) && null != attributeType.AttributeValue)
                {
                    paymentStateString = (String)attributeType.AttributeValue[0];
                }
                if (attributeType.Name.Equals(MANDATE_REF_KEY) && null != attributeType.AttributeValue)
                {
                    mandateReference = (String)attributeType.AttributeValue[0];
                }
                if (attributeType.Name.Equals(DOCDATA_REF_KEY) && null != attributeType.AttributeValue)
                {
                    docdataReference = (String)attributeType.AttributeValue[0];
                }
                if (attributeType.Name.Equals(MENU_URL_KEY) && null != attributeType.AttributeValue)
                {
                    paymentMenuURL = (String)attributeType.AttributeValue[0];
                }
            }

            return(new LinkIDPaymentResponse(orderReference, LinkIDPaymentResponse.parse(paymentStateString),
                                             mandateReference, docdataReference, paymentMenuURL));
        }
示例#4
0
 public NexoPayment(PaymentTypeEnumeration paymentType = PaymentTypeEnumeration.Normal) : base(MessageCategoryEnumeration.Payment)
 {
     RequestItem = new PaymentRequestType();
     ReplyItem   = new PaymentResponseType();
     PaymentType = paymentType;
 }