コード例 #1
0
        /// <summary>
        /// restore already purchased user's transactions for non consumable iaps.
        /// For Android we use the received list for detecting previous purchases
        /// </summary>
        public static void RestoreTransactions()
        {
            #if UNITY_IPHONE
            StoreKitBinding.restoreCompletedTransactions();
            #elif UNITY_ANDROID
            if (prods == null)
            {
                RestoreFailed("Restoring transactions failed. Please try again.");
                return;
            }

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

            //update ShopManager GUI items
            if (ShopManager.GetInstance())
            {
                ShopManager.SetItemState();
            }
        }
コード例 #2
0
ファイル: IAP.cs プロジェクト: Veryphone/VeryGitHub
    // iOS Only. Restores all previous transactions. This is used when a user gets a new device and they need to restore their old purchases.
    // DO NOT call this on every launch. It will prompt the user for their password. Each transaction that is restored will have
    // the completion handler called for it
    public static void restoreCompletedTransactions(Action <string> completionHandler)
    {
        _purchaseCompletionAction  = null;
        _purchaseRestorationAction = completionHandler;

#if UNITY_IPHONE
        StoreKitBinding.restoreCompletedTransactions();
#endif
    }
コード例 #3
0
        //
        public void RestorePurchase()
        {
            if (!CoreUtility.Me.ShowInternetConnection())
            {
                return;
            }
#if (UNITY_IOS && !STOREKIT) || (UNITY_ANDROID && !GOOGLEIAB)
            PopupMessages.Me.InAppNotIntegratedMessage();
            return;
#endif

            isRestore            = true;
            isRestoreItemSuccess = false;
            PopupMessages.Me.RestoreProcessMessage();

            #region iOS Methods
#if UNITY_IOS && STOREKIT
#if !UNITY_EDITOR
            StoreKitBinding.restoreCompletedTransactions();
#endif
#if UNITY_EDITOR
            ASKRestoreTransactionsFailed("Not works in editor mode");
#endif
#endif
            #endregion
            //
            #region Android => Google Play Mathods
#if UNITY_ANDROID && !AMAZONSTORE && GOOGLEIAB
#if !UNITY_EDITOR
            GoogleIAB.queryInventory(inappids);
#endif
#if UNITY_EDITOR
            IABQueryInventoryFailed("Not works in editor mode");
#endif
#endif
            #endregion
            //
            #region Android => Amazon Store Methods
#if UNITY_ANDROID && !UNITY_EDITOR && AMAZONSTORE
#if !UNITY_EDITOR
            ResetInput resetInput = new ResetInput();
            resetInput.Reset = false;
            iapService.GetPurchaseUpdates(resetInput);
#endif
#if UNITY_EDITOR
            MarketPlaceNotSuported();
#endif
#endif
            #endregion
        }
コード例 #4
0
 public void RestorePurchase()
 {
     Main.Instance.PlayButtonSound();
     isRestoring = true;
             #if UNITY_IOS
     StoreKitBinding.restoreCompletedTransactions();
             #elif UNITY_ANDROID
     if (canRestored)
     {
         Debug.Log("Restored Purchase");
         //			GoogleIAB.purchaseProduct(Constants.PRODUCT_ID, "NoAds");
         GoogleIAB.purchaseProduct(Constants.PRODUCT_ID);
     }
             #endif
 }
