예제 #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);
        }
예제 #2
0
 internal InGamePurchasing()
 {
     this._user = InGamePurchasing.SteamUnityAPI_SteamUser();
     this._apps = InGamePurchasing.SteamUnityAPI_SteamApps();
     if (this._internalOnTransactionAuthorizationReceived != null)
     {
         return;
     }
     this._internalOnTransactionAuthorizationReceived = new OnTransactionAuthorizationReceivedFromSteam(this.OnTransactionAuthorizationReceived);
     InGamePurchasing.SteamUnityAPI_SetTransactionAuthorizationCallback(Marshal.GetFunctionPointerForDelegate((Delegate)this._internalOnTransactionAuthorizationReceived));
 }
예제 #3
0
 public InGamePurchase NewPurchase(bool useTestMode, string webAPIKey, ulong orderID)
 {
     if (this._regionInfo == null)
     {
         this._steamID = new SteamID(InGamePurchasing.SteamUnityAPI_SteamUser_GetSteamID(this._user));
         string currentGameLanguage = InGamePurchasing.SteamUnityAPI_SteamApps_GetCurrentGameLanguage(this._apps);
         foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(CultureTypes.AllCultures))
         {
             if (cultureInfo.DisplayName.Equals(currentGameLanguage, StringComparison.OrdinalIgnoreCase) || cultureInfo.EnglishName.Equals(currentGameLanguage, StringComparison.OrdinalIgnoreCase) || cultureInfo.NativeName.Equals(currentGameLanguage, StringComparison.OrdinalIgnoreCase))
             {
                 this._language = cultureInfo.TwoLetterISOLanguageName;
                 break;
             }
         }
         this.FetchRegionInfo(useTestMode, webAPIKey);
     }
     return(new InGamePurchase(useTestMode, webAPIKey, orderID));
 }
예제 #4
0
 private void OnTransactionAuthorizationReceived(ref MicroTxnAuthorizationResponse_t callbackData)
 {
     foreach (InGamePurchase purchase in this._outstandingPurchases)
     {
         if ((long)purchase.OrderID == (long)callbackData.m_ulOrderID)
         {
             if ((int)callbackData.m_bAuthorized == 1)
             {
                 SteamWebAPIRequest steamWebApiRequest = CommunityExpress.Instance.SteamWebAPI.NewRequest(this.GetWebInterface(purchase.UseTestMode), "FinalizeTxn", "v0001");
                 steamWebApiRequest.AddPostValue("key", purchase.WebAPIKey);
                 steamWebApiRequest.AddPostValue("orderid", callbackData.m_ulOrderID.ToString());
                 steamWebApiRequest.AddPostValue("appid", InGamePurchasing.SteamUnityAPI_SteamUtils_GetAppID().ToString());
                 steamWebApiRequest.Execute(new OnRequestComplete(this.OnTransactionFinalized));
                 break;
             }
             else
             {
                 purchase.InGamePurchaseCompleteCallback(purchase, false);
                 this._outstandingPurchases.Remove(purchase);
                 break;
             }
         }
     }
 }