namespace UnityEngine.Purchasing { /// /// May be purchased as an In App Purchase. /// public class Product { /// /// Products must have a definition as minimum. /// /// Further metadata may be populated following retrieval from the /// store system. /// internal Product(ProductDefinition definition, ProductMetadata metadata, string receipt) { this.definition = definition; this.metadata = metadata; this.receipt = receipt; } internal Product(ProductDefinition definition, ProductMetadata metadata) : this(definition, metadata, null) { } /// /// Basic immutable product properties. /// public ProductDefinition definition { get; private set; } /// /// Localized metadata provided by the store system. /// /// The metadata. public ProductMetadata metadata { get; internal set; } /// /// Determine if this product is available to purchase according to /// the store subsystem. /// /// This will be false if the product's identifier is unknown, /// incorrect or otherwise disabled with the store provider /// (ie Apple, Google et al). /// /// If this is false, purchase attempts will immediately fail. /// public bool availableToPurchase { get; internal set; } /// /// A unique identifier for this product's transaction. /// This will only be set when the product was purchased during this session. /// Consumable's transactionID are not set between app restarts unless it has a pending transaction. /// Once a consumable has been acknowledged (ConfirmPendingPurchase) the `transactionID` is removed. /// public string transactionID { get; internal set; } /// /// A unique identifier for this Apple product's original transaction. /// /// This will only be set when the Apple product was purchased during this session. /// public string appleOriginalTransactionID { get; internal set; } /// /// Indicates if this Apple product is restored. /// public bool appleProductIsRestored { get; internal set; } /// /// Owned Non Consumables and Subscriptions should always have receipts. /// Consumable's receipts are not persisted between App restarts unless it has a pending transaction. /// Once a consumable has been acknowledged (ConfirmPendingPurchase) the `receipt` is removed. /// public bool hasReceipt => !string.IsNullOrEmpty(receipt); /// /// The purchase receipt for this product, if owned. /// For consumable purchases, this will be the most recent purchase receipt. /// Consumable's receipts are not set between app restarts unless it has a pending transaction. /// Once a consumable has been acknowledged (ConfirmPendingPurchase) the `receipt` is removed. /// Receipts is in JSON format. /// public string receipt { get; internal set; } /// /// Check if this product is equal to another. /// /// The product to compare with this object. /// True if the products are equal public override bool Equals(object obj) { if (obj == null) { return false; } var p = obj as Product; if (p == null) { return false; } return definition.Equals(p.definition); } /// /// Get the unique Hash representing the product. /// /// The hash code as integer public override int GetHashCode() { return definition.GetHashCode(); } } }