コード例 #5
0
    public void RestorePurchase()
    {
        #if UNITY_IOS
        IsRestorePurchase = true;
        StoreKitBinding.restoreCompletedTransactions();
        #endif


        #if UNITY_ANDROID
        if (NonConsumedSku.Count > 0)
        {
            for (int i = 0; i < NonConsumedSku.Count; i++)
            {
                string  prodID = NonConsumedSku[i];
                IAPUnit iap    = mInAppProducts.Find(prod => prod.IAP_Id == prodID);

                if (iap != null)
                {
                    if (iap.mIAPtypes == IAP_Type.NonConsumable)
                    {
                        UIManager.Instance.ShowPopUp("All purchases have been restored", null, TypeOfPopUpButtons.Ok, TypeOfPopUp.Buttoned, 0, null, null, "Restore Successful!");
                        GameManager.Instance.AddDeductCurrency(iap.mCurrency, AddDeductAction.Add, iap.prodValue);
                    }
                    else
                    {
                        UIManager.Instance.ShowPopUp("Nothing To Restore", null, TypeOfPopUpButtons.Ok, TypeOfPopUp.Buttoned, 0, null, null);
                    }
                }
                else
                {
                    UIManager.Instance.ShowPopUp("Nothing To Restore", null, TypeOfPopUpButtons.Ok, TypeOfPopUp.Buttoned, 0, null, null);
                }
            }
        }
        else
        {
            UIManager.Instance.ShowPopUp("Nothing To Restore", null, TypeOfPopUpButtons.Ok, TypeOfPopUp.Buttoned, 0, null, null);
        }
        #endif
    }
