Exemple #1
0
        // set product to purchased after successful verification (or without)
        // Consumable IAPs must be consumed
        // For non consumable IAPs or subscriptions, alter database entry
        private void PurchaseVerified(string id)
        {
            if (!IAPObjects.ContainsKey(id))
            {
                return;
            }
            IAPObject obj = IAPObjects[id];

            if (obj.type == IAPType.consumable)
            {
                OpenIAB.consumeProduct(inventory.GetPurchase(obj.GetIdentifier()));                 //local id
                return;
            }

            //don't continue if the product is already purchased,
            //for example if we just want to verify an existing product again
            if (DBManager.isPurchased(id))
            {
                return;
            }

            if (obj.type == IAPType.nonConsumable || obj.type == IAPType.subscription)
            {
                DBManager.SetToPurchased(id);
            }

            purchaseSucceededEvent(id);
        }
Exemple #2
0
    private void OnQueryInventorySucceeded(Inventory inventory)
    {
        Debug.Log("Query inventory succeeded: " + inventory);
        foreach (Purchase item in inventory.GetAllPurchases())
        {
            OpenIAB.consumeProduct(item);
        }
//
//		// Do we have the infinite ammo subscription?
//		Purchase infiniteAmmoPurchase = inventory.GetPurchase(SKU_INFINITE_AMMO);
//		bool subscribedToInfiniteAmmo = (infiniteAmmoPurchase != null && VerifyDeveloperPayload(infiniteAmmoPurchase.DeveloperPayload));
//		Debug.Log("User " + (subscribedToInfiniteAmmo ? "HAS" : "DOES NOT HAVE") + " infinite ammo subscription.");
//		if (subscribedToInfiniteAmmo) {
//			_playerAmmoBox.IsInfinite = true;
//		}
//
//		// Check cowboy hat purchase
//		Purchase cowboyHatPurchase = inventory.GetPurchase(SKU_COWBOY_HAT);
//		bool isCowboyHat = (cowboyHatPurchase != null && VerifyDeveloperPayload(cowboyHatPurchase.DeveloperPayload));
//		Debug.Log("User " + (isCowboyHat ? "HAS" : "HAS NO") + " cowboy hat");
//		_playerHat.PutOn = isCowboyHat;
//
//		// Check for delivery of expandable items. If we own some, we should consume everything immediately
//		Purchase medKitPurchase = inventory.GetPurchase(SKU_MEDKIT);
//		if (medKitPurchase  != null && VerifyDeveloperPayload(medKitPurchase.DeveloperPayload)) {
//			//Debug.Log("We have MedKit. Consuming it.");
//			OpenIAB.consumeProduct(inventory.GetPurchase(SKU_MEDKIT));
//		}
//		Purchase ammoPurchase = inventory.GetPurchase(SKU_AMMO);
//		if (ammoPurchase != null && VerifyDeveloperPayload(ammoPurchase.DeveloperPayload)) {
//			//Debug.Log("We have ammo. Consuming it.");
//			OpenIAB.consumeProduct(inventory.GetPurchase(SKU_AMMO));
//		}
    }
Exemple #3
0
    private void OnPurchaseSucceded(Purchase purchase)
    {
        Debug.Log("Purchase succeded: " + purchase.Sku + "; Payload: " + purchase.DeveloperPayload);
        if (!VerifyDeveloperPayload(purchase.DeveloperPayload))
        {
            return;
        }
        switch (purchase.Sku)
        {
        case SKU_MEDKIT:
            OpenIAB.consumeProduct(purchase);
            return;

        case SKU_AMMO:
            OpenIAB.consumeProduct(purchase);
            return;

        case SKU_COWBOY_HAT:
            _playerHat.PutOn = true;
            break;

        case SKU_INFINITE_AMMO:
            _playerAmmoBox.IsInfinite = true;
            break;

        default:
            Debug.LogWarning("Unknown SKU: " + purchase.Sku);
            break;
        }
        _processingPayment = false;
    }
Exemple #4
0
    private void OnPurchaseSucceded(Purchase purchase)
    {
        Debug.Log("Purchase succeded: " + purchase.Sku + "; Payload: " + purchase.DeveloperPayload);

        //MainMap.WasInApp = true;
        PlayerPrefs.SetInt("WasInApp", 1);
        PlayerPrefs.Save();
        _purchaseDone = true;
        InitScriptName.InitScript.Instance.PurchaseSucceded();
        OpenIAB.consumeProduct(purchase);
        if (!VerifyDeveloperPayload(purchase.DeveloperPayload))
        {
            return;
        }
//		switch (purchase.Sku) {
//		case SKU_MEDKIT:
//			OpenIAB.consumeProduct(purchase);
//			return;
//		case SKU_AMMO:
//			OpenIAB.consumeProduct(purchase);
//			return;
//		case SKU_COWBOY_HAT:
//			_playerHat.PutOn = true;
//			break;
//		case SKU_INFINITE_AMMO:
//			_playerAmmoBox.IsInfinite = true;
//			break;
//		default:
//			Debug.LogWarning("Unknown SKU: " + purchase.Sku);
//			break;
//		}
        _processingPayment = false;
    }
