Search Unity

IAP worked only one time then it says "unavailable products"

Discussion in 'Unity IAP' started by chaelpix, Jun 23, 2021.

  1. chaelpix

    chaelpix

    Joined:
    Jul 4, 2017
    Posts:
    5
    Hi,
    Will make 2 weeks that I want IAP works, I checked a lot of tutorials, a lot of issues on this forum, but I don't find what's wrong with my script.
    It worked one time on my phone after downloaded from internal testing on GooglePlay, then on this device and an another phone it seems that all my products are unavailable according the logcat. But all is setup on playconsole, words match, and because It worked one time and then I didn't do any modification, so I don't think that's the problem, but I attach 2 images about saved words ID. I'm very confused.

    using Unity 2021.1.12f1
    using IAP 3.2.2

    Here my IAP initialization script:
    And I attach the logcat.txt
    Code (CSharp):
    1. public class Purchaser : Singleton<Purchaser>, IStoreListener
    2.     {
    3.  
    4.     private static IStoreController m_StoreController;          // The Unity Purchasing system.
    5.         private static IExtensionProvider m_StoreExtensionProvider; // The store-specific Purchasing subsystems.
    6.        
    7.         // specific mapping to Unity Purchasing's AddProduct, below.
    8.         public string life_20 = "life_20";
    9.         public string life_45 = "life_45";
    10.         public string life_90 = "life_90";
    11.         public string life_165 = "life_165";
    12.         public string coin_10 = "coin_10";
    13.         public string coin_25 = "coin_25";
    14.         public string coin_45 = "coin_45";
    15.         public string coin_90 = "coin_90";
    16.         public string coin_200 = "coin_200";
    17.         public string key_50 = "key_50";
    18.         public string key_140 = "key_140";
    19.         public string key_00 = "key_00";
    20.         public string special_499 = "special_499";
    21.         public string special_99 = "special_99";
    22.  
    23.         private void Start()
    24.         {
    25.           if (m_StoreController == null)
    26.           {
    27.             // Begin to configure our connection to Purchasing
    28.             InitializePurchasing();
    29.            }
    30.  
    31.          }
    32.  
    33.         public void InitializePurchasing()
    34.         {
    35.             // If we have already connected to Purchasing ...
    36.             if (IsInitialized())
    37.             {
    38.                 // ... we are done here.
    39.                 return;
    40.             }
    41.  
    42.         // Create a builder, first passing in a suite of Unity provided stores.
    43.           ConfigurationBuilder builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    44.  
    45.             // Add a product to sell / restore by way of its identifier, associating the general identifier
    46.             // with its store-specific identifiers.
    47.             builder.AddProduct(life_20, ProductType.Consumable);
    48.             builder.AddProduct(life_45, ProductType.Consumable);
    49.             builder.AddProduct(life_90, ProductType.Consumable);
    50.             builder.AddProduct(life_165, ProductType.Consumable);
    51.             builder.AddProduct(coin_10, ProductType.Consumable);
    52.             builder.AddProduct(coin_25, ProductType.Consumable);
    53.             builder.AddProduct(coin_45, ProductType.Consumable);
    54.             builder.AddProduct(coin_90, ProductType.Consumable);
    55.             builder.AddProduct(coin_200, ProductType.Consumable);
    56.             builder.AddProduct(key_50, ProductType.Consumable);
    57.             builder.AddProduct(key_140, ProductType.Consumable);
    58.             builder.AddProduct(key_00, ProductType.Consumable);
    59.             builder.AddProduct(special_499, ProductType.Consumable);
    60.             builder.AddProduct(special_99, ProductType.Consumable);
    61.  
    62.             UnityPurchasing.Initialize(this, builder);
    63.         }
    64.  
    65. public bool IsInitialized()
    66.         {
    67.             // Only say we are initialized if both the Purchasing references are set.
    68.             return m_StoreController != null && m_StoreExtensionProvider != null;
    69.         }
    70.  
    71. //....
    72.  
     

    Attached Files:

  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are there any notices on your Google dashboard? Have you published to Closed testing then downloaded your game via Google Play? You need to do this the first time, subsequently you can sideload your app (install via USB). Also, test with a different user account (not your developer account). Also, please share your full purchase script, as an attachment.
     
  3. chaelpix

    chaelpix

    Joined:
    Jul 4, 2017
    Posts:
    5
    Hi, thanks for your reply

    I publish in "Internal testing" then download from it usually, so after reading your reply I published a release in Closed Testing (it's pending 'cause examination so can't try now, but I will give news as soon as possible). Is that can make a big difference ?

    Yes, I use a different account for testing, and even a 2nd device without my developer account to be sure.

    Here the full purchase script.
    Thanks for your time
     

    Attached Files:

  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I always test via Closed testing to ensure everything is configured correctly https://docs.unity3d.com/Packages/com.unity.purchasing@3.2/manual/UnityIAPGoogleConfiguration.html
     
  5. chaelpix

    chaelpix

    Joined:
    Jul 4, 2017
    Posts:
    5
    That's work in closed testing, thanks you. I hope it will work in Production contrary to the actual production release, but I feel it was this mistake that make the IAP not working. Thanks
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry I don't quite follow. What does this mean "work in Production contrary to the actual production release". Are you saying that IAP is not working in your published app? Did you publish without testing IAP?
     
  7. chaelpix

    chaelpix

    Joined:
    Jul 4, 2017
    Posts:
    5
    I implemented the IAP since about 2 weeks, then sometimes I done some tests who were unsuccessful. I had a release date that I wanted to respect so I was focusing on the game core.

    The last day before publishing, because I knew the first days the players would be my family and friends, I said myself it won't be important if doesn't work yet, so I removed the shop for them.
    But the IAP manager with the script are still in the scene so I was able to see if was working with logcat.
    (The logcat of this published release says exactly the same things that the logcat.txt I sent.)

    Then, Today, I recreated the IAP script from scratch by following the tutorials, and that made the "Purchaser" script that I sent. And when I built for Internal Testing on Google Play, It worked only one time as described my first message.

    After, you told me to publish in Closed Testing, that what I done and since, IAP works in Closed Testing.
    That's why now I think it will works in Production. I'll publish the new version tomorrow to see it.

    I hope it's well explained, I'll say tomorrow if worked or not.
    Thanks again for your time.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it, sorry for my confusion. Yes, if it works in Closed testing, then it should work great in Production!
     
  9. chaelpix

    chaelpix

    Joined:
    Jul 4, 2017
    Posts:
    5
    Hi,
    Yes it's working, thanks a lot.
    Have a nice day