1
0

GooglePlayReceipt.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. namespace UnityEngine.Purchasing.Security
  3. {
  4. // See Google's reference docs.
  5. // http://developer.android.com/google/play/billing/billing_reference.html
  6. /// <summary>
  7. /// The state of the GooglePlay purchase.
  8. /// </summary>
  9. public enum GooglePurchaseState
  10. {
  11. /// <summary>
  12. /// The purchase was completed.
  13. /// </summary>
  14. Purchased,
  15. /// <summary>
  16. /// The purchase was cancelled.
  17. /// </summary>
  18. Cancelled,
  19. /// <summary>
  20. /// The purchase was refunded.
  21. /// </summary>
  22. Refunded
  23. }
  24. /// <summary>
  25. /// A GooglePlay purchase receipt
  26. /// </summary>
  27. public class GooglePlayReceipt : IPurchaseReceipt
  28. {
  29. /// <summary>
  30. /// The item's product identifier.
  31. /// </summary>
  32. public string productID { get; private set; }
  33. /// <summary>
  34. /// A unique order identifier for the transaction. This identifier corresponds to the Google payments order ID.
  35. /// </summary>
  36. public string orderID { get; private set; }
  37. /// <summary>
  38. /// The ID of the transaction.
  39. /// </summary>
  40. public string transactionID => orderID;
  41. /// <summary>
  42. /// The package name of the app.
  43. /// </summary>
  44. public string packageName { get; private set; }
  45. /// <summary>
  46. /// A token that uniquely identifies a purchase for a given item and user pair.
  47. /// </summary>
  48. public string purchaseToken { get; private set; }
  49. /// <summary>
  50. /// The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).
  51. /// </summary>
  52. public DateTime purchaseDate { get; private set; }
  53. /// <summary>
  54. /// The purchase state of the order.
  55. /// </summary>
  56. public GooglePurchaseState purchaseState { get; private set; }
  57. /// <summary>
  58. /// Constructor that initializes the members from the input parameters.
  59. /// </summary>
  60. /// <param name="productID"> The item's product identifier. </param>
  61. /// <param name="orderID"> The unique order identifier for the transaction. </param>
  62. /// <param name="packageName"> The package name of the app. </param>
  63. /// <param name="purchaseToken"> The token that uniquely identifies a purchase for a given item and user pair. </param>
  64. /// <param name="purchaseTime"> The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970). </param>
  65. /// <param name="purchaseState"> The purchase state of the order. </param>
  66. public GooglePlayReceipt(string productID, string orderID, string packageName,
  67. string purchaseToken, DateTime purchaseTime, GooglePurchaseState purchaseState)
  68. {
  69. this.productID = productID;
  70. this.orderID = orderID;
  71. this.packageName = packageName;
  72. this.purchaseToken = purchaseToken;
  73. this.purchaseDate = purchaseTime;
  74. this.purchaseState = purchaseState;
  75. }
  76. }
  77. }