Exemple #5
0
    private void OnPurchaseSucceded(Purchase purchase)
    {
        Debug.Log("Purchase succeded: " + purchase.Sku + "; Payload: " + purchase.DeveloperPayload);
        if (!VerifyDeveloperPayload(purchase.DeveloperPayload))
        {
            return;
        }
        switch (purchase.Sku)
        {
        case SKU_GAS:
            OpenIAB.consumeProduct(purchase);
            break;

        case SKU_PREMIUM:
            _isPremium = true;
            _car.SetPremium();
            break;

        case SKU_INFINITE_GAS:
            _subscribedToInfiniteGas = true;
            _tank = TANK_MAX;
            break;

        default:
            Debug.LogWarning("Unknown SKU: " + purchase.Sku);
            break;
        }
        _processingPayment = false;
    }
Exemple #6
0
        public void ConsumeProduct(Purchase purchase, bool anyway = false)
        {
            WriteLog("starting consume: {0}", purchase.Sku);

            if (anyway)
            {
                OpenIAB.consumeProduct(purchase);
            }
            else
            {
                switch (_state)
                {
                case State.Busy:
                    CompleteTask(Failed, "can't consume product", "busy");
                    break;

                case State.Ready:
                    _state = State.Busy;
                    OpenIAB.consumeProduct(purchase);
                    break;

                default:
                    CompleteTask(Failed, "ConsumeProduct", "not initialized");
                    break;
                }
            }
        }
Exemple #7
0
    private void OnPurchaseSucceded(Purchase purchase)
    {
        Debug.Log("Purchase Succeeded - " + purchase.Sku + " and " + PluginManager._insta.inAppRemoveAdID);
        PlayerPrefs.SetInt("InApp", 1);
        PlayerPrefs.Save();
        _purchaseDone = true;
        Debug.Log("Working");

        if (purchase.Sku.Equals(PluginManager._insta.inAppRemoveAdID))
        {
            Debug.Log("Ad Removed");
            PlayerPrefs.SetInt("removeAd", 1);
            PlayerPrefs.Save();
            PluginManager._insta.destroyAds();
            //GameObject.Find ("Canvas").transform.Find ("Panel").transform.Find ("Buttons").transform.Find ("RemoveAdBtn").gameObject.SetActive (false);
            //GameObject.Find ("Canvas").transform.Find ("Panel").transform.Find ("AdRemoved").gameObject.SetActive (true);

            if (Application.loadedLevelName.Equals("Home_scene"))             //msg show only if its home screen
            {
                HomeManager._insta.RemoveAdBtn.SetActive(false);
                HomeManager._insta.myMsg = "Ad Remove Successfully";
                HomeManager._insta.StartCoroutine(HomeManager._insta.ControllerSelection());
            }
        }
        OpenIAB.consumeProduct(purchase);
        _processingPayment = false;
    }
    public void OnPurchaseSucceeded(Purchase purchase)
    {
        if (AudioManager.instance.sfxEnabled)
        {
            this.GetComponent <AudioSource>().Play();
        }

        Debug.Log("OnPurchaseSucceeded");
        OpenIAB.consumeProduct(purchase);

        ValidateGooglePlayPurchaseRequest request = new ValidateGooglePlayPurchaseRequest();

        request.ReceiptJson = purchase.OriginalJson;
        request.Signature   = purchase.Signature;
        PlayFabClientAPI.ValidateGooglePlayPurchase(request, OnValidateCompleted, OnValidateError);

        // calling this before validation?
        UpdateUserDataRequest dataRequest = new UpdateUserDataRequest();

        dataRequest.Data = new Dictionary <string, string>();
        dataRequest.Data.Add(GameConstants.boughtSheKey, "true");
        dataRequest.Permission = UserDataPermission.Public;
        PlayFabClientAPI.UpdateUserData(dataRequest, OnDataUpdateCompleted, OnDataUpdateError);

        AccountManager.instance.BuyShe();
    }
    private void OnPurchaseSucceded(Purchase purchase)
    {
        Debug.Log("Purchase succeded: " + purchase.Sku + "; Payload: " + purchase.DeveloperPayload);
        if (!VerifyDeveloperPayload(purchase.DeveloperPayload))
        {
            return;
        }

        Debug.Log("Purchase JSON: " + purchase.OriginalJson);
        Debug.Log("Purchase Signature: " + purchase.Signature);

        // Check what was purchased and update game
        switch (purchase.Sku)
        {
        case SKU_SMALL_GEM:
            // Consume repair kit
            OpenIAB.consumeProduct(purchase);
            break;

        case SKU_MED_GEM:
            // _ship.IsGodMode = true;
            OpenIAB.consumeProduct(purchase);
            break;;

        case SKU_LARGE_GEM:
            // _ship.IsPremiumSkin = true;
            OpenIAB.consumeProduct(purchase);
            break;

        case SKU_XLARGE_GEM:
            OpenIAB.consumeProduct(purchase);
            break;

        case SKU_MEGA_GEM:
            OpenIAB.consumeProduct(purchase);
            break;

        case SKU_EPIC_GEM:
            OpenIAB.consumeProduct(purchase);
            break;

        default:
            Debug.LogWarning("Unknown SKU: " + purchase.Sku);
            break;
        }

        // _processingPayment = false;
        PF_Bridge.RaiseCallbackSuccess("IAB Purchase Success", PlayFabAPIMethods.MakePurchase, MessageDisplayStyle.none);

        if (Application.platform == RuntimePlatform.Android)
        {
            PF_Bridge.ValidateAndroidPurcahse(purchase.OriginalJson, purchase.Signature);
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            // I have chosen to put the reciept in the developer payload field as this was not being used, and seemed like a good place to pass this through
            PF_Bridge.ValidateIosPurchase(purchase.DeveloperPayload);
        }
    }
