Ejemplo n.º 1
0
        public bool StartPurchase(InGamePurchase purchase, OnInGamePurchaseComplete callback)
        {
            if (this._regionInfo == null)
            {
                return(false);
            }
            purchase.InGamePurchaseCompleteCallback = callback;
            SteamWebAPIRequest steamWebApiRequest = CommunityExpress.Instance.SteamWebAPI.NewRequest(this.GetWebInterface(purchase.UseTestMode), "InitTxn", "v0002");

            steamWebApiRequest.AddPostValue("key", purchase.WebAPIKey);
            steamWebApiRequest.AddPostValue("orderid", purchase.OrderID.ToString());
            steamWebApiRequest.AddPostValue("steamid", this._steamID.ToUInt64().ToString());
            steamWebApiRequest.AddPostValue("appid", InGamePurchasing.SteamUnityAPI_SteamUtils_GetAppID().ToString());
            steamWebApiRequest.AddPostValue("itemcount", purchase.ItemList.Count.ToString());
            steamWebApiRequest.AddPostValue("language", this._language);
            steamWebApiRequest.AddPostValue("currency", this._regionInfo.ISOCurrencySymbol);
            int num = 0;

            foreach (InGamePurchase.Item obj in (IEnumerable <InGamePurchase.Item>)purchase.ItemList)
            {
                steamWebApiRequest.AddPostValue("itemid%5B" + (object)num + "%5D", obj.ID.ToString());
                steamWebApiRequest.AddPostValue("qty%5B" + (object)num + "%5D", obj.Quantity.ToString());
                steamWebApiRequest.AddPostValue("amount%5B" + (object)num + "%5D", obj.Amount.ToString());
                steamWebApiRequest.AddPostValue("description%5B" + (object)num + "%5D", obj.Description);
                if (obj.Category != "")
                {
                    steamWebApiRequest.AddPostValue("category%5B" + (object)num + "%5D", obj.Category);
                }
                ++num;
            }
            this._outstandingPurchases.Add(purchase);
            steamWebApiRequest.Execute(new OnRequestComplete(this.OnPurchaseStarted));
            return(true);
        }
Ejemplo n.º 2
0
        private void OnTransactionFinalized(SteamWebAPIRequest request, string response)
        {
            InGamePurchase purchase = (InGamePurchase)null;
            ulong          num      = ulong.Parse(request.GetPostValue("orderid"));

            foreach (InGamePurchase inGamePurchase in this._outstandingPurchases)
            {
                if ((long)inGamePurchase.OrderID == (long)num)
                {
                    purchase = inGamePurchase;
                    break;
                }
            }
            if (purchase == null)
            {
                return;
            }
            bool       successful = false;
            JsonReader jsonReader = (JsonReader) new JsonTextReader((TextReader) new StringReader(response));

            while (jsonReader.Read())
            {
                if (jsonReader.TokenType == JsonToken.PropertyName && jsonReader.Value.Equals((object)"result") && jsonReader.ReadAsString().Equals("OK", StringComparison.OrdinalIgnoreCase))
                {
                    successful = true;
                    break;
                }
            }
            purchase.InGamePurchaseCompleteCallback(purchase, successful);
            this._outstandingPurchases.Remove(purchase);
        }
Ejemplo n.º 3
0
 public bool StartPurchase(InGamePurchase purchase, OnInGamePurchaseComplete callback)
 {
   if (this._regionInfo == null)
     return false;
   purchase.InGamePurchaseCompleteCallback = callback;
   SteamWebAPIRequest steamWebApiRequest = CommunityExpress.Instance.SteamWebAPI.NewRequest(this.GetWebInterface(purchase.UseTestMode), "InitTxn", "v0002");
   steamWebApiRequest.AddPostValue("key", purchase.WebAPIKey);
   steamWebApiRequest.AddPostValue("orderid", purchase.OrderID.ToString());
   steamWebApiRequest.AddPostValue("steamid", this._steamID.ToUInt64().ToString());
   steamWebApiRequest.AddPostValue("appid", InGamePurchasing.SteamUnityAPI_SteamUtils_GetAppID().ToString());
   steamWebApiRequest.AddPostValue("itemcount", purchase.ItemList.Count.ToString());
   steamWebApiRequest.AddPostValue("language", this._language);
   steamWebApiRequest.AddPostValue("currency", this._regionInfo.ISOCurrencySymbol);
   int num = 0;
   foreach (InGamePurchase.Item obj in (IEnumerable<InGamePurchase.Item>) purchase.ItemList)
   {
     steamWebApiRequest.AddPostValue("itemid%5B" + (object) num + "%5D", obj.ID.ToString());
     steamWebApiRequest.AddPostValue("qty%5B" + (object) num + "%5D", obj.Quantity.ToString());
     steamWebApiRequest.AddPostValue("amount%5B" + (object) num + "%5D", obj.Amount.ToString());
     steamWebApiRequest.AddPostValue("description%5B" + (object) num + "%5D", obj.Description);
     if (obj.Category != "")
       steamWebApiRequest.AddPostValue("category%5B" + (object) num + "%5D", obj.Category);
     ++num;
   }
   this._outstandingPurchases.Add(purchase);
   steamWebApiRequest.Execute(new OnRequestComplete(this.OnPurchaseStarted));
   return true;
 }
Ejemplo n.º 4
0
 public void AddItem(InGamePurchase.Item item)
 {
   this._itemList.Add(item);
 }