void CheckDisableIfOwned()
 {
     if ((disableIfOwned && productData.productType == UnityEngine.Purchasing.ProductType.NonConsumable && InAppPurchaseHelper.CheckReceipt(productData.ProductId)) ||
         (disableIfAdRemoved && IAPProcessor.CheckNoAds()))
     {
         gameObject.SetActive(false);
     }
 }
    void Start()
    {
        // If we haven't set up the Unity Purchasing reference
        if (m_StoreController == null)
        {
            // Begin to configure our connection to Purchasing
            InitializePurchasing();
        }

        //add no ads listener earlier: because initiating IAP take some time so splash ads was shown before no ads listener could be added in IAP initiation process
        IAPProcessor.SetupNoAds();
    }
    //
    // --- 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;

        IAPProcessor.Init();
    }
    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    {
        bool isValidPurchase = IAPProcessor.OnPurchase(args);

        //if isValidPurchase was false, you should display an error message
        if (onPurchaseComplete != null)
        {
            onPurchaseComplete.Invoke(isValidPurchase, PurchaseProcessingResult.Complete, args.purchasedProduct.definition.id);
            onPurchaseComplete = null;
        }

        /*// A consumable product has been purchased by this user.
         * if (CompareProductId(productIDDiamond1, args))
         * {
         *  Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
         *  // The consumable item has been successfully purchased, add 100 coins to the player's in-game score.
         * }
         * // Or ... a non-consumable product has been purchased by this user.
         * else if (String.Equals(args.purchasedProduct.definition.id, kProductIDNonConsumable, StringComparison.Ordinal))
         * {
         *  Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
         *  // TODO: The non-consumable item has been successfully purchased, grant this item to the player.
         * }
         * // Or ... a subscription product has been purchased by this user.
         * else if (String.Equals(args.purchasedProduct.definition.id, kProductIDSubscription, StringComparison.Ordinal))
         * {
         *  Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
         *  // TODO: The subscription item has been successfully purchased, grant this to the player.
         * }
         * // Or ... an unknown product has been purchased by this user. Fill in additional products here....
         * else
         * {
         *  Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));
         * }*/

        // Return a flag indicating whether this product has completely been received, or if the application needs
        // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still
        // saving purchased products to the cloud, and when that save is delayed.
        return(PurchaseProcessingResult.Complete);
    }