gn-api-sdk-typescript

A Typescript module for integration of your backend with the payment services provided by Gerencianet.

Um módulo Typescript para integrar seu backend com os serviços de pagamento da Gerencianet.

Instalação

$ npm install gn-api-sdk-typescript

Uso Básico

Importe o módulo:

import Gerencianet from 'gn-api-sdk-typescript';

Insira suas credenciais e defina se deseja usar o sandbox ou não. Você também pode usar o arquivo examples/config.ts de modelo.

export = {
	// PRODUÇÃO = false
	// HOMOLOGAÇÃO = true
	sandbox: false,

	// CREDENCIAIS DE PRODUÇÃO
	clientIdProducao: '',
	clientSecretProducao: '',
	pathCertProducao: '',

	// CREDENCIAIS DE HOMOLOGAÇÃO
	clientIdHomologacao: '',
	clientSecretHomologacao: '',
	pathCertHomologacao: '',

	// VALIDAR MTLS?
	validateMtls: false,
};

Instancie o módulo passando as options:

const gerencianet = Gerencianet(options);

Crie uma cobrança:

var body = {
  items: [{
    name: 'Product A',
    value: 1000,
    amount: 2
  }]
}

gerencianet
  .createCharge({}, body)
  .then(console.log)
  .catch(console.log)
  .done();

Exemplos

Para executar os exemplos, clone este repo e instale as dependências:

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

Defina suas credenciais em config.ts:

export = {
	// PRODUÇÃO = false
	// HOMOLOGAÇÃO = true
	sandbox: false,

	// CREDENCIAIS DE PRODUÇÃO
	clientIdProducao: '',
	clientSecretProducao: '',
	pathCertProducao: '',

	// CREDENCIAIS DE HOMOLOGAÇÃO
	clientIdHomologacao: '',
	clientSecretHomologacao: '',
	pathCertHomologacao: '',

	// VALIDAR MTLS?
	validateMtls: false,
};

Em seguida, execute o exemplo que você deseja:

$ ts-node createCharge.ts

Documentação

A documentação completa com todos os endpoints disponíveis você encontra em: https://dev.gerencianet.com.br/.

License

MIT