Example #1
0
    void OnEnable()
    {
#if UNITY_WEB_PLAYER || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
#else
        if (Debug.isDebugBuild)
        {
            Debug.Log("enabling google IAB");
        }



        GoogleIABManager.consumePurchaseSucceededEvent += (purchase) =>
        {
            GSApi.buyVirtualGoodFromStore(purchase.originalJson, purchase.signature);
            if (Debug.isDebugBuild)
            {
                Debug.Log("consumePurchaseSucceededEvent: " + purchase);
            }
            //GSApi.buyVirtualGoodFromStore(purchase.originalJson,purchase.signature);
        };
        GoogleIABManager.consumePurchaseSucceededEvent += purchaseSucceededEvent;
        GoogleIABManager.queryInventorySucceededEvent  += (purchases, skus) =>
        {
            string[] products = new string[purchases.Count];
            //var convertedProducts = new List<IAPProduct>();
            for (int i = 0; i < purchases.Count; i++)
            {
                products[i] = purchases[i].productId;
                if (Debug.isDebugBuild)
                {
                    Debug.Log(purchases[i].productId);
                }
                if (Debug.isDebugBuild)
                {
                    Debug.Log(purchases[i].packageName);
                }
            }
            GoogleIAB.consumeProducts(products);
        };

        GoogleIABManager.billingSupportedEvent += billingSupportedEvent;
#endif
    }
Example #2
0
    private void IABQueryInventorySucceeded(List <GooglePurchase> arg1, List <GoogleSkuInfo> arg2)
    {
        List <string> skus = new List <string>();

        if (arg1.Count > 1)
        {
            for (int i = 0; i < arg1.Count; i++)
            {
                string  id  = arg1[i].productId;
                IAPUnit iap = mInAppProducts.Find(prod => (prod.IAP_Id == id));

                if (iap.mIAPtypes == IAP_Type.Consumable)
                {
                    skus.Add(iap.IAP_Id);
                }
                else
                {
                    NonConsumedSku.Add(iap.IAP_Id);
                }
            }

            GoogleIAB.consumeProducts(skus.ToArray());
        }
    }
