Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Codeless IAP not working on mobile: Purchase failed because Purchasing was not initialized correctly

Discussion in 'Unity IAP' started by Tiollo, Jul 19, 2018.

  1. Tiollo

    Tiollo

    Joined:
    Mar 14, 2015
    Posts:
    23
    Hey there,

    I am having a few issues with the Codeless IAP, on both iOS and Android.
    Until a few weeks ago, purchases were working fine. I've made a test purchase from my personal device and everything worked.
    But then I haven't been testing it for a while and I found out yesterday that when I tap on the buttons, nothing happens (I made a few updates of my game, but nothing regarding the buttons - except for changing the text inside them).

    When I debug from Android and I get the following error: "Purchase failed because Purchasing was not initialized correctly".

    That's my work environment:
    - Unity 2018.1.5f1 Personal (64 bit) on Windows 10
    - Codeless IAP: 1.20.0 (latest one updated yesterday)

    On the editor the code is working fine (it's showing some other glitches with the canvases when the fake window is shown, but hopefully it should not happen on a mobile device).

    Any help?

    Thanks!
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    So this happened when you updated IAP? I have an idea what it might be, but would need to see the device logs. It would be easiest to capture the logs on Android, described here: https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/ . Specifically, when you upgraded IAP, you should have been prompted to "Upgrade the API, make sure you have a backup", and you would need to select yes. If you didn't get this prompt, then a specific VR error would likely show in your logs.
     
  3. Tiollo

    Tiollo

    Joined:
    Mar 14, 2015
    Posts:
    23
    Actually this is what happened:
    - When Codeless IAP was working and I tested it a few weeks ago, it was with its previous version
    - When I tested it again yesterday and it was not working, it was still with its previous version of Codeless IAP (but I made some other updates of the game that were not related to the IAP part)
    - Yesterday I updated to Codeless IAP 1.20.0 (hoping that it would have fixed the problem) and still was not working. But it happened exactly what you said. There was the "Upgrade the API, make sure you have a backup" message. I tried to make a backup copy but I couldn't because of a .lock file that didn't allow me to make a copy of the folder.
    So I decided to select no in the backup prompt, close Unity and make a backup copy. But then, when I tried again to reimport the Codeless IAP, it didn't show me the backup message again and it tells me there is nothing to import.

    Is there a way to see that message again?

    By the way, the error log "Purchase failed because Purchasing was not initialized correctly" is something that I found out exactly with that guide. This is the complete log:

    07-19 18:14:40.928 2430 2450 I Unity : IAPButton.PurchaseProduct() with product ID: 500coins
    07-19 18:14:40.928 2430 2450 I Unity :
    07-19 18:14:40.928 2430 2450 I Unity : (Filename: ./Runtime/Export/Debug.bindings.h Line: 43)
    07-19 18:14:40.928 2430 2450 I Unity :
    07-19 18:14:40.930 2430 2450 E Unity : Purchase failed because Purchasing was not initialized correctly
    07-19 18:14:40.930 2430 2450 E Unity :
    07-19 18:14:40.930 2430 2450 E Unity : (Filename: ./Runtime/Export/Debug.bindings.h Line: 43)
    07-19 18:14:40.930 2430 2450 E Unity :
    07-19 18:14:40.932 2430 2450 I Unity : IAPButton.OnPurchaseFailed(Product , PurchaseFailureReason PurchasingUnavailable)
    07-19 18:14:40.932 2430 2450 I Unity :
    07-19 18:14:40.932 2430 2450 I Unity : (Filename: ./Runtime/Export/Debug.bindings.h Line: 43)
    07-19 18:14:40.932 2430 2450 I Unity :


    Thanks again!
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please attach the complete log as an attachment, this looks to be only a small portion of the log, and I'm not seeing the VR settings exception that I would expect. Yes, please reimport the IAP asset, and ensure you get that API popup. Perhaps try with a brand new project, and import IAP and add your assets back if you continue to have issues.
     
  5. serialifytbc

    serialifytbc

    Joined:
    Jan 16, 2019
    Posts:
    1
    I have the same error and there's nothing related with vr in the log, it works perfect for me jn android with the same setup, @JeffDUnity3D
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @serialifytbc Sorry, can you elaborate? You mention both "I have the same error" and "it works perfect". There can be many reasons for initialization to fail, we would need additional information.
     
  7. Vollmondum

    Vollmondum

    Joined:
    Sep 19, 2012
    Posts:
    10
    I have this problem as well.
    IAPs were working just fine until updated in like October.
    Purchaser is initialized in editor, purchases are found and are made, but when in the build, both m_StoreController && m_StoreExtensionProvider stay null.
    Did coroutine for initialization, these both stay null.
    Tested on my two phones, and several players did, purchases don't work.
    IAP version 1.20.1
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please provide the device logs. https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/ . There are also script and codeless samples here https://forum.unity.com/threads/sample-iap-project.529555/