/// <summary> /// Gets the purchasable item with the given <c>productId</c>. /// </summary> /// <param name="productId">Product id.</param> /// <returns>Purchasable virtual item with the given id.</returns> /// <exception cref="VirtualItemNotFoundException">Exception is thrown if item is not found.</exception> override protected PurchasableVirtualItem _getPurchasableItemWithProductId(string productId) { IntPtr p = IntPtr.Zero; int err = storeInfo_GetPurchasableItemWithProductId(productId, out p); IOS_ErrorCodes.CheckAndThrowException(err); string nonConsJson = Marshal.PtrToStringAnsi(p); Marshal.FreeHGlobal(p); JSONObject obj = new JSONObject(nonConsJson); return((PurchasableVirtualItem)VirtualItem.factoryItemFromJSONObject(obj)); }
/// <summary> /// Gets the item with the given <c>itemId</c>. /// </summary> /// <param name="itemId">Item id.</param> /// <returns>Item with the given id.</returns> /// <exception cref="VirtualItemNotFoundException">Exception is thrown if item is not found.</exception> override protected VirtualItem _getItemByItemId(string itemId) { IntPtr p = IntPtr.Zero; int err = storeInfo_GetItemByItemId(itemId, out p); IOS_ErrorCodes.CheckAndThrowException(err); string json = Marshal.PtrToStringAnsi(p); Marshal.FreeHGlobal(p); SoomlaUtils.LogDebug(TAG, "Got json: " + json); JSONObject obj = new JSONObject(json); return(VirtualItem.factoryItemFromJSONObject(obj)); }
/// <summary> /// Fetches the virtual goods of your game. /// </summary> /// <returns>All virtual goods.</returns> override protected List <VirtualGood> _getVirtualGoods() { List <VirtualGood> virtualGoods = new List <VirtualGood>(); IntPtr p = IntPtr.Zero; int err = storeInfo_GetVirtualGoods(out p); IOS_ErrorCodes.CheckAndThrowException(err); string goodsJson = Marshal.PtrToStringAnsi(p); Marshal.FreeHGlobal(p); SoomlaUtils.LogDebug(TAG, "Got json: " + goodsJson); JSONObject goodsArr = new JSONObject(goodsJson); foreach (JSONObject obj in goodsArr.list) { virtualGoods.Add((VirtualGood)VirtualItem.factoryItemFromJSONObject(obj)); } return(virtualGoods); }