npm install auth-net-request
var AuthorizeRequest = require('auth-net-request');
var Request = new AuthorizeRequest({
api: '123',
key: '1234',
cert: '/path/to/cert.pem',
rejectUnauthorized: false, // true
requestCert: true, // false
agent: false // http.agent object
sandbox: false // true
});
Request.send(<method>, <xml>, [xmlOptions], function(err, response) {});<method>- As specified in the Auhorize.net API without the "Request" suffix, e.g. "createTransaction".<xml>- Either an XML string or a JavaScript object reflecting the JSON specification in the Authorize.net API.xmlOptions.rejectUnauthorized- seehttps.requestoption. Note: defaults tofalse. Likely want to set totrue.xmlOptions.requestCert- Defaults totrue.xmlOptions.agent- Defaults tofalse.xmlOptions.extraOptions- Adds an<extraOptions>tag to the request. For?
If !err on the send method callback, response is as specified in the
Authorize.net API. E.g. consider checking and recording
response.transactionResponse.responseCode,
response.transactionResponse.authCode and
response.transactionResponse.transId.
If !!err on the send method callback, you can get access to the
following properties of err:
err.nameerr.messageerr.codeerr.stackerr.response- response from Authorize.net API, if the request got that far.
!err on the send method callback does not necessarily mean a
transaction was approved. Note the differences among the following
in the API documentation: messages.resultCode,
messages.message.code and transactionResponse.responseCode.
Version >= 2.x.x has a breaking change, all values are returned as strings rather than strings and numbers (unless the value is an object, array, etc).
- Authorize.net API Reference
- Authorize.net Response Codes
- Node.js https.request