Search Unity

Failed to fetch IAP catalog due to unexpected http status code, attempting to use cache

Discussion in 'Unity IAP' started by Amir-Ward, Mar 31, 2018.

  1. Amir-Ward

    Amir-Ward

    Joined:
    Jan 26, 2015
    Posts:
    30
    Hi, I was prompted to update to the new unity IAP but now I get this error on start up for iOS and Android:

    'Failed to fetch IAP catalog due to unexpected http status code, attempting to use cache'

    Does anyone know what would cause this error and if it will stop users from performing IAP's?
     
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @Amir-Ward,

    Where do you see this error? Is it a message in the log or console?

    You said you were getting this error on iOS and Android. Were you able to complete a purchase? Would you be able to provide a log from your device?
     
  3. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    @Amir-Ward I'm literally getting the same error for no apparent reason. I've tried re-importing IAP package, deleted library folder and re-imported entire project.

    Code's identical to the one from a different previous project with working IAP.

    Updating IAP to 1.18.0 presents this problem for now.

    @ap-unity For me the purchase fails on both editor and device. The editor even throws a NullReferenceError if I try to access product localized currency code or price.

    upload_2018-3-31_4-56-22.png

    upload_2018-3-31_4-58-53.png

    NullReference error occurs for this line specifically -

    Code (CSharp):
    1. CostText.text = MST_StoreController.products.WithID(4COINS).metadata.isoCurrencyCode.ToString() + " " + MST_StoreController.products.WithID(4COINS).metadata.localizedPrice.ToString("0.00");
     
    Last edited: Mar 31, 2018
  4. JayR

    JayR

    Joined:
    Aug 2, 2016
    Posts:
    84
    Hi @Amir-Ward

    That message is not a problem and will not impact your game's normal operation or purchasing.
     
  5. JayR

    JayR

    Joined:
    Aug 2, 2016
    Posts:
    84
    @arrnav
    The quoted error message from the first post in this thread should not impact the process of fetching prices etc from the store. We would need more context from actual device logs to assess if there is a problem, but the NRE itself is likely the result of Products.WithID() returning null or the backing store not receiving complete metadata.
     
  6. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    Hi, in my case the purchasing fails too. When I hit the buy button, device log on my android says :

    OnInitializedFailed InitializationFailureReason:NoProductsAvailable

    I have triple checked and all product IDs exist and are correctly entered in code.

    Also, now purchasing works in editor and there are no errors shown. It's the device which shows problems. Seems that IAP isn't properly getting initialized on device.
     
  7. JayR

    JayR

    Joined:
    Aug 2, 2016
    Posts:
    84
    Hi @arrnav

    The best thing to do if you're seeing a NoProductsAvailable error is look at the initialization flow in the device logs -- the process is generally verbose enough to provide an idea of what is happening. Starting immediately after the previously noted "Failed to fetch ..." line you will see that init flow happening. Possible failures at init time include things like bundle ID mismatches or incomplete store setup. Have IAPs in this specific application worked correctly on an Android device previously? The post Unity IAP not initializing on android provides some useful information when getting Google Play purchasing set up for testing.

    It is also generally a good idea to hide any "buy" buttons or not even show a store page if the initialization failed for some reason. Are you using the "codeless" IAP Buttons or is your purchasing flow handled through scripts?
     
  8. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    upload_2018-3-31_7-44-4.png

    This is the exact log from my device. It's apparent how IAP is not initializing. Apologies if the solution is right under my nose. I might be missing something here.

    I just read somewhere that you need to register a test device on play console to test IAP for an unpublished app first or else it shows Initialization failed. Is this true? As this game is for a client, I haven't registered my phone as a test device yet.
     
  9. ZzappSizzler

    ZzappSizzler

    Joined:
    Jan 15, 2017
    Posts:
    33
    This was working fine until I upgraded to IAP 1.18.0. Now, when running in the editor, I get "Failed to fetch IAP catalog due to unexpected http status code, attempting to use cache". When I build and run on iPad, the prices are no longer fetched and no response from 'Buy' button. Should I just downgrade IAP to 1.17 which was working OK.?
     
    Last edited: Mar 31, 2018
  10. ZzappSizzler

    ZzappSizzler

    Joined:
    Jan 15, 2017
    Posts:
    33
    Downgraded to IAP 1.17 and IAP is working OK now. Thank goodness for version control!
     
  11. JayR

    JayR

    Joined:
    Aug 2, 2016
    Posts:
    84
    @arrnav I'm talking about the actual on-device log -- you can get that using "adb logcat" or the logcat tab in Android Studio. Your screen capture here just shows what is reported by your game and Debug.Log()

    As noted in the other thread your account does need to be set as a tester and you need to download the game through the alpha or beta channel link the first time around to get purchasing to initialize properly.
     
  12. JayR

    JayR

    Joined:
    Aug 2, 2016
    Posts:
    84
    @ZzappSizzler can you provide logs from Xcode from app start through seeing the problem?
     
  13. JayR

    JayR

    Joined:
    Aug 2, 2016
    Posts:
    84
    Also, both @arrnav and @ZzappSizzler can you confirm if your IAP configuration was set up using Codeless IAP buttons or scripted with a ConfigurationBuilder?
     
  14. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    As of now I've implemented IAP through a ConfigurationBuilder. Doesn't codeless IAP cause problems when apple requires you to have a restore non-consumable purchase in your app or am I completely wrong?

    Besides that, I'll be posting a log on the aforementioned problem shortly.
     
  15. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    Hi, here's the adb logcat.
     

    Attached Files:

  16. JayR

    JayR

    Joined:
    Aug 2, 2016
    Posts:
    84
    Hi @arrnav

    The log shows that Unity IAP asked Google Play for information on 17 products but the response we received was empty. Assuming the product IDs used in the app match what's set up on Google Play Console then the next most likely problems are that the APK hasn't been published to one of the test channels, the account you're using isn't set up as a tester on that channel or you didn't download the APK from Play at least once before testing.

    Have you successfully used IAP with this combination of device/account/game before?
     
  17. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    Well yes, my current device and account have both played well in terms of testing before. But this is a new game now.

    An APK of a previous version (which does not implement IAP) had been uploaded for closed alpha testing a while ago. My client has added me as a tester already.

    The only thing left to try now is to upload the new version with IAP implemented to the alpha test channel, then download it from play store and give it a go, as you mentioned.

    I presume this will solve the issue. Will get back with the result here to confirm.
     
  18. JayR

    JayR

    Joined:
    Aug 2, 2016
    Posts:
    84
    Have you downloaded the existing closed alpha build from the store? We've seen some reports suggesting that downloading any build may be sufficient but it isn't a configuration that I've tried.
     
  19. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    So it seems to be solved as I'm able to see the purchase box now after downloading the alpha build. An error saying "The item you requested is not available for purchase" still shows up in place of the price. But I presume that's normal for an unpublished build.

    Thanks for the support!
     
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You need to first download the alpha build, but subsequently you can side load the app (install directly from Unity to the device)
     
  21. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    I had been sideloading so far but that didn't seem to work.
     
  22. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @arrnav Side loading after initially downloading from the store?
     
  23. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    106
    Im having problems with IAP 1.18 as well, several players that had an item purchased are complaining by email after the latest update that the item isn't available for them anymore. I will roll back to 1.17 or 1.16 to fix this.
     
  24. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @PedroRtz What is the error? Are you able to reproduce? Please provide the device logs if so.
     
  25. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    106
    @JeffDUnity3D I'm not sure, I couldn't reproduce. I just received some emails after I updated complaining that they don't have the non-consumable purchase anymore, so I'm trying to revert to an older IAP version now to see if it fixes.

    It could be a problem in a specific Android version. It could be even totally unrelated to IAP 1.18. It could be due to a newer Unity version (I updated Unity and IAP at the same time), or something else.

    I havent changed anything on the code of the purchase module in months.
     
  26. tanveer999

    tanveer999

    Joined:
    Apr 11, 2018
    Posts:
    2
    Even I'm encountering same issue, I recently updated to latest unity version 2017.4.0f1 and updated Unity IAP 1.18.0 now when I click on buy, I get a error "the item you requested is not available for purchase" in Android. but when I initialize the item its successfully getting initialized. is it because of Unity IAP 1.18.0?

    We've a live app with Bundle Version code 10, so I made another with build with code 10.
     
  27. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Your issue is not related to the thread topic "Failed to fetch IAP catalog due to unexpected http status code, attempting to use cache". For best results, it would be best to open a new thread.
     
  28. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    106
    @JeffDUnity3D I released a beta version of my game with an older IAP (not sure if 1.17 or 1.16) and one of the players got back to me by email and said the problem was fixed after updating, so the chance of being a 1.18-related problem is a little higher now (if a 2nd player email me with the same thing the chance will grow significantly).

    I got on this thread due to the "Failed to fetch IAP catalog due to unexpected http status code, attempting to use cache" message, but just to be clear, I got this message on my phone when I first tested after the complain emails, I dont know if the players who complained have this exact message or other messages on their phone.

    And regarding Android OS version, both players who replied my email have Android 7.
     
  29. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Correct, the cache message is not related to the issue that you are having, but possibly something else related to the 1.18 release. We are still investigating.
     
  30. stefanplc

    stefanplc

    Joined:
    Feb 21, 2015
    Posts:
    82
    I've also been getting the same message "Failed to fetch IAP catalog due to unexpected http status code, attempting to use cache" and after building my game on my iPhone for testing I noticed the "purchase" buttons didn't do anything. They previously worked and have been working for many months when I last updated that area of the game. I downgraded to UnityIAP Version: 1.17.0 and everything works great again.
     
  31. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @stefanplc The message is unrelated to the behavior that you are seeing. Please provide the device logs if you are able to reproduce.
     
  32. stefanplc

    stefanplc

    Joined:
    Feb 21, 2015
    Posts:
    82
    Hey Jeff, thank you so much for the quick response. It turns out that it still didn't work, I wasn't getting the debug message anymore so that's why I thought it was fixed. I last updated my game (http://tomeofheroes.com/) at the end of January and if you download it the IAP works just fine on both Android and iOS. I think I was using 1.6 or 1.7 at the time. I tried deleting the two folders inside the Plugins folder titled "UnityChannel" and "UnityPurchasing" and replacing them with what I had up on Github at the time but nothing seems to work. I tried 1.15, 1.16 and 1.17. Since then I haven't made any changes at all to the store code, I've worked on something completely different. The store code actually hasn't been touched for probably more than half a year, I don't recall the exact date. It's very basic and if I remember correctly it's based on a tutorial/blog that you guys posted a while back (I think it's this one: https://unity3d.com/learn/tutorials/topics/ads-analytics/integrating-unity-iap-your-game )

    I pushed the game with IAP version 1.18 on my iphone and attached you can find the log from xcode. I'm not a very experienced developer so while looking through the log file I wasn't sure if any of that information is sensitive so I deleted any parts that looked like IDs or game specific info and only left the rest. The log shows the game starting and me going directly to the shop window and pressing the buy button. There's a 1-2 minute pause after I press the button and then the purchase fails.

    Sorry if I'm missing something obvious and thank you very much for your help!
     

    Attached Files:

    • log.txt
      File size:
      7.1 KB
      Views:
      1,130
  33. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi,
    Are you guys specifying a "storeSpecificId" in "ProductDefinition" and adding a product list via "AddProducts"?
    There is an issue here in Unity IAP 1.18.0.
    Currently, please use "AddProduct(string id, ProductType type, IDs storeIDs)".

    Edit: Sorry, this issue only causes "NoProductsAvailable error" instead of "Failed to fetch IAP catalog due to unexpected http status code, attempting to use cache".
     
    Last edited: Apr 17, 2018
  34. stefanplc

    stefanplc

    Joined:
    Feb 21, 2015
    Posts:
    82
    Hi there, I'm not, I'm only using string id and product type. When you say storeIDs, for apple, is that my Apple ID that I can find on itunesconnect under App Information > General Information > Appple ID? Or do you mean the Bundle ID which is in the com.companynname.appname format? I did a search on google and it says that for Android it's the .com[...] part and that I can grab it from the URL (ex: https://play.google.com/store/apps/details?id=com.pulciu.tomeofheroes). Looking at my apple store URL it's https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1227062768&mt=8 and that ID is the same as my Apple ID.

    Can I add both IDs with one single AddProduct or do I need to do #if UNITY_ANDROID to add the Android and #if UNITY_IOS to add the iOS ones?

    Thank you!
     
  35. stefanplc

    stefanplc

    Joined:
    Feb 21, 2015
    Posts:
    82
    After some google searching I did find that I can use the following:
    Code (CSharp):
    1. builder.AddProduct(Product1Gems, ProductType.Consumable, new IDs() { { "com.pulciu.tomeofheroes", AppleAppStore.Name }, { "com.pulciu.tomeofheroes", GooglePlay.Name }, } );
    But I'm not sure what to put inside the quotes "". Do I need to put the "product ID" for apple which is basically "coins1" or "gems1"? Or do I need to add the product's apple ID which is a bunch of numbers? With the "com.pulciu.tomeofheroes" I get a "BuyProductID FAIL. Not initialized" error in my log in xcode.

    Thanks!
     
  36. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi @stefanplc ,
    I checked your log again and I found that the error you got was "-1001" which means "The connection timed out.".
    https://developer.apple.com/documentation/storekit/handling_errors?language=objc
    Please use another network to test it out, like LTE.

    When I said "storeIDs", it meant product ids in stores, instead of bundle id or package name.
    Sometimes, you have different product ids for one same product in several stores.

    If the product "Product1Gems" has the same product id in App Store and Google Play, you can just use the code below.
    Code (CSharp):
    1. builder.AddProduct("the same product id", ProductType.Consumable);
    Otherwise, you can specify product ids via the code below.
    Code (CSharp):
    1. builder.AddProduct("unified product id", ProductType.Consumable, new IDs() { { "product id in App Store", AppleAppStore.Name }, { "product id in Google Play", GooglePlay.Name }, } );
    We have a demo project in Unity IAP plugin. You can find it at "Assets\Plugins\UnityPurchasing\script\IAPDemo.cs" and "Assets\Plugins\UnityPurchasing\scenes\IAP Demo.unity".
    Please refer to that.

    Sorry that your question is not related to this thread, please create another thread or a support ticket if you have further questions.
    https://analytics.cloud.unity3d.com/support/
     
  37. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    302
    Can you @unityjingyao confirm that this was indeed a timeout issue? I'm receiving this error on iOS when building to device about 1/3 of the times upon startup and i'm on WiFi . Can't say whether this occured on v1.17, but to my knowledge I didn't notice this problem. But when this issue occur, initialization fails and thus no IAPs will work during this session.
     
  38. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  39. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi @Maisey ,
    The error code "-1001" means "The connection timed out." instead of the "Failed to fetch IAP catalog due to unexpected http status code" error.
     
  40. Lad-Ty

    Lad-Ty

    Joined:
    May 7, 2013
    Posts:
    61
    Hello,

    I upgraded to unity 2017.4.3f1 today, and also updated IAPs to 1.18. I am getting this error now, and none of the products I list in the ingame store show any price on them (aka obviously failed to load). The apk is uploaded in alpha in Google Play, downloaded as well, still nothing. Obviously all worked prior to the updates. I even reverted the iap part to 1.17, but even so the products arent showing properly (though I think it removes the fetch error). Previous version it was working with is IAPs 1.17 and Unity 2017.3.0f3.

    Weirdest part in all this is, that a debug.log prior and after calling UnityPurchasing.Initialize(this, builder); show nicely. But Debug.log in either OnInitialized or OnInitializeFailed are NOT being printed. As in, neither of those methods seems to be called! o_O

    I have no idea what to do with this, since there are 2 methods in the listener and not 1 of them gets called at all. I have no clue if thats directly caused by the fetch error, but it's all I have to go on right no :-| But I sure need this sorted asap, because builds from Unity 2017.3.0f3 are causing very weird frameskips even resulting in a disappearing NGUI elements, and in the release notes I was reading a lot of android fixes leading to 2017.4.3f1
     
  41. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi @Lad-Ty ,
    Could you please provide me a full log on Android platform?
     
  42. Neozman

    Neozman

    Joined:
    Sep 29, 2016
    Posts:
    67
    Hi, we are now getting the following problem:

    Unity 2017.4.6f1, IAP ver 1.18

    We have 32 exsiting inapps on android platfom (since older IAP ver. ). They are working fine (initializing, testing, purchasing)

    But now we tried to create 6 more inapps on google play console. And encountered that IAP system can't find them in market data. In addition, we are getting "Failed to fetch IAP catalog due to unexpected http status code, attempting to use cache" error each time. What should we do?
     
  43. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @UDN_15e2bf7b-c274-4752-93d0-21bd7af5e273 You can ignore the status code message as previously mentioned. To avoid it, you can upgrade to 1.20.1. Can you elaborate "can't find them in market data"? What is market data? Please provide a screenshot. Keep in mind that on Google, you can't test with your own user account, you must use a tester account in an Alpha/Beta release. Otherwise, purchasing will be unavailable. Be sure to follow the directions here: https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html
     
  44. neozmin

    neozmin

    Joined:
    Jun 15, 2018
    Posts:
    10
    thanks for reply.

    As i have mentioned before, our app have 32 inapps registred and successfully being purchased for quite a long time. But after upgrading on 1.18, new inapps from google play can't even be initialized. I mean, product arrays. Old inapps are working, new - are not.
     
  45. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @neozmin I'm assuming you just changed your user name here. Not sure what you mean by product arrays. You mention both "can't even be initialized" and then say "old inapps are working" which are contrary statements. Please provide your device logs. If you just added new products to the store, it may take some time for them to become active.