public static void Initialize(IStoreAssets storeAssets) { if (string.IsNullOrEmpty(SoomSettings.CustomSecret)) { StoreUtils.LogError(TAG, "SOOMLA/UNITY MISSING customSecret !!! Stopping here !!"); throw new ExitGUIException(); } if (SoomSettings.CustomSecret==SoomSettings.ONLY_ONCE_DEFAULT) { StoreUtils.LogError(TAG, "SOOMLA/UNITY You have to change customSecret !!! Stopping here !!"); throw new ExitGUIException(); } 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(); } instance._setupSoomSec(); instance._initialize(storeAssets); }
protected override void _initialize(IStoreAssets storeAssets) { 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(); } StoreInfo.Initialize(storeAssets); 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); }
/// <summary> /// Initializes the SOOMLA SDK. /// </summary> /// <param name="storeAssets">Your game's economy.</param> /// <exception cref="ExitGUIException">Thrown if soomlaSecret is missing or has not been changed. /// </exception> protected override void _initialize(IStoreAssets storeAssets) { if (StoreSettings.GPlayBP && (string.IsNullOrEmpty(StoreSettings.AndroidPublicKey) || StoreSettings.AndroidPublicKey==StoreSettings.AND_PUB_KEY_DEFAULT)) { SoomlaUtils.LogError(TAG, "SOOMLA/UNITY You chose Google Play billing service but publicKey is not set!! Stopping here!!"); throw new ExitGUIException(); } StoreInfo.Initialize(storeAssets); AndroidJNI.PushLocalFrame(100); using(AndroidJavaObject jniStoreAssetsInstance = new AndroidJavaObject("com.soomla.unity.StoreAssets")) { using(AndroidJavaClass jniSoomlaStoreClass = new AndroidJavaClass("com.soomla.store.SoomlaStore")) { jniSoomlaStore = jniSoomlaStoreClass.CallStatic<AndroidJavaObject>("getInstance"); jniSoomlaStore.Call<bool>("initialize", jniStoreAssetsInstance); } } if (StoreSettings.GPlayBP) { using(AndroidJavaClass jniGooglePlayIabServiceClass = new AndroidJavaClass("com.soomla.store.billing.google.GooglePlayIabService")) { AndroidJavaObject jniGooglePlayIabService = jniGooglePlayIabServiceClass.CallStatic<AndroidJavaObject>("getInstance"); jniGooglePlayIabService.Call("setPublicKey", StoreSettings.AndroidPublicKey); jniGooglePlayIabServiceClass.SetStatic("AllowAndroidTestPurchases", StoreSettings.AndroidTestPurchases); } } AndroidJNI.PopLocalFrame(IntPtr.Zero); }
public static void Initialize(IStoreAssets storeAssets) { if (string.IsNullOrEmpty(Soomla.GetInstance().publicKey) || string.IsNullOrEmpty(Soomla.GetInstance().customSecret) || string.IsNullOrEmpty(Soomla.GetInstance().soomSec)) { Debug.Log("SOOMLA/UNITY MISSING publickKey or customSecret or soomSec !!! Stopping here !!"); throw new ExitGUIException(); } //init SOOM_SEC #if UNITY_ANDROID 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().publicKey, Soomla.GetInstance().customSecret); } } //init EventHandler using(AndroidJavaClass jniEventHandler = new AndroidJavaClass("com.soomla.unity.EventHandler")) { jniEventHandler.CallStatic("initialize"); } AndroidJNI.PopLocalFrame(IntPtr.Zero); #elif UNITY_IOS storeController_Init(Soomla.GetInstance().customSecret); #endif }
/// <summary> /// Initializes the SOOMLA SDK. /// This initializer also initializes StoreInfo. /// </summary> /// /// <param name="storeAssets"> The store assets. </param> /// <param name="testMode"> Run in testmode for store IAP </param> /// /// <returns> true if it succeeds, false if it fails. </returns> public bool initialize(IStoreAssets storeAssets, bool testMode) { if (mInitialized) { String err = "SoomlaStore is already initialized. You can't initialize it twice!"; handleErrorResult(err); return(false); } StoreConfig.STORE_TEST_MODE = testMode; StoreManager.OnItemPurchasedCB += handleSuccessfulPurchase; StoreManager.OnItemPurchaseCancelCB += handleCancelledPurchase; StoreManager.OnListingLoadedCB += refreshMarketItemsDetails; StoreManager.GetInstance().Initialize(); SoomlaUtils.LogDebug(TAG, "SoomlaStore Initializing ..."); StoreInfo.setStoreAssets(storeAssets); // Update SOOMLA store from DB StoreInfo.initializeFromDB(); refreshInventory(); mInitialized = true; StoreEvents.GetInstance().PostSoomlaStoreInitializedEvent(); return(true); }
/// <summary> /// Initializes the SOOMLA SDK. /// </summary> /// <param name="storeAssets">Your game's economy.</param> /// <exception cref="ExitGUIException">Thrown if customSecret or soomSec is missing or has not been changed. /// </exception> public static void Initialize(IStoreAssets storeAssets) { if (string.IsNullOrEmpty(SoomSettings.CustomSecret)) { Utils.LogError(TAG, "SOOMLA/UNITY MISSING customSecret !!! Stopping here !!"); throw new ExitGUIException(); } if (SoomSettings.CustomSecret == SoomSettings.ONLY_ONCE_DEFAULT) { Utils.LogError(TAG, "SOOMLA/UNITY You have to change customSecret !!! Stopping here !!"); throw new ExitGUIException(); } if (string.IsNullOrEmpty(SoomSettings.SoomSecret)) { Utils.LogError(TAG, "SOOMLA/UNITY MISSING soomSec !!! Stopping here !!"); throw new ExitGUIException(); } if (SoomSettings.SoomSecret == SoomSettings.ONLY_ONCE_DEFAULT) { Utils.LogError(TAG, "SOOMLA/UNITY You have to change soomSec !!! Stopping here !!"); throw new ExitGUIException(); } instance._setupSoomSec(); instance._initialize(storeAssets); }
/// <summary> /// Initializes the SOOMLA SDK. /// This initializer also initializes StoreInfo. /// </summary> /// /// <param name="storeAssets"> The store assets. </param> /// <param name="testMode"> Run in testmode for store IAP </param> /// /// <returns> true if it succeeds, false if it fails. </returns> public bool initialize(IStoreAssets storeAssets, bool testMode) { if (mInitialized) { String err = "SoomlaStore is already initialized. You can't initialize it twice!"; handleErrorResult(err); return(false); } StoreConfig.STORE_TEST_MODE = testMode; initStoreManager(); SoomlaUtils.LogDebug(TAG, "SoomlaStore Initializing ..."); StoreInfo.setStoreAssets(storeAssets); // Update SOOMLA store from DB StoreInfo.initializeFromDB(); refreshInventory(); mInitialized = true; BusProvider.Instance.Post(new SoomlaStoreInitializedEvent()); return(true); }
/// <summary> /// Initializes the SOOMLA SDK. /// </summary> /// <param name="storeAssets">Your game's economy.</param> /// <exception cref="ExitGUIException">Thrown if soomlaSecret is missing or has not been changed. /// </exception> protected override void _initialize(IStoreAssets storeAssets) { if (StoreSettings.GPlayBP && (string.IsNullOrEmpty(StoreSettings.AndroidPublicKey) || StoreSettings.AndroidPublicKey == StoreSettings.AND_PUB_KEY_DEFAULT)) { SoomlaUtils.LogError(TAG, "SOOMLA/UNITY You chose Google Play billing service but publicKey is not set!! Stopping here!!"); throw new ExitGUIException(); } StoreInfo.Initialize(storeAssets); AndroidJNI.PushLocalFrame(100); using (AndroidJavaObject jniStoreAssetsInstance = new AndroidJavaObject("com.soomla.unity.StoreAssets")) { using (AndroidJavaClass jniSoomlaStoreClass = new AndroidJavaClass("com.soomla.store.SoomlaStore")) { jniSoomlaStore = jniSoomlaStoreClass.CallStatic <AndroidJavaObject>("getInstance"); jniSoomlaStore.Call <bool>("initialize", jniStoreAssetsInstance); } } if (StoreSettings.GPlayBP) { using (AndroidJavaClass jniGooglePlayIabServiceClass = new AndroidJavaClass("com.soomla.store.billing.google.GooglePlayIabService")) { AndroidJavaObject jniGooglePlayIabService = jniGooglePlayIabServiceClass.CallStatic <AndroidJavaObject>("getInstance"); jniGooglePlayIabService.Call("setPublicKey", StoreSettings.AndroidPublicKey); jniGooglePlayIabServiceClass.SetStatic("AllowAndroidTestPurchases", StoreSettings.AndroidTestPurchases); } } AndroidJNI.PopLocalFrame(IntPtr.Zero); }
/// <summary> /// Initializes the SOOMLA SDK. /// This initializer also initializes StoreInfo. /// </summary> /// /// <param name="storeAssets"> The store assets. </param> /// <param name="testMode"> Run in testmode for store IAP </param> /// /// <returns> true if it succeeds, false if it fails. </returns> public bool initialize(IStoreAssets storeAssets, bool testMode) { if (mInitialized) { String err = "SoomlaStore is already initialized. You can't initialize it twice!"; handleErrorResult(err); return false; } StoreConfig.STORE_TEST_MODE = testMode; initStoreManager(); SoomlaUtils.LogDebug(TAG, "SoomlaStore Initializing ..."); StoreInfo.setStoreAssets(storeAssets); // Update SOOMLA store from DB StoreInfo.initializeFromDB(); refreshInventory(); mInitialized = true; BusProvider.Instance.Post(new SoomlaStoreInitializedEvent()); return true; }
/** Protected Functions **/ /** These protected virtual functions will only run when in editor **/ virtual protected void _setStoreAssets(IStoreAssets storeAssets) { #if UNITY_EDITOR string storeJSON = IStoreAssetsToJSON(storeAssets); KeyValueStorage.SetValue(keyMetaStoreInfo(), storeJSON); #endif }
/// <summary> /// Initializes <c>StoreInfo</c>. /// On first initialization, when the database doesn't have any previous version of the store /// metadata, <c>StoreInfo</c> gets loaded from the given <c>IStoreAssets</c>. /// After the first initialization, <c>StoreInfo</c> will be initialized from the database. /// /// IMPORTANT: If you want to override the current <c>StoreInfo</c>, you'll have to bump /// the version of your implementation of <c>IStoreAssets</c> in order to remove the /// metadata when the application loads. Bumping the version is done by returning a higher /// number in <c>IStoreAssets</c>'s <c>getVersion</c>. /// </summary> /// <param name="storeAssets">your game's economy</param> override protected void _setStoreAssets(IStoreAssets storeAssets) { SoomlaUtils.LogDebug(TAG, "pushing IStoreAssets to StoreInfo on iOS side"); string storeAssetsJSON = IStoreAssetsToJSON(storeAssets); int version = storeAssets.GetVersion(); int err = storeInfo_SetStoreAssets(storeAssetsJSON, version); IOS_ErrorCodes.CheckAndThrowException(err); SoomlaUtils.LogDebug(TAG, "done! (pushing data to StoreAssets on iOS side)"); }
// 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 && !UNITY_EDITOR 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 && !UNITY_EDITOR storeController_SetSSV(Soomla.GetInstance().iosServerSideVerification); storeController_SetSoomSec(Soomla.GetInstance().soomSec); #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("initialize", jniStoreAssetsInstance, Soomla.GetInstance().androidPublicKey, Soomla.GetInstance().customSecret); } } AndroidJNI.PopLocalFrame(IntPtr.Zero); // setting test mode on Android SetAndroidTestMode(Soomla.GetInstance().androidTestMode); #elif UNITY_IOS && !UNITY_EDITOR storeController_Init(Soomla.GetInstance().customSecret); #endif }
/// <summary> /// Initializes <c>StoreInfo</c>. /// On first initialization, when the database doesn't have any previous version of the store /// metadata, <c>StoreInfo</c> gets loaded from the given <c>IStoreAssets</c>. /// After the first initialization, <c>StoreInfo</c> will be initialized from the database. /// /// IMPORTANT: If you want to override the current <c>StoreInfo</c>, you'll have to bump /// the version of your implementation of <c>IStoreAssets</c> in order to remove the /// metadata when the application loads. Bumping the version is done by returning a higher /// number in <c>IStoreAssets</c>'s <c>getVersion</c>. /// </summary> override protected void _setStoreAssets(IStoreAssets storeAssets) { SoomlaUtils.LogDebug(TAG, "pushing data to StoreAssets on wp side"); string storeAssetsJSON = IStoreAssetsToJSON(storeAssets); int version = storeAssets.GetVersion(); SoomlaWpStore.data.GenericStoreAssets.GetInstance().Prepare(version, storeAssetsJSON); SoomlaWpStore.data.StoreInfo.setStoreAssets(SoomlaWpStore.data.GenericStoreAssets.GetInstance()); SoomlaUtils.LogDebug(TAG, "done! (pushing data to StoreAssets on wp side)"); }
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 && !UNITY_EDITOR 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 && !UNITY_EDITOR storeController_SetSSV(Soomla.GetInstance().iosServerSideVerification); storeController_SetSoomSec(Soomla.GetInstance().soomSec); #endif StoreInfo.Initialize(storeAssets); #if UNITY_ANDROID && !UNITY_EDITOR 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 && !UNITY_EDITOR storeController_Init(Soomla.GetInstance().customSecret); #endif }
/// <summary> /// Initializes <c>StoreInfo</c>. /// On first initialization, when the database doesn't have any previous version of the store /// metadata, <c>StoreInfo</c> gets loaded from the given <c>IStoreAssets</c>. /// After the first initialization, <c>StoreInfo</c> will be initialized from the database. /// /// IMPORTANT: If you want to override the current <c>StoreInfo</c>, you'll have to bump /// the version of your implementation of <c>IStoreAssets</c> in order to remove the /// metadata when the application loads. Bumping the version is done by returning a higher /// number in <c>IStoreAssets</c>'s <c>getVersion</c>. /// </summary> override protected void _setStoreAssets(IStoreAssets storeAssets) { SoomlaUtils.LogDebug(TAG, "pushing IStoreAssets to StoreInfo on java side"); AndroidJNI.PushLocalFrame(100); string storeAssetsJSON = IStoreAssetsToJSON(storeAssets); int version = storeAssets.GetVersion(); using(AndroidJavaClass jniStoreInfoClass = new AndroidJavaClass("com.soomla.store.data.StoreInfo")) { jniStoreInfoClass.CallStatic("setStoreAssets", version, storeAssetsJSON); } AndroidJNI.PopLocalFrame(IntPtr.Zero); SoomlaUtils.LogDebug(TAG, "done! (pushing data to StoreAssets on java side)"); }
private static void validateStoreAssets(IStoreAssets storeAssets) { if (storeAssets == null) { throw new ArgumentException("The given store assets can't be null!"); } if (!assetsArrayHasMarketIdDuplicates(storeAssets.GetGoods()) || !assetsArrayHasMarketIdDuplicates(storeAssets.GetCurrencyPacks())) { throw new ArgumentException("The given store assets has duplicates at marketItem productId!"); } }
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 }
/// <summary> /// Initializes <c>StoreInfo</c>. /// On first initialization, when the database doesn't have any previous version of the store /// metadata, <c>StoreInfo</c> gets loaded from the given <c>IStoreAssets</c>. /// After the first initialization, <c>StoreInfo</c> will be initialized from the database. /// /// IMPORTANT: If you want to override the current <c>StoreInfo</c>, you'll have to bump /// the version of your implementation of <c>IStoreAssets</c> in order to remove the /// metadata when the application loads. Bumping the version is done by returning a higher /// number in <c>IStoreAssets</c>'s <c>getVersion</c>. /// </summary> override protected void _setStoreAssets(IStoreAssets storeAssets) { SoomlaUtils.LogDebug(TAG, "pushing IStoreAssets to StoreInfo on java side"); AndroidJNI.PushLocalFrame(100); string storeAssetsJSON = IStoreAssetsToJSON(storeAssets); int version = storeAssets.GetVersion(); using (AndroidJavaClass jniStoreInfoClass = new AndroidJavaClass("com.soomla.store.data.StoreInfo")) { jniStoreInfoClass.CallStatic("setStoreAssets", version, storeAssetsJSON); } AndroidJNI.PopLocalFrame(IntPtr.Zero); SoomlaUtils.LogDebug(TAG, "done! (pushing data to StoreAssets on java side)"); }
public static void Initialize(IStoreAssets storeAssets) { if (string.IsNullOrEmpty(SoomSettings.CustomSecret)) { StoreUtils.LogError(TAG, "SOOMLA/UNITY MISSING customSecret !!! Stopping here !!"); throw new ExitGUIException(); } if (SoomSettings.CustomSecret == SoomSettings.ONLY_ONCE_DEFAULT) { StoreUtils.LogError(TAG, "SOOMLA/UNITY You have to change customSecret !!! Stopping here !!"); throw new ExitGUIException(); } SetupSoomSec(); #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(); } #elif UNITY_IOS && !UNITY_EDITOR storeController_SetSSV(SoomSettings.IosSSV, "https://verify.soom.la/verify_ios?platform=unity4"); #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 }
/// <summary> /// Initializes the SOOMLA SDK. /// </summary> /// <param name="storeAssets">Your game's economy.</param> /// <exception cref="ExitGUIException">Thrown if soomlaSecret is missing or has not been changed. /// </exception> public static void Initialize(IStoreAssets storeAssets) { if (string.IsNullOrEmpty(CoreSettings.SoomlaSecret)) { SoomlaUtils.LogError(TAG, "SOOMLA/UNITY MISSING SoomlaSecret !!! Stopping here !!"); throw new ExitGUIException(); } if (CoreSettings.SoomlaSecret==CoreSettings.ONLY_ONCE_DEFAULT) { SoomlaUtils.LogError(TAG, "SOOMLA/UNITY You have to change SoomlaSecret !!! Stopping here !!"); throw new ExitGUIException(); } instance._initialize(storeAssets); }
/// <summary> /// Initializes the SOOMLA SDK. /// </summary> /// <param name="storeAssets">Your game's economy.</param> /// <exception cref="ExitGUIException">Thrown if soomlaSecret is missing or has not been changed.</exception> public static bool Initialize(IStoreAssets storeAssets) { StoreEvents.Initialize(); if (string.IsNullOrEmpty(CoreSettings.SoomlaSecret)) { SoomlaUtils.LogError(TAG, "MISSING SoomlaSecret !!! Stopping here !!"); throw new ExitGUIException(); } if (CoreSettings.SoomlaSecret == CoreSettings.ONLY_ONCE_DEFAULT) { SoomlaUtils.LogError(TAG, "You have to change SoomlaSecret !!! Stopping here !!"); throw new ExitGUIException(); } var storeEvents = GameObject.FindObjectOfType <StoreEvents> (); if (storeEvents == null) { SoomlaUtils.LogDebug(TAG, "StoreEvents Component not found in scene. We're continuing from here but you won't get many events."); } if (Initialized) { StoreEvents.Instance.onUnexpectedStoreError("{\"errorCode\": 0}", true); SoomlaUtils.LogError(TAG, "SoomlaStore is already initialized. You can't initialize it twice!"); return(false); } SoomlaUtils.LogDebug(TAG, "SoomlaStore Initializing ..."); StoreInfo.SetStoreAssets(storeAssets); instance._loadBillingService(); #if UNITY_IOS // On iOS we only refresh market items instance._refreshMarketItemsDetails(); #elif UNITY_ANDROID // On Android we refresh market items and restore transactions instance._refreshInventory(); #elif UNITY_WP8 instance._refreshInventory(); #endif Initialized = true; StoreEvents.Instance.onSoomlaStoreInitialized("", true); return(true); }
/** * Initializes <code>StoreInfo</code>. * On first initialization, when the database doesn't have any previous version of the store * metadata, <code>StoreInfo</code> gets loaded from the given <code>IStoreAssets</code>. * After the first initialization, <code>StoreInfo</code> will be initialized from the database. * * IMPORTANT: If you want to override the current <code>StoreInfo</code>, you'll have to bump * the version of your implementation of <code>IStoreAssets</code> in order to remove the * metadata when the application loads. Bumping the version is done by returning a higher number * in {@link com.soomla.store.IStoreAssets#getVersion()}. */ public static void setStoreAssets(IStoreAssets storeAssets){ if (storeAssets == null){ SoomlaUtils.LogError(TAG, "The given store assets can't be null!"); return; } mCurrentAssetsVersion = storeAssets.GetVersion(); checkMetadataVersion(); // we always initialize from the database, unless this is the first time the game is // loaded - in that case we initialize with setStoreAssets. if (!initializeFromDB()){ initializeWithStoreAssets(storeAssets); } }
/// <summary> /// Initializes the SOOMLA SDK. /// </summary> /// <param name="storeAssets">Your game's economy.</param> /// <exception cref="ExitGUIException">Thrown if soomlaSecret is missing or has not been changed. /// </exception> public static void Initialize(IStoreAssets storeAssets) { if (string.IsNullOrEmpty(CoreSettings.SoomlaSecret)) { SoomlaUtils.LogError(TAG, "SOOMLA/UNITY MISSING SoomlaSecret !!! Stopping here !!"); throw new ExitGUIException(); } if (CoreSettings.SoomlaSecret == CoreSettings.ONLY_ONCE_DEFAULT) { SoomlaUtils.LogError(TAG, "SOOMLA/UNITY You have to change SoomlaSecret !!! Stopping here !!"); throw new ExitGUIException(); } instance._initialize(storeAssets); }
/// <summary> /// NOTE: This function is manually called when you initialize SoomlaStore. You won't need to call /// it on regular use of SOOMLA Store. /// /// Initializes <code>StoreInfo</code>. /// On first initialization, when the database doesn't have any previous version of the store /// metadata, <code>StoreInfo</code> gets loaded from the given <code>IStoreAssets</code>. /// After the first initialization, <code>StoreInfo</code> will be initialized from the database. /// /// IMPORTANT: If you want to override the metadata on the current <code>StoreInfo</code>, you'll have to bump /// the version of your implementation of <code>IStoreAssets</code> in order to remove the /// metadata when the application loads. Bumping the version is done by returning a higher number /// in {@link com.soomla.store.IStoreAssets#getVersion()}. /// </summary> public static void SetStoreAssets(IStoreAssets storeAssets) { SoomlaUtils.LogDebug(TAG, "Setting store assets in SoomlaInfo"); try { validateStoreAssets(storeAssets); instance._setStoreAssets(storeAssets); // At this point we have StoreInfo JSON saved at the local key-value storage. We can just // continue by initializing from DB. initializeFromDB(); } catch (System.ArgumentException exception) { SoomlaUtils.LogError(TAG, exception.Message); } }
/// <summary> /// NOTE: This function is manually called when you initialize SoomlaStore. You won't need to call /// it on regular use of SOOMLA Store. /// /// Initializes <code>StoreInfo</code>. /// On first initialization, when the database doesn't have any previous version of the store /// metadata, <code>StoreInfo</code> gets loaded from the given <code>IStoreAssets</code>. /// After the first initialization, <code>StoreInfo</code> will be initialized from the database. /// /// IMPORTANT: If you want to override the metadata on the current <code>StoreInfo</code>, you'll have to bump /// the version of your implementation of <code>IStoreAssets</code> in order to remove the /// metadata when the application loads. Bumping the version is done by returning a higher number /// in {@link com.soomla.store.IStoreAssets#getVersion()}. /// </summary> public static void SetStoreAssets(IStoreAssets storeAssets) { SoomlaUtils.LogDebug(TAG, "Setting store assets in SoomlaInfo"); if (storeAssets == null) { SoomlaUtils.LogError(TAG, "The given store assets can't be null!"); return; } instance._setStoreAssets(storeAssets); // At this point we have StoreInfo JSON saved at the local key-value storage. We can just // continue by initializing from DB. initializeFromDB(); }
private static void validateStoreAssets(IStoreAssets storeAssets) { if (storeAssets == null) { throw new ArgumentException("The given store assets can't be null!"); } if (storeAssets.GetCurrencies() == null || storeAssets.GetCurrencyPacks() == null || storeAssets.GetGoods() == null || storeAssets.GetCategories() == null) { throw new ArgumentException("All IStoreAssets methods shouldn't return NULL-pointer references!"); } if (!assetsArrayHasMarketIdDuplicates(storeAssets.GetGoods()) || !assetsArrayHasMarketIdDuplicates(storeAssets.GetCurrencyPacks())) { throw new ArgumentException("The given store assets has duplicates at marketItem productId!"); } }
/// <summary> /// Initializes the SOOMLA SDK. /// </summary> /// <param name="storeAssets">Your game's economy.</param> /// <exception cref="ExitGUIException">Thrown if soomlaSecret is missing or has not been changed.</exception> public static bool Initialize(IStoreAssets storeAssets) { if (string.IsNullOrEmpty(CoreSettings.SoomlaSecret)) { SoomlaUtils.LogError(TAG, "MISSING SoomlaSecret !!! Stopping here !!"); throw new ExitGUIException(); } if (CoreSettings.SoomlaSecret==CoreSettings.ONLY_ONCE_DEFAULT) { SoomlaUtils.LogError(TAG, "You have to change SoomlaSecret !!! Stopping here !!"); throw new ExitGUIException(); } var storeEvents = GameObject.FindObjectOfType<StoreEvents> (); if (storeEvents == null) { SoomlaUtils.LogDebug(TAG, "StoreEvents Component not found in scene. We're continuing from here but you won't get many events."); } if (Initialized) { StoreEvents.Instance.onUnexpectedStoreError("{\"errorCode\": 0}", true); SoomlaUtils.LogError(TAG, "SoomlaStore is already initialized. You can't initialize it twice!"); return false; } SoomlaUtils.LogDebug(TAG, "SoomlaStore Initializing ..."); StoreInfo.SetStoreAssets(storeAssets); instance._loadBillingService(); #if UNITY_IOS // On iOS we only refresh market items instance._refreshMarketItemsDetails(); #elif UNITY_ANDROID // On Android we refresh market items and restore transactions instance._refreshInventory(); #elif (UNITY_WP8 || UNITY_WSA) //|| UNITY_WSA instance._refreshInventory(); #endif Initialized = true; StoreEvents.Instance.onSoomlaStoreInitialized("", true); return true; }
/** * Initializes <code>StoreInfo</code>. * On first initialization, when the database doesn't have any previous version of the store * metadata, <code>StoreInfo</code> gets loaded from the given <code>IStoreAssets</code>. * After the first initialization, <code>StoreInfo</code> will be initialized from the database. * * IMPORTANT: If you want to override the current <code>StoreInfo</code>, you'll have to bump * the version of your implementation of <code>IStoreAssets</code> in order to remove the * metadata when the application loads. Bumping the version is done by returning a higher number * in {@link com.soomla.store.IStoreAssets#getVersion()}. */ public static void setStoreAssets(IStoreAssets storeAssets) { if (storeAssets == null) { SoomlaUtils.LogError(TAG, "The given store assets can't be null!"); return; } mCurrentAssetsVersion = storeAssets.GetVersion(); checkMetadataVersion(); // we always initialize from the database, unless this is the first time the game is // loaded - in that case we initialize with setStoreAssets. if (!initializeFromDB()) { initializeWithStoreAssets(storeAssets); } }
/// <summary> /// NOTE: This function is manually called when you initialize SoomlaStore. You won't need to call /// it on regular use of SOOMLA Store. /// /// Initializes <code>StoreInfo</code>. /// On first initialization, when the database doesn't have any previous version of the store /// metadata, <code>StoreInfo</code> gets loaded from the given <code>IStoreAssets</code>. /// After the first initialization, <code>StoreInfo</code> will be initialized from the database. /// /// IMPORTANT: If you want to override the metadata on the current <code>StoreInfo</code>, you'll have to bump /// the version of your implementation of <code>IStoreAssets</code> in order to remove the /// metadata when the application loads. Bumping the version is done by returning a higher number /// in {@link com.soomla.store.IStoreAssets#getVersion()}. /// </summary> public static void SetStoreAssets(IStoreAssets storeAssets){ SoomlaUtils.LogDebug(TAG, "Setting store assets in SoomlaInfo"); try { validateStoreAssets(storeAssets); instance._setStoreAssets(storeAssets); // At this point we have StoreInfo JSON saved at the local key-value storage. We can just // continue by initializing from DB. initializeFromDB(); } catch (System.ArgumentException exception) { SoomlaUtils.LogError(TAG, exception.Message); } }
/// <summary> /// Initializes the SOOMLA SDK. /// </summary> /// <param name="storeAssets">Your game's economy.</param> protected override void _initialize(IStoreAssets storeAssets) { soomlaStore_SetSSV(StoreSettings.IosSSV, "https://verify.soom.la/verify_ios?platform=unity4"); StoreInfo.Initialize(storeAssets); soomlaStore_Init(); }
/// <summary> /// Initializes the SOOMLA SDK. /// </summary> /// <param name="storeAssets">Your game's economy.</param> protected override void _initialize(IStoreAssets storeAssets) { storeController_SetSSV(SoomSettings.IosSSV, "https://verify.soom.la/verify_ios?platform=unity4"); StoreInfo.Initialize(storeAssets); storeController_Init(SoomSettings.CustomSecret); }
/** * Initializes from <code>IStoreAssets</code>. * This happens only once - when the game is loaded for the first time. * * @param storeAssets game economy */ private static void initializeWithStoreAssets(IStoreAssets storeAssets) { // fall-back here if the json doesn't exist, // we load the store from the given {@link IStoreAssets}. mCurrencies = new List<VirtualCurrency>(); mCurrencies.AddRange(storeAssets.GetCurrencies()); mCurrencyPacks = new List<VirtualCurrencyPack>(); mCurrencyPacks.AddRange(storeAssets.GetCurrencyPacks()); mGoods = new List<VirtualGood>(); mGoods.AddRange(storeAssets.GetGoods()); mCategories = new List<VirtualCategory>(); mCategories.AddRange(storeAssets.GetCategories()); //mNonConsumables = new List<NonConsumableItem>(); //mNonConsumables.AddRange(storeAssets.GetNonConsumableItems()); mVirtualItems = new Dictionary<String, VirtualItem>(); mPurchasableItems = new Dictionary<String, PurchasableVirtualItem>(); mGoodsCategories = new Dictionary<String, VirtualCategory>(); mGoodsUpgrades = new Dictionary<String, List<UpgradeVG>>(); foreach(VirtualCurrency vi in mCurrencies) { mVirtualItems.Add(vi.getItemId(), vi); } foreach(VirtualCurrencyPack vi in mCurrencyPacks) { mVirtualItems.Add(vi.getItemId(), vi); PurchaseType purchaseType = vi.GetPurchaseType(); if (purchaseType is PurchaseWithMarket) { mPurchasableItems.Add(((PurchaseWithMarket) purchaseType).getMarketItem() .getProductId(), vi); } } foreach(VirtualGood vi in mGoods) { mVirtualItems.Add(vi.getItemId(), vi); if (vi is UpgradeVG) { List<UpgradeVG> upgrades; if (mGoodsUpgrades.ContainsKey(((UpgradeVG)vi).getGoodItemId())) { upgrades = mGoodsUpgrades[((UpgradeVG)vi).getGoodItemId()]; } else { upgrades = null; } if (upgrades == null) { upgrades = new List<UpgradeVG>(); mGoodsUpgrades.Add(((UpgradeVG) vi).getGoodItemId(), upgrades); } upgrades.Add((UpgradeVG) vi); } PurchaseType purchaseType = vi.GetPurchaseType(); if (purchaseType is PurchaseWithMarket) { mPurchasableItems.Add(((PurchaseWithMarket) purchaseType).getMarketItem() .getProductId(), vi); } } /* foreach(NonConsumableItem vi in mNonConsumables) { mVirtualItems.Add(vi.getItemId(), vi); PurchaseType purchaseType = vi.GetPurchaseType(); if (purchaseType is PurchaseWithMarket) { mPurchasableItems.Add(((PurchaseWithMarket) purchaseType).getMarketItem() .getProductId(), vi); } } */ foreach(VirtualCategory category in mCategories) { foreach(String goodItemId in category.getGoodsItemIds()) { mGoodsCategories.Add(goodItemId, category); } } save(); }
public static void Initialize(IStoreAssets storeAssets) { // 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 UpgradeVG) { upGoods.Add(g.toJSONObject()); } else if (g is LifetimeVG) { ltGoods.Add(g.toJSONObject()); } else if (g is SingleUsePackVG) { paGoods.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 && !UNITY_EDITOR 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 && !UNITY_EDITOR 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 }
protected virtual void _initialize(IStoreAssets storeAssets) { }
public static void Initialize(IStoreAssets storeAssets) { #if UNITY_ANDROID Debug.Log("pushing data to StoreAssets on java side"); AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniStoreAssets = new AndroidJavaClass("com.soomla.unity.StoreAssets")) { //storeAssets version jniStoreAssets.CallStatic("setVersion", storeAssets.GetVersion()); Dictionary<int, AndroidJavaObject> jniCategories = new Dictionary<int, AndroidJavaObject>(); //virtual categories using(AndroidJavaObject jniVirtualCategories = jniStoreAssets.GetStatic<AndroidJavaObject>("virtualCategories")) { jniVirtualCategories.Call("clear"); AndroidJNI.PushLocalFrame(100); foreach(VirtualCategory vc in storeAssets.GetVirtualCategories()){ jniCategories[vc.Id] = vc.toAndroidJavaObject(jniStoreAssets); jniVirtualCategories.Call<bool>("add", jniCategories[vc.Id]); } AndroidJNI.PopLocalFrame(IntPtr.Zero); } //non consumable items using(AndroidJavaObject jniNonConsumableItems = jniStoreAssets.GetStatic<AndroidJavaObject>("nonConsumableItems")) { jniNonConsumableItems.Call("clear"); AndroidJNI.PushLocalFrame(100); foreach(NonConsumableItem non in storeAssets.GetNonConsumableItems()){ using(AndroidJavaObject obj = non.toAndroidJavaObject()) { jniNonConsumableItems.Call<bool>("add", obj); } } AndroidJNI.PopLocalFrame(IntPtr.Zero); } Dictionary<string, AndroidJavaObject> jniCurrencies = new Dictionary<string, AndroidJavaObject>(); //Virtual currencies using(AndroidJavaObject jniVirtualCurrencies = jniStoreAssets.GetStatic<AndroidJavaObject>("virtualCurrencies")) { jniVirtualCurrencies.Call("clear"); AndroidJNI.PushLocalFrame(100); foreach(VirtualCurrency vc in storeAssets.GetVirtualCurrencies()){ jniCurrencies[vc.ItemId] = vc.toAndroidJavaObject(); jniVirtualCurrencies.Call<bool>("add", jniCurrencies[vc.ItemId]); } AndroidJNI.PopLocalFrame(IntPtr.Zero); } //Virtual currency packs using(AndroidJavaObject jniVirtualCurrencyPacks = jniStoreAssets.GetStatic<AndroidJavaObject>("virtualCurrencyPacks")) { jniVirtualCurrencyPacks.Call("clear"); AndroidJNI.PushLocalFrame(100); foreach(VirtualCurrencyPack vcp in storeAssets.GetVirtualCurrencyPacks()){ using(AndroidJavaObject obj = vcp.toAndroidJavaObject(jniCurrencies[vcp.Currency.ItemId])) { jniVirtualCurrencyPacks.Call<bool>("add", obj); } } AndroidJNI.PopLocalFrame(IntPtr.Zero); } //Virtual goods using(AndroidJavaObject jniVirtualGoods = jniStoreAssets.GetStatic<AndroidJavaObject>("virtualGoods")) { jniVirtualGoods.Call("clear"); foreach(VirtualGood vg in storeAssets.GetVirtualGoods()){ AndroidJNI.PushLocalFrame(100); using(AndroidJavaObject obj = vg.toAndroidJavaObject(jniStoreAssets, jniCategories[vg.Category.Id])) { jniVirtualGoods.Call<bool>("add", obj); } AndroidJNI.PopLocalFrame(IntPtr.Zero); } } foreach(KeyValuePair<int, AndroidJavaObject> kvp in jniCategories) { kvp.Value.Dispose(); } foreach(KeyValuePair<string, AndroidJavaObject> kvp in jniCurrencies) { kvp.Value.Dispose(); } } AndroidJNI.PopLocalFrame(IntPtr.Zero); Debug.Log("done! (pushing data to StoreAssets on java side)"); #elif UNITY_IOS Debug.Log("pushing data to StoreAssets on ios side"); storeAssets_Init(); // storeAssets version storeAssets_SetVersion(storeAssets.GetVersion()); //virtual categories foreach(VirtualCategory vc in storeAssets.GetVirtualCategories()){ storeAssets_AddCategory(vc.Name, vc.Id, vc.Equipping.ToString()); } //ios market items foreach(NonConsumableItem non in storeAssets.GetNonConsumableItems()){ storeAssets_AddNonConsumable(non.Name, non.Description, non.ItemId, non.MarketItem.Price, non.MarketItem.ProductId); } //Virtual currencies foreach(VirtualCurrency vc in storeAssets.GetVirtualCurrencies()){ storeAssets_AddCurrency(vc.Name, vc.Description, vc.ItemId); } //Virtual currency packs foreach(VirtualCurrencyPack vcp in storeAssets.GetVirtualCurrencyPacks()){ storeAssets_AddCurrencyPack(vcp.Name, vcp.Description, vcp.ItemId, vcp.MarketItem.Price, vcp.MarketItem.ProductId, vcp.CurrencyAmount, vcp.Currency.ItemId); } //Virtual goods foreach(VirtualGood vg in storeAssets.GetVirtualGoods()){ string json = vg.PriceModel.toJSONObject().print(); storeAssets_AddVirtualGood(vg.Name, vg.Description, vg.ItemId, vg.Category.Id, json); } Debug.Log("done! (pushing data to StoreAssets on ios side)"); #endif }
/// <summary> /// Initializes <c>StoreInfo</c>. /// On first initialization, when the database doesn't have any previous version of the store /// metadata, <c>StoreInfo</c> gets loaded from the given <c>IStoreAssets</c>. /// After the first initialization, <c>StoreInfo</c> will be initialized from the database. /// /// IMPORTANT: If you want to override the current <c>StoreInfo</c>, you'll have to bump /// the version of your implementation of <c>IStoreAssets</c> in order to remove the /// metadata when the application loads. Bumping the version is done by returning a higher /// number in <c>IStoreAssets</c>'s <c>getVersion</c>. /// </summary> /// <param name="storeAssets">your game's economy</param> public static void Initialize(IStoreAssets storeAssets) { // Utils.LogDebug(TAG, "Adding currency"); JSONObject currencies = new JSONObject(JSONObject.Type.ARRAY); foreach (VirtualCurrency vi in storeAssets.GetCurrencies()) { currencies.Add(vi.toJSONObject()); } // Utils.LogDebug(TAG, "Adding packs"); JSONObject packs = new JSONObject(JSONObject.Type.ARRAY); foreach (VirtualCurrencyPack vi in storeAssets.GetCurrencyPacks()) { packs.Add(vi.toJSONObject()); } // Utils.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 UpgradeVG) { upGoods.Add(g.toJSONObject()); } else if (g is LifetimeVG) { ltGoods.Add(g.toJSONObject()); } else if (g is SingleUsePackVG) { paGoods.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); // Utils.LogDebug(TAG, "Adding categories"); JSONObject categories = new JSONObject(JSONObject.Type.ARRAY); foreach (VirtualCategory vi in storeAssets.GetCategories()) { categories.Add(vi.toJSONObject()); } // Utils.LogDebug(TAG, "Adding nonConsumables"); JSONObject nonConsumables = new JSONObject(JSONObject.Type.ARRAY); foreach (NonConsumableItem vi in storeAssets.GetNonConsumableItems()) { nonConsumables.Add(vi.toJSONObject()); } // Utils.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(); instance._initialize(storeAssets.GetVersion(), storeAssetsJSON); }
/** * Initializes from <code>IStoreAssets</code>. * This happens only once - when the game is loaded for the first time. * * @param storeAssets game economy */ private static void initializeWithStoreAssets(IStoreAssets storeAssets) { // fall-back here if the json doesn't exist, // we load the store from the given {@link IStoreAssets}. mCurrencies = new List <VirtualCurrency>(); mCurrencies.AddRange(storeAssets.GetCurrencies()); mCurrencyPacks = new List <VirtualCurrencyPack>(); mCurrencyPacks.AddRange(storeAssets.GetCurrencyPacks()); mGoods = new List <VirtualGood>(); mGoods.AddRange(storeAssets.GetGoods()); mCategories = new List <VirtualCategory>(); mCategories.AddRange(storeAssets.GetCategories()); //mNonConsumables = new List<NonConsumableItem>(); //mNonConsumables.AddRange(storeAssets.GetNonConsumableItems()); mVirtualItems = new Dictionary <String, VirtualItem>(); mPurchasableItems = new Dictionary <String, PurchasableVirtualItem>(); mGoodsCategories = new Dictionary <String, VirtualCategory>(); mGoodsUpgrades = new Dictionary <String, List <UpgradeVG> >(); foreach (VirtualCurrency vi in mCurrencies) { mVirtualItems.Add(vi.getItemId(), vi); } foreach (VirtualCurrencyPack vi in mCurrencyPacks) { mVirtualItems.Add(vi.getItemId(), vi); PurchaseType purchaseType = vi.GetPurchaseType(); if (purchaseType is PurchaseWithMarket) { mPurchasableItems.Add(((PurchaseWithMarket)purchaseType).getMarketItem() .getProductId(), vi); } } foreach (VirtualGood vi in mGoods) { mVirtualItems.Add(vi.getItemId(), vi); if (vi is UpgradeVG) { List <UpgradeVG> upgrades = mGoodsUpgrades[((UpgradeVG)vi).getGoodItemId()]; if (upgrades == null) { upgrades = new List <UpgradeVG>(); mGoodsUpgrades.Add(((UpgradeVG)vi).getGoodItemId(), upgrades); } upgrades.Add((UpgradeVG)vi); } PurchaseType purchaseType = vi.GetPurchaseType(); if (purchaseType is PurchaseWithMarket) { mPurchasableItems.Add(((PurchaseWithMarket)purchaseType).getMarketItem() .getProductId(), vi); } } /* * foreach(NonConsumableItem vi in mNonConsumables) { * mVirtualItems.Add(vi.getItemId(), vi); * * PurchaseType purchaseType = vi.GetPurchaseType(); * if (purchaseType is PurchaseWithMarket) { * mPurchasableItems.Add(((PurchaseWithMarket) purchaseType).getMarketItem() * .getProductId(), vi); * } * }*/ foreach (VirtualCategory category in mCategories) { foreach (String goodItemId in category.getGoodsItemIds()) { mGoodsCategories.Add(goodItemId, category); } } save(); }
/// <summary> /// Initializes the SOOMLA SDK. /// This initializer also initializes StoreInfo. /// </summary> /// /// <param name="storeAssets"> The store assets. </param> /// <param name="testMode"> Run in testmode for store IAP </param> /// /// <returns> true if it succeeds, false if it fails. </returns> public bool initialize(IStoreAssets storeAssets, bool testMode) { return true; }
/** Protected Functions **/ protected static string IStoreAssetsToJSON(IStoreAssets storeAssets) { // Utils.LogDebug(TAG, "Adding currency"); JSONObject currencies = new JSONObject(JSONObject.Type.ARRAY); foreach(VirtualCurrency vi in storeAssets.GetCurrencies()) { currencies.Add(vi.toJSONObject()); } // Utils.LogDebug(TAG, "Adding packs"); JSONObject packs = new JSONObject(JSONObject.Type.ARRAY); foreach(VirtualCurrencyPack vi in storeAssets.GetCurrencyPacks()) { packs.Add(vi.toJSONObject()); } // Utils.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 UpgradeVG) { upGoods.Add(g.toJSONObject()); } else if (g is LifetimeVG) { ltGoods.Add(g.toJSONObject()); } else if (g is SingleUsePackVG) { paGoods.Add(g.toJSONObject()); } } JSONObject goods = new JSONObject(JSONObject.Type.OBJECT); goods.AddField(StoreJSONConsts.STORE_GOODS_SU, suGoods); goods.AddField(StoreJSONConsts.STORE_GOODS_LT, ltGoods); goods.AddField(StoreJSONConsts.STORE_GOODS_EQ, eqGoods); goods.AddField(StoreJSONConsts.STORE_GOODS_UP, upGoods); goods.AddField(StoreJSONConsts.STORE_GOODS_PA, paGoods); // Utils.LogDebug(TAG, "Adding categories"); JSONObject categories = new JSONObject(JSONObject.Type.ARRAY); foreach(VirtualCategory vi in storeAssets.GetCategories()) { categories.Add(vi.toJSONObject()); } // Utils.LogDebug(TAG, "Preparing StoreAssets JSONObject"); JSONObject storeAssetsObj = new JSONObject(JSONObject.Type.OBJECT); storeAssetsObj.AddField(StoreJSONConsts.STORE_CATEGORIES, categories); storeAssetsObj.AddField(StoreJSONConsts.STORE_CURRENCIES, currencies); storeAssetsObj.AddField(StoreJSONConsts.STORE_CURRENCYPACKS, packs); storeAssetsObj.AddField(StoreJSONConsts.STORE_GOODS, goods); return storeAssetsObj.print(); }
/** * Initializes <code>StoreInfo</code>. * On first initialization, when the database doesn't have any previous version of the store * metadata, <code>StoreInfo</code> gets loaded from the given <code>IStoreAssets</code>. * After the first initialization, <code>StoreInfo</code> will be initialized from the database. * * IMPORTANT: If you want to override the current <code>StoreInfo</code>, you'll have to bump * the version of your implementation of <code>IStoreAssets</code> in order to remove the * metadata when the application loads. Bumping the version is done by returning a higher number * in {@link com.soomla.store.IStoreAssets#getVersion()}. */ public static void setStoreAssets(IStoreAssets storeAssets) { }
public static void Initialize(IStoreAssets storeAssets) { // 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 UpgradeVG) { upGoods.Add(g.toJSONObject()); } else if (g is LifetimeVG) { ltGoods.Add(g.toJSONObject()); } else if (g is SingleUsePackVG) { paGoods.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(); instance._initialize(storeAssets.GetVersion(), storeAssetsJSON); }
public Store(IStoreAssets assets) { Assets = assets; }
/// <summary> /// NOTE: This function is manually called when you initialize SoomlaStore. You won't need to call /// it on regular use of SOOMLA Store. /// /// Initializes <code>StoreInfo</code>. /// On first initialization, when the database doesn't have any previous version of the store /// metadata, <code>StoreInfo</code> gets loaded from the given <code>IStoreAssets</code>. /// After the first initialization, <code>StoreInfo</code> will be initialized from the database. /// /// IMPORTANT: If you want to override the metadata on the current <code>StoreInfo</code>, you'll have to bump /// the version of your implementation of <code>IStoreAssets</code> in order to remove the /// metadata when the application loads. Bumping the version is done by returning a higher number /// in {@link com.soomla.store.IStoreAssets#getVersion()}. /// </summary> public static void SetStoreAssets(IStoreAssets storeAssets) { SoomlaUtils.LogDebug(TAG, "Setting store assets in SoomlaInfo"); if (storeAssets == null){ SoomlaUtils.LogError(TAG, "The given store assets can't be null!"); return; } instance._setStoreAssets(storeAssets); // At this point we have StoreInfo JSON saved at the local key-value storage. We can just // continue by initializing from DB. initializeFromDB(); }
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 }
// 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 }