Example #3
0
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("Initialize IAB"))
        {
            var key = "your public key from the Android developer portal here";
            key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmffbbQPr/zqRjP3vkxr1601/eKsXm5kO2NzQge8m7PeUj5V+saeounyL34U8WoZ3BvCRKbw6DrRLs2DMoVuCLq7QtJggBHT/bBSHGczEXGIPjWpw6OQb24EWM0PaTRTH2x2mC/X6RwIKcPLJFmy68T38Eh0DXnF4jjiIoaD0W8AYLjLzv0WvbIfgtJlvmmwvI2/Kta1LRnW3/Ggi5jb9UmXZAUIBz8kQtSH5FUCmFOQHMzekfg8rQ4VO1nlWhnB58UPwsxWt/DNyDfqv2VMeA2+VJG0fkiMl/6vWA7+ianVTU3owXcvxJHseEDUVYo1wEKfhK7ErGB7sxDJx5wHXAwIDAQAB";
            GoogleIAB.init(key);
        }


        if (GUILayout.Button("Query Inventory"))
        {
            // enter all the available skus from the Play Developer Console in this array so that item information can be fetched for them
            var skus = new string[] { "com.prime31.testproduct", "android.test.purchased", "com.prime31.managedproduct", "com.prime31.testsubscription" };
            GoogleIAB.queryInventory(skus);
        }


        if (GUILayout.Button("Are subscriptions supported?"))
        {
            Debug.Log("subscriptions supported: " + GoogleIAB.areSubscriptionsSupported());
        }


        if (GUILayout.Button("Purchase Test Product"))
        {
            GoogleIAB.purchaseProduct("android.test.purchased");
        }


        if (GUILayout.Button("Consume Test Purchase"))
        {
            GoogleIAB.consumeProduct("android.test.purchased");
        }


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


        endColumn(true);


        if (GUILayout.Button("Purchase Real Product"))
        {
            GoogleIAB.purchaseProduct("com.prime31.testproduct", "payload that gets stored and returned");
        }


        if (GUILayout.Button("Purchase Real Subscription"))
        {
            GoogleIAB.purchaseProduct("com.prime31.testsubscription", "subscription payload");
        }


        if (GUILayout.Button("Consume Real Purchase"))
        {
            GoogleIAB.consumeProduct("com.prime31.testproduct");
        }


        if (GUILayout.Button("Enable High Details Logs"))
        {
            GoogleIAB.enableLogging(true);
        }


        if (GUILayout.Button("Consume Multiple Purchases"))
        {
            var skus = new string[] { "com.prime31.testproduct", "android.test.purchased" };
            GoogleIAB.consumeProducts(skus);
        }

        endColumn();
    }
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("Initialize IAB"))
        {
            var key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr4RxjBkG9CEW7Z/ug+F739LXkLiTO6+Igv/2h4WqsYzLUzJJC0RBG4EsKT5LepByCSZ3AD+mBIe13kKQJisLmgtlTspkiEwCqX+oJEpm7FN2iRZX9h7EtE/p/2B2K/hFCUJqe44nliRwUhnmTo7+5v8jy2osNASATAwU4CWr+RlCZ+DnWiDM0WqnIqSiSkluSnay4zYfKzD9zsv7tfj1EYyV96RefYDV+xaBP7F43z9//SfZ5EwNtt/pjzY3y/F5hOCY0YM2foMp5JELZOHHLtTFXMtBvuO5RW62ze+h10T1kcwWAzf19aXHr3AwuKByD94C5ghPVUm/p4M1ZXdEAwIDAQAB";
            //key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmffbbQPr/zqRjP3vkxr1601/eKsXm5kO2NzQge8m7PeUj5V+saeounyL34U8WoZ3BvCRKbw6DrRLs2DMoVuCLq7QtJggBHT/bBSHGczEXGIPjWpw6OQb24EWM0PaTRTH2x2mC/X6RwIKcPLJFmy68T38Eh0DXnF4jjiIoaD0W8AYLjLzv0WvbIfgtJlvmmwvI2/Kta1LRnW3/Ggi5jb9UmXZAUIBz8kQtSH5FUCmFOQHMzekfg8rQ4VO1nlWhnB58UPwsxWt/DNyDfqv2VMeA2+VJG0fkiMl/6vWA7+ianVTU3owXcvxJHseEDUVYo1wEKfhK7ErGB7sxDJx5wHXAwIDAQAB";
            GoogleIAB.init(key);
        }


        if (GUILayout.Button("Query Inventory"))
        {
            // enter all the available skus from the Play Developer Console in this array so that item information can be fetched for them
            var skus = new string[] { "com.prime31.testproduct", "android.test.purchased", "com.prime31.managedproduct", "com.prime31.testsubscription" };
            GoogleIAB.queryInventory(skus);
        }


        if (GUILayout.Button("Are subscriptions supported?"))
        {
            Debug.Log("subscriptions supported: " + GoogleIAB.areSubscriptionsSupported());
        }


        if (GUILayout.Button("Purchase Test Product"))
        {
            GoogleIAB.purchaseProduct("test003");
        }


        if (GUILayout.Button("Consume Test Purchase"))
        {
            GoogleIAB.consumeProduct("test003");
        }


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


        endColumn(true);


        if (GUILayout.Button("Purchase Real Product"))
        {
            GoogleIAB.purchaseProduct("com.prime31.testproduct", "payload that gets stored and returned");
        }


        if (GUILayout.Button("Purchase Real Subscription"))
        {
            GoogleIAB.purchaseProduct("com.prime31.testsubscription", "subscription payload");
        }


        if (GUILayout.Button("Consume Real Purchase"))
        {
            GoogleIAB.consumeProduct("com.prime31.testproduct");
        }


        if (GUILayout.Button("Enable High Details Logs"))
        {
            GoogleIAB.enableLogging(true);
        }


        if (GUILayout.Button("Consume Multiple Purchases"))
        {
            var skus = new string[] { "com.prime31.testproduct", "android.test.purchased" };
            GoogleIAB.consumeProducts(skus);
        }

        endColumn();
    }
