Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Purchase failed because Purchasing was not initialized correctly

Discussion in 'Unity IAP' started by summerian, Dec 21, 2018.

  1. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    110
    I'm testing a consumable purchase on Android and I had it working once but then for an unknown reason it stopped working when I click the buy button.

    When checking the ADB LOG it looks like there is a JSON error.

    When it worked once I was using manual initialization i.e. not using the provided catalog and buttons.
    Now I'm trying the IAP catalog and automatic Initialization but neither approaches are working anymore.

    Not really sure what I'm doing wrong.

    12-21 19:31:13.520 5075 5107 I UnityIAP: Starting in-app billing setup.
    12-21 19:31:13.530 5075 5075 I UnityIAP: Billing service connected.
    12-21 19:31:13.530 5075 5161 I UnityIAP: invoking callback
    12-21 19:31:13.530 5075 5161 I UnityIAP: Checking for in-app billing 3 support.
    12-21 19:31:13.535 5075 5161 I UnityIAP: In-app billing version 3 supported for games.starberry.coffeecorp
    12-21 19:31:13.540 5075 5161 I UnityIAP: Subscriptions AVAILABLE.
    12-21 19:31:13.545 5075 5161 I UnityIAP: Subscription upgrade and downgrade are AVAILABLE.
    12-21 19:31:13.548 5075 5161 I UnityIAP: Subscriptions information parse AVAILABLE.
    12-21 19:31:13.551 5075 5161 I UnityIAP: VR supported.
    12-21 19:31:13.551 5075 5161 I UnityIAP: onIabSetupFinished: 0
    12-21 19:31:13.551 5075 5161 I UnityIAP: Requesting 1 products
    12-21 19:31:13.552 5075 5161 I UnityIAP: QueryInventory: 1
    12-21 19:31:13.552 5075 5161 I UnityIAP: invoking callback
    12-21 19:31:13.552 5075 5161 I UnityIAP: Querying owned items, item type: inapp
    12-21 19:31:13.552 5075 5161 I UnityIAP: Package name: games.starberry.coffeecorp
    12-21 19:31:13.552 5075 5161 I UnityIAP: Calling getPurchases with continuation token: null
    12-21 19:31:13.558 5075 5161 I UnityIAP: Owned items response: 0
    12-21 19:31:13.558 5075 5161 I UnityIAP: Sku is owned: games.starberry.coffeecorp.iap.tests.gold.one
    12-21 19:31:13.559 5075 5161 I UnityIAP: Continuation token: null
    12-21 19:31:13.559 5075 5161 I UnityIAP: Querying SKU details.
    12-21 19:31:13.566 5075 5161 I UnityIAP: Querying owned items, item type: subs
    12-21 19:31:13.566 5075 5161 I UnityIAP: Package name: games.starberry.coffeecorp
    12-21 19:31:13.567 5075 5161 I UnityIAP: Calling getPurchases with continuation token: null
    12-21 19:31:13.601 5075 5161 I UnityIAP: Owned items response: 0
    12-21 19:31:13.601 5075 5161 I UnityIAP: Continuation token: null
    12-21 19:31:13.601 5075 5161 I UnityIAP: Querying SKU details.
    12-21 19:31:13.608 5075 5161 I UnityIAP: Querying owned items' purchase history, item type: subs
    12-21 19:31:13.608 5075 5161 I UnityIAP: Package name: games.starberry.coffeecorp
    12-21 19:31:13.608 5075 5161 I UnityIAP: Calling getPurchaseHistory with continuation token: null
    12-21 19:31:13.697 5075 5161 I UnityIAP: Purchase history response: 0
    12-21 19:31:13.697 5075 5161 I UnityIAP: Continuation token: null
    12-21 19:31:13.697 5075 5161 I UnityIAP: onQueryInventoryFinished: true
    12-21 19:31:13.697 5075 5161 I UnityIAP: Inventory refresh successful. (response: 0:OK)
    12-21 19:31:13.697 5075 5161 I UnityIAP: The number of owned skus is0
    12-21 19:31:13.697 5075 5161 I UnityIAP: The number of purchased skus is1
    12-21 19:31:13.697 5075 5161 I UnityIAP: The number of subscriptions purchased history is0
    12-21 19:31:15.119 5075 5107 E Unity : Exception: Error: called non-existent method System.String SimpleJson.SimpleJson::SerializeObject(System.Object)
    12-21 19:31:15.119 5075 5107 E Unity : at SimpleJson.SimpleJson.SerializeObject (System.Object ) [0x00000] in <00000000000000000000000000000000>:0
    12-21 19:31:15.119 5075 5107 E Unity : at UnityEngine.Purchasing.PurchasingManager.OnProductsRetrieved (System.Collections.Generic.List`1[T] products) [0x00000] in <00000000000000000000000000000000>:0
    12-21 19:31:15.119 5075 5107 E Unity : at UnityEngine.Purchasing.JSONStore.OnProductsRetrieved (System.String json) [0x00000] in <00000000000000000000000000000000>:0
    12-21 19:31:15.119 5075 5107 E Unity : at UnityEngine.Purchasing.Extension.UnityUtil.Update () [0x00000] in <00000000000000000000000000000000>:0
    12-21 19:31:15.119 5075 5107 E Unity :
    12-21 19:31:15.119 5075 5107 E Unity : (Filename: currently not available on il2cpp Line: -1)
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    3,130
    Please use IAP 1.20.1 and the latest version of Unity. This issue was fixed already. And THANK YOU for providing the logs, it is always very helpful. If you are already using 1.20.1 and a recent version of Unity, we will need to revisit this issue.
     
    summerian likes this.
  3. capcappy7

    capcappy7

    Joined:
    Sep 30, 2018
    Posts:
    1
    I am having a very similar error to summerian and I have checked and everything appears to be updated. I am going to manually update to unity 2018.3 to see if this fixes it.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    3,130
    And make sure you are using IAP 1.20.1 (it's the latest in the asset store)
     
  5. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    110
    I'm already using IAP 1.20.1 and I just upgraded from 2018.3.b12 to Unity 2018.3.0f2 and now I'm getting another error.
    I'm now using the codeless approach and created a button via the IAP menu. The product ID corresponds correctly to the Google Play setup.
    When I click the button I see this in the log:

    12-28 10:54:44.360 29888 29916 E Unity : Purchase failed because Purchasing was not initialized correctly
    12-28 10:54:44.360 29888 29916 E Unity : UnityEngine.Logger:Log(LogType, Object)
    12-28 10:54:44.360 29888 29916 E Unity : UnityEngine.Purchasing.CodelessIAPStoreListener:InitiatePurchase(String)
    12-28 10:54:44.360 29888 29916 E Unity : UnityEngine.Events.UnityEvent:Invoke()
    12-28 10:54:44.360 29888 29916 E Unity : UnityEngine.EventSystems.StandaloneInputModule:processTouchPress(PointerEventData, Boolean, Boolean)
    12-28 10:54:44.360 29888 29916 E Unity : UnityEngine.EventSystems.StandaloneInputModule:processTouchEvents()
    12-28 10:54:44.360 29888 29916 E Unity : UnityEngine.EventSystems.StandaloneInputModule:process()
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    3,130
    summerian likes this.