A go library for integration of your backend with the payment services provided by Gerencianet.
Install with:
$ go get github.com/gerencianet/gn-api-sdk-go-pix/gerencianet
$ go mod init github.com/gerencianet/gn-api-sdk-go-pix
go 1.16.5
openssl pkcs12 -in path.p12 -out newfile.crt.pem -clcerts -nokeys // certificado
openssl pkcs12 -in path.p12 -out newfile.key.pem -nocerts -nodes // chave privada
import (
"fmt"
"github.com/gerencianet/gn-api-sdk-go-pix/gerencianet"
"github.com/gerencianet/gn-api-sdk-go-pix/_examples/configs"
)
credentials := map[string]interface{} {
"client_id": "Your Client_Id",
"client_secret": "Your Client_Secret",
"sandbox": true,
"timeout": 20,
"CA" : "Path to your public key",
"Key" : "Path to your private key",
}
gn := gerencianet.NewGerencianet(credentials)
body := map[string]interface{} {
"calendario": map[string]interface{} {
"expiracao": 3600,
},
"devedor": map[string]interface{}{
"cpf": "12345678909",
"nome": "Francisco da Silva",
},
"valor": map[string]interface{} {
"original": "00.01",
},
"chave": "47e7e515-44d3-42cc-8e1f-ef529b4ba4d1",
"solicitacaoPagador": "Teste.",
"infoAdicionais": []map[string]interface{} {
{
"nome": "Campo 1",
"valor": "Informação Adicional1 do PSP-Recebedor",
},
},
}
res, err := gn.CreateImmediateCharge(body)
You can run the examples inside _examples
with
$ go run example.go
:
$ go run chargecreateImmediateCharge.go
Just remember to set the correct credentials inside examples/configs.go
before running.
The library is available as open source under the terms of the MIT License.