Exemplo n.º 1
0
        protected PurchasableVirtualItem(AndroidJavaObject jniVirtualItem) :
            base(jniVirtualItem)
        {
            StoreUtils.LogDebug(TAG, "Trying to create PurchasableVirtualItem with itemId: " + jniVirtualItem.Call <string>("getItemId"));
            using (AndroidJavaObject jniPurchaseType = jniVirtualItem.Call <AndroidJavaObject>("getPurchaseType")) {
                System.IntPtr cls = AndroidJNI.FindClass("com/soomla/store/purchaseTypes/PurchaseWithMarket");
                if (AndroidJNI.IsInstanceOf(jniPurchaseType.GetRawObject(), cls))
                {
                    using (AndroidJavaObject jniMarketItem = jniPurchaseType.Call <AndroidJavaObject>("getMarketItem")) {
                        PurchaseType = new PurchaseWithMarket(jniMarketItem.Call <string>("getProductId"), jniMarketItem.Call <double>("getPrice"));
                    }
                }
                else
                {
                    cls = AndroidJNI.FindClass("com/soomla/store/purchaseTypes/PurchaseWithVirtualItem");
                    if (AndroidJNI.IsInstanceOf(jniPurchaseType.GetRawObject(), cls))
                    {
                        string itemId = jniPurchaseType.Call <string>("getTargetItemId");
                        int    amount = jniPurchaseType.Call <int>("getAmount");

                        PurchaseType = new PurchaseWithVirtualItem(itemId, amount);
                    }
                    else
                    {
                        StoreUtils.LogError(TAG, "Couldn't determine what type of class is the given purchaseType.");
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// see parent
        /// </returns>
        public override JSONObject toJSONObject()
        {
            JSONObject jsonObject = base.toJSONObject();

            try {
                JSONObject purchasableObj = new JSONObject(JSONObject.Type.OBJECT);

                if (PurchaseType is PurchaseWithMarket)
                {
                    purchasableObj.AddField(JSONConsts.PURCHASE_TYPE, JSONConsts.PURCHASE_TYPE_MARKET);

                    MarketItem mi = ((PurchaseWithMarket)PurchaseType).MarketItem;
                    purchasableObj.AddField(JSONConsts.PURCHASE_MARKET_ITEM, mi.toJSONObject());
                }
                else if (PurchaseType is PurchaseWithVirtualItem)
                {
                    purchasableObj.AddField(JSONConsts.PURCHASE_TYPE, JSONConsts.PURCHASE_TYPE_VI);

                    purchasableObj.AddField(JSONConsts.PURCHASE_VI_ITEMID, ((PurchaseWithVirtualItem)PurchaseType).ItemId);
                    purchasableObj.AddField(JSONConsts.PURCHASE_VI_AMOUNT, ((PurchaseWithVirtualItem)PurchaseType).Amount);
                }

                jsonObject.AddField(JSONConsts.PURCHASABLE_ITEM, purchasableObj);
            } catch (System.Exception e) {
                StoreUtils.LogError(TAG, "An error occurred while generating JSON object. " + e.Message);
            }

            return(jsonObject);
        }
Exemplo n.º 3
0
        public static void Initialize(IStoreAssets storeAssets)
        {
            if (string.IsNullOrEmpty(SoomSettings.CustomSecret) || string.IsNullOrEmpty(SoomSettings.SoomSecret))
            {
                StoreUtils.LogError(TAG, "SOOMLA/UNITY MISSING customSecret or soomSec !!! Stopping here !!");
                throw new ExitGUIException();
            }

            if (SoomSettings.CustomSecret == SoomSettings.ONLY_ONCE_DEFAULT || SoomSettings.SoomSecret == SoomSettings.ONLY_ONCE_DEFAULT)
            {
                StoreUtils.LogError(TAG, "SOOMLA/UNITY You have to change customSecret and soomSec !!! Stopping here !!");
                throw new ExitGUIException();
            }

#if UNITY_ANDROID && !UNITY_EDITOR
            if (string.IsNullOrEmpty(SoomSettings.AndroidPublicKey))
            {
                StoreUtils.LogError(TAG, "SOOMLA/UNITY MISSING publickKey !!! Stopping here !!");
                throw new ExitGUIException();
            }

            if (SoomSettings.AndroidPublicKey == SoomSettings.AND_PUB_KEY_DEFAULT)
            {
                StoreUtils.LogError(TAG, "SOOMLA/UNITY You have to change android publicKey !!! Stopping here !!");
                throw new ExitGUIException();
            }

            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaClass jniStoreAssets = new AndroidJavaClass("com.soomla.unity.StoreAssets")) {
                jniStoreAssets.CallStatic("setSoomSec", SoomSettings.SoomSecret);
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
            storeController_SetSSV(SoomSettings.IosSSV, "https://verify.soom.la/verify_ios?platform=unity4");
            storeController_SetSoomSec(SoomSettings.SoomSecret);
#endif

            StoreInfo.Initialize(storeAssets);
#if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJNI.PushLocalFrame(100);
            //init EventHandler
            using (AndroidJavaClass jniEventHandler = new AndroidJavaClass("com.soomla.unity.EventHandler")) {
                jniEventHandler.CallStatic("initialize");
            }
            using (AndroidJavaObject jniStoreAssetsInstance = new AndroidJavaObject("com.soomla.unity.StoreAssets")) {
                using (AndroidJavaClass jniStoreControllerClass = new AndroidJavaClass("com.soomla.store.StoreController")) {
                    jniStoreController = jniStoreControllerClass.CallStatic <AndroidJavaObject>("getInstance");
                    jniStoreController.Call <bool>("initialize", jniStoreAssetsInstance, SoomSettings.AndroidPublicKey, SoomSettings.CustomSecret);
                }
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
            storeController_Init(SoomSettings.CustomSecret);
#endif
        }
Exemplo n.º 4
0
        public static VirtualItem factoryItemFromJNI(AndroidJavaObject jniItem)
        {
            StoreUtils.LogDebug(TAG, "Trying to create VirtualItem with itemId: " + jniItem.Call <string>("getItemId"));

            if (isInstanceOf(jniItem, "com/soomla/store/domain/virtualGoods/SingleUseVG"))
            {
                return(new SingleUseVG(jniItem));
            }
            else if (isInstanceOf(jniItem, "com/soomla/store/domain/virtualGoods/EquippableVG"))
            {
                return(new EquippableVG(jniItem));
            }
            else if (isInstanceOf(jniItem, "com/soomla/store/domain/virtualGoods/UpgradeVG"))
            {
                return(new UpgradeVG(jniItem));
            }
            else if (isInstanceOf(jniItem, "com/soomla/store/domain/virtualGoods/LifetimeVG"))
            {
                return(new LifetimeVG(jniItem));
            }
            else if (isInstanceOf(jniItem, "com/soomla/store/domain/virtualGoods/SingleUsePackVG"))
            {
                return(new SingleUsePackVG(jniItem));
            }
            else if (isInstanceOf(jniItem, "com/soomla/store/domain/virtualCurrencies/VirtualCurrency"))
            {
                return(new VirtualCurrency(jniItem));
            }
            else if (isInstanceOf(jniItem, "com/soomla/store/domain/virtualCurrencies/VirtualCurrencyPack"))
            {
                return(new VirtualCurrencyPack(jniItem));
            }
            else if (isInstanceOf(jniItem, "com/soomla/store/domain/NonConsumableItem"))
            {
                return(new NonConsumableItem(jniItem));
            }
            else
            {
                StoreUtils.LogError(TAG, "Couldn't determine what type of class is the given jniItem.");
            }

            return(null);
        }
Exemplo n.º 5
0
        public static void SetupSoomSec()
        {
            if (string.IsNullOrEmpty(SoomSettings.SoomSecret))
            {
                StoreUtils.LogError(TAG, "SOOMLA/UNITY MISSING soomSec !!! Stopping here !!");
                throw new ExitGUIException();
            }

            if (SoomSettings.SoomSecret == SoomSettings.ONLY_ONCE_DEFAULT)
            {
                StoreUtils.LogError(TAG, "SOOMLA/UNITY You have to change soomSec !!! Stopping here !!");
                throw new ExitGUIException();
            }

                        #if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaClass jniStoreAssets = new AndroidJavaClass("com.soomla.unity.StoreAssets")) {
                jniStoreAssets.CallStatic("setSoomSec", SoomSettings.SoomSecret);
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
                        #elif UNITY_IOS && !UNITY_EDITOR
            storeController_SetSoomSec(SoomSettings.SoomSecret);
                        #endif
        }
Exemplo n.º 6
0
        /// <summary>
        /// see parent
        /// </returns>
        protected PurchasableVirtualItem(JSONObject jsonItem) :
            base(jsonItem)
        {
            JSONObject purchasableObj = (JSONObject)jsonItem[JSONConsts.PURCHASABLE_ITEM];
            string     purchaseType   = purchasableObj[JSONConsts.PURCHASE_TYPE].str;

            if (purchaseType == JSONConsts.PURCHASE_TYPE_MARKET)
            {
                JSONObject marketItemObj = (JSONObject)purchasableObj[JSONConsts.PURCHASE_MARKET_ITEM];

                PurchaseType = new PurchaseWithMarket(new MarketItem(marketItemObj));
            }
            else if (purchaseType == JSONConsts.PURCHASE_TYPE_VI)
            {
                string itemId = purchasableObj[JSONConsts.PURCHASE_VI_ITEMID].str;
                int    amount = System.Convert.ToInt32(((JSONObject)purchasableObj[JSONConsts.PURCHASE_VI_AMOUNT]).n);

                PurchaseType = new PurchaseWithVirtualItem(itemId, amount);
            }
            else
            {
                StoreUtils.LogError(TAG, "Couldn't determine what type of class is the given purchaseType.");
            }
        }