GO

Our API is RESTful and responds in JSON. Gerencianet uses OAuth to provide authorized access to the API. Our NodeJS SDK is already prepared to perform this authentication automatically.

Below, check out the procedures for installing the Gerencianet SDK in GO:

$ go get github.com/gerencianet/gn-api-sdk-go/gerencianet

Tested with

  • Go 1.8, 1.16

Basic use

import (
"github.com/gerencianet/gn-api-sdk-go/gerencianet"
)
credentials := map[string]interface{} {
"client_id": "client_id",
"client_secret": "client_secret",
"sandbox": true,
"timeout": 10,
}
gn := gerencianet.NewGerencianet(credentials)
body = {
"items": [{
"name": "Product 1",
"value": 1000,
"amount": 2,
}],
"shippings": [{
"name": "Default Shipping Cost",
"value": 100,
}]
}
res, err := gn.CreateCharge(body)

Examples

You can run the examples inside _examples with $ go run example.go:

$ go run charge/create_charge.go

Just remember to set the correct credentials inside _examples/configs.go before they run.


Tests

To run the tests, just run:

$ go test