Exemple #10
0
 private void OnQueryInventorySucceeded(Inventory inventory)
 {
     Debug.Log("Query inventory succeeded: " + inventory);
     foreach (Purchase item in inventory.GetAllPurchases())
     {
         OpenIAB.consumeProduct(item);
     }
 }
Exemple #11
0
    //возвращает купление продукты для того что бы можно было их повторно купить
    private void ProductDataReceived(Inventory inv)
    {
        List <Purchase> prods = inv.GetAllPurchases();

        for (int i = 0; i < prods.Count; i++)
        {
            OpenIAB.consumeProduct(prods[i]);
        }
    }
Exemple #12
0
        // tries to consume all previous purchases stored on the device.
        // Do not use for production versions! this is for testing only
        private void DebugConsumeProducts()
        {
            Debug.Log("Attempting to consume all purchases.");
            List <Purchase> prods = inventory.GetAllPurchases();

            for (int i = 0; i < prods.Count; i++)
            {
                OpenIAB.consumeProduct(prods[i]);
            }
        }
Exemple #13
0
    private void OnQueryInventorySucceeded(Inventory inventory)
    {
        SkuDetails skusDetail = inventory.GetSkuDetails(ItemPurchaseStore.AndroidStore);

        priceText.text = skusDetail.CurrencyCode + " " + skusDetail.PriceValue;

#if UNITY_ANDROID
        if (inventory.HasPurchase(ItemPurchaseStore.AndroidStore))
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(inventory.GetPurchase(ItemPurchaseStore.AndroidStore));
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#elif UNITY_IOS
        if (inventory.HasPurchase(ItemPurchaseStore.IosStore))
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(inventory.GetPurchase(ItemPurchaseStore.IosStore));
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#elif UNITY_WP8
        if (inventory.HasPurchase(ItemPurchaseStore.WpStore))
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(inventory.GetPurchase(ItemPurchaseStore.WpStore));
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#endif
    }
Exemple #14
0
    private void queryInventorySucceededEvent(Inventory inventory)
    {
        Debug.Log("queryInventorySucceededEvent: " + inventory);
        if (inventory != null)
        {
            _label = inventory.ToString();

            List <Purchase> prods = inventory.GetAllPurchases();

            foreach (Purchase p in prods)
            {
                OpenIAB.consumeProduct(p);
            }
        }
    }
Exemple #15
0
//    private void OnGUI() {
//        float yPos = 5.0f;
//        float xPos = 5.0f;
//        float width = (Screen.width >= 800 || Screen.height >= 800) ? 320 : 160;
//        float height = (Screen.width >= 800 || Screen.height >= 800) ? 80 : 40;
//        float heightPlus = height + 10.0f;
//
////        if (GUI.Button(new Rect(xPos, yPos, width, height), "Initialize OpenIAB")) {
////            // Application public key
////            var public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqibEPHCtfPm3Rn26gbE6vhCc1d6A072im+oWNlkUAJYV//pt1vCkYLqkkw/P2esPSWaw1nt66650vfVYc3sYY6L782n/C+IvZWQt0EaLrqsSoNfN5VqPhPeGf3wqsOvbKw9YqZWyKL4ddZUzRUPex5xIzjHHm3qIJI5v7iFJHOxOj0bLuEG8lH0Ljt/w2bNe4o0XXoshYDqpzIKmKy6OYNQOs8iBTJlfSmPrlGudmldW6CsuAKeVGm+Z+2xx3Xxsx3eSwEgEaUc1ZsMWSGsV6dXgc3JrUvK23JRJUu8X5Ec1OQLyxL3VelD5f0iKVTJ1kw59tMAVZ7DDpzPggWpUkwIDAQAB";
////
////            var options = new Options();
////            options.verifyMode = OptionsVerifyMode.VERIFY_SKIP;
////            options.storeKeys = new Dictionary<string, string> {
////                {OpenIAB_Android.STORE_GOOGLE, public_key}
////            };
////
////            // Transmit options and start the service
////            OpenIAB.init(options);
////        }
//
//        if (!_isInitialized)
//            return;
//
//        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Test Purchase")) {
//            OpenIAB.purchaseProduct("android.test.purchased");
//        }
//
//        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Test Refund")) {
//            OpenIAB.purchaseProduct("android.test.refunded");
//        }
//
//        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Test Item Unavailable")) {
//            OpenIAB.purchaseProduct("android.test.item_unavailable");
//        }
//
//        xPos = Screen.width - width - 5.0f;
//        yPos = 5.0f;
//
//        if (GUI.Button(new Rect(xPos, yPos, width, height), "Test Purchase Canceled")) {
//            OpenIAB.purchaseProduct("android.test.canceled");
//        }
//
//        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Query Inventory")) {
//            OpenIAB.queryInventory(new string[] { SKU });
//        }
//
//        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Purchase Real Product")) {
//            OpenIAB.purchaseProduct(SKU);
//        }
//
//        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Consume Real Product")) {
//            OpenIAB.consumeProduct(Purchase.CreateFromSku(SKU));
//        }
//    }
#endif

#if UNITY_WP8
    void OnGUI()
    {
        if (GUI.Button(new Rect(10, 10, Screen.width * 0.3f, Screen.height * 0.1f), "QUERY INVENTORY"))
        {
            OpenIAB.queryInventory(new string[] { SKU_AMMO, SKU_MEDKIT, SKU_SUBSCRIPTION });
        }
        if (GUI.Button(new Rect(20 + Screen.width * 0.3f, 10, Screen.width * 0.3f, Screen.height * 0.1f), "Purchase"))
        {
            OpenIAB.purchaseProduct(SKU_MEDKIT);
        }
        if (GUI.Button(new Rect(30 + Screen.width * 0.6f, 10, Screen.width * 0.3f, Screen.height * 0.1f), "Consume"))
        {
            OpenIAB.consumeProduct(Purchase.CreateFromSku(SKU_MEDKIT));
        }
        GUI.Label(new Rect(10, 20 + Screen.height * 0.1f, Screen.width, Screen.height), _label);
    }
Exemple #16
0
    //-------------------------------------------------------------------------
    public static void pay(string buy_item_key, string charge_data, _ePayType pay_type)
    {
        if (pay_type == _ePayType.AppStore)
        {
            //OpenIAB.purchaseProduct(buy_item_key);

            if (mInventory != null && mInventory.HasPurchase(buy_item_key))
            {
                OpenIAB.consumeProduct(mInventory.GetPurchase(buy_item_key));
            }
        }
        else
        {
            mIPay.pay(charge_data, (int)pay_type);
        }
    }
Exemple #17
0
    private void OnPurchaseSucceded(Purchase purchase)
    {
        Debug.Log("Purchase succeded: " + purchase.Sku + "; Payload: " + purchase.DeveloperPayload);

        //MainMap.WasInApp = true;
        PlayerPrefs.SetInt("WasInApp", 1);
        PlayerPrefs.Save();
        _purchaseDone = true;
        //InitScriptName.InitScript.Instance.PurchaseSucceded();
        OpenIAB.consumeProduct(purchase);
        if (!VerifyDeveloperPayload(purchase.DeveloperPayload))
        {
            return;
        }

        _processingPayment = false;
    }
