Exemple #1
0
    private void Start()
    {
        OpenIAB.mapSku(SKU_MEDKIT, STORE_ONEPF, "onepf.sku_medkit");
        OpenIAB.mapSku(SKU_AMMO, STORE_ONEPF, "onepf.sku_ammo");
        OpenIAB.mapSku(SKU_COWBOY_HAT, STORE_ONEPF, "onepf.sku_cowboy_hat");
        OpenIAB.mapSku(SKU_INFINITE_AMMO, STORE_ONEPF, "onepf.sku_infinite_ammo");

        OpenIAB.init(new Dictionary <string, string> {
            { OpenIAB.STORE_AMAZON, "c18a8ce946f646999c35b3da532aa9e3" },
            { OpenIAB.STORE_GOOGLE, "" },
            { OpenIAB.STORE_TSTORE, "" },
            { OpenIAB.STORE_SAMSUNG, "" },
            { OpenIAB.STORE_YANDEX, "" }
        });
    }
Exemple #2
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 #3
0
    void Start()
    {
        OpenIAB.mapSku(SKU_money_10k, OpenIAB_Android.STORE_GOOGLE, "money_10k");
        OpenIAB.mapSku(SKU_money_25k, OpenIAB_Android.STORE_GOOGLE, "money_25k");
        OpenIAB.mapSku(SKU_money_50k, OpenIAB_Android.STORE_GOOGLE, "money_50k");
        OpenIAB.mapSku(SKU_money_100k, OpenIAB_Android.STORE_GOOGLE, "money_100k");
        OpenIAB.mapSku(SKU_money_1mln, OpenIAB_Android.STORE_GOOGLE, "money_1mln");

        var options = new OnePF.Options();

        options.storeKeys.Add(OpenIAB_Android.STORE_GOOGLE, googleKey);
        OpenIAB.init(options);

        //OpenIAB.consumeProduct();
        input_script = GameObject.Find("MobileInput").GetComponent <InputManager>();
    }
Exemple #4
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 #5
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 #6
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 #7
0
    void InitOpenIAB()
    {
        var googlePublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjGg+p9dYT3X41S8CwJCsdilPjhiLzvdVL2CBT/APh3Nkk4fiFs6cpqecgl+H9h9SmbPhWJ8qrWDiTTV1bLKtlEI4lQkCJ5U8nT13Z6U7VmP7h1A+DHyvEvvF3ox7kZmY4x9LCypHav/7DsS88eWA0zLFm8+juqBprPsGupy6JasSibvC0MWWIcvl3vJ5LCQKppP/1BJV+IE7Y8s0NQFwI2ZcgprFBsqQr/h2r9+zFAcS7D0WtiJq/jS/PJqav/6bXo5UWVXmZCfC6GavucIKybOdybNbb/K0MXqph6MkPaqgYT+If9h/Vlt8tIafWE6SuKtFMk0I8XbqdAfpFbgkzQIDAQAB/uhGQaCoZO/I+fhgpfiwKkDRf+STIWSvJyuSK3GipO7EnADSlAIa1l+dGGL+7fsAuEV+sp0cQOfWSsELB9t9TnEsA3g9lHz4z7EsdiyPl/GOr0ei3KHdGM3t20pqVE/hy48de7daiiKbgg9po99J8bVcZktLwbqc12H1WsCjDYsJjRMz5uDGttFHv1/xojkbqgbsolJK3GcaUhj0z6tkmRxZo64z9LI1TxjaDt3p+mDQxTFBpY0V1mb1BcSAY9ko3rEJes37TEi7HNZCvzrRZGBTfKB62OsQIDAQAB";

        var options = new Options();

        options.storeKeys = new Dictionary <string, string> {
            { OpenIAB_Android.STORE_GOOGLE, googlePublicKey }
        };
        //options.checkInventoryTimeoutMs = Options.INVENTORY_CHECK_TIMEOUT_MS * 2;
        //options.discoveryTimeoutMs = Options.DISCOVER_TIMEOUT_MS * 2;
        //options.checkInventory = false;
        options.verifyMode          = OptionsVerifyMode.VERIFY_SKIP;
        options.storeSearchStrategy = SearchStrategy.INSTALLER_THEN_BEST_FIT;

        OpenIAB.init(options);
    }
