/// <summary> /// Handles the <c>onMarketItemsRefreshFinished</c> event, which is fired when items associated with market are /// refreshed (prices, titles ...). /// </summary> /// <param name="message">Message that contains information about the process that is occurring.</param> public void onMarketItemsRefreshFinished(string message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFinished: " + message); var eventJSON = new JSONObject(message); List <MarketItem> marketItems = new List <MarketItem>(); foreach (var micJSON in eventJSON.list) { string productId = micJSON[StoreJSONConsts.MARKETITEM_PRODUCT_ID].str; string marketPrice = micJSON[StoreJSONConsts.MARKETITEM_MARKETPRICE].str; string marketTitle = micJSON[StoreJSONConsts.MARKETITEM_MARKETTITLE].str; string marketDescription = micJSON[StoreJSONConsts.MARKETITEM_MARKETDESC].str; string marketCurrencyCode = micJSON[StoreJSONConsts.MARKETITEM_MARKETCURRENCYCODE].str; long marketPriceMicros = System.Convert.ToInt64(micJSON[StoreJSONConsts.MARKETITEM_MARKETPRICEMICROS].n); try { PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(productId); MarketItem mi = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem; mi.MarketPriceAndCurrency = marketPrice; mi.MarketTitle = marketTitle; mi.MarketDescription = marketDescription; mi.MarketCurrencyCode = marketCurrencyCode; mi.MarketPriceMicros = marketPriceMicros; pvi.Save(); marketItems.Add(mi); } catch (VirtualItemNotFoundException ex) { SoomlaUtils.LogDebug(TAG, ex.Message); } } StoreEvents.OnMarketItemsRefreshFinished(marketItems); }
public static void onMarketItemsRefreshFinished(MarketItemsRefreshFinishedEvent _Event) { List <SoomlaWpStore.domain.MarketItem> pluginMarketItems = _Event.GetMarketItems(); SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFinished: " + pluginMarketItems.Count); List <MarketItem> marketItems = new List <MarketItem>(); foreach (SoomlaWpStore.domain.MarketItem mic in pluginMarketItems) { try { PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(mic.getProductId()); MarketItem mi = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem; mi.MarketPriceAndCurrency = mic.getMarketPrice(); mi.MarketTitle = mic.getMarketTitle(); mi.MarketDescription = mic.getMarketDescription(); if (mic.isPriceSuccessfullyParsed()) { mi.MarketPriceMicros = mic.getMarketPriceMicros(); mi.MarketCurrencyCode = mic.getMarketCurrencyCode(); } pvi.Save(); marketItems.Add(mi); } catch (VirtualItemNotFoundException ex) { SoomlaUtils.LogDebug(TAG, ex.Message); } } StoreEvents.OnMarketItemsRefreshFinished(marketItems); }