Exemple #18
0
    private void OnPurchaseSucceded(Purchase purchase) //to VerifyDeveloperPayload to our own server
    {
#if UNITY_ANDROID
        if (purchase.Sku == ItemPurchaseStore.AndroidStore)
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(purchase);
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#elif UNITY_IOS
        if (purchase.Sku == ItemPurchaseStore.IosStore)
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(purchase);
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#elif UNITY_WP8
        if (purchase.Sku == ItemPurchaseStore.WpStore)
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(purchase);
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#endif
    }
Exemple #19
0
    private void purchaseSucceededEvent(Purchase purchase)
    {
        Debug.Log("purchaseSucceededEvent: " + purchase);
        _label = "PURCHASED:" + purchase.ToString();
        int diamond = 10;

        switch (purchase.Sku)
        {
        case "package1":
            diamond = quatity[0];
            break;

        case "package2":
            diamond = quatity[1];
            break;

        case "package3":
            diamond = quatity[2];
            break;

        case "package4":
            diamond = quatity[3];
            break;

        case "package5":
            diamond = quatity[4];
            break;

        case "package6":
            diamond = quatity[5];
            break;

        default:
            break;
        }
        Debug.Log("------------------------purchase.Sku " + purchase.Sku + " diamond " + diamond);
        GoogleAnalytics.instance.LogScreen("Buy Inapp: " + diamond + " diamonds!");
        VariableSystem.AddDiamond(diamond);
        //Consume purchase
        OpenIAB.consumeProduct(purchase);
#if UNITY_ANDROID
        MobilePlugin.getInstance().ShowToast("Purchase success! You have got " + diamond);
#endif
    }
Exemple #20
0
    private void OnQueryInventorySucceeded(Inventory inventory)
    {
        Debug.Log("Query inventory succeeded: " + inventory);

        /*
         * Check for items we own. Notice that for each purchase, we check
         * the developer payload to see if it's correct! See
         * verifyDeveloperPayload().
         */
        // Do we have the premium upgrade?
        Purchase premiumPurchase = inventory.GetPurchase(SKU_PREMIUM);

        _isPremium = (premiumPurchase != null && VerifyDeveloperPayload(premiumPurchase.DeveloperPayload));
        Debug.Log("User is " + (_isPremium ? "PREMIUM" : "NOT PREMIUM"));
        if (_isPremium)
        {
            _car.SetPremium();
        }
        else
        {
            _car.SetRegular();
        }

        // Do we have the infinite gas plan?
        Purchase infiniteGasPurchase = inventory.GetPurchase(SKU_INFINITE_GAS);

        _subscribedToInfiniteGas = (infiniteGasPurchase != null && VerifyDeveloperPayload(infiniteGasPurchase.DeveloperPayload));
        Debug.Log("User " + (_subscribedToInfiniteGas ? "HAS" : "DOES NOT HAVE") + " infinite gas subscription.");
        if (_subscribedToInfiniteGas)
        {
            _tank = TANK_MAX;
        }

        // Check for gas delivery -- if we own gas, we should fill up the tank immediately
        Purchase gasPurchase = inventory.GetPurchase(SKU_GAS);

        if (gasPurchase != null && VerifyDeveloperPayload(gasPurchase.DeveloperPayload))
        {
            Debug.Log("We have gas. Consuming it.");
            OpenIAB.consumeProduct(inventory.GetPurchase(SKU_GAS));
        }
    }
Exemple #21
0
        // Once we've received the productList, we create a
        // cross-platform version of it and overwrite
        // the existing shop item values with this online data
        // Optional: verify old purchases online.
        private void ProductDataReceived(Inventory inv)
        {
            //store fetched inventory for later access
            inventory = inv;

            //check for non-consumed consumables
            List <Purchase> prods = inv.GetAllPurchases();

            for (int i = 0; i < prods.Count; i++)
            {
                IAPObject obj = GetIAPObject(prods[i].Sku);
                if (obj != null && obj.type == IAPType.consumable)
                {
                    OpenIAB.consumeProduct(prods[i]);
                }
            }

                        #if UNITY_ANDROID
            if ((verificationType == VerificationType.onStart || verificationType == VerificationType.both) &&
                !string.IsNullOrEmpty(serverUrl))
            {
                VerifyReceipts();
            }
                        #endif

            //build live cache
            productCache = new List <IAPArticle>();
            for (int i = 0; i < ids.Length; i++)
            {
                if (inv.GetSkuDetails(ids[i]) != null)
                {
                    productCache.Add(new IAPArticle(inv.GetSkuDetails(ids[i])));
                }
            }

            if (ShopManager.GetInstance())
            {
                ShopManager.OverwriteWithFetch(productCache);
            }
        }
