UnityPurchasing.Initialize Error [SOLVED]

Hi All,

Im greatly confused as to why I am getting this error:
Assets/IAPControler.cs(51,20): error CS1502: The best overloaded method match for `UnityEngine.Purchasing.UnityPurchasing.Initialize(UnityEngine.Purchasing.IStoreListener, UnityEngine.Purchasing.ConfigurationBuilder)’ has some invalid arguments

when I call:

UnityPurchasing.Initialize (this, builder);

in:

public static string aProductID = "coins150";
        public static string bProductID = "coins400";
        public static string cProductID = "coins1200";

        void Start()
        {
            if (m_StoreController == null)
            {
                InitializePurchasing();
            }
        }

        public void InitializePurchasing()
        {
            if (IsInitialized())
            {
                return;
            }
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            builder.AddProduct (aProductID, ProductType.Consumable);
            builder.AddProduct (bProductID, ProductType.Consumable);
            builder.AddProduct (cProductID, ProductType.Consumable);

            UnityPurchasing.Initialize (this, builder);
        }

I am using a namespace, could this be my problem?

The first parameter must be an IStoreListener. ‘this’ means the object in which this code lives, so, this class/script file. Does this class implement that interface? e.g.:

public class Foo : MonoBehaviour, UnityEngine.Purchasing.IStoreListener {
1 Like

Ahh that did the trick! Thanks for the help! :slight_smile: