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
- Add cmd/pixgen CLI with generate and serve commands and /pix, /healthz handlers
- Add Dockerfile, Makefile, bin/.gitkeep and update README and examples
- Implement Pix parser, dynamic payload fetching, validations and unit tests
- Add internal lightweight cobra substitute and replace in go.mod
Generate ~~and validate~~ payments of Brazil Instant Payment System (Pix), making fast and simple to handle charges and proccess then in your project.
5
+
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.
-`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.
164
+
165
+
### Supported Pix key formats
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`).
171
+
172
+
### Amount & TxID
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.
176
+
177
+
### Dynamic payload fetching
178
+
179
+
`FetchDynamicPayload` understands responses as:
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.
184
+
185
+
Local testing (HTTP URLs) is accepted when targeting `localhost` or `127.*`. Production URLs must be HTTPS.
186
+
187
+
## Build & Docker
188
+
189
+
-`make build`, `make test`, `make fmt`
190
+
-`make cli` compila o binário em `bin/pixgen`
191
+
-`make run ARGS="serve --addr :8080"` executa o servidor REST local
192
+
-`make docker-build && make docker-run` constroem e sobem a imagem (porta 8080)
193
+
45
194
## Roadmap
46
195
47
196
-[x] Generate payments based on parameters
48
197
-[x] Static
49
198
-[x] Dynamic
50
-
-[] Parse and validate EMV Codes
199
+
-[x] Parse and validate EMV Codes
51
200
-[x] Export generated/parsed payment to Image
52
201
-[x] Export generated/parsed payment to EMV Code
53
-
-[ ] Fetch, parse and validate remote payloads from dynamic payments
54
-
-[ ] Verify if has already expired
55
-
-[ ] Improve tests
56
-
-[ ] Doccumentation with all methods, parameters and some examples
57
-
-[ ] Add dynamic payment tests
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
58
209
59
210
## Contributing
60
211
@@ -64,4 +215,4 @@ Please contribute using [GitHub Flow](https://guides.github.com/introduction/flo
64
215
65
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.
0 commit comments