protected PurchasableVirtualItem(AndroidJavaObject jniVirtualItem)
            : base(jniVirtualItem)
        {
            SoomlaUtils.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")) {
                        MarketItem mi = new MarketItem(jniMarketItem);
                        PurchaseType = new PurchaseWithMarket(mi);
                    }
                } 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 {
                        SoomlaUtils.LogError(TAG, "Couldn't determine what type of class is the given purchaseType.");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        /// <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);

            string[]          marketItemsChanges = Regex.Split(message, "#SOOM#");
            List <MarketItem> marketItems        = new List <MarketItem>();

            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;
                    pvi.save();

                    marketItems.Add(mi);
                } catch (VirtualItemNotFoundException ex) {
                    SoomlaUtils.LogDebug(TAG, ex.Message);
                }
            }

            StoreEvents.OnMarketItemsRefreshFinished(marketItems);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// see parent.
        /// </summary>
        /// <returns>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(StoreJSONConsts.PURCHASE_TYPE, StoreJSONConsts.PURCHASE_TYPE_MARKET);

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

                    purchasableObj.AddField(StoreJSONConsts.PURCHASE_VI_ITEMID, ((PurchaseWithVirtualItem)PurchaseType).TargetItemId);
                    purchasableObj.AddField(StoreJSONConsts.PURCHASE_VI_AMOUNT, ((PurchaseWithVirtualItem)PurchaseType).Amount);
                }

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

            return(jsonObject);
        }
        protected PurchasableVirtualItem(AndroidJavaObject jniVirtualItem) :
            base(jniVirtualItem)
        {
            SoomlaUtils.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")) {
                        MarketItem mi = new MarketItem(jniMarketItem);
                        PurchaseType = new PurchaseWithMarket(mi);
                    }
                }
                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
                    {
                        SoomlaUtils.LogError(TAG, "Couldn't determine what type of class is the given purchaseType.");
                    }
                }
            }
        }
Ejemplo n.º 7
0
        protected PurchasableVirtualItem(SoomlaWpStore.domain.PurchasableVirtualItem wpPurchasableVirtualItem) :
            base(wpPurchasableVirtualItem)
        {
            SoomlaUtils.LogDebug(TAG, "Trying to create PurchasableVirtualItem with itemId: " +
                                 wpPurchasableVirtualItem.getItemId());

            SoomlaWpStore.purchasesTypes.PurchaseType wpPT = wpPurchasableVirtualItem.GetPurchaseType();
            if (wpPT is SoomlaWpStore.purchasesTypes.PurchaseWithMarket)
            {
                SoomlaWpStore.purchasesTypes.PurchaseWithMarket wpPWM = (SoomlaWpStore.purchasesTypes.PurchaseWithMarket)wpPT;
                string productId = wpPWM.getMarketItem().getProductId();

                /*MarketItem.Consumable consType = MarketItem.Consumable.CONSUMABLE;
                 * if(wpPWM.getMarketItem().getManaged() == SoomlaWpStore.domain.MarketItem.Managed.MANAGED)
                 * {
                 *  consType = MarketItem.Consumable.CONSUMABLE;
                 * }
                 * if (wpPWM.getMarketItem().getManaged() == SoomlaWpStore.domain.MarketItem.Managed.UNMANAGED)
                 * {
                 *  consType = MarketItem.Consumable.NONCONSUMABLE;
                 * }
                 * if (wpPWM.getMarketItem().getManaged() == SoomlaWpStore.domain.MarketItem.Managed.SUBSCRIPTION)
                 * {
                 *  consType = MarketItem.Consumable.SUBSCRIPTION;
                 * }*/
                double price = wpPWM.getMarketItem().getPrice();

                MarketItem mi = new MarketItem(productId, price);
                mi.MarketTitle            = wpPWM.getMarketItem().getMarketTitle();
                mi.MarketPriceAndCurrency = wpPWM.getMarketItem().getMarketPrice();
                mi.MarketDescription      = wpPWM.getMarketItem().getMarketDescription();
                if (wpPWM.getMarketItem().isPriceSuccessfullyParsed())
                {
                    mi.MarketPriceMicros  = wpPWM.getMarketItem().getMarketPriceMicros();
                    mi.MarketCurrencyCode = wpPWM.getMarketItem().getMarketCurrencyCode();
                }
                PurchaseType = new PurchaseWithMarket(mi);
            }

            if (wpPT is SoomlaWpStore.purchasesTypes.PurchaseWithVirtualItem)
            {
                SoomlaWpStore.purchasesTypes.PurchaseWithVirtualItem wpPWVI = (SoomlaWpStore.purchasesTypes.PurchaseWithVirtualItem)wpPT;
                string itemId = wpPWVI.getTargetItemId();
                int    amount = wpPWVI.getAmount();
                PurchaseType = new PurchaseWithVirtualItem(itemId, amount);
            }
        }
