Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,15 @@ redeemable, the callback will be invoked with an `Error` passed as the first par
**v1.5.0 or later is required to use this method**

Updates your account's display languages for the Steam store.

### redeemGameKey(gameKey[, callback])
- `gameKey` - The Steam game key you want to redeem
Comment on lines +164 to +165
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### redeemGameKey(gameKey[, callback])
- `gameKey` - The Steam game key you want to redeem
### redeemSteamKey(steamKey[, callback])
- `steamKey` - The Steam activation key you want to redeem

or simply

Suggested change
### redeemGameKey(gameKey[, callback])
- `gameKey` - The Steam game key you want to redeem
### redeemKey(key[, callback])
- `key` - The Steam activation key you want to redeem

Steam keys don't only activate games, they activate any type of app. Technically, steam keys redeem steam packages.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or "product key" 🤔

- `callback` - Optional. Called when the request completes.
- `err` - An `Error` object if the request fails, or `null` on success
- `eresult` - An `EResult` value from `SteamStore.EResult`
- `ekeyactivationresult` - A value from `SteamStore.EKeyActivationResult`
- `purchase_receipt_info` - Info about the redeemed key

**v1.6.0 or later is required to use this method**

Attempts to redeem a Steam game key on your account.
30 changes: 30 additions & 0 deletions components/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ SteamStore.prototype.EPurchaseResult = EPurchaseResult;
var EResult = require('../resources/EResult.js');
SteamStore.prototype.EResult = EResult;

var EKeyActivationResult = require('../resources/EKeyActivationResult.js');
SteamStore.prototype.EKeyActivationResult = EKeyActivationResult;

SteamStore.prototype.addPhoneNumber = function(number, bypassConfirmation, callback) {
if(typeof bypassConfirmation === 'function') {
callback = bypassConfirmation;
Expand Down Expand Up @@ -318,3 +321,30 @@ SteamStore.prototype.redeemWalletCode = function(code, callback) {
});
});
};

SteamStore.prototype.redeemGameKey = function(code, callback) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SteamStore.prototype.redeemGameKey = function(code, callback) {
SteamStore.prototype.redeemSteamKey = function(code, callback) {

or simply

Suggested change
SteamStore.prototype.redeemGameKey = function(code, callback) {
SteamStore.prototype.redeemKey = function(code, callback) {

Steam keys don't only activate games, they activate any type of app. Technically, steam keys redeem steam packages.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or "product key" 🤔

var self = this;
self.request.post({
"uri": "https://store.steampowered.com/account/ajaxregisterkey/",
"form": {
"product_key": code,
"sessionid": this.getSessionID()
},
"json": true
}, function(err, response, body) {
if (!callback) {
return;
}

if (self._checkHttpError(err, response, callback)) {
return;
}

if (!body.success && !body.purchase_receipt_info) {
callback(new Error("Malformed response"));
return;
}

callback(null, body.success, body.purchase_result_details, body.purchase_receipt_info);
});
};
27 changes: 27 additions & 0 deletions resources/EKeyActivationResult.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @enum EKeyActivationResult
*/
module.exports = {
"Success": 0, // Key redeemed successfully
"UnexpectedError": 4, // Unexpected Error
"AlreadyInAccount": 9, // Account already has the product
"CountryRestriction": 13, // Product key not available in country
"InvalidProductKey": 14, // Invalid product key
"UsedProductKey": 15, // Product key already used
"GameRequired": 24, // Activating the product key requires another product in account
"PlayOnPS3": 36, // Game can only activated when played on PS3
"AccountBalanceKey": 50, // Key is a balance card
"TooManyActivations": 53, // Too many activations from account or IP

// Value-to-name mapping for convenience
"0": "Success",
"4": "UnexpectedError",
"9": "AlreadyInAccount",
"13": "CountryRestriction",
"14": "InvalidProductKey",
"15": "UsedProductKey",
"24": "GameRequired",
"36": "PlayOnPS3",
"50": "AccountBalanceKey",
"53": "TooManyActivations",
};