forked from FilipeMata/gn-api-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from gerencianet/TZSD_729-SDK-com-Settle
Tzsd 729 sdk com settle
- Loading branch information
Showing
7 changed files
with
147 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,81 @@ | ||
# gn-api-sdk-go | ||
|
||
> A go library for integration of your backend with the payment services | ||
provided by [Gerencianet](http://gerencianet.com.br). | ||
|
||
[![Build Status](https://travis-ci.org/gerencianet/gn-api-sdk-go.svg)](https://travis-ci.org/gerencianet/gn-api-sdk-go) | ||
[![Coverage Status](https://coveralls.io/repos/github/gerencianet/gn-api-sdk-go/badge.svg?branch=master)](https://coveralls.io/github/gerencianet/gn-api-sdk-go?branch=master) | ||
|
||
## Installation | ||
|
||
Install with: | ||
|
||
```bash | ||
$ go get github.com/gerencianet/gn-api-sdk-go/gerencianet | ||
``` | ||
## Tested with | ||
``` | ||
go 1.8 | ||
``` | ||
## Basic usage | ||
|
||
```go | ||
|
||
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`: | ||
|
||
```bash | ||
$ go run charge/create_charge.go | ||
``` | ||
|
||
Just remember to set the correct credentials inside `examples/configs.go` before running. | ||
|
||
## Tests | ||
|
||
To run the tests, just run: | ||
|
||
```bash | ||
$ go test | ||
``` | ||
|
||
## Additional documentation | ||
|
||
The full documentation with all available endpoints is in https://dev.gerencianet.com.br/. | ||
|
||
## Changelog | ||
|
||
[CHANGELOG](CHANGELOG.md) | ||
|
||
## Contributing | ||
|
||
Bug reports and pull requests are welcome on GitHub at https://github.com/gerencianet/gn-api-sdk-go. This project is intended to be a safe, welcoming space for collaboration. | ||
|
||
## License | ||
|
||
The library is available as open source under the terms of the [MIT License](LICENSE). | ||
# gn-api-sdk-go | ||
|
||
> A go library for integration of your backend with the payment services | ||
provided by [Gerencianet](http://gerencianet.com.br). | ||
|
||
[![Build Status](https://travis-ci.org/gerencianet/gn-api-sdk-go.svg)](https://travis-ci.org/gerencianet/gn-api-sdk-go) | ||
[![Coverage Status](https://coveralls.io/repos/github/gerencianet/gn-api-sdk-go/badge.svg?branch=master)](https://coveralls.io/github/gerencianet/gn-api-sdk-go?branch=master) | ||
|
||
## Installation | ||
|
||
Install with: | ||
|
||
```bash | ||
|
||
$ go get github.com/gerencianet/gn-api-sdk-go/gerencianet | ||
``` | ||
## Tested with | ||
``` | ||
go 1.8 and 1.11.4 | ||
``` | ||
## Basic usage | ||
|
||
```go | ||
|
||
import ( | ||
"github.com/FilipeMata/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`: | ||
|
||
```bash | ||
$ go run charge/create_charge.go | ||
``` | ||
|
||
Just remember to set the correct credentials inside `examples/configs.go` before running. | ||
|
||
## Tests | ||
|
||
To run the tests, just run: | ||
|
||
```bash | ||
$ go test | ||
``` | ||
|
||
## Changelog | ||
|
||
[CHANGELOG](CHANGELOG.md) | ||
|
||
|
||
## License | ||
|
||
The library is available as open source under the terms of the [MIT License](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/gerencianet/gn-api-sdk-go/gerencianet" | ||
"github.com/gerencianet/gn-api-sdk-go/_examples/configs" | ||
) | ||
|
||
func main(){ | ||
|
||
credentials := configs.Credentials | ||
gn := gerencianet.NewGerencianet(credentials) | ||
|
||
res, err := gn.SettleCarnetParcel(1, 1) // no lugar dos 1s coloque o carnet_id e o numero da parcela respectivamente | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
} else { | ||
fmt.Println(res) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/gerencianet/gn-api-sdk-go/gerencianet" | ||
"github.com/gerencianet/gn-api-sdk-go/_examples/configs" | ||
) | ||
|
||
func main(){ | ||
|
||
credentials := configs.Credentials | ||
gn := gerencianet.NewGerencianet(credentials) | ||
|
||
res, err := gn.SettleCharge(1) // no lugar do 1 coloque o charge_id certo | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
} else { | ||
fmt.Println(res) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters