Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

purchaseState == 4 (out of three possible)

Discussion in 'Unity IAP' started by MaximPP, Aug 25, 2021.

  1. MaximPP

    MaximPP

    Joined:
    Jan 26, 2019
    Posts:
    76
    Code (CSharp):
    1. GooglePlayReceipt google = productReceipt as GooglePlayReceipt;
    2. Debug.Log (Convert.ToString(google.purchaseState));
    When validating purchases from players, I get purchaseState == 4, although in the code I see an enum GooglePurchaseState that only has three (0, 1, 2) states.

    Code (CSharp):
    1. public enum GooglePurchaseState
    2. {
    3.     Purchased,
    4.     Cancelled,
    5.     Refunded
    6. }
    where did state number 4 come from? This is definitely a cheat purchase, the player somehow learned to call ProcessPurchase() when the application restarts and he successfully passes the validation many times with purchaseState==4

    Unity 2020.3.15, IAP 3.2.3, Android
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @MaximPP Google hasn't updated the enum documentation. It's a new purchase option from Google referred to as a Pending or Deferred purchase. It is a valid state, and not a cheat. The user will purchase the in app product in the game then has 3 days to pay at a physical location approved by Google. If they don't pay, the transaction is cancelled. Until they pay, purchaseState = 4, and you should continue to return Pending from ProcessPurchase. Once they pay, purchaseState = 1 and you award the product and return Complete from ProcessPurchase. This code demonstrates a good technique to get the value https://forum.unity.com/threads/google-play-iap-problem.1140367/#post-7351220
     
  3. MaximPP

    MaximPP

    Joined:
    Jan 26, 2019
    Posts:
    76
    Thank you for the clarification