Sberbank Acquiring API written in Go
Make sure your project is using Go Modules (it will have a go.mod
file in its
root if it already is):
go mod init
Then, reference stripe-go in a Go program with import
:
import (
"github.com/helios-ag/sberbank-acquiring-go/acquiring"
"github.com/helios-ag/sberbank-acquiring-go/currency"
)
Run any of the normal go
commands (build
/install
/test
). The Go
toolchain will resolve and fetch the module automatically.
Alternatively, you can also explicitly go get
the package into a project:
go get -u github.com/helios-ag/sberbank-acquiring-go
Get password and username
Set mode sandbox or production, currency, language
Configure client as in an example below
Example below:
package main
import (
"context"
"fmt"
"github.com/helios-ag/sberbank-acquiring-go/acquiring"
"github.com/helios-ag/sberbank-acquiring-go/currency"
)
func main() {
cfg := acquiring.ClientConfig{
UserName: "test-api", // Replace with your own
Currency: currency.RUB,
Password: "test", // Replace with your own
Language: "ru",
SessionTimeoutSecs: 1200,
SandboxMode: true,
}
client, err := acquiring.NewClient(&cfg)
if err != nil {
panic(err)
}
order := acquiring.Order{
OrderNumber: "test",
Amount: 100,
Description: "My Order for Client",
}
result, _, err := client.RegisterOrder(context.Background(), order)
if err != nil {
panic(err)
}
fmt.Println(result.ErrorCode)
fmt.Println(result.ErrorMessage)
fmt.Println(result.FormUrl)
fmt.Println(result.OrderId)
}
Run example go build example.go