gn-api-sdk-typescript
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

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,
	client_id: 'seuclient_id',
	client_secret: 'seuclient_secret',
	certificate: 'caminhoAteOCertificadoPix',
};

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((resposta: any) => {
		console.log(resposta);
	})
	.catch((error: Promise<any>) => {
		console.log(error);
	})
	.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,
	client_id: 'seuclient_id',
	client_secret: 'seuclient_secret',
	certificate: 'caminhoAteOCertificadoPix',
};

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

Package Sidebar

Install

npm i gn-api-sdk-typescript

Weekly Downloads

1,701

Version

2.0.1

License

MIT

Unpacked Size

109 kB

Total Files

123

Last publish

Collaborators

  • jvoliveiragn