rglenn415 / RGupyter

Real time experiments with JS/CSS/HTML or Python in JupyterLab
13 stars 2 forks source link

Cookie for checkout post request #1

Open jlund7 opened 5 years ago

jlund7 commented 5 years ago

I have been trying and trying on this chrome extension that I have created, but every time I try to send the checkout POST request instead of getting a response of status: "queued", I get status: "failed". I have come to the conclusion that it is something to do with the cookie, please let me know how to trick the cookie into sending the request or what?

rglenn415 commented 5 years ago

This is either with the cookie or with your headers. What I did was play around with the headers when pooky was down and try to purchase any item. Once the headers are accepted as legitimate, work on solving pooky

jlund7 commented 5 years ago

cause the request gets a 200 status, and I have mimicked a legitimate request's headers other than the cookie, and it wont let me set a "unsafe" header for the cookie

rglenn415 commented 5 years ago

Send me your post request headers. I probably spent 20+ hours working on header formatting, there are lots of small details. Inspect the headers on multiple browsers, in incognito, and other stuff like that

jlund7 commented 5 years ago

I will post when I get home in a few hours

jlund7 commented 5 years ago

var add_cart_url = "https://www.supremenewyork.com/shop/" + item_id + "/add.json"

    var http1 = new XMLHttpRequest();
    http1.open('POST', add_cart_url, true);

    //Send the proper header information along with the request
    http1.setRequestHeader('accept', 'application/json');
    http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http1.setRequestHeader('x-requested-with', 'XMLHttpRequest');

    http1.onreadystatechange = function() {//Call a function when the state changes.
        if(http1.readyState == 4 && http1.status == 200) {
            console.log(http1.responseText)
            chrome.runtime.sendMessage({redirect: "https://www.supremenewyork.com/mobile/#cart"});
        }
    }
    http1.send('st=' + item_color_id + '&s=' + item_size_id + '&qty=1');

var mobile_checkout = "https://www.supremenewyork.com/checkout.json"; var size_decoded = '{"' + item_size_id + '"'; var phone_formatted = result.phone_num.slice(0, 3) + "-" + result.phone_num.slice(3, 6) + "-" + result.phone_num.slice(6, 10); var card_formatted = result.card_num.slice(0, 4) + " " + result.card_num.slice(4, 8)

jlund7 commented 5 years ago

Not sure whit formatted the code like that, but there is where I set headers n whatnot

jlund7 commented 5 years ago

Also for the headers there are some things that it will not let me set and says "Refused to set unsafe header"

jlund7 commented 5 years ago

and also I cant get the checkout post request to work when I send it directly in the console of supremenewyork.com after I add the item to the cart manually. Not sure if this is the cookies or headers, please let me know if you are even able to send the checkout post request directly through the console, and if it returns a slug and status queued.

rglenn415 commented 5 years ago

You are missing the correct headers and data fields. Keep playing with it more. You don't even have all the fields from the console log. Try firefox and chrome header inspecting

jlund7 commented 5 years ago

I know I am missing the headers because it says "Refused to set unsafe header" for some of them and i basically mimicked the form data. I am sending the checkout post request mobile version of it. Not sure if I am suppose to be sending the regular version of the post request, but I will try that as well, appreciate it

jlund7 commented 5 years ago

by chance do you know where the authenticity_token is being generated from in the form data and header?

jlund7 commented 5 years ago

Alright I actually found the token, but now this is the same problem that goes back to the cookies, for whatever reason the cookies that get added to ATC try to add themselves into the checkout cookies response when they are not suppose to be there. set-cookie: cart=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000 set-cookie: pure_cart=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000 do you know a way to remove these Reponses from the request you send?

jlund7 commented 5 years ago

are those 2 response set-cookie from the time not being set properly with the pooky proxies or something.... I know there is suppose to be a specific time set somewhere, do you know anything about that?