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); }
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; } } } }