This repo contains the Go library for Craftgate API.
- Go 1.19 or newer
go get github.com/craftgate/craftgate-go-client
You can import Craftgate
client using:
import (
craftgate "github.com/craftgate/craftgate-go-client/adapter"
)
To access the Craftgate API you'll first need to obtain API credentials (e.g. an API key and a secret key). If you don't already have a Craftgate account, you can signup at https://craftgate.io
Once you've obtained your API credentials, you can start using Craftgate by instantiating a Craftgate
with your credentials.
client, _ := craftgate.New("<YOUR API KEY>", "<YOUR SECRET KEY>", "https://api.craftgate.io")
request := craftgate.SearchInstallmentsRequest{
BinNumber: "487074",
Price: 100,
Currency: craftgate.Currency_TRY,
}
res, err := client.Installment.SearchInstallments(context.Background(), request)
if err != nil {
t.Errorf("Error %s", err)
}
Also, you can pass the options to make localization for API responses. You can use tr
or en
right now.
client, _ := craftgate.New("<YOUR API KEY>", "<YOUR SECRET KEY>", "https://api.craftgate.io", craftgate.WithLocalization("en"))
request := craftgate.SearchInstallmentsRequest{
BinNumber: "487074",
Price: 100,
Currency: craftgate.Currency_TRY,
}
res, err := client.Installment.SearchInstallments(context.Background(), request)
if err != nil {
t.Errorf("Error %s", err)
}
You should use production API servers at https://api.craftgate.io
for real world. For testing purposes, please use the sandbox URL https://sandbox-api.craftgate.io
.
Included in the project are a number of examples that cover almost all use-cases. Refer to the tests/
folder] for more info.
If you've cloned this repo on your development machine and wish to run the examples you can run an example with the command go test ./...
or run single test with the command go test tests/installment_test.go
Let's quickly review an example where we implement a credit card payment scenario.
For more examples covering almost all use-cases, check out the examples in the
tests/
folder
client, _ := craftgate.New("<YOUR API KEY>", "<YOUR SECRET KEY>", "https://sandbox-api.craftgate.io");
request := craftgate.CreatePaymentRequest{
Price: 100,
PaidPrice: 100,
Currency: craftgate.Currency_TRY,
...
}
res, err := client.Payment.CreatePayment(context.Background(), request)
if err != nil {
t.Errorf("Error %s", err)
}
For all contributions to this client please see the contribution guide here.
MIT