コード例 #6
0
    // fund 2000

    /*
     * 1. 10,000 gram Gold for 5 Strong Engine
     *      : Strong engine can destroy everything by collide.. it's a great engine to make scores..
     * 2. 30,000 Gram Gold for 10 Gost Engine
     *      : Ghost Engine can Go as fast as inside any objects this is a so amaizing engine ever.. buy this engine to make more score
     * 3. 50,000 Grams Gold for 10 Magnet Engine
     *      : It's a Magnet Field Engine it can destroy all obstracles and collect gold stone and coins autometically.. buy this engine..
     *      Enjoy a funny train journey
     *
     *
     * 1. 30,000 gram Gold at $1
     * 2. 70,000 gram Gold at $1.99
     *
     *
     *
     *
     */



    void Update()
    {
        CoinsDeposit.GetComponent <TextMesh>().text = "" + gold;
        HealthText.GetComponent <TextMesh>().text   = "" + Health;
        HB1_details.GetComponent <TextMesh>().text  = "Protect yourself \nfrom Front Collision..\nSpending 5,000 coins";
        HB2_details.GetComponent <TextMesh>().text  = "Protect yourself \nforever from Front \nCollision... does not\nmatter the obstacle \nsize..and quantity.. ";
        CB1_details.GetComponent <TextMesh>().text  = "Get coins and use \nother features...";
        CB2_details.GetComponent <TextMesh>().text  = "Get Mega coins and \nuse other features...\ndon't worry.. about\nmissed coins.. on \nGame play";
        CXB1_details.GetComponent <TextMesh>().text = "Get Double coins value\nenjoy more funn...";
        CXB2_details.GetComponent <TextMesh>().text = "4x multiply coins value\nenjoy more funn...";
        EB1_details.GetComponent <TextMesh>().text  = "Unlock Challengeing \nnever die Ghost mode \nIt is incredible.. \nrealy great..";
        EB2_details.GetComponent <TextMesh>().text  = "Unlock Super Mode.\nfeel your joy\nand funn with game.";

        if (PlayerPrefs.GetInt("M_Health") > 0)
        {
            _hbuy2.SetActiveRecursively(false);
        }
        else
        {
            _hbuy2.SetActiveRecursively(true);
        }

        if (PlayerPrefs.GetInt("COIN2X") > 0)
        {
            _cxbuy1.SetActiveRecursively(false);
        }
        else
        {
            _cxbuy1.SetActiveRecursively(true);
        }


        if (PlayerPrefs.GetInt("COIN4X") > 0)
        {
            _cxbuy2.SetActiveRecursively(false);
        }
        else
        {
            _cxbuy2.SetActiveRecursively(true);
        }

        if (PlayerPrefs.GetInt("S_ENG") > 0)
        {
            _engbuy2.SetActiveRecursively(false);
        }
        else
        {
            _engbuy2.SetActiveRecursively(true);
        }


        if (PlayerPrefs.GetInt("G_ENG") > 0)
        {
            _engbuy1.SetActiveRecursively(false);
        }
        else
        {
            _engbuy1.SetActiveRecursively(true);
        }



        if (Input.GetMouseButtonDown(0))
        {
            Vector3 touchPos = Input.mousePosition;

            if (Back.HitTest(touchPos))
            {
                _StoreMenu.isS_Close = true;
                PlayerPrefs.SetInt("Health", Health);
                StartCoroutine(waitlevels(0.9f));
                audio.PlayOneShot(ActionSound);
            }
            if (Restore.HitTest(touchPos))
            {
                audio.PlayOneShot(ActionSound);
                StoreKitBinding.restoreCompletedTransactions();
            }

            ray = Camera.main.ScreenPointToRay(Input.mousePosition);


            if (Physics.Raycast(ray, out hit, 500))
            {
                if (hit.collider.tag == "_hbuy1")                                                // 5000 coins >>

                {
                    audio.PlayOneShot(ActionSound);
                    if (gold > 4999)
                    {
                        Health += 24;
                        gold   -= 5000;
                    }

                    // Heale += 24;
                }
                if (hit.collider.tag == "_hbuy2")                                                // 40,000 coins $0.99
                {
                    audio.PlayOneShot(ActionSound);
                    if (gold > 39999)
                    {
                        PlayerPrefs.SetInt("M_Health", 2);                                                        // true
                        gold -= 40000;
                    }
                    else
                    {
                        StoreKitBinding.purchaseProduct("HMpack", 1);
                    }
                }
                if (hit.collider.tag == "_cbuy1")                                               //$0.99  >>
                {
                    audio.PlayOneShot(ActionSound);
                    //gold += 50000;
                    StoreKitBinding.purchaseProduct("CSpack", 1);
                }
                if (hit.collider.tag == "_cbuy2")                                                //$1.99 >>
                {
                    audio.PlayOneShot(ActionSound);
                    //gold+= 900000;
                    StoreKitBinding.purchaseProduct("CMpack", 1);
                }
                if (hit.collider.tag == "_cxbuy1")                                                // 50,000 coins
                {
                    audio.PlayOneShot(ActionSound);
                    if (gold > 49999)
                    {
                        PlayerPrefs.SetInt("COIN2X", 2);
                        gold -= 50000;
                    }
                }
                if (hit.collider.tag == "_cxbuy2")                                                //3,00,000 coins $0.99
                {
                    audio.PlayOneShot(ActionSound);
                    if (gold > 299999)
                    {
                        gold -= 300000;
                        PlayerPrefs.SetInt("COIN4X", 2);
                    }
                    else
                    {
                        StoreKitBinding.purchaseProduct("CXpack", 1);
                    }
                }
                if (hit.collider.tag == "_engbuy1")                                               //7,00,000 coins $1.99
                {
                    audio.PlayOneShot(ActionSound);
                    if (gold > 699999)
                    {
                        gold -= 700000;
                        PlayerPrefs.SetInt("G_ENG", 2);
                    }
                    else
                    {
                        StoreKitBinding.purchaseProduct("ESpack", 1);
                    }
                }
                if (hit.collider.tag == "_engbuy2")                                               //9,00,000 coins $2.99
                {
                    audio.PlayOneShot(ActionSound);
                    if (gold > 899999)
                    {
                        gold -= 900000;
                        PlayerPrefs.SetInt("S_ENG", 2);
                    }
                    else
                    {
                        StoreKitBinding.purchaseProduct("EMpack", 1);
                    }
                }
            }
        }
    }