Exemple #22
0
    private void OnGUI()
    {
        _column = 0;
        _row    = 0;

        GUI.skin.button.fontSize = (Screen.width >= SMALL_SCREEN_SIZE || Screen.height >= SMALL_SCREEN_SIZE) ? LARGE_FONT_SIZE : SMALL_FONT_SIZE;

        if (Button("Initialize OpenIAB"))
        {
            // Application public key
            var googlePublicKey  = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgEEaiFfxugLWAH4CQqXYttXlj3GI2ozlcnWlZDaO2VYkcUhbrAz368FMmw2g40zgIDfyopFqETXf0dMTDw7VH3JOXZID2ATtTfBXaU4hqTf2lSwcY9RXe/Uz0x1nf1oLAf85oWZ7uuXScR747ekzRZB4vb4afm2DsbE30ohZD/WzQ22xByX6583yYE19RdE9yJzFckEPlHuOeMgKOa4WErt11PHB6FTdT5eN96/jjjeEoYhX/NGkOWKW0Y0T0A7CdUC0D4t2xxkzAQHdgLfcRw9+/EIcaysLhncWYiCifJrRBGpqZU1IrNuehrC5FXUN99786c/TwlxNG5nflE6sWwIDAQAB";
            var yandexPublicKey  = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApvU8l4ONEEsSGznPN6DnjIbJnv6vEgm08nbbi+2fMc0V46N7x7jBWTWAf2K6XLZg/rLUkqbWISq12PLvt7ydcsD+Hb9ZubdN2h8LNCTohVPeDbJjd5khtF4J5FNP2/XSTc1C7cSCBTGmqH0fUr77v4x/JMpxKlSjPN6KbNnaF2BLDAdi3012lz2XX4BVgUj7LArID/vYSYGlwMzMkvhUSpvZOM/WIPN+8YDgQAFBlRGRjLhY/3Vpq/AtXtVAzzyfTOZYkwNqdXpwAq5+/51LphowUI5NEBYh8lhQeOJmPNA6EcF1h5L9cJTVLy3bkuCXcjoN2eEO1Nq0h/40G0R4pwIDAQAB";
            var slideMePublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAogOQb0mMbuq4FQ4ZhWRhN8k76/gXOUE370VubZa9Up25GdptYXoRNniecUTDLyjfvWp7+YFW8iPqIp523qNXtQ0EynNhK4xNLvJCd1CjfAju6M0f+o8MOL1zV7g3dHqxICZoHwqBbQOWneDzG/DzJ22AVdLKwty0qbv8ESaCOCJe31ZnoYVMw5KNVkSuRrrhiGGh6xj7F3qZ0T5TOSp3fK7soDamQLevuU7Ndn5IQACjo92HNN0O2PR2cvEjkCRuIkNk2hnqinac984JCzCC0SC/JBnUZUAeYJ7Y8sjT+79z1T1g7yGgDesopnqORiBkeXEZHrFy7PifdA/ZX7rRwQIDAQAB";

            var options = new Options();
            options.checkInventoryTimeoutMs = Options.INVENTORY_CHECK_TIMEOUT_MS * 2;
            options.discoveryTimeoutMs      = Options.DISCOVER_TIMEOUT_MS * 2;
            options.checkInventory          = false;
            options.verifyMode          = OptionsVerifyMode.VERIFY_SKIP;
            options.prefferedStoreNames = new string[] { OpenIAB_Android.STORE_AMAZON };
            options.availableStoreNames = new string[] { OpenIAB_Android.STORE_AMAZON };
            options.storeKeys           = new Dictionary <string, string> {
                { OpenIAB_Android.STORE_GOOGLE, googlePublicKey }
            };
            options.storeKeys = new Dictionary <string, string> {
                { OpenIAB_Android.STORE_YANDEX, yandexPublicKey }
            };
            options.storeKeys = new Dictionary <string, string> {
                { OpenIAB_Android.STORE_SLIDEME, slideMePublicKey }
            };
            options.storeSearchStrategy = SearchStrategy.INSTALLER_THEN_BEST_FIT;

            // Transmit options and start the service
            OpenIAB.init(options);
        }

        if (!_isInitialized)
        {
            return;
        }

        if (Button("Query Inventory"))
        {
            OpenIAB.queryInventory(new string[] { SKU });
        }

        if (Button("Purchase Product"))
        {
            OpenIAB.purchaseProduct(SKU);
        }

        if (Button("Consume Product"))
        {
            if (_inventory != null && _inventory.HasPurchase(SKU))
            {
                OpenIAB.consumeProduct(_inventory.GetPurchase(SKU));
            }
        }

// Android specific buttons
#if UNITY_ANDROID
        if (Button("Test Purchase"))
        {
            OpenIAB.purchaseProduct("android.test.purchased");
        }

        if (Button("Test Consume"))
        {
            if (_inventory != null && _inventory.HasPurchase("android.test.purchased"))
            {
                OpenIAB.consumeProduct(_inventory.GetPurchase("android.test.purchased"));
            }
        }

        if (Button("Test Item Unavailable"))
        {
            OpenIAB.purchaseProduct("android.test.item_unavailable");
        }

        if (Button("Test Purchase Canceled"))
        {
            OpenIAB.purchaseProduct("android.test.canceled");
        }
#endif
    }
