Search Unity

IAP non-cosumable testing

Discussion in 'Game Foundation' started by metiscoda, Aug 18, 2020.

  1. metiscoda

    metiscoda

    Joined:
    Nov 18, 2013
    Posts:
    41
    Hi,
    I've set up IAP catalog as well as IAP transactions on the GF db. I'm still testing in Editor and I see all my IAP items but they are all priced at 0. I'm guessing that is expected in the Editor? Now I had one non-consumable item that I bought while testing the purchase. Now everytime I open up the store, I get a nullreferenceexception (prolly when it tries to display the non-consumable). How do I remove the record of the transaction from my state? i.e. I want to retest purchasing this non-cosumable item. Restarting the editor does not seem to remove it.

    Here's the exception:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEngine.GameFoundation.UI.StoreView.IsIAPTransactionPurchasable (UnityEngine.GameFoundation.IAPTransaction iapTransaction) (at Library/PackageCache/com.unity.game.foundation@0.6.0-preview.2/UI/Runtime/StoreView.cs:521)
    3. UnityEngine.GameFoundation.UI.StoreView.UpdateContent () (at Library/PackageCache/com.unity.game.foundation@0.6.0-preview.2/UI/Runtime/StoreView.cs:446)
    4. UnityEngine.GameFoundation.UI.StoreView.Start () (at Library/PackageCache/com.unity.game.foundation@0.6.0-preview.2/UI/Runtime/StoreView.cs:203)
    5.  
     
  2. erika_d

    erika_d

    Joined:
    Jan 20, 2016
    Posts:
    413
    Hi @metiscoda,

    Sorry to hear you're getting a nullref when you have a purchased non-consumable, and thanks for including the exception stack trace. We'll take a look at this issue and see if we can duplicate it and get back to you. If you could also share the device logs when testing IAP that would be helpful for us duplicating it properly! (Instructions for how to get the device logs: Android: https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/ and iOS: https://forum.unity.com/threads/how-to-capturing-device-logs-on-ios.529920/ )
     
  3. metiscoda

    metiscoda

    Joined:
    Nov 18, 2013
    Posts:
    41
    I'm testing in Editor, not on device yet. What I want to know if there is a mechanism to make the non-consumable buyable again, as once I have bought it, it disappears from the store.
     
  4. erika_d

    erika_d

    Joined:
    Jan 20, 2016
    Posts:
    413
    It disappearing from the store is a factor of the StoreView component associated with the Store prefab. You could make a copy of the StoreView component and change how the component handles that situation. But even if you change the component to keep the item visible in the store, it being purchasable again is a factor of the iOS/android/etc stores. If a non-consumable item is already owned it will fail to purchase again if it's attempted. You'd need to make it consumable if you want it to be purchasable multiple times.

    You can check out this thread from someone else who wanted to change the StoreView component to show non consumable items: https://forum.unity.com/threads/putting-out-an-item-after-buying-from-store.932874/
     
  5. metiscoda

    metiscoda

    Joined:
    Nov 18, 2013
    Posts:
    41
    Thanks for that link. I wanted to know how to reset the fact that I bought that non-cosumable IAP while I'm testing. But maybe I should be asking on the IAP forum?
     
  6. erika_d

    erika_d

    Joined:
    Jan 20, 2016
    Posts:
    413
    My guess is this would have to do with how the IAPs are set up for testing in the platform store, for example Google has a page/section on how to test non consumable IAPs https://developer.android.com/google/play/billing/test#non-consumable. Likely that's where you need to research for testing non consumable purchases again, because IAP (and Game Foundation through IAP) are told what is non-consumable by querying the platform store. You're right though that there are likely some forum posts already about this (and that have more info) in the IAP forum.
     
  7. erika_d

    erika_d

    Joined:
    Jan 20, 2016
    Posts:
    413
  8. metiscoda

    metiscoda

    Joined:
    Nov 18, 2013
    Posts:
    41
    Thanks for that link too - I asked the question there. What I want to do does not have to do with platform stores - in the editor I want to change the state of the user (in the editor not logged in to any store) so that they can purchase the same non-consumable. Maybe a reset of the whole purchase history of the editor user?
     
  9. erika_d

    erika_d

    Joined:
    Jan 20, 2016
    Posts:
    413
    To my knowledge all IAP management comes, at its core, from the platform stores, and Unity IAP serves as the bridge between you and them. When you tell Unity IAP to process a purchase, it communicates on your behalf to the platform stores to request the product be purchased, who see if the user is eligible for the purchase, charges them if eligible, and then responds to Unity IAP with the results, who returns them to you.

    I understand that you are not testing on a physical device yet, in that case Unity IAP provides a fake store with a fake platform store UI to mimic what would happen with a platform store, however I believe all actual/accurate IAP testing needs to be ultimately done on a device otherwise it won't accurately represent your users' experiences (i.e just because it works in the editor with the fake store, doesn't mean it will work when you ultimately ship to users). So I'm not sure whether what you're trying to do can be done, or if you were able to do it, whether it would help you in the way you want it to help you. You could try clearing the editor's cache on your computer though perhaps.

    It's good that you asked in the IAP forum though, maybe they will have additional info/insight or know of a special IAP testing feature that will help achieve your ends. Perhaps explaining to them what you're ultimately trying to achieve by testing it in this way will help them provide you with a solution.

    To your original questions, yes, it's expected to see a price of 0 when in the Editor (because the price comes from the platform stores). And for Game Foundation specifically, are you still getting the null reference exception when you open the store window, or has that gone away?
     
  10. metiscoda

    metiscoda

    Joined:
    Nov 18, 2013
    Posts:
    41
    The null reference exception still happens in the editor.
     
  11. metiscoda

    metiscoda

    Joined:
    Nov 18, 2013
    Posts:
    41
    Ignore this - it was a user error - I had wrong bundle id in the IAP transaction - this could be a common error - maybe GF could check IAP catalog to make sure bundle id exists in IAP catalog.
     
    erika_d and mingz-unity like this.
  12. erika_d

    erika_d

    Joined:
    Jan 20, 2016
    Posts:
    413
    @metiscoda,

    Thanks for the update and feedback. We'll make a note on it to see what quality of life improvements we can do there.