Categorygithub.com/adyen/adyen-go-api-library/v14
modulepackage
14.0.0
Repository: https://github.com/adyen/adyen-go-api-library.git
Documentation: pkg.go.dev

# README

Go

Adyen Golang API Client Library

Go Reference

This is the officially supported golang library for using Adyen's APIs.

Supported API versions

The Library supports all APIs under the following services:

APIDescriptionService constructorSupported version
Checkout APIOur latest integration for accepting online payments.client.Checkout()v71
Payouts APIEndpoints for sending funds to your customers.client.Payout()v68
Recurring APIEndpoints for managing saved payment details.client.Recurring()v68
BIN lookup APIThe BIN Lookup API provides endpoints for retrieving information based on a given BIN.client.BinLookup()v54
Disputes APIYou can use the Disputes API to automate the dispute handling process so that you can respond to disputes and chargebacks as soon as they are initiated. The Disputes API lets you retrieve defense reasons, supply and delete defense documents, and accept or defend disputes.client.Disputes()v30
POS Terminal Management APIEndpoints for managing your point-of-sale payment terminals.client.PosTerminalManagement()v1
Management APIConfigure and manage your Adyen company and merchant accounts, stores, and payment terminals.client.Management()v3
Data Protection APIAdyen Data Protection API provides a way for you to process Subject Erasure Requests as mandated in GDPR.client.DataProtection()v1
Balance Control APIThe Balance Control API lets you transfer funds between merchant accounts that belong to the same legal entity and are under the same company account.client.BalanceControl()v1
Legal Entity Management APIManage legal entities that contain information required for verification.client.LegalEntity()v3
Configuration APIThe Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts.client.BalancePlatform()v2
Transfers APIThe Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument.client.Transfers()v4
Stored Value APIManage both online and point-of-sale gift cards and other stored-value cards.client.StoredValue()v46
POS Mobile APIThe POS Mobile API is used in the mutual authentication flow between an Adyen Android or iOS POS Mobile SDK and the Adyen payments platform. The POS Mobile SDK for Android or iOS devices enables businesses to accept in-person payments using a commercial off-the-shelf (COTS) device like a phone. For example, Tap to Pay transactions, or transactions on a mobile device in combination with a card readerclient.PosMobile()v68
Payments App APIThe Payments App API is used to Board and manage the Adyen Payments App on your Android mobile devicesclient.PaymentsApp()v1
Payments APIOur classic integration for online payments.client.Payments()v68
Account APIDeprecated: This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead.client.PlatformsAccount()v6
Fund APIDeprecated: This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead.client.PlatformsFund()v6
Hosted onboarding APIDeprecated: This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead.client.PlatformsHostedOnboardingPage()v6
Notification Configuration APIDeprecated: This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead.client.PlatformsNotificationConfiguration()v6

For more information, refer to our documentation or the API Explorer.

Supported Webhook versions

The library supports all webhooks under the following model directories:

WebhooksDescriptionPackageSupported Version
Payment WebhooksAdyen uses webhooks to send notifications about payment status updates, newly available reports, and other events that can be subscribed to. For more information, refer to our documentation.webhookv1
Authentication WebhooksAdyen sends this webhook when the process of cardholder authentication is finalized, whether it is completed successfully, fails, or expires.acswebhookv1
Configuration WebhooksYou can use these webhooks to build your implementation. For example, you can use this information to update internal statuses when the status of a capability is changed.configurationwebhookv2
Transfer WebhooksYou can use these webhooks to build your implementation. For example, you can use this information to update balances in your own dashboards or to keep track of incoming funds.transferwebhookv4
Report WebhooksYou can download reports programmatically by making an HTTP GET request, or manually from your Balance Platform Customer Areareportwebhookv1
Management WebhooksAdyen uses webhooks to inform your system about events that happen with your Adyen company and merchant accounts, stores, payment terminals, and payment methods when using Management API.managementwebhookv3
Transaction WebhooksAdyen sends webhooks to inform your system about incoming and outgoing transfers in your platform. You can use these webhooks to build your implementation. For example, you can use this information to update balances in your own dashboards or to keep track of incoming funds.transactionwebhookv4
Platforms Notifications WebhooksDeprecated: This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead.platformsnotificationeventsv6

Prerequisites

Documentation

Installation

You can use go modules to add our library to your project

go get github.com/adyen/adyen-go-api-library/[email protected]

Usage examples

Using APIs with APIKey