Exemple #23
0
    private void OnGUI()
    {
        _column = 0;
        _row    = 0;

        GUI.skin.button.fontSize = (Screen.width >= SMALL_SCREEN_SIZE || Screen.height >= SMALL_SCREEN_SIZE) ? LARGE_FONT_SIZE : SMALL_FONT_SIZE;

        if (Button("Initialize OpenIAB"))
        {
            // Application public key
            var publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgEEaiFfxugLWAH4CQqXYttXlj3GI2ozlcnWlZDaO2VYkcUhbrAz368FMmw2g40zgIDfyopFqETXf0dMTDw7VH3JOXZID2ATtTfBXaU4hqTf2lSwcY9RXe/Uz0x1nf1oLAf85oWZ7uuXScR747ekzRZB4vb4afm2DsbE30ohZD/WzQ22xByX6583yYE19RdE9yJzFckEPlHuOeMgKOa4WErt11PHB6FTdT5eN96/jjjeEoYhX/NGkOWKW0Y0T0A7CdUC0D4t2xxkzAQHdgLfcRw9+/EIcaysLhncWYiCifJrRBGpqZU1IrNuehrC5FXUN99786c/TwlxNG5nflE6sWwIDAQAB";

            var options = new Options();
            options.checkInventoryTimeoutMs = Options.INVENTORY_CHECK_TIMEOUT_MS * 2;
            options.discoveryTimeoutMs      = Options.DISCOVER_TIMEOUT_MS * 2;
            options.checkInventory          = false;
            options.verifyMode          = OptionsVerifyMode.VERIFY_SKIP;
            options.prefferedStoreNames = new string[] { OpenIAB_Android.STORE_GOOGLE };
            options.availableStoreNames = new string[] { OpenIAB_Android.STORE_GOOGLE };
            options.storeKeys           = new Dictionary <string, string> {
                { OpenIAB_Android.STORE_GOOGLE, publicKey }
            };
            options.storeSearchStrategy = SearchStrategy.INSTALLER_THEN_BEST_FIT;

            // Transmit options and start the service
            OpenIAB.init(options);
        }

        if (!_isInitialized)
        {
            return;
        }

        if (Button("Query Inventory"))
        {
            OpenIAB.queryInventory(new string[] { SKU });
        }

        if (Button("Purchase Product"))
        {
            OpenIAB.purchaseProduct(SKU);
        }

        if (Button("Consume Product"))
        {
            if (_inventory != null && _inventory.HasPurchase(SKU))
            {
                OpenIAB.consumeProduct(_inventory.GetPurchase(SKU));
            }
        }

// Android specific buttons
#if UNITY_ANDROID
        if (Button("Test Purchase"))
        {
            OpenIAB.purchaseProduct("android.test.purchased");
        }

        if (Button("Test Consume"))
        {
            if (_inventory != null && _inventory.HasPurchase("android.test.purchased"))
            {
                OpenIAB.consumeProduct(_inventory.GetPurchase("android.test.purchased"));
            }
        }

        if (Button("Test Item Unavailable"))
        {
            OpenIAB.purchaseProduct("android.test.item_unavailable");
        }

        if (Button("Test Purchase Canceled"))
        {
            OpenIAB.purchaseProduct("android.test.canceled");
        }
#endif
    }
