I'm having problems with unity IAP services; I followed this (https://www.youtube.com/watch?v=3IQ-CvBQz0o&t=229s)tutorial on online to the tea and it works within Unity Editor however it doesn't work on my mobile. I checked through everything and even tested it out on a different mobile, but it still giving the same results. I recently upgraded unity 5.4 to 5.5 and even before I upgraded to 5.5, I was still having the same problem as before; I even tried out the new IAP system that unity 5.5 provide and still having the same problem. Heck, I think that the problem is, is that my IAP script (the one which was also provided my unity) isn't working on mobile, as before mention it does work within unity engine.One more thing to mention is that my IAP script was working before (on mobiles), before it stopped working on mobile phones, however I am not sure how or what triggered my script to not work now on mobile phones.
My Script:
public static IAPManager Instance{set; get;}
private static IStoreController m_StoreController;
private static IExtensionProvider m_StoreExtensionProvider;
public static string PRODUCT_50_GOLD = "gold50";
public static string PRODUCT_100_GOLD = "gold100";
public static string PRODUCT_NO_ADS = "noads";
private void Awake()
{
Instance = this;
}
private void Start()
{
if (m_StoreController == null)
{
InitializePurchasing();
}
}
public void InitializePurchasing()
{
if (IsInitialized())
{
return;
}
var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
builder.AddProduct(PRODUCT_50_GOLD, ProductType.Consumable);
builder.AddProduct(PRODUCT_100_GOLD, ProductType.Consumable);
builder.AddProduct(PRODUCT_NO_ADS, ProductType.NonConsumable);
UnityPurchasing.Initialize(this, builder);
}
private bool IsInitialized()
{
return m_StoreController != null && m_StoreExtensionProvider != null;
}
public void Buy50Gold()
{
BuyProductID(PRODUCT_50_GOLD);
}
public void Buy100Gold()
{
BuyProductID(PRODUCT_100_GOLD);
}
public void BuyNoAds()
{
BuyProductID(PRODUCT_NO_ADS);
}
private void BuyProductID(string productId)
{
if (IsInitialized())
{
Product product = m_StoreController.products.WithID(productId);
if (product != null && product.availableToPurchase)
{
Debug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
m_StoreController.InitiatePurchase(product);
}
else
{
Debug.Log("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
}
}
else
{
Debug.Log("BuyProductID FAIL. Not initialized.");
}
}
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
{
Debug.Log("OnInitialized: PASS");
m_StoreController = controller;
m_StoreExtensionProvider = extensions;
}
public void OnInitializeFailed(InitializationFailureReason error)
{
Debug.Log("OnInitializeFailed InitializationFailureReason:" + error);
}
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
if (String.Equals(args.purchasedProduct.definition.id, PRODUCT_50_GOLD, StringComparison.Ordinal))
{
Debug.Log ("Purchase Successfull!");
ScoreManager.Coin += 50;
}
else if (String.Equals(args.purchasedProduct.definition.id, PRODUCT_100_GOLD, StringComparison.Ordinal))
{
Debug.Log ("Purchase Successfull!");
ScoreManager.Coin += 100;
}
else if (String.Equals(args.purchasedProduct.definition.id, PRODUCT_NO_ADS, StringComparison.Ordinal))
{
Debug.Log ("Purchase Successfull!");
}
else
{
Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));
}
return PurchaseProcessingResult.Complete;
}
public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
{
Debug.Log(string.Format("OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason));
}
}
The below code is being referenced above:
private void Start() {
}
public void Buy50Gold() {
IAPManager.Instance.Buy50Gold ();
}
public void Buy100Gold() {
IAPManager.Instance.Buy100Gold ();
}
public void BuyNoAds() {
IAPManager.Instance.BuyNoAds ();
}
What I have tried:
Upgrading to Unity 5.5 and using the new IAP system. Doesn't work