Skip to content

Commit a320b03

Browse files
committed
First commit
0 parents  commit a320b03

File tree

12 files changed

+603
-0
lines changed

12 files changed

+603
-0
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
on: [push, pull_request]
2+
name: tests
3+
4+
jobs:
5+
test:
6+
strategy:
7+
matrix:
8+
go-version: [1.x, 1.14.x]
9+
platform: [ubuntu-latest]
10+
runs-on: ${{ matrix.platform }}
11+
12+
steps:
13+
- uses: actions/setup-go@v2
14+
with:
15+
go-version: ${{ matrix.go-version }}
16+
- uses: actions/checkout@v2
17+
18+
- name: Cache go modules
19+
uses: actions/cache@v2
20+
with:
21+
path: ~/go/pkg/mod
22+
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
23+
restore-keys: ${{ runner.os }}-go-
24+
25+
- name: Run go test
26+
run: go test -v -race -coverprofile coverage.txt -covermode atomic ./...
27+
28+
- name: Upload coverage to Codecov
29+
uses: codecov/codecov-action@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at jonnasfonini@gmail.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2021 Jonnas Fonini
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# go-pix #
2+
3+
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/fonini/go-pix/pix)
4+
[![Test Status](https://github.com/fonini/go-pix/workflows/tests/badge.svg)](https://github.com/fonini/go-pix/actions?query=workflow%3Atests)
5+
[![codecov](https://codecov.io/gh/fonini/go-pix/branch/master/graph/badge.svg?token=FB25JPH4ED)](https://codecov.io/gh/fonini/go-pix)
6+
[![Go Report Card](https://goreportcard.com/badge/github.com/fonini/go-pix)](https://goreportcard.com/report/github.com/fonini/go-pix)
7+
8+
go-pix is a Go library for generating [Pix](https://www.bcb.gov.br/estabilidadefinanceira/pix) transactions using Copy and Paste or QR codes.
9+
10+
## About Pix ##
11+
12+
![Generated QR code](pix.png?raw=true)
13+
14+
Pix is a system created by the Brazilian Central Bank to allow instant payments. The new payment method allows immediate money transfer, 24 hours a day, 7 days a week, including weekends and holidays.
15+
16+
The address key is a way to identify the user’s account. There are four types of address keys that users can use:
17+
18+
* CPF/CNPJ
19+
* Email address
20+
* Cellphone number
21+
* Random key – a set of random number, letters, and symbols
22+
23+
This key binds the basic information to the user’s complete account information, allowing users to send and receive money using only an address key.
24+
25+
## Usage ##
26+
27+
```go
28+
import "github.com/fonini/go-pix/pix"
29+
```
30+
31+
### Generating a Copy and Paste code
32+
33+
```go
34+
options := pix.Options{
35+
Name: "Jonnas Fonini",
36+
Key: "jonnasfonini@gmail.com",
37+
City: "Marau",
38+
Amount: 20.67,
39+
Description: "Invoice #4",
40+
}
41+
42+
copyPaste, err := pix.Pix(options)
43+
44+
if err != nil {
45+
panic(err)
46+
}
47+
48+
fmt.Println(copyPaste) // will output: "00020126580014BR.GOV.BCB.PIX0122jonnasfonini@gmail.com0210Invoice #4520400005303986540520.675802BR5913Jonnas Fonini6005Marau62410503***50300017BR.GOV.BCB.BRCODE01051.0.06304CF13"
49+
```
50+
51+
### Generating a QR code
52+
53+
You can use the Copy and Paste code generated above to generate a QR code
54+
55+
```go
56+
options := QRCodeOptions{Size: 256, Content: copyPaste}
57+
58+
qrCode, err := pix.QRCode(options)
59+
60+
if err != nil {
61+
panic(err)
62+
}
63+
```
64+
65+
The ```qrCode``` is a byte array, containing a graphical representation of the Copy and Paste code in the form of a QR code.
66+
67+
![Generated QR code](qr.png?raw=true)
68+
69+
## Tests ##
70+
71+
```
72+
go test ./pix
73+
```

go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/fonini/go-pix
2+
3+
go 1.16
4+
5+
require (
6+
github.com/google/go-cmp v0.5.4
7+
github.com/r10r/crc16 v0.1.1
8+
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
9+
)

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
2+
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
3+
github.com/r10r/crc16 v0.1.1 h1:BsuCL6d+j0hBCQ/nNnwHmlTF0shVES2IagUgh1MS6yU=
4+
github.com/r10r/crc16 v0.1.1/go.mod h1:I17p13f8bQGzqw5+futttVdERhbvzpgjlPZdwIJ0ka8=
5+
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
6+
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
7+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
8+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

pix.png

10.5 KB
Loading

0 commit comments

Comments
 (0)