Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Identify sandbox user UnityIAP Android

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

  1. Kleton5

    Kleton5

    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

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,372
    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. Kleton5

    Kleton5

    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

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,372
    Sorry no it's not available on LTS
     
unityunity