The Adyen API Library for golang enables you to work with Adyen APIs.
The Library supports all APIs under the following services:
- checkout
- checkout utility
- payments
- modifications
- payouts
- recurring
- notifications
- BIN lookup
- Go 1.13 or higher
You can use go modules to add our library to your project
go get github.com/adyen/adyen-go-api-library- https://docs.adyen.com/developers/development-resources/libraries
- https://docs.adyen.com/developers/checkout
import (
"github.com/adyen/adyen-go-api-library/src/checkout"
"github.com/adyen/adyen-go-api-library/src/common"
"github.com/adyen/adyen-go-api-library/src/adyen"
)
client := adyen.NewClient(&common.Config{
ApiKey: "your api key",
Environment: common.TestEnv,
})
res, httpRes, err := client.Checkout.PaymentMethods(&checkout.PaymentMethodsRequest{
MerchantAccount: "your merchant account",
})import (
"github.com/adyen/adyen-go-api-library/src/checkout"
"github.com/adyen/adyen-go-api-library/src/common"
"github.com/adyen/adyen-go-api-library/src/adyen"
)
client := adyen.NewClient(&common.Config{
ApiKey: "your api key",
Environment: common.LiveEnv,
LiveEndpointURLPrefix: "1797a841fbb37ca7-AdyenDemo", // Refer to https://docs.adyen.com/development-resources/live-endpoints#live-url-prefix
})
res, httpRes, err := client.Checkout.PaymentMethods(&checkout.PaymentMethodsRequest{
MerchantAccount: "your merchant account",
})import (
"github.com/adyen/adyen-go-api-library/src/recurring"
"github.com/adyen/adyen-go-api-library/src/common"
"github.com/adyen/adyen-go-api-library/src/adyen"
)
client := adyen.NewClient(&common.Config{
Username: USER,
Password: PASS,
Environment: common.TestEnv,
ApplicationName: "adyen-api-go-library",
})
res, httpRes, err := client.Recurring.ListRecurringDetails(&recurring.RecurringDetailsRequest{
MerchantAccount: MerchantAccount,
Recurring: &recurring.RecurringType{
Contract: "RECURRING",
},
ShopperReference: "ref",
})import (
"github.com/adyen/adyen-go-api-library/src/adyen"
"github.com/adyen/adyen-go-api-library/src/common"
)
client := adyen.NewClient(&common.Config{
ApiKey: "your api key",
Environment: common.TestEnv,
})
notification, err := client.Notification.HandleNotificationRequest(jsonRequestString)import (
"github.com/adyen/adyen-go-api-library/src/common"
"github.com/adyen/adyen-go-api-library/src/checkout"
"github.com/adyen/adyen-go-api-library/src/adyen"
)
client := adyen.NewClient(&common.Config{
ApiKey: "your api key",
Environment: common.TestEnv,
})
res, httpRes, err := client.Checkout.Payments(&checkout.PaymentRequest{
Reference: "123456781235",
Amount: checkout.Amount{
Value: 1250,
Currency: "EUR",
},
CountryCode: "NL",
MerchantAccount: MerchantAccount,
Channel: "Web",
ReturnUrl: "http://localhost:3000/redirect",
PaymentMethod: map[string]interface{}{
"type": "ideal",
"issuer": "1121",
},
})
errorText := err.Error()
errorMessage := err.(common.APIError).Message
errorCode := err.(common.APIError).Code
errorType := err.(common.APIError).Type
httpStatusCode := httpRes.StatusCode
httpStatus := httpRes.StatusBy default, Go http.DefaultClient will be used to submit requests to the API. But you can change that by injecting your own HttpClient on your client instance.
client := adyen.NewClient(&common.Config{
HTTPClient: &http.Client{
CheckRedirect: redirectPolicyFunc,
Timeout: 10 * time.MilliSeconds,
},
Environment: common.TestEnv,
ApiKey: "your api key",
})You can configure a proxy connection by injecting your own http.Client with a custom Transport on your client instance.
Example:
//creating the proxyURL
proxyURL, _ := url.Parse("http://myproxy:7000")
transport := &http.Transport{
Proxy: http.ProxyURL(proxyURL),
}
client = adyen.NewClient(&common.Config{
HTTPClient: &http.Client{
Transport: transport,
},
Environment: common.TestEnv,
ApiKey: "your api key",
})If you have a feature request, or spotted a bug or a technical problem, create a github issue. For other questions, contact our support team.
We strongly encourage you to join us in contributing to this repository so everyone can benefit from:
- New features and functionality
- Resolved bug fixes and issues
- Any general improvements
Read our contribution guidelines to find out how.
MIT license. For more information, see the LICENSE file.