/** NonConsumables **/ public static bool NonConsumableItemExists(string nonConsItemId) { if (!Application.isEditor) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Calling NonConsumableItemExists with: " + nonConsItemId); #if UNITY_ANDROID bool result = false; AndroidJNI.PushLocalFrame(100); using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) { result = AndroidJNIHandler.CallStatic <bool>(jniStoreInventory, "nonConsumableItemExists", nonConsItemId); } AndroidJNI.PopLocalFrame(IntPtr.Zero); return(result); #elif UNITY_IOS bool result = false; int err = storeInventory_NonConsumableItemExists(nonConsItemId, out result); IOS_ErrorCodes.CheckAndThrowException(err); return(result); #endif } return(false); }
public static int GetGoodUpgradeLevel(string goodItemId) { if (!Application.isEditor) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Calling GetGoodUpgradeLevel with: " + goodItemId); #if UNITY_ANDROID int level = 0; AndroidJNI.PushLocalFrame(100); using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) { level = AndroidJNIHandler.CallStatic <int>(jniStoreInventory, "getGoodUpgradeLevel", goodItemId); } AndroidJNI.PopLocalFrame(IntPtr.Zero); return(level); #elif UNITY_IOS int level = 0; int err = storeInventory_GetGoodUpgradeLevel(goodItemId, out level); IOS_ErrorCodes.CheckAndThrowException(err); return(level); #endif } return(0); }
public static bool IsVirtualGoodEquipped(string goodItemId) { if (!Application.isEditor) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Calling IsVirtualGoodEquipped with: " + goodItemId); #if UNITY_ANDROID bool result = false; AndroidJNI.PushLocalFrame(100); using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) { result = AndroidJNIHandler.CallStatic <bool>(jniStoreInventory, "isVirtualGoodEquipped", goodItemId); } AndroidJNI.PopLocalFrame(IntPtr.Zero); return(result); #elif UNITY_IOS bool result = false; int err = storeInventory_IsVirtualGoodEquipped(goodItemId, out result); IOS_ErrorCodes.CheckAndThrowException(err); return(result); #endif } return(false); }
/** Virtual Items **/ public static int GetItemBalance(string itemId) { if (!Application.isEditor) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Calling GetItemBalance with: " + itemId); #if UNITY_ANDROID && !UNITY_EDITOR AndroidJNI.PushLocalFrame(100); int balance = 0; using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) { balance = AndroidJNIHandler.CallStatic <int>(jniStoreInventory, "getVirtualItemBalance", itemId); } AndroidJNI.PopLocalFrame(IntPtr.Zero); return(balance); #elif UNITY_IOS && !UNITY_EDITOR int balance = 0; int err = storeInventory_GetItemBalance(itemId, out balance); IOS_ErrorCodes.CheckAndThrowException(err); return(balance); #endif } return(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."); } }
public void onClosingStore(string message) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onClosingStore"); Events.OnClosingStore(); }
public void onBillingNotSupported(string message) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onBillingNotSupported"); Events.OnBillingNotSupported(); }
public void onStoreControllerInitialized(string message) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onStoreControllerInitialized"); Events.OnStoreControllerInitialized(); }
public void onUnexpectedErrorInStore(string message) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onUnexpectedErrorInStore"); Events.OnUnexpectedErrorInStore(); }
public void onRestoreTransactionsStarted(string message) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onRestoreTransactionsStarted"); Events.OnRestoreTransactionsStarted(); }
// private static AndroidJavaClass jniStoreInfo = new AndroidJavaClass("com.soomla.unity.StoreInfo"); #endif public static void Initialize(IStoreAssets storeAssets) { #if UNITY_EDITOR StoreInfo.storeAssets = storeAssets; #endif // StoreUtils.LogDebug(TAG, "Adding currency"); JSONObject currencies = new JSONObject(JSONObject.Type.ARRAY); foreach (VirtualCurrency vi in storeAssets.GetCurrencies()) { currencies.Add(vi.toJSONObject()); } // StoreUtils.LogDebug(TAG, "Adding packs"); JSONObject packs = new JSONObject(JSONObject.Type.ARRAY); foreach (VirtualCurrencyPack vi in storeAssets.GetCurrencyPacks()) { packs.Add(vi.toJSONObject()); } // StoreUtils.LogDebug(TAG, "Adding goods"); JSONObject suGoods = new JSONObject(JSONObject.Type.ARRAY); JSONObject ltGoods = new JSONObject(JSONObject.Type.ARRAY); JSONObject eqGoods = new JSONObject(JSONObject.Type.ARRAY); JSONObject upGoods = new JSONObject(JSONObject.Type.ARRAY); JSONObject paGoods = new JSONObject(JSONObject.Type.ARRAY); foreach (VirtualGood g in storeAssets.GetGoods()) { if (g is SingleUseVG) { suGoods.Add(g.toJSONObject()); } else if (g is EquippableVG) { eqGoods.Add(g.toJSONObject()); } else if (g is LifetimeVG) { ltGoods.Add(g.toJSONObject()); } else if (g is SingleUsePackVG) { paGoods.Add(g.toJSONObject()); } else if (g is UpgradeVG) { upGoods.Add(g.toJSONObject()); } } JSONObject goods = new JSONObject(JSONObject.Type.OBJECT); goods.AddField(JSONConsts.STORE_GOODS_SU, suGoods); goods.AddField(JSONConsts.STORE_GOODS_LT, ltGoods); goods.AddField(JSONConsts.STORE_GOODS_EQ, eqGoods); goods.AddField(JSONConsts.STORE_GOODS_UP, upGoods); goods.AddField(JSONConsts.STORE_GOODS_PA, paGoods); // StoreUtils.LogDebug(TAG, "Adding categories"); JSONObject categories = new JSONObject(JSONObject.Type.ARRAY); foreach (VirtualCategory vi in storeAssets.GetCategories()) { categories.Add(vi.toJSONObject()); } // StoreUtils.LogDebug(TAG, "Adding nonConsumables"); JSONObject nonConsumables = new JSONObject(JSONObject.Type.ARRAY); foreach (NonConsumableItem vi in storeAssets.GetNonConsumableItems()) { nonConsumables.Add(vi.toJSONObject()); } // StoreUtils.LogDebug(TAG, "Preparing StoreAssets JSONObject"); JSONObject storeAssetsObj = new JSONObject(JSONObject.Type.OBJECT); storeAssetsObj.AddField(JSONConsts.STORE_CATEGORIES, categories); storeAssetsObj.AddField(JSONConsts.STORE_CURRENCIES, currencies); storeAssetsObj.AddField(JSONConsts.STORE_CURRENCYPACKS, packs); storeAssetsObj.AddField(JSONConsts.STORE_GOODS, goods); storeAssetsObj.AddField(JSONConsts.STORE_NONCONSUMABLES, nonConsumables); string storeAssetsJSON = storeAssetsObj.print(); #if UNITY_ANDROID StoreUtils.LogDebug(TAG, "pushing data to StoreAssets on java side"); using (AndroidJavaClass jniStoreAssets = new AndroidJavaClass("com.soomla.unity.StoreAssets")) { jniStoreAssets.CallStatic("prepare", storeAssets.GetVersion(), storeAssetsJSON); } StoreUtils.LogDebug(TAG, "done! (pushing data to StoreAssets on java side)"); #elif UNITY_IOS StoreUtils.LogDebug(TAG, "pushing data to StoreAssets on ios side"); storeAssets_Init(storeAssets.GetVersion(), storeAssetsJSON); StoreUtils.LogDebug(TAG, "done! (pushing data to StoreAssets on ios side)"); #endif }
// private static AndroidJavaObject jniUnityEventHandler = null; #endif public static void Initialize(IStoreAssets storeAssets) { if (string.IsNullOrEmpty(Soomla.GetInstance().customSecret) || string.IsNullOrEmpty(Soomla.GetInstance().soomSec)) { StoreUtils.LogError(TAG, "SOOMLA/UNITY MISSING customSecret or soomSec !!! Stopping here !!"); throw new ExitGUIException(); } if (Soomla.GetInstance().customSecret == Soomla.ONLY_ONCE_DEFAULT || Soomla.GetInstance().soomSec == Soomla.ONLY_ONCE_DEFAULT) { StoreUtils.LogError(TAG, "SOOMLA/UNITY You have to change customSecret and soomSec !!! Stopping here !!"); throw new ExitGUIException(); } //init SOOM_SEC #if UNITY_ANDROID if (string.IsNullOrEmpty(Soomla.GetInstance().androidPublicKey)) { StoreUtils.LogError(TAG, "SOOMLA/UNITY MISSING publickKey !!! Stopping here !!"); throw new ExitGUIException(); } if (Soomla.GetInstance().androidPublicKey == Soomla.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", Soomla.GetInstance().soomSec); } AndroidJNI.PopLocalFrame(IntPtr.Zero); #elif UNITY_IOS storeController_SetSoomSec(Soomla.GetInstance().soomSec); #endif StoreInfo.Initialize(storeAssets); #if UNITY_ANDROID AndroidJNI.PushLocalFrame(100); 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("initialize", jniStoreAssetsInstance, Soomla.GetInstance().androidPublicKey, Soomla.GetInstance().customSecret); } } //init EventHandler using (AndroidJavaClass jniEventHandler = new AndroidJavaClass("com.soomla.unity.EventHandler")) { jniEventHandler.CallStatic("initialize"); } AndroidJNI.PopLocalFrame(IntPtr.Zero); // setting test mode on Android SetAndroidTestMode(Soomla.GetInstance().androidTestMode); #elif UNITY_IOS storeController_Init(Soomla.GetInstance().customSecret); #endif #if UNITY_EDITOR if (UnityEngine.Random.value < 0.1) { // make billing ddisabled StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Simulate disabled billing"); Events.OnBillingNotSupported(); } else { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Simulate enabled billing"); Events.OnBillingSupported(); } #endif }