Exemple #8
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 #9
0
    private void purchaseSucceededEvent(Purchase purchase)
    {
        Debug.Log("purchaseSucceededEvent: " + purchase);
        _label = "PURCHASED:" + purchase.ToString();

        if (_inventory != null)
        {
            var sk = _inventory.GetSkuDetails(purchase.Sku);
            var pr = 0f;
            float.TryParse(sk.PriceValue, out pr);
            pr *= 100;
            AnalyticsManager.TrackBusinessEvent(sk.CurrencyCode, (int)pr, "pack", sk.Title, "shop");
            Debug.Log("Purchase analytics sent");
        }
        purchaseSucceeded(purchase.Sku);
        OpenIAB.queryInventory();
    }
Exemple #10
0
    public bool Donate()
    {
        if (_isInitialized)
        {
            string randomString = B64X.GetNewKey() + B64X.GetNewKey();

            //real Purchase
            OpenIAB.purchaseProduct(SKU, randomString);
            //ToDo: save payload on server

            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemple #11
0
    private void Start()
    {
        // Map skus for different stores
        OpenIAB.mapSku(SKU, OpenIAB_Android.STORE_GOOGLE, "missileman.paid");
        //OpenIAB.mapSku(SKU, OpenIAB_Android.STORE_GOOGLE, "android.test.purchased");

        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);
    }
Exemple #12
0
    //const string SKU_AdRemove = "com.fss.removead";

    private void Start()
    {
        instance = this;
        //OpenIAB.mapSku (SKU, OpenIAB_iOS.STORE, "fbss");
        OpenIAB.mapSku(PluginManager._insta.inAppRemoveAdID, OpenIAB_iOS.STORE, PluginManager._insta.inAppRemoveAdID);
        OpenIAB.mapSku(PluginManager._insta.inAppRemoveAdID, OpenIAB_Android.STORE_GOOGLE, PluginManager._insta.inAppRemoveAdID);

        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.storeKeys  = new Dictionary <string, string> {
            { OpenIAB_Android.STORE_GOOGLE, PluginManager._insta.publicKeyAndroid }
        };
        OpenIAB.init(options);
    }
Exemple #13
0
    private void Start()
    {
        // SKU's for iOS MUST be mapped. Mappings for other stores are optional
        OpenIAB.mapSku(SKU_MEDKIT, OpenIAB_iOS.STORE, "30_real");
        OpenIAB.mapSku(SKU_AMMO, OpenIAB_iOS.STORE, "75_real");
        OpenIAB.mapSku(SKU_INFINITE_AMMO, OpenIAB_iOS.STORE, "noncons_2");
        OpenIAB.mapSku(SKU_COWBOY_HAT, OpenIAB_iOS.STORE, "noncons_1");

        OpenIAB.mapSku(SKU_MEDKIT, STORE_ONEPF, "onepf.sku_medkit");
        OpenIAB.mapSku(SKU_AMMO, STORE_ONEPF, "onepf.sku_ammo");
        OpenIAB.mapSku(SKU_COWBOY_HAT, STORE_ONEPF, "onepf.sku_cowboy_hat");
        OpenIAB.mapSku(SKU_INFINITE_AMMO, STORE_ONEPF, "onepf.sku_infinite_ammo");

        var options = new OnePF.Options();

        options.storeKeys.Add(OpenIAB_Android.STORE_GOOGLE, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtKiFBiESx95DM1B6acfQVSns4fHR8wwvwzvHTwYac2TWEBdTkvn2tmZwu61NYrp2Puq1qHfgRM2M1pZcfmtUcDwTInP7uD5Gebom8MrOQfC6L8gMj9uksq1MyYq3vhkcHibKhpF47iaLvWsSnzYuwZ0iWGYh71OA2G7S28D1ikQdG+pzJdw9eFi6W+Gmfo0INII30npkNHwxnDv9wZ+eGqvp5M/JqZF3O3p8kjvsUb2IQj7eZlvSAhM/Z2p5XdSi1Os1r2Xu4um0Wv2HcgcbfCJqBwruuZVE+51zyPUMRYkm2/Nv9MyIEHmejvo0wHRmW1iuUzbwgEnkJYxPRqVUKwIDAQAB");
        OpenIAB.init(options);
    }
Exemple #14
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 #15
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 #16
0
    private void Start()
    {
        OpenIAB.mapSku(SKU, OpenIAB_Android.STORE_GOOGLE, SKU);

        init();

        //Consume Product
        //if (_inventory != null && _inventory.HasPurchase(SKU))
        //OpenIAB.consumeProduct(_inventory.GetPurchase(SKU));

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

        //Test Item Unavailable
        //OpenIAB.purchaseProduct("android.test.item_unavailable");

        //Test Purchase Canceled
        //OpenIAB.purchaseProduct("android.test.canceled");
    }
Exemple #17
0
    private void FixedUpdate()
    {
        if (ClickedPurchase.tapped)
        {
            ClickedPurchase.tapped = false;
            OpenIAB.queryInventory(new string[] { SKU });
            //OpenIAB.purchaseProduct("missileman.paid");
        }
        if (ClickedPurchase.query)
        {
            ClickedPurchase.query = false;
            OpenIAB.queryInventory(new string[] { SKU });
            query = true;
        }
//		else if(ClickedRemove.tapped)
//		{
//			ClickedRemove.tapped = false;
//			PlayerPrefs.SetInt("p1a5I8d", 0);
//		}
    }
Exemple #18
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 #19
0
 public void buy_button(int id_button)
 {
     if (id_button == 0)
     {
         OpenIAB.purchaseProduct(SKU_money_10k);
     }
     else if (id_button == 1)
     {
         OpenIAB.purchaseProduct(SKU_money_25k);
     }
     else if (id_button == 2)
     {
         OpenIAB.purchaseProduct(SKU_money_50k);
     }
     else if (id_button == 3)
     {
         OpenIAB.purchaseProduct(SKU_money_100k);
     }
     else if (id_button == 4)
     {
         OpenIAB.purchaseProduct(SKU_money_1mln);
     }
 }
    public void Initialize()
    {
        OpenIABEventManager.purchaseSucceededEvent += OnPurchaseSucceeded;

        OpenIAB.mapSku("buyshe", OpenIAB_Android.STORE_GOOGLE, "buyshe");

        var googlePublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiaoqnY/8dixib9ZY1sYPfBvdc8uhGMZ24HYDGbgtpBiHR5aZ5LuQ9eJgfRLnXeCMZVVD5IqWBtehjTtoq2xsD+yvauYX7mTboq5OEEVwTBfkXYRsGyuIV9CBRBY+2sCE9fGGIu+LwTFA+SucXh3r10J4scANSIINV7VXgqg8AK7xTmU70IwkQwHg2271uIlSHaDpKPXYkYHvo4IifyWOxTE3uiwX4I/RP0IIhRph/zNwGDY6VnhVxjsCS8Ua0EfVdONCLFOiwNitfjdZ22OiAVVfL8aFllVSbGQrC6mzJTtjuSySp+Suu6ZbU+16fmzwFkolybV0ibChNg/ajY3X1QIDAQAB";

        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, googlePublicKey }
        };
        options.storeSearchStrategy = SearchStrategy.INSTALLER_THEN_BEST_FIT;

        OpenIAB.init(options);
    }
