shahin2019:
this code does not working for me on google play in unity 2019.1.9, why?
public class ShopManager2 : MonoBehaviour, IStoreListener
{
public static ShopManager2 Instance{ set; get;}
private static IStoreController m_StoreController; // The Unity Purchasing system.
private static IExtensionProvider m_StoreExtensionProvider; // The store-specific Purchasing subsystems.
public static string PRODUCT_30_level = "com.dezi.waronfrozenland2.ss2222";
public static string PRODUCT_Removeadss = "com.dezi.waronfrozenland2.xxxxxxx";
private void Awake(){
Instance = this;
}
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())
{
return;
}
var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
builder.AddProduct(PRODUCT_30_level, ProductType.Consumable);
builder.AddProduct(PRODUCT_Removeadss, ProductType.Consumable);
UnityPurchasing.Initialize(this, builder);
}
private bool IsInitialized()
{
return m_StoreController != null && m_StoreExtensionProvider != null;
}
public void levelss09_30_level()
{
BuyProductID(PRODUCT_30_level);
}
public void removeadsss()
{
BuyProductID(PRODUCT_Removeadss);
}
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_30_level, StringComparison.Ordinal))
{
shopping.buy30 =5000;
}
else if (String.Equals(args.purchasedProduct.definition.id,PRODUCT_Removeadss, StringComparison.Ordinal))
{
buy_Remove_Ads.buy_ads =5000;
}
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));
}
}
you can see my game ion google play for checking :
https://play.google.com/store/apps/details?id=com.dezi.waronfrozenland2
please what is wrong in this code answer me
This thread refers to Codeless IAP, you are using scripting. Please open a new topic. When you open the new thread, please attach the device logs, they are essential for debugging https://discussions.unity.com/t/699654