Skip to content

Commit 8038294

Browse files
committed
Genral fixes
1 parent b26d8c3 commit 8038294

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

examples/main.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/thiagozs/go-pixgen/pix"
7+
)
8+
9+
func main() {
10+
opts := []pix.Options{
11+
pix.OptPixKey("28707746806"),
12+
pix.OptDescription("Teste"),
13+
pix.OptMerchantName("Thiago Zilli Sarmento"),
14+
pix.OptMerchantCity("Ararangua"),
15+
pix.OptAmount("1.00"),
16+
pix.OptAditionalInfo("gerado por go-pixgen"),
17+
pix.OptKind(pix.STATIC),
18+
}
19+
20+
p, err := pix.New(opts...)
21+
if err != nil {
22+
fmt.Println(err.Error())
23+
return
24+
}
25+
26+
if err := p.Validates(); err != nil {
27+
fmt.Println(err.Error())
28+
return
29+
}
30+
31+
cpy := p.GenPayload()
32+
33+
fmt.Printf("Copy and Paste: %s\n", cpy)
34+
35+
// bts, err := p.GenQRCode()
36+
// if err != nil {
37+
// fmt.Println(err.Error())
38+
// return
39+
// }
40+
41+
// fmt.Printf("QRCode: %b\n", bts)
42+
}

pix/options.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func (pix PixKind) String() string {
1414
type Options func(o *OptionsParams) error
1515

1616
type OptionsParams struct {
17-
id string
17+
txId string
1818
pixKey string
1919
description string
2020
amount string
@@ -59,9 +59,9 @@ func OptKind(kind PixKind) Options {
5959
}
6060
}
6161

62-
func OptId(id string) Options {
62+
func OptTxId(id string) Options {
6363
return func(o *OptionsParams) error {
64-
o.id = id
64+
o.txId = id
6565
return nil
6666
}
6767
}
@@ -103,8 +103,8 @@ func OptAmount(amount string) Options {
103103

104104
// ------------- getters
105105

106-
func (o *OptionsParams) GetId() string {
107-
return o.id
106+
func (o *OptionsParams) GetTxId() string {
107+
return o.txId
108108
}
109109

110110
func (o *OptionsParams) GetPixKey() string {

pix/pix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ func (p *Pix) generateMAI() string {
102102

103103
func (p *Pix) generateAdditionalData() string {
104104
txid := "***"
105-
if len(p.params.id) > 0 {
106-
txid = p.params.id
105+
if len(p.params.txId) > 0 {
106+
txid = p.params.txId
107107
}
108108
return p.getValue(TAG_TXID, txid)
109109
}

0 commit comments

Comments
 (0)