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.
$ npm install gn-api-sdk-typescript
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();
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
A documentação completa com todos os endpoints disponíveis você encontra em: https://dev.gerencianet.com.br/.