コード例 #7
0
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("Get Can Make Payments"))
        {
            bool canMakePayments = StoreKitBinding.canMakePayments();
            Debug.Log("StoreKit canMakePayments: " + canMakePayments);
        }


        if (GUILayout.Button("Request Product Data"))
        {
            // array of product ID's from iTunesConnect. MUST match exactly what you have there!
            var productIdentifiers = new string[] { "anotherProduct", "tt", "testProduct", "sevenDays", "oneMonthSubsciber" };
            StoreKitBinding.requestProductData(productIdentifiers);
        }


        if (GUILayout.Button("Restore Completed Transactions"))
        {
            StoreKitBinding.restoreCompletedTransactions();
        }


        endColumn(true);


        // enforce the fact that we can't purchase products until we retrieve the product data
        if (_products != null && _products.Count > 0)
        {
            if (GUILayout.Button("Purchase Random Product"))
            {
                var productIndex = Random.Range(0, _products.Count);
                var product      = _products[productIndex];

                Debug.Log("preparing to purchase product: " + product.productIdentifier);
                StoreKitBinding.purchaseProduct(product.productIdentifier, 1);
            }
        }
        else
        {
            GUILayout.Label("Once you successfully request product data a purchase button will appear here for testing");
        }


        if (GUILayout.Button("Get Saved Transactions"))
        {
            List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions();

            // Print all the transactions to the console
            Debug.Log("\ntotal transaction received: " + transactionList.Count);

            foreach (StoreKitTransaction transaction in transactionList)
            {
                Debug.Log(transaction.ToString() + "\n");
            }
        }


        if (GUILayout.Button("Turn Off Auto Confirmation of Transactions"))
        {
            // this is used when you want to validate receipts on your own server or when dealing with iTunes hosted content
            // you must manually call StoreKitBinding.finishPendingTransactions when the download/validation is complete
            StoreKitManager.autoConfirmTransactions = false;
        }


        if (GUILayout.Button("Cancel Downloads"))
        {
            StoreKitBinding.cancelDownloads();
        }


        if (GUILayout.Button("Display App Store"))
        {
            StoreKitBinding.displayStoreWithProductId("305967442");
        }

        endColumn();
    }
コード例 #8
0
 public void Restore()
 {
     StoreKitBinding.restoreCompletedTransactions();
 }
コード例 #9
0
    void OnGUI()
    {
        return;

        if (GUILayout.Button("Get Can Make Payments"))
        {
            canMakePayments = StoreKitBinding.canMakePayments();
            Debug.Log("StoreKit canMakePayments: " + canMakePayments);
        }


        if (GUILayout.Button("Get Product Data"))
        {
            // array of product ID's from iTunesConnect.  MUST match exactly what you have there!
            var productIdentifiers = new string[] { "com.DMDEnterprise.kicktheballfree.100coins", "com.DMDEnterprise.kicktheballfree.200coins" };
            StoreKitBinding.requestProductData(productIdentifiers);
        }


        if (GUILayout.Button("Restore Completed Transactions"))
        {
            StoreKitBinding.restoreCompletedTransactions();
        }



        // enforce the fact that we can't purchase products until we retrieve the product data
        if (_products != null && _products.Count > 0)
        {
            if (GUILayout.Button("Purchase Random Product"))
            {
                var productIndex = Random.Range(0, _products.Count);
                var product      = _products[productIndex];

                Debug.Log("preparing to purchase product: " + product.productIdentifier);
                StoreKitBinding.purchaseProduct(product.productIdentifier, 1);
            }
        }


        if (GUILayout.Button("Get Saved Transactions"))
        {
            List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions();

            // Print all the transactions to the console
            Debug.Log("\ntotal transaction received: " + transactionList.Count);

            foreach (StoreKitTransaction transaction in transactionList)
            {
                Debug.Log(transaction.ToString() + "\n");
            }
        }


        if (GUILayout.Button("Turn Off Auto Confirmation of Transactions"))
        {
            // this is used when you want to validate receipts on your own server or when dealing with iTunes hosted content
            // you must manually call StoreKitBinding.finishPendingTransactions when the download/validation is complete
            StoreKitManager.autoConfirmTransactions = false;
        }


        if (GUILayout.Button("Display App Store"))
        {
            StoreKitBinding.displayStoreWithProductId("305967442");
        }
    }
