Skip to main content

GO

Learn how to install and configure our GO SDK to use Efí APIs

Attention!

Requests made to Efí APIs using the GO SDK require the certificate generated in your Efí account in .pem format.

Check here for a step-by-step guide on converting your P12 certificate to PEM format.


Installation via GO

$ go mod init github.com/efipay/sdk-go-apis-efi

Installation via Git

Our SDK is also available in our Efí Github repository.

$ git clone https://github.com/efipay/sdk-go-apis-efi.git

Tested with

go 1.8, 1.11.4, 1.16.5 and 1.19.2

Basic Usage


import (
"fmt"
"github.com/efipay/sdk-go-apis-efi/src/efipay"
"github.com/efipay/sdk-go-apis-efi/examples/configs"
)

func main(){

credentials := configs.Credentials
efi := efipay.NewEfiPay(credentials)

body := map[string]interface{} {
"items": []map[string]interface{}{
{
"name": "Product 1",
"value": 1000,
"amount": 2,
},
},
"shippings": []map[string]interface{} {
{
"name": "Default Shipping Cost",
"value": 100,
},
},
}

res, err := efi.CreateCharge(body)

if err != nil {
fmt.Println(err)
} else {
fmt.Println(res)
}
}

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 within _examples/configs.go before running.


Tests

To run the tests, simply run:

$ go test