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

IAP Product unavailable in Android Platform

Discussion in 'Unity IAP' started by siddharth3322, Aug 23, 2019.

  1. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    I have already used Unity IAP package for my many games but today I started getting a problem with retrieving IAP product on actual Android device.
    I have created a product and same ID, I have used within the PurchaseManager script.
    The game already releases in Alpha Test section to test In-App purchase implementation.

    Within Unity Editor, I can able to retrieve one IAP product and able to make a purchase too but within Android device that same product is unavailable.

    I have followed this tutorial and code for in-app purchase setup:
    https://learn.unity.com/tutorial/unity-iap

    This kind of error messages, I am getting in the debug log:
    unity_iap_error1.PNG

    unity_iap_error.PNG

    Now please share your side suggestions so I can move ahead for the game publishing.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    So it was working previously, and with no changes from you, it just stopped working today? Or has it never worked. Please show a screenshot of the productID as you have in your Unity project code, and another screenshot of the same product defined on your Google Play developer Dashboard. The spelling has to be same.
     
    siddharth3322 likes this.
  3. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    No, this is a new game project I have created at Play Store and first time submitted a build for the in-app purchase testing.
    As well this is a new account that I got from the customer and as per my thinking, all set up for the account is proper for an in-app purchase.

    Let me upload important code for my PurchaseManager script:

    Code (CSharp):
    1. #if UNITY_ANDROID
    2.     private static string kProductIDRemoveAds = "removeads ";
    3.  
    4. #elif UNITY_IOS
    5.    private static string kProductIDRemoveAds = "removeads ";
    6. #endif
    7.  
    8. void Start()
    9.     {
    10.         if (m_StoreController == null)
    11.         {
    12.             InitializePurchasing();
    13.         }
    14.     }
    15.  
    16.     public void InitializePurchasing()
    17.     {
    18.         if (IsInitialized())
    19.         {
    20.             return;
    21.         }
    22.  
    23.         var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    24.  
    25.         builder.AddProduct(kProductIDRemoveAds, ProductType.NonConsumable);
    26.  
    27.         UnityPurchasing.Initialize(this, builder);
    28.     }
    29.  
    30.  
    31.     private bool IsInitialized()
    32.     {
    33.         return m_StoreController != null && m_StoreExtensionProvider != null;
    34.     }
    35.  
    36.  
    37.     public void PurchaseRemoveAds()
    38.     {
    39.         BuyProductID(kProductIDRemoveAds);
    40.     }
    41.  
    42.  
    43.     void BuyProductID(string productId)
    44.     {
    45.  
    46.         if (IsInitialized())
    47.         {
    48.             Product product = m_StoreController.products.WithID(productId);
    49.  
    50.             if (product != null && product.availableToPurchase)
    51.             {
    52.                 Debug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
    53.                 m_StoreController.InitiatePurchase(product);
    54.             }
    55.             else
    56.             {
    57.                 Debug.Log("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
    58.  
    59.             }
    60.         }
    61.         else
    62.         {
    63.             Debug.Log("BuyProductID FAIL. Not initialized.");
    64.         }
    65.     }
    66.  
    67. //
    68.     // --- IStoreListener
    69.     //
    70.  
    71.     public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    72.     {
    73.         Debug.Log("OnInitialized: PASS");
    74.  
    75.         m_StoreController = controller;
    76.         m_StoreExtensionProvider = extensions;
    77.  
    78.         //var iapProducts = m_StoreController.products;
    79.         //Product[] products = iapProducts.all;
    80.         //foreach(Product p in products)
    81.         //{
    82.         //     Debug.Log("############################# product name: " +  p.metadata.localizedTitle);
    83.         //}
    84.     }
    85.  
    86.     public void OnInitializeFailed(InitializationFailureReason error)
    87.     {
    88.         Debug.Log("OnInitializeFailed InitializationFailureReason:" + error);
    89.  
    90.         switch (error)
    91.         {
    92.             case InitializationFailureReason.AppNotKnown:
    93.                 Debug.LogError("Is your App correctly uploaded on the relevant publisher console?");
    94.                 break;
    95.             case InitializationFailureReason.PurchasingUnavailable:
    96.                 // Ask the user if billing is disabled in device settings.
    97.                 Debug.Log("Billing disabled!");
    98.                 break;
    99.             case InitializationFailureReason.NoProductsAvailable:
    100.                 // Developer configuration error; check product metadata.
    101.                 Debug.Log("No products available for purchase!");
    102.                 break;
    103.         }
    104.     }
    Here I have attached an image for the Play Store dashboard in-app purchase product status.
    play_store_remove_ads.png

    Let me know still if you want further information about this :)
     
  4. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    One thing I want to clarify that I have done the first time for uploading build at Play Store - AAB file :)
    I have already exported Key Store and uploaded APK file at Play Store using this Key Store but Later on, I require to use App Signing feature and I have exported PEM file and uploaded at Play Store.

    Then after I have finished in-app purchase set up within the project and exported singed AAB file and uploaded at Play store for the review purpose.
    Now Alpha test review process is complete and game build is available to download but now above problem started for me.

    This is some extra information that I have done this time compared to all before submissions.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are you using a tester account? You can't use your Developer Account for testing. That is, you can't use the same account as used on the Google Developer dashboard. You need to configure your list of testers on their Dashboard, then you need to download the game via the Google Play test link. On your phone, launch Google Play and make sure that your tester account is logged into Google Play. You need to do this the first time you launch your app, then subsequently you can side-load your app (install directly via USB). Make sure you are following the directions here: https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html . Also, why are putting a space at the end of the productID in your code? It would not be expected to match the string that you have defined on the Dashboard, which does not have a space.
     
    siddharth3322 likes this.
  6. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    @JeffDUnity3D your last line helped me a lot and there is a space-related mistake in product Id field :(
    I have copied value directly from the Play store dashboard so maybe this kind of mistake happened and I honestly I can't able to see that space exists in product id.
    Sorry for bothering you for the silly mistake.