import (
	"context"
	"github.com/adyen/adyen-go-api-library/v14/src/checkout"
	"github.com/adyen/adyen-go-api-library/v14/src/common"
	"github.com/adyen/adyen-go-api-library/v14/src/adyen"
)

client := adyen.NewClient(&common.Config{
    ApiKey:      "your api key",
    Environment: common.TestEnv,
})
service := client.Checkout()

req := service.PaymentsApi.PaymentMethodsInput()
req = req.PaymentMethodsRequest(checkout.PaymentMethodsRequest{
    MerchantAccount: "your merchant account",
})
res, httpRes, err := service.PaymentsApi.PaymentMethods(context.Background(), req)

Using APIs with APIKey for Live env

import (
    "github.com/adyen/adyen-go-api-library/v14/src/checkout"
    "github.com/adyen/adyen-go-api-library/v14/src/common"
    "github.com/adyen/adyen-go-api-library/v14/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
})
service := client.Checkout()

req := service.PaymentsApi.PaymentMethodsInput()
req = req.PaymentMethodsRequest(checkout.PaymentMethodsRequest{
    MerchantAccount: "your merchant account",
})
res, httpRes, err := service.PaymentsApi.PaymentMethods(context.Background(), req)

Using API with Basic Auth

import (
    "github.com/adyen/adyen-go-api-library/v14/src/recurring"
    "github.com/adyen/adyen-go-api-library/v14/src/common"
    "github.com/adyen/adyen-go-api-library/v14/src/adyen"
)

client := adyen.NewClient(&common.Config{
    Username:    "your ws user",
    Password:    "your secret password",
    Environment: common.TestEnv,
    UserAgent:   "Custom Application",
})
service := client.Recurring()

req := service.ListRecurringDetailsInput()
req = req.RecurringDetailsRequest(recurring.RecurringDetailsRequest{
    MerchantAccount: "your merchant account",
    Recurring: &recurring.Recurring{
        Contract: common.PtrString("RECURRING"),
    },
    ShopperReference: "ref",
})
res, httpRes, err := service.ListRecurringDetails(context.Background(), req)

Unmarshalling JSON Strings

In some setups you might need to unmarshal JSON strings to request objects. For example, when using the libraries in combination with Dropin/Components. Please use following methodology when unmarshalling JSON strings:

import (
	"encoding/json"
	"github.com/adyen/adyen-go-api-library/v14/src/checkout"
)
paymentRequest := checkout.PaymentRequest{}
error := json.Unmarshal([]byte("YOUR_JSON_STRING"), &paymentRequest)

Using the webhook parser

import (
	"github.com/adyen/adyen-go-api-library/v14/src/webhook"
)

msg, err := webhook.HandleRequest(`{"live": "false", "notificationItems": []}`)

Getting error details

import (
	"github.com/adyen/adyen-go-api-library/v14/src/common"
	"github.com/adyen/adyen-go-api-library/v14/src/checkout"
	"github.com/adyen/adyen-go-api-library/v14/src/adyen"
)

client := adyen.NewClient(&common.Config{
    ApiKey:      "your api key",
    Environment: common.TestEnv,
})
service := client.Checkout()

req := service.PaymentsApi.PaymentsInput()
paymentMethod := checkout.IdealDetailsAsCheckoutPaymentMethod(checkout.NewIdealDetails("1121"))
_, httpRes, err := service.PaymentsApi.Payments(context.Background(), req.PaymentRequest(checkout.PaymentRequest{
    Reference: "123456781235",
    Amount: checkout.Amount{
        Value:    1250,
        Currency: "EUR",
    },
    CountryCode:     common.PtrString("NL"),
    MerchantAccount: "your merchant account",
    Channel:         common.PtrString("Web"),
    ReturnUrl:       "http://localhost:3000/redirect",
    PaymentMethod:   paymentMethod,
}))

httpStatusCode := httpRes.StatusCode
errorMessage := err.(common.APIError).Message
errorCode := err.(common.APIError).Code
errorType := err.(common.APIError).Type

Custom HTTP Client Configuration

By 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{
        Timeout: 512 * time.Millisecond,
    },
    Environment: common.TestEnv,
    ApiKey:      "your api key",
})

Proxy configuration

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",
})

Support

If you have a feature request, or spotted a bug or a technical problem, create an issue here.

For other questions, contact our Support Team.

Contributing

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.

Feedback

We value your input! Help us enhance our API Libraries and improve the integration experience by providing your feedback. Please take a moment to fill out our feedback form to share your thoughts, suggestions or ideas.

Licence

MIT license. For more information, see the LICENSE file.

# Packages

No description provided by the author
No description provided by the author