/// <summary>
        /// Read a direct payment session request result
        /// </summary>
        /// <param name="streamReader"></param>
        /// <param name="installments"></param>
        internal static void Read(XmlReader reader, Installment installment)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(SerializerHelper.Installment);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.Installment))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SerializerHelper.CreditCardBrand:
                        installment.cardBrand = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Quantity:
                        installment.quantity = reader.ReadElementContentAsInt();
                        break;

                    case SerializerHelper.Amount:
                        installment.amount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.TotalAmount:
                        installment.totalAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.InterestFree:
                        installment.interestFree = reader.ReadElementContentAsBoolean();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="result"></param>
        internal static void Read(XmlReader reader, PreApprovalSearchResult result)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(PreApprovalSearchResultSerializer.PreApprovalSearchResult);

            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, PreApprovalSearchResultSerializer.PreApprovalSearchResult))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }


                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case PreApprovalSearchResultSerializer.Date:
                        result.Date = reader.ReadElementContentAsDateTime();
                        break;

                    case PreApprovalSearchResultSerializer.CurrentPage:
                        result.CurrentPage = reader.ReadElementContentAsInt();
                        break;

                    case PreApprovalSearchResultSerializer.TotalPages:
                        result.TotalPages = reader.ReadElementContentAsInt();
                        break;

                    case PreApprovalSummaryListSerializer.PreApprovals:
                        PreApprovalSummaryListSerializer.Read(reader, result.PreApprovals);
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="result"></param>
        internal static void Read(XmlReader reader, TransactionSearchResult result)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(TransactionSearchResultSerializer.TransactionSearchResult);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, TransactionSearchResultSerializer.TransactionSearchResult))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case TransactionSearchResultSerializer.Date:
                        result.Date = reader.ReadElementContentAsDateTime();
                        break;

                    case TransactionSearchResultSerializer.CurrentPage:
                        result.CurrentPage = reader.ReadElementContentAsInt();
                        break;

                    case TransactionSearchResultSerializer.TotalPages:
                        result.TotalPages = reader.ReadElementContentAsInt();
                        break;

                    case TransactionSummaryListSerializer.Transactions:
                        TransactionSummaryListSerializer.Read(reader, result.Transactions);
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value");
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Converts xml into a ServiceError class
        /// </summary>
        /// <param name="reader"></param>
        internal static ServiceError Read(XmlReader reader)
        {
            string code    = string.Empty;
            string message = string.Empty;

            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return(new ServiceError(code, message));
            }

            reader.ReadStartElement(ErrorSerializer.Error);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, ErrorSerializer.Error))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case ErrorSerializer.Code:
                        code = reader.ReadElementContentAsString();
                        break;

                    case ErrorSerializer.Message:
                        message = reader.ReadElementContentAsString();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }

            ServiceError error = new ServiceError(code, message);

            return(error);
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="paymentResponse"></param>
        internal static void Read(XmlReader reader, PaymentRequestResponse paymentResponse)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            string rootElement = reader.Name;

            reader.ReadStartElement();
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, rootElement))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case PaymentSerializer.Date:
                        paymentResponse.RegistrationDate = reader.ReadElementContentAsDateTime();
                        break;

                    case PaymentSerializer.Code:
                        paymentResponse.Code = reader.ReadElementContentAsString();
                        break;

                    case PaymentSerializer.TransactionCode:
                        paymentResponse.TransactionCode = reader.ReadElementContentAsString();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value");
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="sender"></param>
        internal static void Read(XmlReader reader, Sender sender)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(SenderSerializer.Sender);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SenderSerializer.Sender))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SenderSerializer.Name:
                        sender.Name = reader.ReadElementContentAsString();
                        break;

                    case SenderSerializer.Email:
                        sender.Email = reader.ReadElementContentAsString();
                        break;

                    case PhoneSerializer.Phone:
                        Phone phone = new Phone();
                        PhoneSerializer.Read(reader, phone);
                        sender.Phone = phone;
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value NodeType = " + reader.Name);
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="preApprovalResponse"></param>
        internal static void Read(XmlReader reader, PreApprovalRequestResponse preApprovalResponse)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            string rootElement = reader.Name;

            reader.ReadStartElement();
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, rootElement))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case PreApprovalSerializer.Date:
                        preApprovalResponse.RegistrationDate = reader.ReadElementContentAsDateTime();
                        break;

                    case PreApprovalSerializer.Code:
                        preApprovalResponse.Code = reader.ReadElementContentAsString();
                        break;

                    case PreApprovalSerializer.Status:
                        preApprovalResponse.Status = reader.ReadElementContentAsString();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="shipping"></param>
        internal static void Read(XmlReader reader, Shipping shipping)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(ShippingSerializer.Shipping);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, ShippingSerializer.Shipping))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case ShippingSerializer.ShippingType:
                        shipping.ShippingType = reader.ReadElementContentAsInt();
                        break;

                    case ShippingSerializer.Cost:
                        shipping.Cost = reader.ReadElementContentAsDecimal();
                        break;

                    case AddressSerializer.Address:
                        Address address = new Address();
                        AddressSerializer.Read(reader, address);
                        shipping.Address = address;
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="permission">PagSeguro AuthorizationPermissions</param>
        internal static void Read(XmlReader reader, AuthorizationPermissions permission)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(SerializerHelper.Permission);

            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.Permission))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SerializerHelper.Code:
                        permission.Code = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Status:
                        permission.Status = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.LastUpdate:
                        permission.LastUpdate = reader.ReadElementContentAsDateTime();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value");
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Read a payment cancel request
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="result"></param>
        public static void Read(XmlReader reader, RequestResponse result)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Text:
                    result.Response = reader.Value;
                    break;
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Read a direct payment session request result
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="result"></param>
        public static void Read(XmlReader reader, Session session)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Text:
                    session.id = reader.Value;
                    break;
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="result">PagSeguro AuthorizationSearchResult</param>
        internal static void Read(XmlReader reader, AuthorizationSearchResult result)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);

                return;
            }
            reader.ReadStartElement(SerializerHelper.AuthorizationSearchResult);

            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.AuthorizationSearchResult))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }


                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SerializerHelper.Date:
                        result.Date = reader.ReadElementContentAsDateTime();
                        break;

                    case SerializerHelper.Authorizations:
                        AuthorizationSummaryListSerializer.Read(reader, result.Authorizations);
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader">PagSeguro AuthorizationSummary</param>
        /// <param name="result"></param>
        internal static void Read(XmlReader reader, AuthorizationSummary result)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(SerializerHelper.Account);

            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.Account))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SerializerHelper.PublicKey:

                        AuthorizationAccount authorizationAccount = new AuthorizationAccount
                        {
                            PublicKey = reader.ReadElementContentAsString()
                        };
                        result.Account = authorizationAccount;
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="paymentMethod"></param>
        internal static void Read(XmlReader reader, PaymentMethod paymentMethod)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(PaymentMethodSerializer.PaymentMethod);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, PaymentMethodSerializer.PaymentMethod))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case PaymentMethodSerializer.PaymentMethodType:
                        paymentMethod.PaymentMethodType = reader.ReadElementContentAsInt();
                        break;

                    case PaymentMethodSerializer.PaymentMethodCode:
                        paymentMethod.PaymentMethodCode = reader.ReadElementContentAsInt();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="item"></param>
        internal static void Read(XmlReader reader, CreditorFees creditorFees)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(CreditorFeesSerializer.CreditorFees);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, CreditorFeesSerializer.CreditorFees))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case CreditorFeesSerializer.IntermediationRateAmount:
                        creditorFees.intermediationRateAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case CreditorFeesSerializer.IntermediationFeeAmount:
                        creditorFees.intermediationFeeAmount = reader.ReadElementContentAsDecimal();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="phone"></param>
        internal static void Read(XmlReader reader, Phone phone)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(PhoneSerializer.Phone);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, PhoneSerializer.Phone))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case PhoneSerializer.AreaCode:
                        phone.AreaCode = reader.ReadElementContentAsString();
                        break;

                    case PhoneSerializer.Number:
                        phone.Number = reader.ReadElementContentAsString();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value");
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        internal static void Read(XmlReader reader, CreditorFees creditorFees)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(CreditorFees);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, CreditorFees))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case IntermediationRateAmount:
                        creditorFees.IntermediationRateAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case IntermediationFeeAmount:
                        creditorFees.IntermediationFeeAmount = reader.ReadElementContentAsDecimal();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value foo = " + reader.Name);
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="permissions">PagSeguro AuthorizationPermissions List</param>
        internal static void Read(XmlReader reader, IList <AuthorizationPermissions> permissions)
        {
            permissions.Clear();

            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
            }

            reader.ReadStartElement(SerializerHelper.Permissions);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.Permissions))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    AuthorizationPermissions permission = new AuthorizationPermissions();
                    switch (reader.Name)
                    {
                    case SerializerHelper.Permission:
                        AuthorizationPermissionSerializer.Read(reader, permission);
                        permissions.Add(permission);
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value");
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="authorizations">PagSeguro AuthorizationSummary List</param>
        internal static void Read(XmlReader reader, IList <AuthorizationSummary> authorizations)
        {
            authorizations.Clear();

            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
            }

            reader.ReadStartElement(SerializerHelper.Authorizations);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.Authorizations))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    AuthorizationSummary authorization = new AuthorizationSummary();
                    switch (reader.Name)
                    {
                    case SerializerHelper.Authorization:
                        AuthorizationSummarySerializer.Read(reader, authorization);
                        authorizations.Add(authorization);
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="items"></param>
        internal static void Read(XmlReader reader, IList <Item> items)
        {
            items.Clear();

            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
            }

            reader.ReadStartElement(ItemListSerializer.Items);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, ItemListSerializer.Items))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case ItemSerializer.Item:
                        Item item = new Item();
                        ItemSerializer.Read(reader, item);
                        items.Add(item);
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="preApprovals"></param>
        internal static void Read(XmlReader reader, IList <PreApprovalSummary> preApprovals)
        {
            preApprovals.Clear();

            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
            }

            reader.ReadStartElement(PreApprovalSummaryListSerializer.PreApprovals);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, PreApprovalSummaryListSerializer.PreApprovals))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    PreApprovalSummary preApproval = new PreApprovalSummary();
                    switch (reader.Name)
                    {
                    case SerializerHelper.PreApproval:
                        PreApprovalSummarySerializer.Read(reader, preApproval);
                        preApprovals.Add(preApproval);
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value");
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="transactions"></param>
        internal static void Read(XmlReader reader, IList <TransactionSummary> transactions)
        {
            transactions.Clear();

            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
            }

            reader.ReadStartElement(TransactionSummaryListSerializer.Transactions);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, TransactionSummaryListSerializer.Transactions))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    TransactionSummary transaction = new TransactionSummary();
                    switch (reader.Name)
                    {
                    case SerializerHelper.Transaction:
                        TransactionSummarySerializer.Read(reader, transaction);
                        transactions.Add(transaction);
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value");
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Read a direct payment session request result
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="session"></param>
        public static void Read(XmlReader reader, Session session)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Text:
                    session.id = reader.Value;
                    break;

                default:
                    throw new InvalidOperationException("Unexpected value NodeType = " + reader.NodeType);
                }
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Read a payment cancel request
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="result"></param>
        public static void Read(XmlReader reader, RequestResponse result)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Text:
                    result.Response = reader.Value;
                    break;

                default:
                    throw new InvalidOperationException("Unexpected value");
                }
            }
        }
        /// <summary>
        /// Read a direct payment session request result
        /// </summary>
        /// <param name="streamReader"></param>
        /// <param name="installments"></param>
        internal static void Read(XmlReader reader, Installments installments)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(SerializerHelper.Installments);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.Installments))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SerializerHelper.Installment:
                        Installment installment = new Installment();
                        InstallmentSerializer.Read(reader, installment);
                        installments.Add(installment);
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Converts xml into a list of ServiceError class
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="errors"></param>
        internal static void Read(XmlReader reader, IList <ServiceError> errors)
        {
            errors.Clear();

            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
            }

            reader.ReadStartElement(ErrorsSerializer.Errors);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, ErrorsSerializer.Errors))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case ErrorSerializer.Error:
                        errors.Add(ErrorSerializer.Read(reader));
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="authorization">PagSeguro AuthorizationResponse</param>
        internal static void Read(XmlReader reader, AuthorizationResponse authorization)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement();
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.PreApproval))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SerializerHelper.Code:
                        authorization.Code = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Date:
                        authorization.Date = reader.ReadElementContentAsDateTime();
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="preApproval"></param>
        internal static void Read(XmlReader reader, PreApprovalSummary preApproval)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(SerializerHelper.PreApproval);

            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.PreApproval))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SerializerHelper.Code:
                        preApproval.Code = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Date:
                        preApproval.Date = reader.ReadElementContentAsDateTime();
                        break;

                    case SerializerHelper.Reference:
                        preApproval.Reference = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.TransactionStatus:
                        preApproval.Status = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.LastEventDate:
                        preApproval.LastEventDate = reader.ReadElementContentAsDateTime();
                        break;

                    case SerializerHelper.Name:
                        preApproval.Name = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Tracker:
                        preApproval.Tracker = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Charge:
                        preApproval.Charge = reader.ReadElementContentAsString();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value");
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="transaction"></param>
        /// <param name="payment"></param>
        internal static void Read(XmlReader reader, Transaction transaction, bool payment = true)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement();
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.PreApproval))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SerializerHelper.Code:
                        transaction.Code = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Date:
                        transaction.Date = reader.ReadElementContentAsDateTime();
                        break;

                    case SerializerHelper.Reference:
                        transaction.Reference = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.TransactionType:
                        transaction.TransactionType = reader.ReadElementContentAsInt();
                        break;

                    case SerializerHelper.TransactionStatus:
                        transaction.TransactionStatus = reader.ReadElementContentAsInt();
                        break;

                    case SerializerHelper.GrossAmount:
                        transaction.GrossAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.DiscountAmount:
                        transaction.DiscountAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.CreditorFees:
                        CreditorFees creditorFees = new CreditorFees();
                        CreditorFeesSerializer.Read(reader, creditorFees);
                        transaction.CreditorFees = creditorFees;
                        break;

                    case SerializerHelper.FeeAmount:
                        transaction.FeeAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.NetAmount:
                        transaction.NetAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.ExtraAmount:
                        transaction.ExtraAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.LastEventDate:
                        transaction.LastEventDate = reader.ReadElementContentAsDateTime();
                        break;

                    case SerializerHelper.InstallmentCount:
                        transaction.InstallmentCount = reader.ReadElementContentAsInt();
                        break;

                    case PaymentMethodSerializer.PaymentMethod:
                        PaymentMethod paymentMethod = new PaymentMethod();
                        PaymentMethodSerializer.Read(reader, paymentMethod);
                        transaction.PaymentMethod = paymentMethod;
                        break;

                    case ItemListSerializer.Items:
                        ItemListSerializer.Read(reader, transaction.Items);
                        break;

                    case SenderSerializer.Sender:
                        Sender sender = new Sender();
                        SenderSerializer.Read(reader, sender);
                        transaction.Sender = sender;
                        break;

                    case ShippingSerializer.Shipping:
                        Shipping shipping = new Shipping();
                        ShippingSerializer.Read(reader, shipping);
                        transaction.Shipping = shipping;
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Esempio n. 30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="transaction"></param>
        internal static void Read(XmlReader reader, TransactionSummary transaction)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(TransactionSerializerHelper.Transaction);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, TransactionSerializerHelper.Transaction))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case TransactionSerializerHelper.Code:
                        transaction.Code = reader.ReadElementContentAsString();
                        break;

                    case TransactionSerializerHelper.Date:
                        transaction.Date = reader.ReadElementContentAsDateTime();
                        break;

                    case TransactionSerializerHelper.Reference:
                        transaction.Reference = reader.ReadElementContentAsString();
                        break;

                    case TransactionSerializerHelper.TransactionType:
                        transaction.TransactionType = reader.ReadElementContentAsInt();
                        break;

                    case TransactionSerializerHelper.TransactionStatus:
                        transaction.TransactionStatus = reader.ReadElementContentAsInt();
                        break;

                    case TransactionSerializerHelper.GrossAmount:
                        transaction.GrossAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case TransactionSerializerHelper.DiscountAmount:
                        transaction.DiscountAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case TransactionSerializerHelper.FeeAmount:
                        transaction.FeeAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case TransactionSerializerHelper.NetAmount:
                        transaction.NetAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case TransactionSerializerHelper.ExtraAmount:
                        transaction.ExtraAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case TransactionSerializerHelper.LastEventDate:
                        transaction.LastEventDate = reader.ReadElementContentAsDateTime();
                        break;

                    case PaymentMethodSerializer.PaymentMethod:
                        PaymentMethod paymentMethod = new PaymentMethod();
                        PaymentMethodSerializer.Read(reader, paymentMethod);
                        transaction.PaymentMethod = paymentMethod;
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }