Unity IAP "Unavailable product" for all products

  • 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

  •       public void InitializePurchasing()
          {
              // If we have already connected to Purchasing ...
              if (IsInitialized())
              {
                  // ... we are done here.
                  return;
              }
              if (GetInitStatus() == InitStatus.LOADING)
              {
                  return;
              }
              SetInitStatus(InitStatus.LOADING);
    
              // Create a builder, first passing in a suite of Unity provided stores.
              var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    
              // Add a product to sell / restore by way of its identifier, associating the general identifier
              // with its store-specific identifiers.
              foreach (var purchase in purchases)
              {
                  if (purchase.isConsumable)
                  {
                      builder.AddProduct(purchase.appleId, ProductType.Consumable);
                  }
                  else
                  {
                      builder.AddProduct(purchase.appleId, ProductType.NonConsumable);
                  }
              }
    
    

#if UNITY_ANDROID
// Play Pass
builder.AddProduct(playPassId, ProductType.NonConsumable);
#endif

        // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
        // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
        UnityPurchasing.Initialize(this, builder);
    }

- **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

@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.

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

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.

Do I need to re-call UnityPurchasing.Initialize(this, builder); after the connection appears?

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.

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?

Please test to confirm! For testing in my Sample project, I have an Initialize button so I can test initialization at any time.