コード例 #10
0
 public void RestoreAllPurshesh()
 {
     StoreKitBinding.restoreCompletedTransactions();
 }
コード例 #11
0
    void OnGUI()
    {
        float yPos       = 5.0f;
        float xPos       = 5.0f;
        float width      = (Screen.width >= 960 || Screen.height >= 960) ? 320 : 160;
        float height     = (Screen.width >= 960 || Screen.height >= 960) ? 80 : 40;
        float heightPlus = height + 10.0f;

        if (GUI.Button(new Rect(xPos, yPos, width, height), "Get Can Make Payments"))
        {
            bool canMakePayments = StoreKitBinding.canMakePayments();
            Debug.Log("StoreKit canMakePayments: " + canMakePayments);
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Get Product Data"))
        {
            // array of product ID's from iTunesConnect.  MUST match exactly what you have there!
            var productIdentifiers = new string[] { "anotherProduct", "tt", "testProduct", "sevenDays", "oneMonthSubsciber" };
            StoreKitBinding.requestProductData(productIdentifiers);
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Restore Completed Transactions"))
        {
            StoreKitBinding.restoreCompletedTransactions();
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Validate Receipt"))
        {
            // grab the transactions, then just validate the first one
            List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions();
            if (transactionList.Count > 0)
            {
                StoreKitBinding.validateReceipt(transactionList[0].base64EncodedTransactionReceipt, true);
            }
        }

        // Second column
        xPos = Screen.width - width - 5.0f;
        yPos = 5.0f;

        // enforce the fact that we can't purchase products until we retrieve the product data
        if (_products != null && _products.Count > 0)
        {
            if (GUI.Button(new Rect(xPos, yPos, width, height), "Purchase Random Product"))
            {
                var productIndex = Random.Range(0, _products.Count);
                var product      = _products[productIndex];

                Debug.Log("preparing to purchase product: " + product.productIdentifier);
                StoreKitBinding.purchaseProduct(product.productIdentifier, 1);
            }
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Validate Subscription"))
        {
            // grab the transactions and if we have a subscription in there validate it
            List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions();
            foreach (var t in transactionList)
            {
                if (t.productIdentifier == "sevenDays")
                {
                    StoreKitBinding.validateAutoRenewableReceipt(t.base64EncodedTransactionReceipt, "YOUR_SECRET_FROM_ITC", true);
                    break;
                }
            }
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Get Saved Transactions"))
        {
            List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions();

            // Print all the transactions to the console
            Debug.Log("\ntotal transaction received: " + transactionList.Count);

            foreach (StoreKitTransaction transaction in transactionList)
            {
                Debug.Log(transaction.ToString() + "\n");
            }
        }
    }
コード例 #12
0
    void OnGUI()
    {
        float yPos  = 10.0f;
        float xPos  = 20.0f;
        float width = 210.0f;

        if (GUI.Button(new Rect(xPos, yPos, width, 40), "Get Can Make Payments"))
        {
            bool canMakePayments = StoreKitBinding.canMakePayments();
            Debug.Log("StoreKit canMakePayments: " + canMakePayments);
        }


        if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Get Product Data"))
        {
            // comma delimited list of product ID's from iTunesConnect.  MUST match exactly what you have there!
            string productIdentifiers = "anotherProduct,tt,testProduct,sevenDays,oneMonthSubsciber";
            StoreKitBinding.requestProductData(productIdentifiers);
        }


        if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Restore Completed Transactions"))
        {
            StoreKitBinding.restoreCompletedTransactions();
        }


        if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Validate Receipt"))
        {
            // grab the transactions, then just validate the first one
            List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions();
            if (transactionList.Count > 0)
            {
                StoreKitBinding.validateReceipt(transactionList[0].base64EncodedTransactionReceipt, true);
            }
        }

        // Second column
        xPos += xPos + width;
        yPos  = 10.0f;
        if (GUI.Button(new Rect(xPos, yPos, width, 40), "Purchase Product 1"))
        {
            StoreKitBinding.purchaseProduct("testProduct", 1);
        }


        if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Purchase Product 2"))
        {
            StoreKitBinding.purchaseProduct("anotherProduct", 1);
        }


        if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Purchase Subscription"))
        {
            StoreKitBinding.purchaseProduct("sevenDays", 1);
        }


        if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Validate Subscription"))
        {
            // grab the transactions and if we have a subscription in there validate it
            List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions();
            foreach (var t in transactionList)
            {
                if (t.productIdentifier == "sevenDays")
                {
                    StoreKitBinding.validateAutoRenewableReceipt(t.base64EncodedTransactionReceipt, "YOUR_SECRET_FROM_ITC", true);
                    break;
                }
            }
        }


        if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Get Saved Transactions"))
        {
            List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions();

            // Print all the transactions to the console
            Debug.Log("\ntotal transaction received: " + transactionList.Count);

            foreach (StoreKitTransaction transaction in transactionList)
            {
                Debug.Log(transaction.ToString() + "\n");
            }
        }
    }
コード例 #13
0
    void OnGUI()
    {
        //write your GUI elements for 1280x720
        GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(Screen.width / targetWidth, Screen.height / targetHeight, 1));

        KongregateAPI kongregate = KongregateAPI.GetAPI();

        // isReady() is true if we are on iOS platform and the API is initalized properly
        if (kongregate.IsReady())
        {
#if UNITY_STANDALONE
            if (GUI.Button(new Rect(targetWidth / 2 - 170 - 5, 10, 80, 40), "Reset Data"))
            {
                Kongregate.DataStore dataStore = Kongregate.DataStore.Get("analytics");
                string playerId = dataStore.GetString("player_id", "");
                Debug.Log("PlayerID was: " + playerId);
                dataStore.DeleteAll();
                if (!string.IsNullOrEmpty(playerId))
                {
                    dataStore.SetString("player_id", playerId);
                }
            }
#endif

            // add a simple button to demonstrate hidding and showing the K button
            if (GUI.Button(new Rect(targetWidth / 2 - 80 - 5, 10, 80, 40), "Toggle K"))
            {
                if (kongregate.Mobile.ButtonIsHidden())
                {
                    kongregate.Mobile.ButtonShow();
                }
                else
                {
                    kongregate.Mobile.ButtonHide();
                }
            }

            // add a simple button to demonstrate submitting stats
            if (GUI.Button(new Rect(targetWidth / 2 + 5, 10, 80, 40), "Submit Win"))
            {
                kongregate.Stats.Submit("Wins", 1);
            }

            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "type", "Gold Pack" },
                { "discount_percent", 12.5 },
                { "context_of_offer", "StoreFront" }
            };

            if (mPurchaseReady)
            {
                if (GUI.Button(new Rect(targetWidth / 2 - 170 - 5, 60, 80, 40), "Purchase"))
                {
                    mPurchaseReady = false; // disable button when clicked
#if UNITY_IPHONE && PRIME31_STOREKIT
                    kongregate.Analytics.StartPurchase("com.kongregate.mobile.games.angryBots.t05_coins", 1, fields);
                    StoreKitBinding.purchaseProduct("com.kongregate.mobile.games.angryBots.t05_coins", 1);
#elif UNITY_ANDROID && PRIME31_STOREKIT
                    kongregate.Analytics.StartPurchase("com.kongregate.android.games.angrybots.t03_hard", 1, fields);
                    GoogleIAB.purchaseProduct("com.kongregate.android.games.angrybots.t03_hard");
#elif UNITY_WEBPLAYER || UNITY_WEBGL
                    kongregate.Analytics.StartPurchase("com.kongregate.web.angrybots.t05_hard", 1, fields);

                    // Use the Javascript API to initiate the purchase. Notice in this flow we call finishPurchase via
                    // the Javascript API after the purchase is completed by serializing the game fields needed. You
                    // could also save the game fields into a variable in your Unity script and then call
                    // kongregate.Analytics.FinishPurchase(...) in the Unity callback as well.
                    Application.ExternalEval(string.Format(
                                                 @"kongregate.mtx.purchaseItems(['com.kongregate.web.angrybots.t05_hard'], function(result){{
                var status = result.success ? 'SUCCESS' : 'FAIL';
                var data = result.success ? '{0}' : '{1}';
                kongregate.analytics.finishPurchase(status, result.purchase_id, data);

                // Fire the callback in the Unity code
                kongregateUnitySupport.getUnityObject().SendMessage('Kongregate', 'OnKredPurchaseResult', status);
            }});"
                                                 , Kongregate.Analytics.toAnalyticEventJSON(getPurchaseFields()), Kongregate.Analytics.toAnalyticEventJSON(fields)));
#elif UNITY_STANDALONE
                    kongregate.Analytics.StartPurchase("com.kongregate.mobile.games.angryBots.t05_hard", 1, fields);
#endif
                }

#if UNITY_IPHONE && PRIME31_STOREKIT
                if (GUI.Button(new Rect(targetWidth / 2 + 5, 60, 80, 40), "Restore"))
                {
                    StoreKitBinding.restoreCompletedTransactions();
                }
#endif
                if (mRecentPurchase)
                {
                    GUI.Box(new Rect(targetWidth / 2 - 70, targetHeight / 2 - 30, 140, 60), "Purchase Successful!");
                    if (GUI.Button(new Rect(targetWidth / 2 - 20, targetHeight / 2, 40, 20), "OK"))
                    {
                        mRecentPurchase = false;
                    }
                }
            }

#if UNITY_STANDALONE
            if (!mPurchaseReady)
            {
                if (GUI.Button(new Rect(targetWidth / 2 - 170 - 5, 60, 80, 40), "Finish"))
                {
                    kongregate.Analytics.FinishPurchase("SUCCESS", null, getPurchaseFields());
                    mPurchaseReady = true;
                }

                if (GUI.Button(new Rect(targetWidth / 2 - 80 - 5, 60, 80, 40), "Cancel"))
                {
                    kongregate.Analytics.FinishPurchase("FAIL", null, fields);
                    mPurchaseReady = true;
                }
            }
#endif

            // add text fields to demonstrate submitting generic stat types
            GUI.Label(new Rect(targetWidth / 2 + 95, 10, 50, 20), "Stat:");
            mCustomStatId = GUI.TextField(new Rect(targetWidth / 2 + 140, 10, 80, 20), mCustomStatId);
            GUI.Label(new Rect(targetWidth / 2 + 95, 35, 50, 20), "Value:");
            mCustomStatValue = GUI.TextField(new Rect(targetWidth / 2 + 140, 35, 80, 20), mCustomStatValue);
            if (GUI.Button(new Rect(targetWidth / 2 + 230, 10, 80, 40), "Submit"))
            {
                long value = 0;
                if (long.TryParse(mCustomStatValue, out value))
                {
                    kongregate.Stats.Submit(mCustomStatId, long.Parse(mCustomStatValue));
                }
            }

            if (GUI.Button(new Rect(targetWidth / 2 + 430, 10, 100, 40), "Inventory"))
            {
                mInventory = false;
                kongregate.Mtx.RequestUserItemList();
            }

            GUI.Box(new Rect(5, 105, 200, 60), "");

            if (mInventory)
            {
                GUI.Label(new Rect(10, 110, 200, 20), "Has AWESOME GUN: " + mHasGun);
            }
            else
            {
                GUI.Label(new Rect(10, 110, 200, 20), "Requesting inventory...");
            }

            if (mUsername != null)
            {
                GUI.Label(new Rect(10, 125, 200, 20), "Username: "******", id: " + mUserId);
                GUI.Label(new Rect(10, 140, 200, 20), "KongPlus: " + mHasKongPlus);
            }

            if (GUI.Button(new Rect(targetWidth / 2 + 535, 10, 100, 40), "FBPost"))
            {
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "link", "http://www.kongregate.com" },
                    { "name", "AngryBots" },
                    { "caption", "Testing 123" },
                    { "description", "Test Post" }
                };
