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. Dismiss Notice

iOS - Unity Purchasing - OnInitialize Failed - NoProductsAvailable

Discussion in 'iOS and tvOS' started by BonusLevelDevelopment, Sep 25, 2016.

  1. BonusLevelDevelopment

    BonusLevelDevelopment

    Joined:
    Oct 20, 2013
    Posts:
    9
    **Note: I'll update thread with solution if I find one before any replies. **

    ***Update: I have a feeling the issue is due to the fact that my "Paid Applications" Contract is still in a state of "In progress" Pending Tax and Bank info** I will contact Apple to confirm this interrupts testing iAP's.



    Hi, I'm experiencing an issue, as described in the title, where in-app purchasing is failing to initialize. Reason stated: "OnInitializeFailed InitializationFailureReason: NoProductsAvailable" . I'm wondering what I'm missing?

    Here's the checklist of what I've done:
    -created the app in iTunes Connect (with in-app purchasing enabled in the iOS App ID in Apple Developer site)
    -specified the bundle ID in Unity to the same as the bundle ID for the app.
    -iTunes Connect: added in-app purchase in features>In-App Purchases. (Status of the In-App purchase is listed as "Ready to Submit)
    -iTunes Connect: added In-App purchase to iTunes Connect> iOS App > 1.0 Prepare for Submission > "In-App Purchases" section.
    -iTunes Connect> iOS App > 1.0 Prepare for Submission > "Build" section - added current build.
    -set the kProductIDNonConsumable = the ProductID as-spelled in the In-App purchase ProductID field. Also, set the kProductNameAppleNonConsumable = the ProductID as-spelled in the In-App purchase ProductID field.
    -build the project, deploy to my non-Jailbroken iPad, Archive, validate archive, upload archive, delete existing version from iPad, and install the app uploaded build via TestFlight.
    -Before running the app, I log-out of itunes store in ipad settings.

    Here is the portion of the script pertaining to purchasing initialization, derived from the Unity example project for the iAP system:

    Code (CSharp):
    1.  
    2. public class Purchaser : MonoBehaviour, IStoreListener
    3. {
    4.     public UnityEngine.UI.Text txtOutput;
    5.  
    6.     private static IStoreController m_StoreController;          // The Unity Purchasing system.
    7.     private static IExtensionProvider m_StoreExtensionProvider; // The store-specific Purchasing subsystems.
    8.  
    9.     // Product identifiers for all products capable of being purchased:
    10.     // "convenience" general identifiers for use with Purchasing, and their store-specific identifier
    11.     // counterparts for use with and outside of Unity Purchasing. Define store-specific identifiers
    12.     // also on each platform's publisher dashboard (iTunes Connect, Google Play Developer Console, etc.)
    13.  
    14.     // General product identifiers for the consumable, non-consumable, and subscription products.
    15.     // Use these handles in the code to reference which product to purchase. Also use these values
    16.     // when defining the Product Identifiers on the store. Except, for illustration purposes, the
    17.     // kProductIDSubscription - it has custom Apple and Google identifiers. We declare their store-
    18.     // specific mapping to Unity Purchasing's AddProduct, below.
    19.     public static string kProductIDConsumable =    "consumable";
    20.     public static string kProductIDNonConsumable = "ProductIDasListedInITunesConnect";
    21.     public static string kProductIDSubscription =  "subscription";
    22.  
    23.     // Apple App Store-specific product identifier for the non-consumable producK -BES
    24.     private static string kProductNameAppleNonConsumable = "ProductIDasListedInITunesConnect";
    25.  
    26.     void Awake()
    27.     {
    28.         // If we haven't set up the Unity Purchasing reference
    29.         if (m_StoreController == null)
    30.         {
    31.             // Begin to configure our connection to Purchasing
    32.            InitializePurchasing();
    33.         }
    34.     }
    35.  
    36.  
    37.     public void InitializePurchasing()
    38.     {
    39.         // If we have already connected to Purchasing ...
    40.         if (IsInitialized())
    41.         {
    42.             // ... we are done here.
    43.             return;
    44.         }
    45.    
    46.         // Create a builder, first passing in a suite of Unity provided stores.
    47.         var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    48.    
    49.         // Add a product to sell / restore by way of its identifier, associating the general identifier
    50.         // with its store-specific identifiers.
    51.          
    52.         // adding the non-consumable product.
    53.            builder.AddProduct(kProductIDNonConsumable, ProductType.NonConsumable, new IDs(){
    54.             { kProductNameAppleNonConsumable, AppleAppStore.Name },
    55.         });
    56.    
    57.         // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
    58.         // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
    59.         UnityPurchasing.Initialize(this, builder);
    60.     }
    61.  
    62.  
    63.     private bool IsInitialized()
    64.     {
    65.         // Only say we are initialized if both the Purchasing references are set.
    66.         return m_StoreController != null && m_StoreExtensionProvider != null;
    67.     }
    68.      
    69.  
    70.     //
    71.     // --- IStoreListener
    72.     //
    73.  
    74.     public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    75.     {
    76.         // Purchasing has succeeded initializing. Collect our Purchasing references.
    77.         Debug.Log("OnInitialized: PASS");
    78.    
    79.         // Overall Purchasing system, configured with products for this application.
    80.         m_StoreController = controller;
    81.         // Store specific subsystem, for accessing device-specific store features.
    82.         m_StoreExtensionProvider = extensions;
    83.     }
    84.  
    85.  
    86.     public void OnInitializeFailed(InitializationFailureReason error)
    87.     {
    88.         // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
    89.         //bes: Debug.Log("OnInitializeFailed InitializationFailureReason:" + error);
    90.         txtOutput.text = "OnInitializeFailed InitializationFailureReason:" + error;
    91.     }
    92.  
    93. }

    Any ideas on what I'm doing wrong?
     
    Last edited: Sep 26, 2016
    KingKRoecks and sama-van like this.
  2. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    735
    Hey @Frank-Grimes,
    I have run into this issue for the reason you stated at the top of your post in the update. Once I had all of my tax information and agreements in order, the IAPs started to show up. Please let us know if you run into further issues.
    Cheers,
    Chris
     
    KingKRoecks and WittyTech like this.
  3. BonusLevelDevelopment

    BonusLevelDevelopment

    Joined:
    Oct 20, 2013
    Posts:
    9
    Will do Chris. I'm holding-off on in-app testing until I create a new Apple dev account for my LLC.
     
  4. BonusLevelDevelopment

    BonusLevelDevelopment

    Joined:
    Oct 20, 2013
    Posts:
    9
    UPDATE: Resolved: I was able to test via iOS device successfully: The issue was that I didn't complete filling out the banking and tax forms under the "Paid Applications Agreement" in the iTunes Connect "Tax and Banking" section.

    I spun my wheels in lieu of filling out the forms completely :( :(

    I hope this helps others who are checking-off the items in their checklist during troubleshooting.
     
  5. ICrazymouse

    ICrazymouse

    Joined:
    May 15, 2019
    Posts:
    5
    Thank U Very Much!!!
     
  6. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    145
    Fingers crossed this was my issue as well :) thanks for this post!