https://github.com/martinusso/getnet
SDK golang para integração com a API Getnet
https://github.com/martinusso/getnet
cartao-de-credito creditcard getnet golang
Last synced: 4 months ago
JSON representation
SDK golang para integração com a API Getnet
- Host: GitHub
- URL: https://github.com/martinusso/getnet
- Owner: martinusso
- License: mit
- Created: 2020-07-21T19:24:48.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-05T15:43:27.000Z (almost 6 years ago)
- Last Synced: 2024-06-20T01:50:53.332Z (almost 2 years ago)
- Topics: cartao-de-credito, creditcard, getnet, golang
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# getnet
[](https://travis-ci.org/martinusso/getnet)
[](https://coveralls.io/github/martinusso/getnet?branch=master)
[](https://goreportcard.com/report/github.com/martinusso/getnet)
SDK golang para integração com a API Getnet.
Consulte a documentação oficial da API Getnet https://developers.getnet.com.br/api para maiores detalhes sobre os campos.
## Funcionalidades
- Autenticação
- Geração do token de acesso
- Tokenização
- Geração do token do cartão
- Pagamento
- Verificação de cartão
- Pagamento com cartão de crédito
## Usando
```
go get "github.com/martinusso/getnet"
```
### Autenticação - Geração do token de acesso
```
var err error
credentials := getnet.ClientCredentials{
ID: "ecb847f2-e423-40c0-808c-55d2098a92ab",
Secret: "1386f27e-0f2e-45f7-9efd-c8fdc1657426"}
credentials.AccessToken, err = credentials.NewAccessToken()
if err != nil {
log.Fatal(err)
}
```
### Tokenização - Geração do token do cartão
```
var err error
card := getnet.Card{
CardNumber: "5155901222280001",
CardHolderName: "JOAO DA SILVA",
SecurityCode: "123",
Brand: "Mastercard",
ExpirationMonth: "12",
ExpirationYear: "20",
}
card.NumberToken, err = card.Token(credentials)
if err != nil {
log.Fatal(err)
}
```
### Cartão de Crédito
#### Pagamento com cartão de crédito
```
payment := getnet.Payment{
Amount: 1.00,
Currency: "BRL",
Order: getnet.Order{
OrderID: "ea3dae62-1125-4eb4-b3ef-dcb720e8899d",
SalesTax: 0,
ProductType: Service,
},
Customer: getnet.Customer{
CustomerID: "customer_id",
FirstName: "João",
LastName: "da Silva",
Email: "customer@email.com.br",
DocumentType: "CPF",
DocumentNumber: "12345678912",
PhoneNumber: "27987654321",
BillingAddress: getnet.BillingAddress{
Street: "Av. Brasil",
Number: "1000",
Complement: "Sala 1",
District: "São Geraldo",
City: "Porto Alegre",
State: "RS",
Country: "Brasil",
PostalCode: "90230060",
},
},
Credit: getnet.Credit{
Delayed: false,
Authenticated: false,
PreAuthorization: false,
SaveCardData: false,
TransactionType: Full,
NumberInstallments: 1,
SoftDescriptor: "Texto exibido na fatura do cartão do comprador",
DynamicMCC: 1799,
Card: card, // Tokenização - Geração do token do cartão
},
}
// credentials obtido em Autenticação - Geração do token de acesso
response, error := payment.Pay(credentials)
```