Example #5
0
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("Initialize IAB"))
        {
            var key = "your public key from the Android developer portal here";
            key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu6jn+Es/Lp/MaC6HsFY1XDVd7ZRU19b7NnOmjKN4Zs/kgb1/A8g0tlrgs85/yfzmroPIp66SnTsvtuV1bbbNcIwaecswCTHNOAksokZtLlOc7B/90cp1EdNM1ERKxmcLy3nsaCvWkTDSP/+MD0jdI1KLwCTnjsbcNAUy+zSlIu0xmw+lGSoB/0l4xiniF701yLjWct0OMNljOoSOVRiq5/mhXrt8UWHpB/F4JNJB3CbqODALPII5fcg7KNXo7P0Zov+ndAF2UjzSCru1H97bWoQYScdrtCgnrBGuNtInbSw5qUZFaPDouKaRHOgbSU+4a4+7ZcvjEmXpY9AlNAEZrQIDAQAB";
            GoogleIAB.init(key);
        }


        if (GUILayout.Button("Query Inventory"))
        {
            // enter all the available skus from the Play Developer Console in this array so that item information can be fetched for them
            var skus = new string[] { "com.prime31.testproduct", "android.test.purchased", "com.prime31.managedproduct", "com.prime31.testsubscription" };
            GoogleIAB.queryInventory(skus);
        }


        if (GUILayout.Button("Are subscriptions supported?"))
        {
            Debug.Log("subscriptions supported: " + GoogleIAB.areSubscriptionsSupported());
        }


        if (GUILayout.Button("Purchase Test Product"))
        {
            GoogleIAB.purchaseProduct("android.test.purchased");
        }


        if (GUILayout.Button("Consume Test Purchase"))
        {
            GoogleIAB.consumeProduct("android.test.purchased");
        }


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


        endColumn(true);


        if (GUILayout.Button("Purchase Real Product"))
        {
            GoogleIAB.purchaseProduct("ruby_50", "payload that gets stored and returned");
        }


        if (GUILayout.Button("Purchase Real Subscription"))
        {
            GoogleIAB.purchaseProduct("com.prime31.testsubscription", "subscription payload");
        }


        if (GUILayout.Button("Consume Real Purchase"))
        {
            GoogleIAB.consumeProduct("com.prime31.testproduct");
        }


        if (GUILayout.Button("Enable High Details Logs"))
        {
            GoogleIAB.enableLogging(true);
        }


        if (GUILayout.Button("Consume Multiple Purchases"))
        {
            var skus = new string[] { "com.prime31.testproduct", "android.test.purchased" };
            GoogleIAB.consumeProducts(skus);
        }

        endColumn();
    }
