/// <summary>
        /// Use to when the user wants to buy a IAP.
        /// </summary>
        /// <param name="inAppID">IAP ID</param>
        /// <param name="buyCallback">The callback that fires when done.</param>
        public void Buy(string inAppID, InAppPurchaseBuyCallbackMethod buyCallback)
        {
            if (buyingProduct || restoringProducts)
            {
                Debug.LogError("You must wait for the last buy, restore or consume to finish!");
                if (buyCallback != null)
                {
                    buyCallback(inAppID, null, false);
                }
                return;
            }
            buyingProduct    = true;
            this.buyCallback = buyCallback;

            // skip if item is already purchased locally
            if (IsPurchased(inAppID))
            {
                Debug.Log("InApp already puchased: " + inAppID);
                buyingProduct = false;
                if (buyCallback != null)
                {
                    buyCallback(inAppID, null, true);
                }
                return;
            }

            plugin.BuyInApp(inAppID, async_BuyCallback);
        }
示例#2
0
 public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback)
 {
     Native.BuyInApp(inAppID, purchasedCallback);
 }