nodejs sdk for Authorize.Net
npm install authorizenetnpm install authorizenet
javascript
var merchantAuthenticationType = new ApiContracts.MerchantAuthenticationType();
merchantAuthenticationType.setName('YOUR_API_LOGIN_ID');
merchantAuthenticationType.setTransactionKey('YOUR_TRANSACTION_KEY');
`
An authentication test sample is provided and can be run with the following command:
node sample/test.js
Never include your Login ID and Transaction Key directly in a file that's in a publicly accessible portion of your website. As a best practice, define the API Login ID and Transaction Key in a constants file, and reference those constants in the appropriate place in your code.
$3
Authorize.Net maintains a complete sandbox environment for testing and development purposes. The sandbox environment is an exact replica of our production environment, with simulated transaction authorization and settlement. By default, this SDK is configured to use with the sandbox environment. To switch to the production environment, call setEnvironment on the controller variable before execute.
For example:
`javascript
// For PRODUCTION use
ctrl.setEnvironment(SDKConstants.endpoint.production);
`
API credentials are different for each environment, so be sure to switch to the appropriate credentials when switching environments.
SDK Usage Examples and Sample Code
When using this SDK, downloading the Authorize.Net sample code repository is recommended.
* Authorize.Net Node.js Sample Code Repository (on GitHub)
The repository contains comprehensive sample code for all common uses of the Authorize.Net API:
The API Reference contains details and examples of the structure and formatting of the Authorize.Net API.
* Developer Center API Reference
Use the examples in the API Reference to determine which methods and information to include in an API request using this SDK.
Create a Chase Pay Transaction
Use this method to authorize and capture a payment using a tokenized credit card number issued by Chase Pay. Chase Pay transactions are only available to merchants using the Paymentech processor.
The following information is required in the request:
- payment token
- expiration date
- cryptogram received from the token provider
- tokenRequestorName
- tokenRequestorId
- tokenRequestorEci
When using the SDK to submit Chase Pay transactions, consider the following points:
- tokenRequesterName must be populated with ”CHASE_PAY”
- tokenRequestorId must be populated with the Token Requestor ID provided by Chase Pay services for each transaction during consumer checkout
- tokenRequesterEci must be populated with the ECI Indicator provided by Chase Pay services for each transaction during consumer checkout
Building & Testing the SDK
$3
mocha
$3
mocha test/
$3
1. Create a config object as follows:
`javascript
config = {
'proxy': {
'setProxy': true,
'proxyUrl': 'http://:@:'
}
}
`
2. Pass this config object to the controller constructor.
For example,
`javascript
var ctrl = new ApiControllers.CreateTransactionController(createRequest.getJSON(), config);
`
$3
For additional help in testing your own code, Authorize.Net maintains a comprehensive testing guide that includes test credit card numbers to use and special triggers to generate certain responses from the sandbox environment.
$3
Authorize.Net is phasing out the MD5 based transHash element in favor of the SHA-512 based transHashSHA2. The setting in the Merchant Interface which controlled the MD5 Hash option is no longer available, and the transHash element will stop returning values at a later date to be determined. For information on how to use transHashSHA2, see the [Transaction Hash Upgrade Guide] (https://developer.authorize.net/support/hash_upgrade/).
License
This repository is distributed under a proprietary license. See the provided LICENSE.txt` file.