Jump to content
McKay Development

igor

Member
  • Posts

    6
  • Joined

  • Last visited

igor's Achievements

  1. igor

    buy confirmation

    nevermind, I am just dumb: after the first request I do update to body but I don't update content-len header
  2. igor

    buy confirmation

    Hello everyone! Due to recent update I tried implementing buy order confirmation and I failed (partly)๐Ÿ˜ž. I came here to ask for help because It seems I can't understand why my code runs into the problems. here are the pieces of my code: function getCookiesHeaders(contentLength, cookiesStr, itemName, game) { return { Accept: "*/*", "Accept-Encoding": "gzip, deflate, br, zstd", "Accept-Language": "en-US,en;q=0.9", Connection: "keep-alive", "Content-Length": contentLength, "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", Cookie: cookiesStr, Host: "steamcommunity.com", Origin: "https://steamcommunity.com", Referer: `https://steamcommunity.com/market/listings/${ GAME_IDENTIFIERS[game] }/${encodeURI(itemName)}`, "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-origin", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36", "sec-ch-ua": '"Google Chrome";v="138", "Not)A.Brand";v="8", "Chromium";v="138"', "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": '"Windows"', }; } function getParamsWithFee(cookies, priceInfo) { const { converted_price: subtotal, converted_fee: fee } = priceInfo; return { sessionid: cookies.sessionid, currency: 18, subtotal, fee, total: fee + subtotal, quantity: 1, billing_state: "", save_my_address: 0, confirmation: 0 }; } function generateListingIdLink(listingId) { return "https://steamcommunity.com/market/buylisting/" + listingId; } async function buyItem(itemName, priceDetails, listingId, game, buyingCookies) { // all these params are fine const confData = { identitySecret: "myIdentitySecretFromMyFile", steamId: "mySteamIdFromMyFile", cookies: buyingCookies }; const { cookies, cookiesStr } = getStrObjCookies(buyingCookies); const params = getParamsWithFee(cookies, priceDetails); const { bodyParams, contentLength } = getSearchParamsData(params); const headers = getCookiesHeaders(contentLength, cookiesStr, itemName, game); const sendBuyReq = async () => { try{ const response = await axios.post(generateListingIdLink(listingId), bodyParams, { headers, validateStatus: (statusCode) => { return statusCode <= 400 || statusCode === 406}}) // validateStatus needs to be done because axios thinks that 406 statusCode here is error and it falls into catch scope console.log('Response status:', response.status); return response; }catch(err){ console.log(err.message, "--errorMsg--"); throw err; } } try { const { data } = await sendBuyReq(); // that's fine it works great. From SDA it's clearly visible that the buy order is set. // I tried here await waitTime(2) so my buy information could get in time to the servers. await confirmBuyListing(confData); // The problem might be right here but it's unlikely because by itself it works await waitTime(1); // I tried increasing time from 1 sec to 2 secs. bodyParams.set("confirmation", data.confirmation?.confirmation_id); // updataing params with confirmationId to send new buyLink() const { data: finalizedData } = await sendBuyReq(); // THE MAIN PROBLEM IS HERE if (finalizedData.success === 22) console.log(finalizedData); // testing } catch (err) { console.log(err); } } I tried checking for confirmation_id and it's fine. Left that just as bodyParams.set("confirmation", data.confirmation?.confirmation_id); I think that line with "// THE MAIN PROBLEM IS HERE" is main part because when I make request it shows "status:502" but the original repetitave steam request shows "status:406" And this is the part where I can't understand why I get 502 code in my code. If needed I will add confirmBuyListing function for clarification. Shortly I tested the function with browser manual buying and it confirmed and I bought the item Despite what I wrote above my second thought would be, the problem lies within both confirmation function and buyLink function. I've seen 3 diffrent projects that this confirmation logic was implemented in: C#, JS, PYTHON and I chose python approach because pythonists have already confirmed that they solved this confirmation problem so I tried to follow their solution (this solution could be found in steamPy issues on git). I don't know what is the cause of that status 502. I did almost everything I prayed and cursed and still can't find the cause of that. I am not giving up on this but the only thing I am looking here is help๐Ÿ˜ฐ๐Ÿ˜ฐ *Possible solution is to run python solution directly in my js file from pythonists (the last thing I wanna do).
  3. Hmm... That's an interesting piece of information. The only thing I knew was if you get rid of that restriction steam server let you have responses with the appropriate currency setting "...&currency=<currencyCode>&..." and if you have that restriction, items from steamcommunity would have their country currency that this item was set in. Thx for your response.
  4. Hi๐Ÿ‘‹! I am not sure why does steam need webTradeEligibility cookie? (for steamcommunity) In case of sessionId, steamLoginSecure, steamCountry it's clear for me that without the ones steam would not allow me to fetch their data not many time (~20 reqs per min (not sure of that๐Ÿ˜…)). In general: does steamcommunity use only three of these I mentioned above or steamcommunity.com domain uses: webTradeEligibility, timezoneOffset, cookieSettings, browserid, steamDidLoginRefresh in addition mentioned ones? This question had happened because of my regular steam response errors with cookies (sessionId, steamLoginSecure, steamCountry) using axios (some times with different web proxies). link I used these cookies with: https://steamcommunity.com/market/listings/730/${SkinName}/render/?query=&start=0&count=10&country=UA&language=russian&currency=18 steamcommunity.com/market/listings/730/AK-47 | Neon Revolution (Field-Tested)/render/?query=&start=0&count=10&country=UA&language=russian&currency=18 In addition to that I was sure that steam sends response errors because of my multiple reqs or mb there was something on their server side so tried to reproduce the same response errors but using my browser with logged account and the link above, all of that testing left me currious because the responses were perfect, by "perfect" I mean I had no errors at all and response was always "{"success":true,...". And again why does it happen? Thx in advance.
  5. igor

    logout and cookies

    Thank you so SO SO much.
  6. I have a question about cookies lifetime: when I logout from steamcommunity.com (or other steam domain) cookies get expired as well? I'm having some problems with my code where the code takes cookies from the browser and right after I logout from browser and my cookies get expired. Is it possible or it's just my dummy assumption?
×
×
  • Create New...