Search Unity

Trouble with IAP Enabling [Bug]

Discussion in 'Game Foundation' started by VektaCo, Jan 25, 2021.

  1. VektaCo

    VektaCo

    Joined:
    Sep 30, 2019
    Posts:
    31
    I am having trouble getting IAP enabled.
    Half the time the 'Purchasing Enabled' button is greyed out, but when it does allow me to activate it GameFoundation doesn't initialise on play.
    Is this a known issue?

    upload_2021-1-24_17-6-31.png
     
    Last edited: Jan 25, 2021
  2. tony_c-unity3d

    tony_c-unity3d

    Unity Technologies

    Joined:
    Jul 18, 2019
    Posts:
    28
    Hi,

    You say it happens "half the time"--have you been turning IAP off and on repeatedly? Normally I believe our customers turn it on and leave it so I'm just curious if there's a work flow we should consider and test more thoroughly going forward.

    That said, it should not be doing that (obviously!). Would you mind sharing your repro steps (if you have them) so we can try to debug it on our end. When IAP is enabled, it installs a bunch of code and enables features so Game Foundation is required to rebuild so perhaps there's an issue related to repeated toggling the packages that may be the root cause your problem. If you've found a work around that's great, and we'd love to hear about it, otherwise we may be able to help you get it setup properly in the short term, unless you really need to toggle IAP on and off during development. Either way, repro steps could really help us get to the bottom of your problem. Cheers.
     
    erika_d likes this.
  3. VektaCo

    VektaCo

    Joined:
    Sep 30, 2019
    Posts:
    31
    Hi @tony_c-unity3d

    Some info.
    I had GameFoundation installed before I enabled IAP.
    The first time I enabled IAP I activated the 'purchasing enabled' button Unity crashed.

    I then toggled IAP on and off until I was able to activate 'purchasing enabled' again. (multiple restarts, removing cached packages and reinstalling the GF and IAP packages fresh)

    IAP continually asks me to Migrate to 2.2.2 even though that is the current version installed.

    upload_2021-1-25_15-4-46.png

    When I am able to enable purchasing, GameFoundation fails to initialise
     
  4. Sukender_OB

    Sukender_OB

    Joined:
    Nov 14, 2019
    Posts:
    18
    Hi @VektaCo , hi @tony_c-unity3d ,

    I just updated from 2.2.1 to 2.2.2 and indeed GF was disabled. However, a compile warning told me that "Unity IAP plugin is installed, but Unity IAP is not enabled. Please enable Unity IAP in the Services window.". This is issued only when UNITY_PURCHASING is not defined. I thus manually added it:

    upload_2021-1-26_7-37-23.png

    However, I'm not 100% sure this is the right way to proceed. What's your opinion on this, @tony_c-unity3d ?
    Thanks.
     
  5. tony_c-unity3d

    tony_c-unity3d

    Unity Technologies

    Joined:
    Jul 18, 2019
    Posts:
    28
    Hi @VektaCo and @Sukender_OB ,
    I'm working on reproducing your issues now and will hopefully have more info for you this afternoon. Quick question: could you both please let me know which version GF and IAP you're using (possibly upgrading to latest could help) as well as what devices you're building for. I may also need to reach out to IAP team, but will see if I can repro and address your issues directly myself first. I'll be in touch with an update ASAP.

    Also, please supply details about Unity version you're both using. I'm working to test as closely as possible to your conditions so any additional info provided will help.
     
    Last edited: Jan 26, 2021
  6. tony_c-unity3d

    tony_c-unity3d

    Unity Technologies

    Joined:
    Jul 18, 2019
    Posts:
    28
    Update: I did test a new project and everything went smoothly. I'll try other options including build types, Unity version, etc, but here's a quick list of my actions for the initial tests:

    * unity 2019.4.16f1
    * new proj (default build settings PC)
    * installed GF 0.8.0-preview (from package manager, enabled preview packages)
    * close/reopen unity
    * iap services, iap, installed, imported
    * close/reopen unity
    * window > gf > settings > runtime
    * hover over 'Purchasing Enabled': on, exists, off
    * clicked purchasing enabled check box (had to click twice, once to select, once to add check)
    * hover: on, exists, on
     
  7. tony_c-unity3d

    tony_c-unity3d

    Unity Technologies

    Joined:
    Jul 18, 2019
    Posts:
    28
    Apologies but I'm still having trouble reproducing your issue. I tried different Unity version, set build to Android and removed IAP then re-added 2.2.2 from package manager this time and everything still went smoothly. Following were my steps (I closed Unity several times to try to simulate your potential work flow of adding packages at different times):

    * Unity 18.4.28f1
    * remove IAP using package manager
    * build settings set to Android
    * close/reopen Unity
    * GF 0.8.0-preview install
    prompt: "Game Foundation : CatalogSettings - No Game Foundation catalog settings file ..."
    * close/reopen Unity
    * use package manager to install IAP 2.2.2
    * close/reopen Unity
    * window > gf > settings > runtime
    * hover: off, does not exist, off
    * services: IAP displayed as "off" (consistent with hover text)
    * services: IAP enable (not for 13) then import then install now then import (all checked) then close, clean up
    * hover: on, exists, off
    * close/reopen unity
    * hover: still on, exists, off
    * clicked text of purchasing enabled to select the control, waited 3 secs, then clicked check box and waited about 10 secs for check mark to appear and control to un-grey and return to selectable.
    * hover: on, exists, on

    @Sukender_OB Since you had to manually add the define, perhaps you ended up without IAP installed correctly. Did you ever use services to enable IAP? That flow seemed to be necessary to properly configure your IAP package for use as I didn't show IAP as installed until after I used the services tab to enable it (please see my setup steps above for reference).

    @VektaCo Have you tried completely uninstalling both packages (or at least IAP) and reinstalling? I used package manager to uninstall, then was able to reinstall IAP and everything went smoothly (I had Game Foundation installed from the start). Also, for best results, please also ensure that you're using Game Foundation 0.8.0-preview and an up-to-date version of Unity.

    Best of luck to both of you. If you can get back to me with your exact Unity, IAP and GF versions you're using, along with as detailed repro steps as possible, I'll test again with your exact config. In the mean time, please feel free to try my repro steps on a new project to confirm you're able to set up properly that way. There's always a chance that whatever other code you have in your project may be interfering with IAP and/or Game Foundation.
     
  8. VektaCo

    VektaCo

    Joined:
    Sep 30, 2019
    Posts:
    31
    Hi @tony_c-unity3d thanks for looking into this.

    I did a full clean install and got it working.

    I came up against this warning first (which imo could be an ERROR and not a warning)
    "Game Foundation : GameFoundationSdk - Failed to initialize the SDK: UnityEngine.GameFoundation.Exceptions.GameFoundationException: You have to disable auto IAP initialization if you want to use GameFoundation with the IAP SDK."

    It took awhile to find where the IAP Auto Initialisation option is, you need to write some text into the catalog to get the option to appear.... smh.

    upload_2021-1-26_22-50-49.png


    p.s removing IAP with 'Purchasing Enabled' set causes gamefoundation to stop compiling, which was very hard to recover from.
     

    Attached Files:

    Last edited: Jan 27, 2021
  9. tony_c-unity3d

    tony_c-unity3d

    Unity Technologies

    Joined:
    Jul 18, 2019
    Posts:
    28
    Hi @VektaCo ,

    Glad you got it working! I'll take a look at your issues today to see if I can reproduce so we can address them in a future release. Removing IAP without disabling it shouldn't cause an issue, but I don't believe it's been tested so it almost certainly does. :/

    Thanks for all your feedback and patience. Have a great day and please don't hesitate to reach out again if you have any other issues.
     
  10. tony_c-unity3d

    tony_c-unity3d

    Unity Technologies

    Joined:
    Jul 18, 2019
    Posts:
    28
    Hi again @VektaCo ,

    I wanted to give you an update.

    Firstly, I added a ticket to make the warning you reported more visible and comprehensive ("Game Foundation : GameFoundationSdk - Failed to initialize the SDK: ...") Hopefully we'll be able to address soon to help smooth out the process going forward.

    Secondly, I tried to reproduce the issue you were having with removing IAP while GF was installed and purchasing enabled. I did have a few issues, most of which we hope to have resolved in IAP SDK 3.0 which the IAP team is hard at work on. There were 2 important findings that might help shine a light on the problems you were having and possible solutions.

    1) I added IAP alone, then tried to remove it from the project using package manager. That caused many errors even without GF. In case you didn't know (I didn't until I reached out to the IAP team), after you remove IAP, you must also delete the Assets/Plugins/UnityPurchasing folder as well. I did this, then restarted Unity and that resolved all errors and warnings.

    2) Even with removing the plugins folder, Game Foundation will still believe IAP is on until Unity is restarted. I'll add a ticket for that as well, but, until the fix is in, the sequence for removing IAP should be:
    * Remove IAP using Package Manager.
    * Delete the plugins/UnityPurchasing folder.
    * Restart Unity.
    * Double-check that Game Foundation Settings shows IAP not installed. This should permit normal development using only GF without purchasing.

    Please feel free to double-check my work and let me know if you have any issues. I tested with 2018 and 2019 with positive results.
     
    mk0a1a, Raghavendra and VektaCo like this.
  11. VektaCo

    VektaCo

    Joined:
    Sep 30, 2019
    Posts:
    31
    @tony_c-unity3d nice one, I'll be investing more into GameFoundation in the coming weeks.
    Looking forward to v1.0
     
    tony_c-unity3d likes this.
  12. VektaCo

    VektaCo

    Joined:
    Sep 30, 2019
    Posts:
    31
    @tony_c-unity3d When running on the device, should GameFoundation fail to initialise if it cannot find any IAP transactions?

    I still have plenty of Virtual Transactions that would still work, and would prefer to just have IAP purchasing disabled in these cases.

    p.s I have fixed my IAP product ID error, but I still think its odd the whole thing fails if it cant find an IAP product.

    //////
    Game Foundation : GameFoundationSdk - Failed to initialize the SDK:
    UnityEngine.GameFoundation.Exceptions.PurchasingAdapterInitializationException: Unity
    Purchasing failed to initialize for the following reason: No products are available for purchase
     
    Last edited: Feb 1, 2021
  13. tony_c-unity3d

    tony_c-unity3d

    Unity Technologies

    Joined:
    Jul 18, 2019
    Posts:
    28
    @VektaCo That's an interesting idea. We'll have to look into it to see if it's just a bug or we may need to redesign our implementation to accommodate a failure in IAP initialization.

    By the way, I'm moving off the Game Foundation team soon, but @richj_unity was actually much more involved in the purchasing end of things so you're in good hands!
     
    VektaCo likes this.
  14. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    11,676
    I support IAP so wanted to jump in here. Do you have products available for purchase as defined on your Google Play developer console? The product I see above is named "asdasd", you would need to define your product on the Google dashboard with the same ProductID, please share a screenshot?
     
  15. VektaCo

    VektaCo

    Joined:
    Sep 30, 2019
    Posts:
    31
    @JeffDUnity3D My ID's are correct and working, that was just an example to show that the "Disable Auto Initialization" option only appears when there is text in the "ID" field.

    This is very bad for somebody searching for where to disable auto initialisation, as GameFoundation requires it is disabled.

    The issue is getting game foundation up and running with IAP has a lot of pain points.
    I wouldnt expect to have to fill in all my IAP catalog details correctly to get GameFoundation to initialise once I have enabled IAP, as it was working before I enabled IAP.
     
    Last edited: Feb 6, 2021
  16. VektaCo

    VektaCo

    Joined:
    Sep 30, 2019
    Posts:
    31
    I've had Unity crashing a lot due to some unrelated issue (mono crash?).

    Which always puts the IAP into this weird state.
    This then requires me to boot Unity in safe mode to stop compile errors with any code referencing IAP.
    e.g GameFoundationSdk.transactions.purchaseSucceededInIAPSDK

    upload_2021-2-5_18-4-59.png

    I then have to go through a process of trying to reinstall the IAP Service, which in turn results in more errors.
    At this point the safest thing to do is to rollback the changes in source control, which tends to fix it.

    upload_2021-2-5_18-11-12.png
     
    Last edited: Feb 6, 2021
  17. Sukender_OB

    Sukender_OB

    Joined:
    Nov 14, 2019
    Posts:
    18
    Hi,

    Sorry for being silent for so long.
    Yes, my game uses Services (IAP + Ads + Analytics) in production successfully since a few months.

    I removed the manually-added "UNITY_PURCHASING" define, and made the following tests:
    * Unity 2020.2.3f1 (recently updated)
    * Build platform = Android. Host = Windows 10 (20H2).
    * Package manager GF says "0.8.0-preview - November 20, 2020"
    * Package manager IAP says "2.2.2 - January 22, 2021"
    * Project settings > Services > IAP is enabled, and says "2.2.2 / up-to-date" (as for today, 2021-02-08). I imported / reimported to make sure it was okay.
    * Closed/reopened Unity
    * Window > GF > Settings > Runtime : everything is grayed out.
    * Reinstalled GF from package manager
    * Window > GF > Settings > Runtime : everything is okay now. Ditto when restarting Unity.

    So it seems upgrading IAP required GF to be reinstalled...? Not a big deal, but a bit frustrating when you don't know the trick ;) !
     
unityunity