Go client (unofficial) for Flow.cl Commerce API, a payment gateway for Chile and Latin America.
go get github.com/fsandov/api-flow-go
All the documentation of Flow API Rest can be found here
- Create a client with your API key and secret key. You can get your keys here (you need to be logged in). Its recommended to use environment variables to store your keys.
- Create a context, you can use the
context.Background()
function. Also you can use thecontext.WithTimeout()
function to set a timeout for the request. - Create a struct with data to send to Flow API.
Example:
import "github.com/fsandov/api-flow-go"
func main() {
// Create a context
ctx := context.Background()
// Set api key and secret key
apiKey := ""
secretKey := ""
// Define data to send to Flow API
orderData := payment.CreateOrderRequest{
CommerceOrder: "",
Subject: "",
Currency: "",
Amount: 1,
Email: "",
PaymentMethod: payment.AllMethods,
URLConfirmation: "",
URLReturn: "",
}
// Create a client with your api key and secret key
client, err := payment.NewClient(apiKey, secretKey)
// Send data to Flow API
order, err := client.CreateOrder(ctx, orderData)
}
You can see more examples in the examples folder of this repository.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.