NodeJS

Our API is RESTful and responds in JSON. Gerencianet uses OAuth to provide authorized access to the API. Our NodeJS SDK is already prepared to perform this authentication automatically.

Below, check out the procedures for installing the Gerencianet SDK in NodeJS:

Installing via NPM

$ npm install gn-api-sdk-node

Tested with com

  • Node 0.12.7, 4.4.0 , e 4.4.4

Basic use

Reference the module:

var Gerencianet = require('gn-api-sdk-node');

Set your credentials and whether you want to use sandbox or not:

var options = {
client_id: 'inform_your_client_id',
client_secret: 'inform_your_client_secret',
sandbox: true
}

Instantiate the module passing your options:

var gerencianet = new Gerencianet(options);

Crie a charge (transação):

var chargeInput = {
items: [{
name: 'Product A',
value: 1000,
amount: 2
}]
}
gerencianet
.createCharge({}, chargeInput)
.then(console.log)
.catch(console.log)
.done();

Exemples

To run the examples, clone this repository and install the dependencies:

$ git clone git@github.com:gerencianet/gn-api-sdk-node.git
$ cd gn-api-sdk-node/examples
$ npm install

Set your oauth keys in the file credentials.js:

module.exports = {
client_id: 'your_client_id',
client_secret: 'your_client_secret'
}

Then run the desired example:

$ node createCharge.js

Tests

To run the test suite, first install the dependencies and then run the npm test:

$ cd gn-api-sdk-node/
$ npm install
$ npm test