Example #6
0
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("*** Initialize IAB"))
        {
            var key = "your public key from the Android developer portal here";
            //key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmffbbQPr/zqRjP3vkxr1601/eKsXm5kO2NzQge8m7PeUj5V+saeounyL34U8WoZ3BvCRKbw6DrRLs2DMoVuCLq7QtJggBHT/bBSHGczEXGIPjWpw6OQb24EWM0PaTRTH2x2mC/X6RwIKcPLJFmy68T38Eh0DXnF4jjiIoaD0W8AYLjLzv0WvbIfgtJlvmmwvI2/Kta1LRnW3/Ggi5jb9UmXZAUIBz8kQtSH5FUCmFOQHMzekfg8rQ4VO1nlWhnB58UPwsxWt/DNyDfqv2VMeA2+VJG0fkiMl/6vWA7+ianVTU3owXcvxJHseEDUVYo1wEKfhK7ErGB7sxDJx5wHXAwIDAQAB";
            key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6CkjzMnNCuwRhqpOelNnvdJkQ6xr3E2I++ubNNOk4GeBx99Fh0wZJZQ6mHB+2b4sD55+rHU2OUavNtM7b8Cu7En4Hkeac1bi4LWf9DiL7OTHz3o6atH9T0gZPewtZb+rkYuXP1GURs+Vt/aKOnAhgOjUsU++KW3rvevnvUMF5hDl3O1XsybepEldJ4aSPvful5NJiIVf3qkiP1jTGcdFTnjznOeGaI9bRmTOrnZIrSsfo5FKcX9hROrolGOy01Oa706yi6xHd6Et0TKtPPbiF8KNB4JUGku/4Uwc37o1osNDVjEp55tyLXP9W4QgXtNNE7tBswvRvGgcMTIcCKUemwIDAQAB";
            GoogleIAB.init(key);
        }

        if (GUILayout.Button("Query Inventory"))
        {
            // enter all the available skus from the Play Developer Console in this array so that item information can be fetched for them
            //var skus = new string[] { "com.prime31.testproduct", "android.test.purchased", "com.prime31.managedproduct", "com.prime31.testsubscription" };
            var skus = new string[] { "xsmall", "small", "medium", "big", "extrabig" };
            GoogleIAB.queryInventory(skus);
        }

        if (GUILayout.Button("Are subscriptions supported?"))
        {
            Debug.Log("subscriptions supported: " + GoogleIAB.areSubscriptionsSupported());
        }

        if (GUILayout.Button("Purchase Test Product"))
        {
            GoogleIAB.purchaseProduct("android.test.purchased");
        }

        if (GUILayout.Button("Consume Test Purchase"))
        {
            GoogleIAB.consumeProduct("android.test.purchased");
        }

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

        endColumn(true);

        if (GUILayout.Button("Purchase Real Product"))
        {
            GoogleIAB.purchaseProduct("com.prime31.testproduct", "payload that gets stored and returned");
        }


        if (GUILayout.Button("Purchase Real Subscription"))
        {
            GoogleIAB.purchaseProduct("com.prime31.testsubscription", "subscription payload");
        }

        if (GUILayout.Button("Consume Real Purchase"))
        {
            GoogleIAB.consumeProduct("com.prime31.testproduct");
        }

        if (GUILayout.Button("Enable High Details Logs"))
        {
            GoogleIAB.enableLogging(true);
        }

        if (GUILayout.Button("Consume Multiple Purchases"))
        {
            var skus = new string[] { "com.prime31.testproduct", "android.test.purchased" };
            GoogleIAB.consumeProducts(skus);
        }

        endColumn();
    }
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("Initialize IAB"))
        {
            var key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApi6+DL/itNA4Qqog3d/wTk4tAxwxQRBF0VbmGv2ry2dhevo7Vi/z8gWTmr6aeQs3R24xCBOyYArceqymT0RKsFsmz7bh6IUc2rO6MftX1QGQdWXSyxYqZo4gOOeMeTYWmpNWubA2riL5hsx1R8mYgSemGW85WCEpRynI5T1yR3ioWoI8Fz3gNyQdcFiwYLn44t9tRX2fMNT3gdxLU4qMlVd+71ArZRyZI/zaYIIFCkRUvDpitYd3aPMzA7LZMGm96zCPd+zpNRptjjU5kG6ezA7JGKx4JJ3/CHKvyKzJrEo5loQLot5bBc+Rw/omyOQgd306P3g72qubFHlFLzFKbwIDAQAB";
            GoogleIAB.init(key);
        }


        if (GUILayout.Button("Query Inventory"))
        {
            // enter all the available skus from the Play Developer Console in this array so that item information can be fetched for them
            var skus = new string[] { "android.test.purchased", "cp1" };
            GoogleIAB.queryInventory(skus);
        }


        if (GUILayout.Button("Are subscriptions supported?"))
        {
            Debug.Log("subscriptions supported: " + GoogleIAB.areSubscriptionsSupported());
        }


        if (GUILayout.Button("Purchase Test Product"))
        {
            GoogleIAB.purchaseProduct("cp1");
        }


        if (GUILayout.Button("Consume Test Purchase"))
        {
            GoogleIAB.consumeProduct("cp1");
        }


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


        endColumn(true);


        if (GUILayout.Button("Purchase Real Product"))
        {
            GoogleIAB.purchaseProduct("com.prime31.testproduct", "payload that gets stored and returned");
        }


        if (GUILayout.Button("Purchase Real Subscription"))
        {
            GoogleIAB.purchaseProduct("com.prime31.testsubscription", "subscription payload");
        }


        if (GUILayout.Button("Consume Real Purchase"))
        {
            GoogleIAB.consumeProduct("com.prime31.testproduct");
        }


        if (GUILayout.Button("Enable High Details Logs"))
        {
            GoogleIAB.enableLogging(true);
        }


        if (GUILayout.Button("Consume Multiple Purchases"))
        {
            var skus = new string[] { "com.prime31.testproduct", "android.test.purchased" };
            GoogleIAB.consumeProducts(skus);
        }

        endColumn();
    }
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("Initialize IAB"))
        {
            var key = "your public key from the Android developer portal here";
            GoogleIAB.init(key);
        }


        if (GUILayout.Button("Query Inventory"))
        {
            // enter all the available skus from the Play Developer Console in this array so that item information can be fetched for them
            var skus = new string[] { "com.prime31.testproduct", "android.test.purchased", "com.prime31.managedproduct", "com.prime31.testsubscription" };
            GoogleIAB.queryInventory(skus);
        }


        if (GUILayout.Button("Are subscriptions supported?"))
        {
            Debug.Log("subscriptions supported: " + GoogleIAB.areSubscriptionsSupported());
        }


        if (GUILayout.Button("Purchase Test Product"))
        {
            GoogleIAB.purchaseProduct("android.test.purchased");
        }


        if (GUILayout.Button("Consume Test Purchase"))
        {
            GoogleIAB.consumeProduct("android.test.purchased");
        }


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


        endColumn(true);


        if (GUILayout.Button("Purchase Real Product"))
        {
            GoogleIAB.purchaseProduct("com.prime31.testproduct", "payload that gets stored and returned");
        }


        if (GUILayout.Button("Purchase Real Subscription"))
        {
            GoogleIAB.purchaseProduct("com.prime31.testsubscription", "subscription payload");
        }


        if (GUILayout.Button("Consume Real Purchase"))
        {
            GoogleIAB.consumeProduct("com.prime31.testproduct");
        }


        if (GUILayout.Button("Enable High Details Logs"))
        {
            GoogleIAB.enableLogging(true);
        }


        if (GUILayout.Button("Consume Multiple Purchases"))
        {
            var skus = new string[] { "com.prime31.testproduct", "android.test.purchased" };
            GoogleIAB.consumeProducts(skus);
        }

        endColumn();
    }