#if UNITY_ANDROID && PRIME31_SOCIAL
                FacebookAndroid.showFacebookShareDialog(parameters);
#elif UNITY_IPHONE && PRIME31_SOCIAL
                FacebookBinding.showFacebookShareDialog(parameters);
#endif
            }

            if (GUI.Button(new Rect(targetWidth / 2 + 535, 60, 100, 40), "More Games"))
            {
                kongregate.Mobile.OpenKongregateWindow(Kongregate.Mobile.TARGET_MORE_GAMES);
            }
            if (GUI.Button(new Rect(targetWidth / 2 + 535, 110, 100, 40), "High Scores"))
            {
                kongregate.Mobile.OpenKongregateWindow(Kongregate.Mobile.TARGET_HIGH_SCORES);
            }
            if (GUI.Button(new Rect(targetWidth / 2 + 535, 160, 100, 40), "Support"))
            {
                kongregate.Mobile.OpenKongregateWindow(Kongregate.Mobile.TARGET_SUPPORT);
            }
            if (GUI.Button(new Rect(targetWidth / 2 + 535, 210, 100, 40), "Forums"))
            {
                kongregate.Mobile.OpenKongregateWindow(Kongregate.Mobile.TARGET_FORUMS);
            }

            // add a simple button to demonstrate submitting analytics
            mPlayTimer = new System.Diagnostics.Stopwatch();
            mPlayTimer.Start();
            if (GUI.Button(new Rect(targetWidth / 2 + 330, 10, 80, 40), "Play Ends"))
            {
                DemoAddAnalyticsEvent();
            }

            // if our button is not hidden, we need to draw it
            Rect kButtonRect = new Rect(10, 10, 100, 100);
            if (kongregate.Mobile.ButtonIsNativeRendering())
            {
                //nothing to do, rendering is handled in native SDK
                // NOTE: notification count is not supported by native rendering
            }
            else if (!kongregate.Mobile.ButtonIsHidden())
            {
                // draw the K button
                if (GUI.Button(kButtonRect, mKongButtonTexture))
                {
                    Debug.Log("You clicked the Kong button!");
                    kongregate.Mobile.OpenKongregateWindow();
                }
                if (mNotificationCountTexture)
                {
                    GUI.Label(new Rect(90, 20, 50, 50), mNotificationCountTexture);
                }
            }

            // add buttons for the deep links
            Rect deepLinkButtonsRect = new Rect(kButtonRect.x, kButtonRect.y + kButtonRect.height + 60, 200, 400);
            Rect targetIdLabelRect   = new Rect(deepLinkButtonsRect.x, deepLinkButtonsRect.y + deepLinkButtonsRect.height + 20, 100, 50);
            Rect targetIdTextRect    = new Rect(targetIdLabelRect.x + targetIdLabelRect.width, targetIdLabelRect.y, 100, 50);
            GUI.Label(targetIdLabelRect, "TargetId:");
            mTargetIdText = GUI.TextField(targetIdTextRect, mTargetIdText);
            int deepLinkClick = GUI.SelectionGrid(deepLinkButtonsRect, -1, mDeepLinkTargets, 2);
            if (deepLinkClick >= 0)
            {
                KongregateAPI.GetAPI().Mobile.OpenKongregateWindow(mDeepLinkTargets[deepLinkClick], mTargetIdText);
            }
        } // IsReady
    }     // OnGUI