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

Codeless IAP - PurchasingUnavailable (Purchasing was not initialized correctly)

Discussion in 'Unity IAP' started by Sir-Magic, Jul 8, 2019.

  1. Sir-Magic

    Sir-Magic

    Joined:
    Jul 20, 2015
    Posts:
    50
    Hi,

    I've had this issue since last year and it is really beginning to bother me as I cannot find out what has gone wrong. I have already searched multiple times on Google and around this forum but I can not find any clear solutions to this issue. I have created an IAP Button to remove adverts from the game. It does not seem to work at all and always gives me the error of: "Purchase failed because Purchasing was not initialized correctly" followed by a message of: "IAPButton.OnPurchaseFailed(Product , PurchaseFailureReason PurchasingUnavailable)". I know this has probably been asked before but I have tried the sample projects from the past and they are too outdated to work. What causes this issue and how can I fix it?

    Attached is a screenshot of the component for my button, in case it is needed.
     

    Attached Files:

  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,956
  3. Sir-Magic

    Sir-Magic

    Joined:
    Jul 20, 2015
    Posts:
    50
    Ah yes, it seems I completely forgot to put in the method there in that screencap! Although I still get this error with the method there. I will check these update samples though, thanks
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,956
  5. Sir-Magic

    Sir-Magic

    Joined:
    Jul 20, 2015
    Posts:
    50
    Right, I haven't actually put this application on any device as of yet so I cannot provide logs as the errors I receive are in the unity editor. Do I need to add the in-app purchases to the app store/play store in order for the fake store to work?
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,956
    Please load the IAPDemo scene included in the IAP asset package to confirm that the fake store is working. The fake store does not perform actual purchases, you need to install on a device for IAP to actually work.
     
  7. Sir-Magic

    Sir-Magic

    Joined:
    Jul 20, 2015
    Posts:
    50
    Yeah, it turns out that the updated samples were the ones I was using last time. On all the buttons/listener I get an error telling me to assign a valid script and when I updated IAP, I got more errors to do with the IAPButtonEditor, so it's not really possible for me to see if the fake store works or not when I'm getting errors on a project that shouldn't have any.
     

    Attached Files:

  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,956
    Please watch the video for the instructions https://forum.unity.com/threads/sample-iap-project.529555/
     
  9. Sir-Magic

    Sir-Magic

    Joined:
    Jul 20, 2015
    Posts:
    50
    I've done it already, the problem that I have is that upon updating the sample projects, they don't work anymore and throw several errors and produce the errors shown above. Is this just me or are the samples not supposed to be updated?
     
  10. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,956
    Yes, the video shows how to update the samples.I do it daily for customers. I would advise you to use Unity 2018, there are issues with IAP on 2019 that are mentioned elsewhere on this forum, including a sticky post, if that applies. I have it working however, using the suggested workarounds. But if you don't need 2019, use 2018 or 2017.
     
  11. Sir-Magic

    Sir-Magic

    Joined:
    Jul 20, 2015
    Posts:
    50
    Hi, I've downgraded the project and I've finally got the sample project working. However, I still get the same issue with my project despite it using the same version of unity. Are there any other reasons that this error could occur?
     
  12. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,956
    Please provide the device logs
     
  13. Sir-Magic

    Sir-Magic

    Joined:
    Jul 20, 2015
    Posts:
    50
    I think I'm going to just have to forget about this project. I can't get the device logs because I still haven't got this working with the fakestore.
     
  14. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,956
    The fake store, as the name suggest, doesn't perform actual transactions. You need to test on a device. To see the fake/demo store in action, load up the IAP Demo scene included in the IAP package.
     
  15. unity_YStBNFkjCiVr1w

    unity_YStBNFkjCiVr1w

    Joined:
    Jul 29, 2019
    Posts:
    1
    I am having these logs while i test it on device
     

    Attached Files:

  16. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,956
    It's generally best to attach the logs as a file instead of a screenshot so it can be searched, etc. But you have a few errors in the logs that you will need to address, you have an Null Reference Exception for example. Are you using the Sample IAP project? Get the basics working first. Have you followed the steps here? https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html This may help also, your Debug.Log statements will show in the device logs https://forum.unity.com/threads/tips-for-new-unity-users.701864/#post-5057741
     
  17. Umerfarooq

    Umerfarooq

    Joined:
    Jun 18, 2016
    Posts:
    8
    Thanks, @JeffDUnity3D for all the guidance and tips.

    I'm using Codeless IAP and I've checked the "automatically initialize unity purchasing" and simply drag and drop(Pass) the functions(Methods) to "On Purchase Complete(product)" of my codeless IAP button and set the IDs on the buttons.

    I have a few questions to ask.
    Question 1:
    While implementing Codeless IAP, Do I need to initialize the products separately in the script or it will be done by "automatically initialize unity purchasing".? because I've not initialized any of the products in the script, I've just checked "automatically initialize unity purchasing".
    Question 2:
    My IAP is working fine in unity editor but when I run on the android device it gives errors like "PRODUCT FAILED BECAUSE PURCHASING WAS NOT INITIALIZED CORRECTLY" and when I click on the buy button it gives this error "PURCHASE FAILED TO INITIALIZE: REASON NO PRODUCT AVAILABLE" . Note: as it's my testing project I've not downloaded it from google play store but the IDs are defined In the relevant projects of google play console.
    To test IAP of a personal project, is it necessary to define/declare Ids on google play store.?
    Question 3:
    What i believe that My codless button implementation(Assign ids, methods) is correct, it will work perfectly fine when I launch the game and download it from google play store. Pls, correct me if I'm wrong.

    One Suggestion here, If "Codeless IAP" is the only slot to implement codeless IAP and the tabs beneath it do not depend on it then in the documentation https://docs.unity3d.com/2018.1/Documentation/Manual/UnityIAPCodelessIAP.html, Under the Parent "Cross Platform Guide" make 2 Childs. 1st should be "Codeless IAP" and 2nd child should be "IAP implementation through Code"(Or whatever name unity suggests).
    Because it kept me confused for 5 days that IF I HAVE TO IMPLEMENT CODELESS IAP OR DO I NEED TO FOLLOW ALL THE TABS UNDER CODELESS IAP.
     
    Last edited: May 12, 2020
  18. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,956
    No, you don't need all the tabs, only the ones that you need. I would suggest that you take a look at the Sample IAP Projects here, the first is scripted IAP, the second is Codeless. You need to define all your products in the Google Store and in your app. Please show a screenshot of your button properties for one of your products, and your products defined on Google Play. These instructions may help https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html and https://forum.unity.com/threads/sample-iap-project.529555/ Personally I would use scripted vs Codeless, I find it easier to implement, no need for a listener, etc.
     
    Umerfarooq likes this.
  19. ipixode

    ipixode

    Joined:
    May 15, 2020
    Posts:
    2
    Hi @JeffDUnity3D

    We have an issue with our IAP initialization as well.
    The game is now on Android under the Beta program. we have started running some marketing to measure all KPIs and stability and we found these issues to hunderds of users:
    GameException : Can't initialize Unity IAP PurchasingUnavailable
    Exception : GameException: Can't initialize Unity IAP PurchasingUnavailable ShopManager.OnInitializeFailed (UnityEngine.Purchasing.InitializationFailureReason error) (at <00000000000000000000000000000000>:0) System.Action.Invoke () (at <00000000000000000000000000000000>:0) Google.Play.Billing.Internal.GooglePlayBillingUtil.Update () (at <00000000000000000000000000000000>:0)

    When checking the IAP by ourselves we see that everything works fine and transitions from our test devices are coming.
    All the issues are coming from a game that is published in the Google Play store and being promoted by pure marketing to real users.

    Attached a few examples of transactions and our issues on crushlytics.

    Please advise
     

    Attached Files:

  20. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,956
    Does it work on your devices when you download it from Google Play? Create a new Google account to test, don't use one of your developer accounts, and switch accounts on one of your test devices (some Android devices allow you hot-switch multiple user accounts, otherwise you need to reset your phone). How are you inviting users to your Beta program?
     
  21. ipixode

    ipixode

    Joined:
    May 15, 2020
    Posts:
    2
    Thanks @JeffDUnity3D ,
    It works on some other devices and I got even one completed payment from our Facebook Marketing Campaign.
    When I asked some random users to test it the payment was also there.

    It's a closed Beta program by Google, so it basically means that we can run real marketing campaigns and the users will be able to download and play it with no problems. More than 10,000 people downloaded the game from the marketing campaign and every time we have a pick of marketing, we also have a pick on those payment issues with lots of devices from different qualities, OS versions, and countries.

    The game is published under beta - so it means that everyone can access there with the below URL:
    https://play.google.com/store/apps/details?id=com.pixode.cwf

    You can see that for the last 24 hours, we had 33 different users with this problem and not even one completed payment.
     

    Attached Files:

  22. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    331
    I installed the app and IAP works fine for me, but I see other errors in the log. Maybe you have aware it, but it is still worth mentioning :
    upload_2020-5-27_17-25-37.png
     
    Last edited: May 28, 2020
  23. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,956
    Does it work on YOUR devices? If not, you should not publish until you fix it. Publish the Sample project and test and compare the logs.
     
unityunity