Exemple #21
0
    private void OnQueryInventorySucceeded(Inventory inventory)
    {
        Debug.Log("Query inventory succeeded: " + inventory);

        // 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 #22
0
    void init()
    {
        // Application public key
        var googlePublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjN/yjT//IzEY3Jl8hClmpsCst+gDXR1GSu1fTJ132Gusw9YJ4h2pSYHkF9HYRlg2MZ9wZCmZ0iedUfw08XSeOdcjVklLexlgJW2FU64y+pHmp9gIxs6nQvvdm4xkC+TT2eTCYG1/rYSwTdM834UgwxGMAcdVK+HykRJrTpR1i0t2w9iiYWYcYnLscw2bGv1BgtFVjLJdrBqelejvqjDq/xRQGx0K5zXhZltEF+fik71dzAZ7GvxT2ckNu3z6BYrNMUznNepW33Hlo4Hk+ZAPeh3o3NG/TZr6lZIii9ZO18emwhYOvwYCMWS1F+8ECMiXVma2R7/0eH1P5ZETOsLcjQIDAQAB";

        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.storeKeys = new Dictionary <string, string> {
            { OpenIAB_Android.STORE_GOOGLE, googlePublicKey }
        };
        //options.storeSearchStrategy = SearchStrategy.INSTALLER_THEN_BEST_FIT;
        options.availableStoreNames = new string[] { OpenIAB_Android.STORE_GOOGLE };
        options.prefferedStoreNames = new string[] { OpenIAB_Android.STORE_GOOGLE };
        options.storeSearchStrategy = SearchStrategy.INSTALLER_THEN_BEST_FIT;
        // Transmit options and start the service
        OpenIAB.init(options);

        //query inventory
        //OpenIAB.queryInventory(new string[] { SKU });
    }
Exemple #23
0
        public OpenIABClient(Options options)
        {
            WriteLog("initializing client...");
            WriteLog("options.checkInventoryTimeoutMs: {0}", options.checkInventoryTimeoutMs);
            WriteLog("options.discoveryTimeoutMs: {0}", options.discoveryTimeoutMs);
            WriteLog("options.verifyMode: {0}", options.verifyMode);
            WriteLog("options.prefferedStoreNames: {0}", string.Join(", ", options.prefferedStoreNames));
            WriteLog("options.storeKeys: {0}", string.Join(", ", options.storeKeys.Select(i => string.Format("{0}:{1}", i.Key, i.Value.Substring(0, 10) + "...")).ToArray()));

            _options = options;

            WriteLog("subscribing events...");

            if (UnityEngine.Object.FindObjectOfType <OpenIABEventManager>() == null)
            {
                throw new Exception("OpenIABEventManager component missed, please add it to game scene");
            }

            OpenIABEventManager.billingSupportedEvent        += BillingSupportedEvent;
            OpenIABEventManager.queryInventorySucceededEvent += QueryInventorySucceededEvent;

            OpenIABEventManager.purchaseSucceededEvent        += purchase => CompleteTask(Purchased, "purchaseSucceededEvent", purchase);
            OpenIABEventManager.consumePurchaseSucceededEvent += purchase => CompleteTask(Consumed, "consumePurchaseSucceededEvent", purchase);
            OpenIABEventManager.transactionRestoredEvent      += sku => CompleteTask(Restored, "transactionRestoredEvent", sku);
            OpenIABEventManager.restoreSucceededEvent         += () => CompleteTask(RestoreCompleted, "restoreSucceededEvent");

            OpenIABEventManager.billingNotSupportedEvent   += error => { CompleteTask(Failed, "billingNotSupportedEvent", error); _state = State.Unknown; };
            OpenIABEventManager.queryInventoryFailedEvent  += error => CompleteTask(Failed, "queryInventoryFailedEvent", error);
            OpenIABEventManager.purchaseFailedEvent        += (number, error) => CompleteTask(Failed, "purchaseFailedEvent", error);
            OpenIABEventManager.consumePurchaseFailedEvent += error => CompleteTask(Failed, "consumePurchaseFailedEvent", error);
            OpenIABEventManager.restoreFailedEvent         += error => CompleteTask(Failed, "restoreFailedEvent", error);

            #if !UNITY_EDITOR
            OpenIAB.enableDebugLogging(true);
            #endif
        }
Exemple #24
0
 void queryInventory()
 {
     OpenIAB.queryInventory();
 }
Exemple #25
0
 public void purchaseProduct(string good)
 {
     _purchaseDone = false;
     OpenIAB.purchaseProduct(good);
 }
Exemple #26
0
 public void ButtonBuy(Transform button)
 {
     OpenIAB.purchaseProduct(button.parent.name);
 }
Exemple #27
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 #28
0
 private void restoreSucceededEvent()
 {
     restoreSucceeded();
     OpenIAB.queryInventory();
 }
Exemple #29
0
 public void Restore()
 {
     OpenIAB.restoreTransactions();
 }
Exemple #30
0
 public void Buy(string sku = SKU)
 {
     print("Buying - " + sku);
     OpenIAB.purchaseProduct(sku);
 }