Code Monkey home page Code Monkey logo

adyen-go-api-library's Introduction

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:

API Description Service constructor Supported version
Checkout API Our latest integration for accepting online payments. client.Checkout() v70
Payouts API Endpoints for sending funds to your customers. client.Payout() v68
Recurring API Endpoints for managing saved payment details. client.Recurring() v68
BIN lookup API The BIN Lookup API provides endpoints for retrieving information based on a given BIN. client.BinLookup() v54
POS Terminal Management API Endpoints for managing your point-of-sale payment terminals. client.PosTerminalManagement() v1
Management API Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. client.Management() v1
Data Protection API Adyen Data Protection API provides a way for you to process Subject Erasure Requests as mandated in GDPR. client.DataProtection() v1
Balance Control API The 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 API Manage legal entities that contain information required for verification. client.LegalEntity() v3
Configuration API The 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 API The 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() v3
Stored Value API Manage both online and point-of-sale gift cards and other stored-value cards. client.StoredValue() v46
Payments API Our classic integration for online payments. client.Payments() v68
Account API Deprecated: 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 API Deprecated: 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 API Deprecated: 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 API Deprecated: 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:

Webhooks Description Package Supported Version
Payment Webhooks Adyen 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. webhook v1
Authentication Webhooks Adyen sends this webhook when the process of cardholder authentication is finalized, whether it is completed successfully, fails, or expires. acswebhook v1
Configuration Webhooks You 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. configurationwebhook v1
Transfer Webhooks 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. transferwebhook v3
Report Webhooks You can download reports programmatically by making an HTTP GET request, or manually from your Balance Platform Customer Area reportwebhook v1
Management Webhooks Adyen 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. managementwebhook v1
Platforms Notifications Webhooks Deprecated: This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. platformsnotificationevents v6

Prerequisites

Documentation

Installation

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

go get github.com/adyen/adyen-go-api-library/v7

Usage examples

Using APIs with APIKey

import (
	"context"
	"github.com/adyen/adyen-go-api-library/v7/src/checkout"
	"github.com/adyen/adyen-go-api-library/v7/src/common"
	"github.com/adyen/adyen-go-api-library/v7/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/v7/src/checkout"
    "github.com/adyen/adyen-go-api-library/v7/src/common"
    "github.com/adyen/adyen-go-api-library/v7/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/v7/src/recurring"
    "github.com/adyen/adyen-go-api-library/v7/src/common"
    "github.com/adyen/adyen-go-api-library/v7/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)

Using the webhook parser

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

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

Getting error details

import (
	"github.com/adyen/adyen-go-api-library/v7/src/common"
	"github.com/adyen/adyen-go-api-library/v7/src/checkout"
	"github.com/adyen/adyen-go-api-library/v7/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.

adyen-go-api-library's People

Contributors

acampos1916 avatar adyenautomationbot avatar alexandrosmor avatar c-seeger avatar cyattilakiss avatar deepu105 avatar dependabot-preview[bot] avatar dependabot[bot] avatar gcatanese avatar kadobot avatar kentokento avatar leandromagnabosco avatar mderasse avatar michaelpaul avatar namanhkapur avatar renovate[bot] avatar rikterbeek avatar sooand avatar steffenmllr avatar strobil avatar wboereboom avatar wilsonpinto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.