amazon-payments
Advanced tools
Comparing version 0.0.4 to 0.1.0
@@ -10,2 +10,3 @@ var request = require('request'); | ||
var offAmazonPayments = require('./offAmazonPayments').offAmazonPayments; | ||
var reports = require('./reports').reports; | ||
var api = require('./api').api; | ||
@@ -27,2 +28,3 @@ | ||
this.offAmazonPayments = new offAmazonPayments(this); | ||
this.reports = new reports(this); | ||
this.api = new api(this); | ||
@@ -100,3 +102,3 @@ } | ||
parseMwsResponse(method, body, callback); | ||
parseMwsResponse(method, res.headers, body, callback); | ||
}); | ||
@@ -179,23 +181,36 @@ } | ||
function parseMwsResponse(method, response, callback) { | ||
xml2js.parseString(response, {explicitArray: false}, function(err, result) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
/** | ||
* Parse the MWS response. | ||
* | ||
* @param {string} method | ||
* @param {Object[]} headers | ||
* @param {string} response | ||
* @param {function} callback | ||
*/ | ||
function parseMwsResponse(method, headers, response, callback) { | ||
// if it's XML, then we an parse correctly | ||
if (response.indexOf("<?xml", 0) === 0) { | ||
xml2js.parseString(response, {explicitArray: false}, function(err, result) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
if (result.ErrorResponse) { | ||
err = { | ||
Code: 'Unknown', | ||
Message: 'Unknown MWS error' | ||
}; | ||
if (result.ErrorResponse) { | ||
err = { | ||
Code: 'Unknown', | ||
Message: 'Unknown MWS error' | ||
}; | ||
if (result.ErrorResponse.Error) { | ||
err = result.ErrorResponse.Error; | ||
if (result.ErrorResponse.Error) { | ||
err = result.ErrorResponse.Error; | ||
} | ||
return callback(error.apiError(err.Code, err.Message, result)); | ||
} else { | ||
callback(null, new Response(method, result)); | ||
} | ||
return callback(error.apiError(err.Code, err.Message, result)); | ||
} else { | ||
callback(null, new Response(method, result)); | ||
} | ||
}); | ||
}); | ||
} else { | ||
callback(null, new Response(method, { "Response": response })); | ||
} | ||
} | ||
@@ -202,0 +217,0 @@ |
@@ -0,1 +1,5 @@ | ||
/** | ||
* Amazon Payments Environments | ||
* @type {Environment} | ||
*/ | ||
exports.Sandbox = new Environment('https://mws.amazonservices.com/OffAmazonPayments_Sandbox/2013-01-01', 'https://api.sandbox.amazon.com'); | ||
@@ -6,2 +10,11 @@ exports.Production = new Environment('https://mws.amazonservices.com/OffAmazonPayments/2013-01-01', 'https://api.amazon.com'); | ||
/** | ||
* Amazon Reports Environments | ||
* @type {Environment} | ||
*/ | ||
exports.Sandbox.Reports = new Environment('https://mws.amazonservices.com/', 'https://api.sandbox.amazon.com'); | ||
exports.Production.Reports = new Environment('https://mws.amazonservices.com/', 'https://api.amazon.com'); | ||
exports.SandboxEU.Reports = new Environment('https://mws-eu.amazonservices.com/', 'https://api.sandbox.amazon.com'); | ||
exports.ProductionEU.Reports = new Environment('https://mws-eu.amazonservices.com/', 'https://api.amazon.com'); | ||
function Environment(mwsEndpoint, apiEndpoint) { | ||
@@ -8,0 +21,0 @@ this.mwsEndpoint = mwsEndpoint; |
@@ -8,3 +8,3 @@ { | ||
"description": "API wrapper for Amazon Payments", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"main": "amazonPayments.js", | ||
@@ -11,0 +11,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
30258
14
655
5