using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; namespace UnityEngine.Purchasing.Default { /// /// A utility class to parse Universal Windows Platform products from XML data. /// public class XMLUtils { /// /// A utility class to parse Universal Windows Platform products from XML data. /// /// The app receipt as raw XML data. /// The TransactionInfo for the products parsed from the XML data. public static IEnumerable ParseProducts(string appReceipt) { if (null == appReceipt) { return new List(); } try { var xml = XElement.Parse(appReceipt); return from product in xml.Descendants("ProductReceipt") select new TransactionInfo() { productId = (string)product.Attribute("ProductId"), transactionId = (string)product.Attribute("Id") }; } catch (XmlException) { return new List(); } } /// /// Data of a transaction for Universal Windows Platform product purchases. /// public class TransactionInfo { /// /// The ID of the product. /// public string productId; /// /// The transaction ID for the purchase. /// public string transactionId; } } }