Example #1
0
        /// <summary>
        /// restore already purchased user's transactions for non consumable iaps.
        /// For Android/WP8 we use the received list for detecting previous purchases
        /// </summary>
        public static void RestoreTransactions()
        {
                        #if UNITY_IPHONE
            OpenIAB.restoreTransactions();
                        #elif UNITY_ANDROID || UNITY_WP8
            if (inventory == null)
            {
                RestoreFailed("Restoring transactions failed. Please try again.");
                return;
            }

            List <string> prods = inventory.GetAllOwnedSkus();
            for (int i = 0; i < prods.Count; i++)
            {
                string id = GetIAPIdentifier(prods[i]);
                if (!DBManager.isPurchased(id))
                {
                    DBManager.SetToPurchased(id);
                }
            }
            RestoreSucceeded();
                        #endif

            //update ShopManager GUI items
            if (ShopManager.GetInstance())
            {
                ShopManager.SetItemState();
            }
        }
Example #2
0
    void OnGUI()
    {
        GUI.skin.window.fontSize = GUI.skin.label.fontSize = GUI.skin.box.fontSize = GUI.skin.button.fontSize = FONT_SIZE;
        if (!_showShopWindow)
        {
            if (string.IsNullOrEmpty(_popupText) && GUI.Button(new Rect(Screen.width - BUTTON_WIDTH - OFFSET, OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT), "Shop", GUI.skin.button))
            {
                ShowShopWindow(true);
            }
            if (GUI.Button(new Rect(Screen.width - BUTTON_WIDTH - OFFSET, OFFSET * 2 + BUTTON_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT / 2), "Restore", GUI.skin.button))
            {
                OpenIAB.restoreTransactions();
            }
        }
        else
        {
            GUI.Window(0, new Rect(Screen.width / 2 - WINDOW_WIDTH / 2, Screen.height / 2 - WINDOW_HEIGHT / 2, WINDOW_WIDTH, WINDOW_HEIGHT), DrawShopWindow, "Game Shop");
        }

        DrawSidePanel();

        if (!string.IsNullOrEmpty(_popupText))
        {
            GUI.Window(0, new Rect(Screen.width / 2 - WINDOW_WIDTH / 2, Screen.height / 2 - WINDOW_HEIGHT / 2, WINDOW_WIDTH, WINDOW_HEIGHT), DrawPopup, "");
        }
    }
Example #3
0
        private void QueryInventorySucceededEvent(Inventory inventory)
        {
            var purchases = inventory.GetAllPurchases();

            if (purchases.Any())
            {
                WriteLog("query inventory succeeded, purchases owned: {0}", string.Join(", ", purchases.Select(i => i.Sku).ToArray()));

                if (_sku == null)
                {
                    foreach (var purchase in purchases)
                    {
                        WriteLog("restoring owned purchase: {0}", purchase.Sku);
                        Purchased(purchase);
                    }
                }
                else
                {
                    var purchase = purchases.SingleOrDefault(i => i.Sku == _sku);

                    if (purchase != null)
                    {
                        WriteLog("restoring owned purchase: {0}", purchase.Sku);
                        Purchased(purchase);
                    }
                }
            }
            else
            {
                WriteLog("query inventory succeeded, owned purchases not found");
            }


            #if UNITY_IPHONE
            if (_sku == null)
            {
                WriteLog("restoring transactions (iOS)...");
                OpenIAB.restoreTransactions();
            }
            #endif

            #if UNITY_ANDROID || UNITY_WEBPLAYER
            if (_sku == null || inventory.HasPurchase(_sku))
            {
                CompleteTask(RestoreCompleted, "purchases successfully restored (inventory check)");
            }
            #endif

            else
            {
                WriteLog("purchasing product: {0}", _sku);
                OpenIAB.purchaseProduct(_sku, Convert.ToString(CRandom.GetRandom(0, 1000000)));
            }
        }
Example #4
0
 public void Restore()
 {
     OpenIAB.restoreTransactions();
 }
Example #5
0
 public void restorePurchase()
 {
     Debug.Log("restore");
     OpenIAB.restoreTransactions();
 }