Skip to content

Commit c86b43c

Browse files
committed
Merge branch 'gerencianet:main' into main
2 parents 7dca0b8 + ecc1cdf commit c86b43c

File tree

5 files changed

+133
-5
lines changed

5 files changed

+133
-5
lines changed

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.eslint.json
2+
.gitignore
3+
.npmignore
4+
.prettierrc.json
5+
package.json
6+
README.md
7+
tsconfig.json

README.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,114 @@
1+
# gn-api-sdk-typescript
12

3+
> A nodejs module for integration of your backend with the payment services provided by [Gerencianet](http://gerencianet.com.br).
4+
5+
> Um módulo nodejs para integrar seu backend com os serviços de pagamento da [Gerencianet](http://gerencianet.com.br).
6+
7+
## Instalação
8+
9+
```bash
10+
$ npm install gn-api-sdk-typescript
11+
```
12+
13+
## Uso Básico
14+
15+
Importe o módulo:
16+
17+
```typescript
18+
import Gerencianet from 'gn-api-sdk-typescript';
19+
```
20+
21+
Insira suas credenciais e defina se deseja usar o sandbox ou não.
22+
Você também pode usar o arquivo [examples/config.ts](examples/config.ts) de modelo.
23+
```typescript
24+
export = {
25+
// PRODUÇÃO = false
26+
// HOMOLOGAÇÃO = true
27+
sandbox: false,
28+
29+
// CREDENCIAIS DE PRODUÇÃO
30+
clientIdProducao: '',
31+
clientSecretProducao: '',
32+
pathCertProducao: '',
33+
34+
// CREDENCIAIS DE HOMOLOGAÇÃO
35+
clientIdHomologacao: '',
36+
clientSecretHomologacao: '',
37+
pathCertHomologacao: '',
38+
39+
// VALIDAR MTLS?
40+
validateMtls: false,
41+
};
42+
```
43+
44+
Instancie o módulo passando as options:
45+
46+
```typescript
47+
const gerencianet = Gerencianet(options);
48+
```
49+
50+
Crie uma cobrança:
51+
52+
```typescript
53+
var body = {
54+
items: [{
55+
name: 'Product A',
56+
value: 1000,
57+
amount: 2
58+
}]
59+
}
60+
61+
gerencianet
62+
.createCharge({}, body)
63+
.then(console.log)
64+
.catch(console.log)
65+
.done();
66+
```
67+
68+
## Exemplos
69+
70+
Para executar os exemplos, clone este repo e instale as dependências:
71+
72+
```bash
73+
$ git clone git@github.com:gerencianet/gn-api-sdk-typescript.git
74+
$ cd gn-api-sdk-typescript/examples
75+
$ npm install
76+
```
77+
78+
Defina suas credenciais em config.ts:
79+
80+
```typescript
81+
export = {
82+
// PRODUÇÃO = false
83+
// HOMOLOGAÇÃO = true
84+
sandbox: false,
85+
86+
// CREDENCIAIS DE PRODUÇÃO
87+
clientIdProducao: '',
88+
clientSecretProducao: '',
89+
pathCertProducao: '',
90+
91+
// CREDENCIAIS DE HOMOLOGAÇÃO
92+
clientIdHomologacao: '',
93+
clientSecretHomologacao: '',
94+
pathCertHomologacao: '',
95+
96+
// VALIDAR MTLS?
97+
validateMtls: false,
98+
};
99+
```
100+
101+
Em seguida, execute o exemplo que você deseja:
102+
103+
```bash
104+
$ ts-node createCharge.ts
105+
```
106+
107+
108+
## Documentação
109+
110+
A documentação completa com todos os endpoints disponíveis você encontra em: https://dev.gerencianet.com.br/.
111+
112+
## License
113+
114+
[MIT](LICENSE)

examples/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"dependencies": {
3-
"gn-api-sdk-typescript": "https://github.com/gerencianet/gn-api-sdk-typescript.git"
3+
"gn-api-sdk-typescript": "https://github.com/gerencianet/gn-api-sdk-typescript.git",
4+
"ts-node": "^9.1.1"
45
}
5-
}
6+
}

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
{
22
"name": "gn-api-sdk-typescript",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"description": "Module for integration with Gerencianet API\"",
55
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
67
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8+
"build": "npx tsc -p ./tsconfig.json",
9+
"prepare": "npm run build",
10+
"postversion": "git push --tags"
811
},
912
"author": "Gerencianet - Consultoria Tecnica | João Vitor Oliveira",
1013
"license": "MIT",
1114
"repository": "gerencianet/gn-api-sdk-typescript",
1215
"homepage": "https://github.com/gerencianet/gn-api-sdk-typescript",
16+
"files": ["dist/*", "examples"],
1317
"keywords": [
1418
"gerencianet",
1519
"pagamentos",

tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,8 @@
6868
"skipLibCheck": true, /* Skip type checking of declaration files. */
6969
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
7070
"resolveJsonModule": true
71-
}
71+
},
72+
"exclude": [
73+
"examples"
74+
]
7275
}

0 commit comments

Comments
 (0)