Search Unity

Identify sandbox user UnityIAP Android

Discussion in 'Unity IAP' started by Qrowl, Jan 9, 2020.

  1. Qrowl

    Qrowl

    Joined:
    Jan 12, 2017
    Posts:
    4
    Hey I've spend the last 2 hours doing research on how to identify a test user purchase in Unity IAP. We are in need of this for our project to exclude IAP made by our QA team, accidental purchases of large sums skew are graphs.

    In Googles API docs I found the value that I need to retreive which is the "purchaseType" however there is no sign of this existing anywhere in the PurchaseEventArgs returned by Unity IAP.
    https://developers.google.com/android-publisher/api-ref/purchases/subscriptions

    In Unity IAP validate receipt documentation the following is mentioned:
    Code (CSharp):
    1. GooglePlayReceipt google = productReceipt as GooglePlayReceipt;
    2.     if (null != google) {
    3.         // This is Google's Order ID.
    4.         // Note that it is null when testing in the sandbox
    5.         // because Google's sandbox does not provide Order IDs.
    6.         Debug.Log(google.transactionID);
    7.         Debug.Log(google.purchaseState);
    8.         Debug.Log(google.purchaseToken);
    However I found a GitHub thread here that clearly mentions that this is no longer the case and from my testing it will always return the same OrderID as a real purchase. Therefore the purchaseType should be used which is not present.

    Perhaps I'm approaching this the wrong way and there is a different solution, but I cannot find any way to get whether the purchase was made by a test user or a real consumer purchase.

    EDIT: I'm using Unity 2019.2.15f with IAP Purchasing package version 2.0.6
    Thanks in advance!
     
    Last edited: Jan 9, 2020
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, this is a feature we are considering in a future version, separating test purchases from actual purchases. We have been recommending in the meantime to use a separate Unity project, granted not ideal.
     
  3. Qrowl

    Qrowl

    Joined:
    Jan 12, 2017
    Posts:
    4
    Appreciate the fast reply!

    Sadly not the solution I was hoping to hear. It's quite the workaround, I hope it's high on the priority list.
     
  4. Legolas-Muradin

    Legolas-Muradin

    Joined:
    Nov 20, 2014
    Posts:
    2
    Hi, @JeffDUnity3D, could this feature be on 2019 LTS versions ? Thank you
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry no it's not available on LTS
     
  6. pdafedar

    pdafedar

    Joined:
    Apr 17, 2018
    Posts:
    9
    Hi @JeffDUnity3D , Is there any update so far on this requirement. Can you let us know the ETA. If not otherwise we may need to move away from unity IAP plugin and use something native.
    Is there a way to identify at least the purchase was done via sandbox environment or not once purchase completes, if not before the purchase?
     
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    No ETA, I doubt we will support this feature.
     
    pdafedar likes this.