Android IAP's working in standalone launcher but not on an Android device (Solved)

Basically I had my app up and running a few weeks ago all IAPS were working and today I noticed after an update (IAPS were not AT ALL changed in my update just a few tweaks to game mechanics) that the IAPS had completely stopped working but were giving normal responses in the standalone below I have included a copy of my IAPManager script and the error codes from my Android SDK Monitor.

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Purchasing;

    public class IAPManager : MonoBehaviour, IStoreListener
    {
        private static IStoreController m_StoreController;          // The Unity Purchasing system.
        private static IExtensionProvider m_StoreExtensionProvider; // The store-specific Purchasing subsystems.

        public static string PRODUCT_1000_GEMS = "1000gems";
        public static string PRODUCT_2500_GEMS = "2500gems";
        public static string PRODUCT_NO_ADS = "noads";

        private int gems;

        private void Start()
        {
            // If we haven't set up the Unity Purchasing reference
            if (m_StoreController == null)
            {
                // Begin to configure our connection to Purchasing
                InitializePurchasing();
            }
        }

        public void InitializePurchasing()
        {
            // If we have already connected to Purchasing ...
            if (IsInitialized())
            {
                // ... we are done here.
                return;
            }

            // Create a builder, first passing in a suite of Unity provided stores.
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            builder.AddProduct(PRODUCT_1000_GEMS, ProductType.Consumable);
            builder.AddProduct(PRODUCT_2500_GEMS, ProductType.Consumable);
            builder.AddProduct(PRODUCT_NO_ADS, ProductType.NonConsumable);

            // 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);
        }
        private bool IsInitialized()
        {
            // Only say we are initialized if both the Purchasing references are set.
            return m_StoreController != null && m_StoreExtensionProvider != null;
        }


        public void Buy1000Gems()
        {
            BuyProductID(PRODUCT_1000_GEMS);
        }
        public void Buy2500Gems()
        {
            BuyProductID(PRODUCT_2500_GEMS);
        }
        public void BuyNoAds()
        {
            BuyProductID(PRODUCT_NO_ADS);
        }


        void BuyProductID(string productId)
        {
            // If Purchasing has been initialized ...
            if (IsInitialized())
            {
                // ... look up the Product reference with the general product identifier and the Purchasing
                // system's products collection.
                Product product = m_StoreController.products.WithID(productId);

                // If the look up found a product for this device's store and that product is ready to be sold ...
                if (product != null && product.availableToPurchase)
                {
                    Debug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
                    // ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed
                    // asynchronously.
                    m_StoreController.InitiatePurchase(product);
                }
                // Otherwise ...
                else
                {
                    // ... report the product look-up failure situation 
                    Debug.Log("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
                }
            }
            // Otherwise ...
            else
            {
                // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or
                // retrying initiailization.
                Debug.Log("BuyProductID FAIL. Not initialized.");
            }
        }

        // 
        // --- IStoreListener
        //

        public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            // Purchasing has succeeded initializing. Collect our Purchasing references.
            Debug.Log("OnInitialized: PASS");

            // Overall Purchasing system, configured with products for this application.
            m_StoreController = controller;
            // Store specific subsystem, for accessing device-specific store features.
            m_StoreExtensionProvider = extensions;
        }
        public void OnInitializeFailed(InitializationFailureReason error)
        {
            // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
            Debug.Log("OnInitializeFailed InitializationFailureReason:" + error);
        }
        public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
        {
            // A consumable product has been purchased by this user.
            if (String.Equals(args.purchasedProduct.definition.id, PRODUCT_1000_GEMS, StringComparison.Ordinal))
            {
                Debug.Log("You just bought 1000 gems");
                gems = PlayerPrefs.GetInt("PlayerMoney");
                PlayerPrefs.SetInt("PlayerMoney", gems + 1000);
            }
            else if (String.Equals(args.purchasedProduct.definition.id, PRODUCT_2500_GEMS, StringComparison.Ordinal))
            {
                Debug.Log("You just bought 2500 gems");
                gems = PlayerPrefs.GetInt("PlayerMoney");
                PlayerPrefs.SetInt("PlayerMoney", gems + 2500);
            }
            else if (String.Equals(args.purchasedProduct.definition.id, PRODUCT_NO_ADS, StringComparison.Ordinal))
            {
                Debug.Log("You just removed all the ads");
                PlayerPrefs.SetInt("Ads", 1);
            }
            else
            {
                Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));
            }

            // Return a flag indicating whether this product has completely been received, or if the application needs
            // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still
            // saving purchased products to the cloud, and when that save is delayed.
            return PurchaseProcessingResult.Complete;
        }


        public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
        {
            // A product purchase attempt did not succeed. Check failureReason for more detail. Consider sharing
            // this reason with the user to guide their troubleshooting actions.
            Debug.Log(string.Format("OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason));
        }
    }

When you update IAP, it asks you if you want to also upgrade your API, you need to choose “Yes” here. The older API had VR Settings, it’s now XR Settings. This IAP forum post may help: IAP Troubleshooting - Remove and Reinstall Unity IAP

1 Like

This fixed it thanks mate! :slight_smile: