Beispiel #1
0
        public void onMarketItemsRefreshed(string message)
        {
            StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshed: " + message);

            string[] marketItemsChanges = Regex.Split(message, "#SOOM#");
            foreach (string mic in marketItemsChanges)
            {
                if (string.IsNullOrEmpty(mic.Trim()))
                {
                    continue;
                }

                JSONObject micJSON           = new JSONObject(mic);
                string     productId         = micJSON["productId"].str;
                string     marketPrice       = micJSON["market_price"].str;
                string     marketTitle       = micJSON["market_title"].str;
                string     marketDescription = micJSON["market_desc"].str;
                try {
                    PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(productId);
                    MarketItem             mi  = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem;
                    mi.MarketPrice       = marketPrice;
                    mi.MarketTitle       = marketTitle;
                    mi.MarketDescription = marketDescription;
                } catch (VirtualItemNotFoundException ex) {
                    StoreUtils.LogDebug(TAG, ex.Message);
                }
            }

            StoreEvents.OnMarketItemsRefreshed();
        }
Beispiel #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);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="marketItem">Market item.</param>
 public PurchaseWithMarket(MarketItem marketItem) :
     base()
 {
     this.MarketItem = marketItem;
 }
 /// <summary>
 /// Constructor.
 /// Constructs a <c>PurchaseWithMarket</c> object by constructing a new <c>MarketItem</c> object
 /// with the given <c>productId</c> and <c>price</c>, and declaring it as UNMANAGED.
 /// </summary>
 /// <param name="productId">Product id as it appears in the Market.</param>
 /// <param name="price">Price in the Market.</param>
 public PurchaseWithMarket(string productId, double price) :
     base()
 {
     this.MarketItem = new MarketItem(productId, MarketItem.Consumable.CONSUMABLE, price);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="com.soomla.unity.PurchaseWithMarket"/> class.
 /// </summary>
 /// <param name='marketItem'>
 /// The representation of the item in the platform's market.
 /// </param>
 public PurchaseWithMarket(MarketItem marketItem)
     : base()
 {
     this.MarketItem = marketItem;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="com.soomla.unity.PurchaseWithMarket"/> class.
 /// </summary>
 /// <param name='productId'>
 /// The productId to purchase in the platform's market.
 /// </param>
 /// <param name='price'>
 /// The price in the platform's market.
 /// </param>
 public PurchaseWithMarket(string productId, double price)
     : base()
 {
     this.MarketItem = new MarketItem(productId, MarketItem.Consumable.CONSUMABLE, price);
 }