Hi guys,
I’ve been trying to implement IAP for a while now for my Google Play game, which has been published. I’ve noticed that the call to the function InitiatePurchase() isn’t completing as during runtime.
Giving the result of line: errorText.text = “InitializedPurchase”.ToString(); never being executed, the last thing to be executed correctly is the “Purchasing product asych…”. Any ideas what’s going wrong I’ve referenced this tutorial:
and followed the UnityDocs, with no luck.
private 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));
errorText.text = (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);
errorText.text = "InitializedPurchase".ToString();
}
// 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");
errorText.text = "Failed Purchase".ToString();
}
}
// Otherwise ...
else
{
// ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or
// retrying initiailization.
Debug.Log("BuyProductID FAIL. Not initialized.");
errorText.text = "Not Initialised".ToString();
}
}