Hi,
is it posible to add games to cart and buy with steam balance ?
Tried it, but not sure if im skipping/missung other requests.
// Add games to cart
for (let i = 0; i < arrayGames.length; i++) {
var gameID = Number(arrayGames[i]);
logINFO(`gameID: ` + gameID);
await addToCart(Steam, Community, sessionID, gameID);
await SLEEP(5000);
}
// Get transaction id
let purchaseId = await scrapTransactionID(Community);
logINFO(purchaseId);
// Buy games in cart
await purchaseGames(Community, purchaseId);
function addToCart(Steam, Community, sessionID, subid) {
return new Promise((resolve) => {
Community.httpRequestPost(
`https://store.steampowered.com/cart/`,
{
form: {
snr: "1_5_9__403",
originating_snr: "1_direct-navigation__",
action: "add_to_cart",
sessionid: sessionID,
subid: subid,
},
headers: {
Host: "store.steampowered.com",
Origin: "https://store.steampowered.com",
},
json: true,
},
(err, res, body) => {
if (!err && res.resposeCode == 200) {
logINFO(`Success`);
} else {
logERROR(`Failed`);
}
}
);
resolve();
});
} // func()
function scrapTransactionID(Community) {
return new Promise((resolve) => {
Community.httpRequestPost(
`https://store.steampowered.com/cart`,
(err, res, body) => {
if (!err) {
let pattern = /https:\/\/store.steampowered.com\/checkout\/\?purchasetype=gift&cart=(\d+)&/;
let match = body.match(pattern);
if (match) {
logINFO(`Matched: ` + match[1]);
resolve(match[1]);
}
}
}
);
});
} //func()
function purchaseGames(Community, purchaseId) {
return new Promise((resolve) => {
Community.httpRequestPost(
`https://store.steampowered.com/checkout/finalizetransaction/`,
{
form: {
transid: purchaseId,
CardCVV2: "",
browserInfo: {
language: "en-US",
javaEnabled: "false",
colorDepth: 24,
screenHeight: 600,
screenWidth: 800,
},
},
headers: {
Host: "store.steampowered.com",
Origin: "https://store.steampowered.com",
Referer: `https://store.steampowered.com/checkout/?purchasetype=self&cart=${purchaseId}&snr=1_8_4__503`,
},
json: true,
},
(err, res, body) => {
if (!err) {
logINFO("success");
}
}
);
resolve();
});
} //func()