Ejemplo n.º 8
0
        /// <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);

            string[]          marketItemsChanges = Regex.Split(message, "#SOOM#");
            List <MarketItem> marketItems        = new List <MarketItem>();

            foreach (string mic in marketItemsChanges)
            {
                if (string.IsNullOrEmpty(mic.Trim()))
                {
                    continue;
                }

                JSONObject micJSON            = new JSONObject(mic);
                string     productId          = micJSON[JSONConsts.MARKETITEM_PRODUCT_ID].str;
                string     marketPrice        = micJSON[JSONConsts.MARKETITEM_MARKETPRICE].str;
                string     marketTitle        = micJSON[JSONConsts.MARKETITEM_MARKETTITLE].str;
                string     marketDescription  = micJSON[JSONConsts.MARKETITEM_MARKETDESC].str;
                string     marketCurrencyCode = micJSON[JSONConsts.MARKETITEM_MARKETCURRENCYCODE].str;
                long       marketPriceMicros  = System.Convert.ToInt64(micJSON[JSONConsts.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);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="marketItem">Market item.</param>
 public PurchaseWithMarket(MarketItem marketItem) :
     base()
 {
     this.MarketItem = marketItem;
 }
Ejemplo n.º 10
0
 /// <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);
 }
Ejemplo n.º 11
0
 /// <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, price);
 }
 /// <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, price);
 }
Ejemplo n.º 14
0
		protected PurchasableVirtualItem(SoomlaWpStore.domain.PurchasableVirtualItem wpPurchasableVirtualItem) :
            base(wpPurchasableVirtualItem)
            {
			SoomlaUtils.LogDebug(TAG, "Trying to create PurchasableVirtualItem with itemId: " +
                                wpPurchasableVirtualItem.getItemId());

            SoomlaWpStore.purchasesTypes.PurchaseType wpPT = wpPurchasableVirtualItem.GetPurchaseType();
            if (wpPT is SoomlaWpStore.purchasesTypes.PurchaseWithMarket)
            {
                SoomlaWpStore.purchasesTypes.PurchaseWithMarket wpPWM = (SoomlaWpStore.purchasesTypes.PurchaseWithMarket)wpPT;
                string productId = wpPWM.getMarketItem().getProductId();
                /*MarketItem.Consumable consType = MarketItem.Consumable.CONSUMABLE;
                if(wpPWM.getMarketItem().getManaged() == SoomlaWpStore.domain.MarketItem.Managed.MANAGED)
                {
                    consType = MarketItem.Consumable.CONSUMABLE;
                }
                if (wpPWM.getMarketItem().getManaged() == SoomlaWpStore.domain.MarketItem.Managed.UNMANAGED)
                {
                    consType = MarketItem.Consumable.NONCONSUMABLE;
                }
                if (wpPWM.getMarketItem().getManaged() == SoomlaWpStore.domain.MarketItem.Managed.SUBSCRIPTION)
                {
                    consType = MarketItem.Consumable.SUBSCRIPTION;
                }*/
                double price = wpPWM.getMarketItem().getPrice();

                MarketItem mi = new MarketItem(productId, price);
                mi.MarketTitle = wpPWM.getMarketItem().getMarketTitle();
                mi.MarketPriceAndCurrency = wpPWM.getMarketItem().getMarketPrice();
                mi.MarketDescription = wpPWM.getMarketItem().getMarketDescription();
                if(wpPWM.getMarketItem().isPriceSuccessfullyParsed())
                {
                    mi.MarketPriceMicros = wpPWM.getMarketItem().getMarketPriceMicros();
                    mi.MarketCurrencyCode = wpPWM.getMarketItem().getMarketCurrencyCode();
                }
                PurchaseType = new PurchaseWithMarket(mi);
            }

            if (wpPT is SoomlaWpStore.purchasesTypes.PurchaseWithVirtualItem)
            {
                SoomlaWpStore.purchasesTypes.PurchaseWithVirtualItem wpPWVI = (SoomlaWpStore.purchasesTypes.PurchaseWithVirtualItem)wpPT;
                string itemId = wpPWVI.getTargetItemId();
                int amount = wpPWVI.getAmount();
                PurchaseType = new PurchaseWithVirtualItem(itemId, amount);
            }
        }
Ejemplo n.º 15
0
 /// <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);
 }