i using unity version 2019.4.18 and unity IAP 2.2.2 for my android&ios app project.
is it useful and can i release my project stable to upgrade IAP version to 3.x.x?(in now, 3.2.2)
i don’t mind to update unity version for this project. just update new version of IAP when new version of IAP release.
Can I use IAP 3.x.x stable in Unity Version 2019.4.18?
if unity preferred to use IAP 2.x.x in Unity version 2019.4.18, i think more about update IAP version ![]()
Yes, please use IAP 3.2.3 that is now available.
@jeffDUnity hi i am using unity 2019.2.6 and IAP version 2.2.2 but i am facing a issue whenever user try any in app his payment is made successfully but user not received any rewards, my same code was working fine in previous version of IAP which i was use from assets store but now from the time i have updated my same project and deliver an update on play store ,InApps rewards not received by user but his payment is made successfully … i am pretty sure about this error because i have done this my own i have made a in app to check everything is fine , my payment done successfully but i have not received any rewards can you please help me ? is there any issue related to IAP version 2.2.2 ? or anything else i am missing regarding to IAP. Thansk
Please share your code and how you are debugging.
@JeffDUnity3D please help me with this i dont know what happend here
This is the testAdsScript.cs which is used to call methods
public void Buy200Coins()
{
Buy50Coins();
usercoins.text = PlayerPrefs.GetInt(“Coins”).ToString();
}
public void Buy500Coins()
{
Buy500Coins();
usercoins.text = PlayerPrefs.GetInt(“Coins”).ToString();
}
public void Buy1000Coins()
{
Buy1000Coins();
usercoins.text = PlayerPrefs.GetInt(“Coins”).ToString();
}
and this is the IAP Manager Script which is used for In apps
public class IAPManager : MonoBehaviour, IStoreListener
{
public static IAPManager IAPManagerInstance{ set; get; }
private static IStoreController m_StoreController; // The Unity Purchasing system.
private static IExtensionProvider m_StoreExtensionProvider; // The store-specific Purchasing subsystems.
// public static string kProductIDConsumable = “consumable”;
// public static string kProductIDNonConsumable = “nonconsumable”;
// public static string kProductIDSubscription = “subscription”;
public static string Add_200_coins = “golds200”;
public static string Add_500_coins = “golds500”;
public static string Add_1000_coins = “golds1000”;
public static string Remove_Ads = “remove_ads”;
void Awake()
{
IAPManagerInstance = this;
}
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());
// Add a product to sell / restore by way of its identifier, associating the general identifier
// with its store-specific identifiers.
builder.AddProduct(Add_200_coins, ProductType.Consumable);
builder.AddProduct(Add_500_coins, ProductType.Consumable);
builder.AddProduct(Add_1000_coins, ProductType.Consumable);
// Continue adding the non-consumable product.
builder.AddProduct(Remove_Ads, ProductType.NonConsumable);
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 Buy200Coins()
{
BuyProductID(Add_200_coins);
}
public void Buy500Coins()
{
BuyProductID(Add_500_coins);
}
public void Buy1000Coins()
{
BuyProductID(Add_1000_coins);
}
public void BuyRemoveAds()
{
BuyProductID(Remove_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.
Debug.Log("sent call to purchase manager it might be success or fail ");
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.”);
}
}
public void RestorePurchases()
{
// If Purchasing has not yet been set up …
if (!IsInitialized())
{
// … report the situation and stop restoring. Consider either waiting longer, or retrying initialization.
Debug.Log(“RestorePurchases FAIL. Not initialized.”);
return;
}
// If we are running on an Apple device …
if (Application.platform == RuntimePlatform.IPhonePlayer ||
Application.platform == RuntimePlatform.OSXPlayer)
{
// … begin restoring purchases
Debug.Log(“RestorePurchases started …”);
// Fetch the Apple store-specific subsystem.
var apple = m_StoreExtensionProvider.GetExtension();
// Begin the asynchronous process of restoring purchases. Expect a confirmation response in
// the Action below, and ProcessPurchase if there are previously purchased products to restore.
apple.RestoreTransactions((result) => {
// The first phase of restoration. If no more responses are received on ProcessPurchase then
// no purchases are available to be restored.
Debug.Log("RestorePurchases continuing: " + result + “. If no further messages, no purchases available to restore.”);
});
}
// Otherwise …
else
{
// We are not running on an Apple device. No work is necessary to restore purchases.
Debug.Log("RestorePurchases FAIL. Not supported on this platform. Current = " + Application.platform);
}
}
//
// — 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)
{
Debug.Log(“OnInitializeFailed InitializationFailureReason:” + error);
}
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
if (String.Equals(args.purchasedProduct.definition.id, Add_200_coins, StringComparison.Ordinal))
{
int num = PlayerPrefs.GetInt (“Coins”);
num = num + 200;
PlayerPrefs.SetInt (“Coins”, num);
Debug.Log(“200 coins added after success purchase from iap manager”);
}
else if (String.Equals(args.purchasedProduct.definition.id, Add_500_coins, StringComparison.Ordinal))
{
int num = PlayerPrefs.GetInt (“Coins”);
num = num + 500;
PlayerPrefs.SetInt (“Coins”, num);
Debug.Log(“500 coins added after success purchase from iap manager”);
}
else if (String.Equals(args.purchasedProduct.definition.id, Add_1000_coins, StringComparison.Ordinal))
{
int num = PlayerPrefs.GetInt (“Coins”);
num = num + 1000;
PlayerPrefs.SetInt (“Coins”, num);
Debug.Log(“1000 coins added after success purchase from iap manager”);
}
else if (String.Equals(args.purchasedProduct.definition.id, Remove_Ads, StringComparison.Ordinal))
{
PlayerPrefs.SetInt (“RemoveAds”,1);
Debug.Log(“remove ads purchase after success purchase from iap manager”);
}
else
{
Debug.Log(string.Format(“ProcessPurchase: FAIL. Unrecognized product: ‘{0}’”, args.purchasedProduct.definition.id));
}
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));
}
}
In the future, please use Code Tags when posting code, or as an attachment. View other posts. What is the debug output when running on the device? The debug output will show in the device logs. https://discussions.unity.com/t/699654