Search Unity

Question Unity IAP "Unavailable product" for all products

Discussion in 'Unity IAP' started by MaximPP, Oct 26, 2021.

  1. MaximPP

    MaximPP

    Joined:
    Jan 26, 2019
    Posts:
    76
    • Description of your issue
      • My Android users often have the "Unavailable product" error for all my products (consumable and non-consumable) resulting in the "NoProductsAvailable" error. But not in 100% of cases. The bug is reproduced in about 2,000 out of 10,000 users per day.
      • The error is reproducible in users from all countries
      • In 98.5% of cases of this error, the Internet is not available to the user.
      • The error occurs about 1-3 seconds after starting the application
      • On my local Android-device, purchases work successfully. The error doesn't happen even without internet
      • At the same time, some users make purchases successfully. I have noticed that some users who have successfully made a purchase also encounter this error in previous gaming sessions.
      • This has been happening for a long time, about a year, on different versions of Unity and on different versions of IAP.
      • I am using variables to pass the productId. But the error displays the correct productId, which means that the variables are being read correctly
      • this bug is not reproducible on iOS users. I have about 100 iOS users per day and 0 errors for several month
    • Your purchasing script

      • Code (CSharp):
        1.         public void InitializePurchasing()
        2.         {
        3.             // If we have already connected to Purchasing ...
        4.             if (IsInitialized())
        5.             {
        6.                 // ... we are done here.
        7.                 return;
        8.             }
        9.             if (GetInitStatus() == InitStatus.LOADING)
        10.             {
        11.                 return;
        12.             }
        13.             SetInitStatus(InitStatus.LOADING);
        14.  
        15.             // Create a builder, first passing in a suite of Unity provided stores.
        16.             var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
        17.  
        18.             // Add a product to sell / restore by way of its identifier, associating the general identifier
        19.             // with its store-specific identifiers.
        20.             foreach (var purchase in purchases)
        21.             {
        22.                 if (purchase.isConsumable)
        23.                 {
        24.                     builder.AddProduct(purchase.appleId, ProductType.Consumable);
        25.                 }
        26.                 else
        27.                 {
        28.                     builder.AddProduct(purchase.appleId, ProductType.NonConsumable);
        29.                 }
        30.             }
        31.  
        32. #if UNITY_ANDROID
        33.             // Play Pass
        34.             builder.AddProduct(playPassId, ProductType.NonConsumable);
        35. #endif
        36.  
        37.             // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
        38.             // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
        39.             UnityPurchasing.Initialize(this, builder);
        40.         }
    • Device logs
      • No local device logs, only in production:

        109:36:41.717 PM view_list Exception: IAPManager: OnInitializeFailed InitializationFailureReason:NoProductsAvailable
        309:36:41.700 PM Unavailable product play_pass_v1-play_pass_v1
        409:36:41.700 PM Unavailable product no_ads_v1-no_ads_v1
        509:36:41.699 PM Unavailable product expert_kit_v1-expert_kit_v1
        609:36:41.698 PM Unavailable product professional_kit_v1-professional_kit_v1
        709:36:41.698 PM Unavailable product specialist_kit_v1-specialist_kit_v1
        809:36:41.626 PM Unavailable product amateur_kit_v1-amateur_kit_v1
        909:36:41.616 PM Unavailable product beginners_kit_v1-beginners_kit_v1
    • Unity Version
      • 2019.4 and 2020.3
    • Unity IAP version
      • IAP 3.1.0 - 4.0.3
    • Platform you are building for: Android
    • Store you are targeting: Google Play
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @MaximPP The internet is required for IAP to initialize, unless a user has purchased previously. You'll want to test with a new user, and no Internet and no previous purchases.
     
  3. MaximPP

    MaximPP

    Joined:
    Jan 26, 2019
    Posts:
    76
    The IAP integration manual (https://docs.unity3d.com/Packages/com.unity.purchasing@4.0/manual/UnityIAPInitialization.html) says that "Note that this will not be called if Internet is unavailable; Unity IAP will attempt initialization until it becomes available." And I was confused that I got an error.

    anyway, does it mean that I have no problem integrating IAP?

    Should I just reinstall the game, or do I need a Google account that hasn't been purchased yet? I tried just reinstalling the game and running it without internet. And I didn't get the "Unavailable product" error
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, you need another Google account, logged into Google Play on the device. It's a bit of a pain, I know. You'll want to test initialization yourself, the initialization behavior has changed since that documentation, sorry about that. I just learned recently that having a prior purchase can make a difference, I still need to do more testing myself.
     
  5. MaximPP

    MaximPP

    Joined:
    Jan 26, 2019
    Posts:
    76
    Do I need to re-call
    UnityPurchasing.Initialize(this, builder);
    after the connection appears?
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    What is the behavior in your testing? I would suggest to try that test too, I will try to do the same when I can get to it.
     
  7. MaximPP

    MaximPP

    Joined:
    Jan 26, 2019
    Posts:
    76
    If a user who has not previously made a purchase on Google Play enters the game without the Internet, then
    OnInitializeFailed
    will occur. Does this mean that I have to manually re-initialize the IAP when this user connects to the internet?
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please test to confirm! For testing in my Sample project, I have an Initialize button so I can test initialization at any time.