Exemple #24
0
    private void OnGUI()
    {
        float yPos       = 5.0f;
        float xPos       = 5.0f;
        float width      = (Screen.width >= 800 || Screen.height >= 800) ? 320 : 160;
        float height     = (Screen.width >= 800 || Screen.height >= 800) ? 80 : 40;
        float heightPlus = height + 10.0f;

        if (GUI.Button(new Rect(xPos, yPos, width, height), "Initialize OpenIAB"))
        {
            // Application public key
            var public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqibEPHCtfPm3Rn26gbE6vhCc1d6A072im+oWNlkUAJYV//pt1vCkYLqkkw/P2esPSWaw1nt66650vfVYc3sYY6L782n/C+IvZWQt0EaLrqsSoNfN5VqPhPeGf3wqsOvbKw9YqZWyKL4ddZUzRUPex5xIzjHHm3qIJI5v7iFJHOxOj0bLuEG8lH0Ljt/w2bNe4o0XXoshYDqpzIKmKy6OYNQOs8iBTJlfSmPrlGudmldW6CsuAKeVGm+Z+2xx3Xxsx3eSwEgEaUc1ZsMWSGsV6dXgc3JrUvK23JRJUu8X5Ec1OQLyxL3VelD5f0iKVTJ1kw59tMAVZ7DDpzPggWpUkwIDAQAB";

            var options = new Options();
            options.verifyMode = OptionsVerifyMode.VERIFY_SKIP;
            options.storeKeys  = new Dictionary <string, string> {
                { OpenIAB_Android.STORE_GOOGLE, public_key }
            };

            // Transmit options and start the service
            OpenIAB.init(options);
        }

        if (!_isInitialized)
        {
            return;
        }

        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Test Purchase"))
        {
            OpenIAB.purchaseProduct("android.test.purchased");
        }

        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Test Refund"))
        {
            OpenIAB.purchaseProduct("android.test.refunded");
        }

        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Test Item Unavailable"))
        {
            OpenIAB.purchaseProduct("android.test.item_unavailable");
        }

        xPos = Screen.width - width - 5.0f;
        yPos = 5.0f;

        if (GUI.Button(new Rect(xPos, yPos, width, height), "Test Purchase Canceled"))
        {
            OpenIAB.purchaseProduct("android.test.canceled");
        }

        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Query Inventory"))
        {
            OpenIAB.queryInventory(new string[] { SKU });
        }

        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Purchase Real Product"))
        {
            OpenIAB.purchaseProduct(SKU);
        }

        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Consume Real Product"))
        {
            OpenIAB.consumeProduct(Purchase.CreateFromSku(SKU));
        }
    }
    private void OnGUI()
    {
        _column = 0;
        _row    = 0;

        GUI.skin.button.fontSize = (Screen.width >= SMALL_SCREEN_SIZE || Screen.height >= SMALL_SCREEN_SIZE) ? LARGE_FONT_SIZE : SMALL_FONT_SIZE;

        if (Button("Initialize OpenIAB"))
        {
            // Application public key
            var publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqibEPHCtfPm3Rn26gbE6vhCc1d6A072im+oWNlkUAJYV//pt1vCkYLqkkw/P2esPSWaw1nt66650vfVYc3sYY6L782n/C+IvZWQt0EaLrqsSoNfN5VqPhPeGf3wqsOvbKw9YqZWyKL4ddZUzRUPex5xIzjHHm3qIJI5v7iFJHOxOj0bLuEG8lH0Ljt/w2bNe4o0XXoshYDqpzIKmKy6OYNQOs8iBTJlfSmPrlGudmldW6CsuAKeVGm+Z+2xx3Xxsx3eSwEgEaUc1ZsMWSGsV6dXgc3JrUvK23JRJUu8X5Ec1OQLyxL3VelD5f0iKVTJ1kw59tMAVZ7DDpzPggWpUkwIDAQAB";

            var options = new Options();
            options.verifyMode = OptionsVerifyMode.VERIFY_SKIP;
            options.storeKeys  = new Dictionary <string, string> {
                { OpenIAB_Android.STORE_GOOGLE, publicKey }
            };

            // Transmit options and start the service
            OpenIAB.init(options);
        }

        if (!_isInitialized)
        {
            return;
        }

        if (Button("Query Inventory"))
        {
            OpenIAB.queryInventory(new string[] { SKU });
        }

        if (Button("Purchase Product"))
        {
            OpenIAB.purchaseProduct(SKU);
        }

        if (Button("Consume Product"))
        {
            OpenIAB.consumeProduct(Purchase.CreateFromSku(SKU));
        }

// Android specific buttons
#if UNITY_ANDROID
        if (Button("Test Purchase"))
        {
            OpenIAB.purchaseProduct("android.test.purchased");
        }

        if (Button("Test Refund"))
        {
            OpenIAB.purchaseProduct("android.test.refunded");
        }

        if (Button("Test Item Unavailable"))
        {
            OpenIAB.purchaseProduct("android.test.item_unavailable");
        }

        if (Button("Test Purchase Canceled"))
        {
            OpenIAB.purchaseProduct("android.test.canceled");
        }
#endif
    }