You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generate and validate payments of Brazil Instant Payment System (Pix), making fast and simple to handle charges and proccess then in your project. Além da lib, o repositório oferece CLI e serviço REST para gerar payloads Pix estáticos ou dinâmicos, incluindo QR Code.
5
+
Gere e valide pagamentos do Sistema de Pagamentos Instantâneo (Pix) do Banco Central de forma simples. Além da biblioteca, este repositório inclui um CLI e um serviço REST para gerar payloads Pix estáticos ou dinâmicos, bem como seus códigos QR.
6
6
7
-
## Features
7
+
## Funcionalidades
8
8
9
-
-Static (copy & paste) and dynamic (URL-based) Pix payload generation.
10
-
- CLI `pixgen`(comandos `generate` e `serve`) para uso local ou como serviço.
11
-
- REST service (`POST /pix`) retornando payload + QR Code (base64) e `GET /healthz`.
12
-
-QR Code byte encoding built-in via `github.com/skip2/go-qrcode`.
13
-
-EMV parsing helpers to inspect payload tags and metadata.
14
-
-Field normalization (Pix keys, amount, TXID) with BACEN-aligned validation.
15
-
-Dynamic Pix resolver with JSON/plain-text support, expiration awareness and mock friendly interface.
9
+
-Geração de payloads Pix estáticos (copia e cola) e dinâmicos (com URL).
10
+
- CLI `pixgen`com comandos `generate` e `serve` para uso local ou como serviço.
11
+
-Serviço REST com `POST /pix` retornando payload + QR Code (base64) e `GET /healthz`.
12
+
-Geração de QR Code via `github.com/skip2/go-qrcode`.
13
+
-Utilitários de parsing EMV para inspeção de tags e metadados.
14
+
-Normalização de dados (chave Pix, valor, TxID) seguindo regras do BACEN.
15
+
-Resolução de Pix dinâmico suportando JSON, texto puro e tratamento de expiração.
16
16
17
-
## Installation
17
+
## Instalação
18
18
19
19
```bash
20
20
go get github.com/thiagozs/go-pixgen
21
21
```
22
22
23
-
Go 1.17 or newer is required.
23
+
Requer Go 1.17 ou superior.
24
24
25
-
## Quick Start
25
+
## Guia rápido
26
26
27
-
### CLI – gerar payload no stdout
27
+
### CLI – gerar payload no terminal
28
28
29
29
```bash
30
30
make cli
@@ -39,9 +39,9 @@ bin/pixgen generate \
39
39
--txid PEDIDO-123
40
40
```
41
41
42
-
Saída inclui o código copia-e-cola, campos relevantes e o QR Code em base64.
42
+
A saída inclui o código copia-e-cola, campos relevantes e o QR Code em base64.
43
43
44
-
### REST service
44
+
### Serviço REST
45
45
46
46
```bash
47
47
make run ARGS="serve --addr :8080"
@@ -68,9 +68,9 @@ curl -X POST http://localhost:8080/pix \
68
68
}
69
69
```
70
70
71
-
Endpoint`GET /healthz` retorna `200 OK` para checagens.
71
+
O endpoint`GET /healthz` retorna `200 OK` para checagens.
72
72
73
-
Exemplo rápido com `curl` + `jq` para visualizar a resposta formatada:
73
+
Exemplo com `curl` + `jq` para visualizar a resposta:
74
74
75
75
```bash
76
76
curl -sS -X POST http://localhost:8080/pix \
@@ -85,9 +85,9 @@ curl -sS -X POST http://localhost:8080/pix \
-`pix.New(opts...) (*pix.Pix, error)`- build a Pix generator using functional options.
160
-
-`(*Pix).GenPayload()`- returns the EMV string and caches it for`GenQRCode()`.
161
-
-`pix.ParsePayload(string) (*ParsedPayload, error)`- converts an EMV payload back into structured fields and validates the CRC.
162
-
-`(*Pix).FetchDynamicPayload(ctx, client)`- downloads a dynamic Pix payload, parses it and checks expiration. Works with `http.Client` stubs for tests.
163
-
-`(*Pix).Validates()`- called automatically by `pix.New`, and can be invoked manually to re-check mutated parameters.
159
+
-`pix.New(opts...) (*pix.Pix, error)`– cria um gerador Pix configurável.
160
+
-`(*Pix).GenPayload()`– retorna o payload EMV e o mantém em cache para`GenQRCode()`.
161
+
-`pix.ParsePayload(string) (*ParsedPayload, error)`– faz o parsing do payload e valida o CRC.
162
+
-`(*Pix).FetchDynamicPayload(ctx, client)`– baixa, valida e parseia payloads dinâmicos remotos.
163
+
-`(*Pix).Validates()`– valida os parâmetros (chaves, tamanho de campos, etc.).
164
164
165
-
### Supported Pix key formats
165
+
### Formatos aceitos de chave Pix
166
166
167
-
-Random EVP UUID (case-normalized to lowercase).
168
-
-Phone (`+55DDDUSER`), accepting raw digits with optional `+55` prefix.
169
-
- CPF/CNPJ (digits only, validated with check digits).
170
-
-Email addresses (validated using`net/mail`).
167
+
- EVP (UUID) – normalizado para minúsculo.
168
+
-Telefone (`+55DDDNÚMERO`) – aceita apenas dígitos com ou sem `+55`.
169
+
- CPF/CNPJ – somente dígitos, com validação dos dígitos verificadores.
170
+
-E-mail – validado via`net/mail`.
171
171
172
-
### Amount & TxID
172
+
### Valor e TxID
173
173
174
-
-Amount accepts up to 13 digits before the separator and up to 2 decimals (`9999999999999.99`cap).
175
-
- TxID allows uppercase/lowercase letters, digits, `.`and`-`up to 35 characters. Value is uppercased when stored.
174
+
-Valor suporta até 13 dígitos antes da vírgula e 2 casas decimais (`9999999999999.99`limite).
175
+
- TxID permite letras, números, `.`e`-`até 35 caracteres e é armazenado em maiúsculas.
176
176
177
-
### Dynamic payload fetching
177
+
### Busca de payload dinâmico
178
178
179
-
`FetchDynamicPayload`understands responses as:
179
+
`FetchDynamicPayload`entende:
180
180
181
-
-Raw EMV payload (any `text/*` content type).
182
-
- JSON containing fields `pixCopyPaste`, `pix`, `payload`, `pixCopiaECola`, etc.
183
-
-Optional expiration keys such as `expiresAt`, `expiration`, `expiry`. Parsed values support RFC3339 and similar layouts.
181
+
-payload EMV bruto (`text/*`).
182
+
- JSON com campos como `pixCopyPaste`, `pix`, `payload`, `pixCopiaECola` etc.
183
+
-Campos de expiração (`expiresAt`, `expiration`, `expiry`) em formatos RFC3339.
184
184
185
-
Local testing (HTTP URLs) is accepted when targeting `localhost`or`127.*`. Production URLs must be HTTPS.
185
+
Para testes locais, URLs HTTP são aceitas quando o host é `localhost`ou`127.*`; para produção exige HTTPS.
186
186
187
187
## Build & Docker
188
188
@@ -193,26 +193,26 @@ Local testing (HTTP URLs) is accepted when targeting `localhost` or `127.*`. Pro
193
193
194
194
## Roadmap
195
195
196
-
-[x]Generate payments based on parameters
197
-
-[x]Static
198
-
-[x]Dynamic
199
-
-[x] Parse and validate EMV Codes
200
-
-[x]Export generated/parsed payment to Image
201
-
-[x]Export generated/parsed payment to EMV Code
202
-
-[x]Fetch, parse and validate remote payloads from dynamic payments
203
-
-[x]Verify if has already expired
204
-
-[x]Improve tests
205
-
-[ ]Documentation with all methods, parameters and more examples
206
-
-[x]Add dynamic payment tests
207
-
-[x] CLI tooling for payload inspection
208
-
-[ ]REST API hardening & auth helpers
196
+
-[x]Gerar pagamentos a partir de parâmetros
197
+
-[x]Estático
198
+
-[x]Dinâmico
199
+
-[x] Parse e validação de códigos EMV
200
+
-[x]Exportar pagamento para imagem
201
+
-[x]Exportar pagamento para código EMV
202
+
-[x]Buscar, parsear e validar payloads dinâmicos remotos
-[ ]Endurecimento da API REST e opções de autenticação
209
209
210
-
## Contributing
210
+
## Contribuindo
211
211
212
-
Please contribute using [GitHub Flow](https://guides.github.com/introduction/flow). Create a branch, add commits, and [open a pull request](https://github.com/thiagozs/go-genpix/compare).
212
+
Siga o [GitHub Flow](https://guides.github.com/introduction/flow): crie uma branch, faça commits e abra um [pull request](https://github.com/thiagozs/go-genpix/compare).
213
213
214
-
## Versioning and license
214
+
## Versionamento e licença
215
215
216
-
Our version numbers follow the [semantic versioning specification](http://semver.org/). You can see the available versions by checking the [tags on this repository](https://github.com/thiagozs/go-pixgen/tags). For more details about our license model, please take a look at the [LICENSE](LICENSE) file.
216
+
Utilizamos [SemVer](http://semver.org/). Confira as versões em [tags](https://github.com/thiagozs/go-pixgen/tags). Licença em [LICENSE](LICENSE).
0 commit comments