Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    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:
    59
    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

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    13,371
    @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:
    59
    Thank you for the clarification
     
unityunity