Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. namespace UnityEngine.Purchasing
  2. {
  3. /// <summary>
  4. /// May be purchased as an In App Purchase.
  5. /// </summary>
  6. public class Product
  7. {
  8. /// <summary>
  9. /// Products must have a definition as minimum.
  10. ///
  11. /// Further metadata may be populated following retrieval from the
  12. /// store system.
  13. /// </summary>
  14. internal Product(ProductDefinition definition, ProductMetadata metadata, string receipt)
  15. {
  16. this.definition = definition;
  17. this.metadata = metadata;
  18. this.receipt = receipt;
  19. }
  20. internal Product(ProductDefinition definition, ProductMetadata metadata) : this(definition, metadata, null)
  21. {
  22. }
  23. /// <summary>
  24. /// Basic immutable product properties.
  25. /// </summary>
  26. public ProductDefinition definition { get; private set; }
  27. /// <summary>
  28. /// Localized metadata provided by the store system.
  29. /// </summary>
  30. /// <value>The metadata.</value>
  31. public ProductMetadata metadata { get; internal set; }
  32. /// <summary>
  33. /// Determine if this product is available to purchase according to
  34. /// the store subsystem.
  35. ///
  36. /// This will be false if the product's identifier is unknown,
  37. /// incorrect or otherwise disabled with the store provider
  38. /// (ie Apple, Google et al).
  39. ///
  40. /// If this is false, purchase attempts will immediately fail.
  41. /// </summary>
  42. public bool availableToPurchase { get; internal set; }
  43. /// <summary>
  44. /// A unique identifier for this product's transaction.
  45. /// This will only be set when the product was purchased during this session.
  46. /// Consumable's transactionID are not set between app restarts unless it has a pending transaction.
  47. /// Once a consumable has been acknowledged (ConfirmPendingPurchase) the `transactionID` is removed.
  48. /// </summary>
  49. public string transactionID { get; internal set; }
  50. /// <summary>
  51. /// A unique identifier for this Apple product's original transaction.
  52. ///
  53. /// This will only be set when the Apple product was purchased during this session.
  54. /// </summary>
  55. public string appleOriginalTransactionID { get; internal set; }
  56. /// <summary>
  57. /// Indicates if this Apple product is restored.
  58. /// </summary>
  59. public bool appleProductIsRestored { get; internal set; }
  60. /// <summary>
  61. /// Owned Non Consumables and Subscriptions should always have receipts.
  62. /// Consumable's receipts are not persisted between App restarts unless it has a pending transaction.
  63. /// Once a consumable has been acknowledged (ConfirmPendingPurchase) the `receipt` is removed.
  64. /// </summary>
  65. public bool hasReceipt => !string.IsNullOrEmpty(receipt);
  66. /// <summary>
  67. /// The purchase receipt for this product, if owned.
  68. /// For consumable purchases, this will be the most recent purchase receipt.
  69. /// Consumable's receipts are not set between app restarts unless it has a pending transaction.
  70. /// Once a consumable has been acknowledged (ConfirmPendingPurchase) the `receipt` is removed.
  71. /// Receipts is in JSON format.
  72. /// </summary>
  73. public string receipt { get; internal set; }
  74. /// <summary>
  75. /// Check if this product is equal to another.
  76. /// </summary>
  77. /// <param name="obj"> The product to compare with this object. </param>
  78. /// <returns> True if the products are equal </returns>
  79. public override bool Equals(object obj)
  80. {
  81. if (obj == null)
  82. {
  83. return false;
  84. }
  85. var p = obj as Product;
  86. if (p == null)
  87. {
  88. return false;
  89. }
  90. return definition.Equals(p.definition);
  91. }
  92. /// <summary>
  93. /// Get the unique Hash representing the product.
  94. /// </summary>
  95. /// <returns> The hash code as integer </returns>
  96. public override int GetHashCode()
  97. {
  98. return definition.GetHashCode();
  99. }
  100. }
  101. }