Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Problem with IAP & GooglePlay store

Discussion in 'Unity IAP' started by dave_mm0, May 27, 2021.

  1. dave_mm0

    dave_mm0

    Joined:
    Feb 8, 2013
    Posts:
    26
    Hey,
    I'm trying to get IAP working with GooglePlay, but I keep getting a InitializationFailureReason.NoProductsAvailable error on initialization.

    Keeping it as simple as I can:
    Code (CSharp):
    1.  
    2. private static string _unlockID = "com.playtogether.runproprun.unlock";
    3. void Awake() {
    4.         ConfigurationBuilder builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    5.         builder.AddProduct(_unlockID, ProductType.NonConsumable);
    6.         UnityPurchasing.Initialize(this, builder);
    7. }
    8.  
    9. public void OnInitializeFailed(InitializationFailureReason error) {
    10.         Debug.Log("Billing failed to initialize!");
    11.         switch (error) {
    12.             case InitializationFailureReason.AppNotKnown:
    13.                 Debug.LogError("Is your App correctly uploaded on the relevant publisher console?");
    14.                 break;
    15.             case InitializationFailureReason.PurchasingUnavailable:
    16.                 // Ask the user if billing is disabled in device settings.
    17.                 Debug.Log("Billing disabled!");
    18.                 break;
    19.             case InitializationFailureReason.NoProductsAvailable:
    20.                 // Developer configuration error; check product metadata.
    21.                 Debug.Log("No products available for purchase!");
    22.                 break;
    23.         }
    24.         MainMenu.Instance.DisplayErrorPanel(error.ToString());
    25.     }
    26.  
    Then on GooglePlay, I have my setup like this:
    upload_2021-5-26_21-50-56.png
    So the IAP is setup and active, yet I cant seem to get it to Init properly.

    I'm using Unity 2020.3.7f1 and IAP package 3.0.2
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are you testing via Closed testing and downloading via the testing opt-in link? Try creating another test user, and have them log into the Play Store on the device to test.
     
    dave_mm0 likes this.
  3. dave_mm0

    dave_mm0

    Joined:
    Feb 8, 2013
    Posts:
    26
    Thanks Jeff, turns out that I just didnt have the right test user setup.

    Another question on Restoring purchases using Codeless IAP. Whenever I select the "Restore" Option on IAPButton, I have no options for a callback:
    upload_2021-6-1_20-1-43.png
    The docs say I should be able to specify one.
    upload_2021-6-1_20-2-11.png

    Looking at the IAPButton code, it doesn't look like there's a Restore Callback... Am I seeing this right?
    upload_2021-6-1_20-2-33.png

    The Docs then say that "ProcessPurchase" will be called for each Purchase that was restored, but I cant set the callback when the "Restore" option is selected
     
    Last edited: Jun 2, 2021
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    For Codeless, your On Purchase method would get triggered (the "GrantCredits" method mentioned in the documentation, but you can call it whatever you want)
     
    Last edited: Jun 2, 2021
    dave_mm0 likes this.
  5. dave_mm0

    dave_mm0

    Joined:
    Feb 8, 2013
    Posts:
    26
    Got it, that worked well enough, thanks!