コード例 #1
0
ファイル: CCTransaction.cs プロジェクト: theolymp/BillomatNet
        internal override XmlElement GetXml(XmlDocument doc)
        {
            XmlElement root = doc.CreateElement("CC_TRANSACTION");

            root.SetAttribute("mode", Mode.ToString().ToLower());

            XmlElement tid = doc.CreateElement("TransactionID");

            tid.InnerText = TransactionId;
            root.AppendChild(tid);

            if (Amount > 0)
            {
                XmlElement e = doc.CreateElement("Amount");
                e.InnerText = Convert.ToInt32(Amount * Math.Pow(10, CurrencyMinorUnits)).ToString(CultureInfo.InvariantCulture);
                e.SetAttribute("minorunits", CurrencyMinorUnits.ToString(CultureInfo.InvariantCulture));
                e.SetAttribute("action", "convert");
                root.AppendChild(e);
            }

            if (!string.IsNullOrEmpty(Currency))
            {
                XmlElement e = doc.CreateElement("Currency");
                e.InnerText = Currency;
                root.AppendChild(e);
            }

            if (!string.IsNullOrEmpty(CountryCode))
            {
                XmlElement e = doc.CreateElement("CountryCode");
                e.InnerText = CountryCode;
                root.AppendChild(e);
            }

            if (!string.IsNullOrEmpty(Usage))
            {
                XmlElement e = doc.CreateElement("Usage");
                e.InnerText = Usage;
                root.AppendChild(e);
            }

            if (!string.IsNullOrEmpty(GuWID))
            {
                XmlElement e = doc.CreateElement("GuWID");
                e.InnerText = GuWID;
                root.AppendChild(e);
            }

            if (ContactData != null)
            {
                root.AppendChild(ContactData.GetXml(doc));
            }

            if (CorpTrustCenterData != null)
            {
                root.AppendChild(CorpTrustCenterData.GetXml(doc));
            }

            if (CreditCardData != null)
            {
                root.AppendChild(CreditCardData.GetXml(doc));
            }

            if (RecurringTransaction != RecurringTransactionType.Single)
            {
                XmlElement e = doc.CreateElement("RECURRING_TRANSACTION");

                XmlElement type = doc.CreateElement("Type");
                type.InnerText = RecurringTransaction.ToString();
                e.AppendChild(type);

                root.AppendChild(e);
            }

            return(root);
        }