Adyen 26.0.0

dotnet add package Adyen --version 26.0.0                
NuGet\Install-Package Adyen -Version 26.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Adyen" Version="26.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Adyen --version 26.0.0                
#r "nuget: Adyen, 26.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Adyen as a Cake Addin
#addin nuget:?package=Adyen&version=26.0.0

// Install Adyen as a Cake Tool
#tool nuget:?package=Adyen&version=26.0.0                

NET api

Adyen .NET API Library

nuget nuget .NET Core

This is the officially supported .NET library for the Adyen's APIs. Are you looking for examples? You can find our .NET Integration examples on GitHub here.

Supported API versions

The library supports all APIs under the following services:

API Description Service Name Supported version
Checkout API Adyen Checkout API provides a simple and flexible way to initiate and authorise online payments. You can use the same integration for payments made with cards (including 3D Secure), mobile wallets, and local payment methods (for example, iDEAL and Sofort). Checkout v71
Payments API A set of API endpoints that allow you to initiate, settle, and modify payments on the Adyen payments platform. You can use the API to accept card payments (including One-Click and 3D Secure), bank transfers, ewallets, and many other payment methods. Payments v68
Recurring API The Recurring APIs allow you to manage and remove your tokens or saved payment details. Tokens should be created with validation during a payment request. Recurring v68
Payouts API A set of API endpoints that allow you to store payout details, confirm, or decline a payout. Payouts v68
Adyen BinLookup API Endpoints for retrieving information, such as cost estimates, and 3D Secure supported version based on a given BIN. Current supported version BinLookup v54
Stored Value API Manage both online and point-of-sale gift cards and other stored-value cards. StoredValue v46
Legal Entity Management API The Legal Entity Management API enables you to manage legal entities that contain information required for verification LegalEntityManagement v3
Management API Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. Management v3
Transfers API The Transfers API provides endpoints that you can use to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. Transfers v4
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. BalancePlatform v2
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. BalanceControl v1
Data Protection API Our Data Protection API allows you to process Subject Erasure Requests as mandated in General Data Protection Regulation (GDPR). DataProtection v1
Terminal API (Cloud communications) Our point-of-sale integration. Cloud-based Terminal API Cloud-based Terminal API
Terminal API (Local communications) Our point-of-sale integration. Local-based Terminal API Local-based Terminal API
POS Terminal Management API This API provides endpoints for managing your point-of-sale (POS) payment terminals. You can use the API to obtain information about a specific terminal, retrieve overviews of your terminals and stores, and assign terminals to a merchant account or store. POSTerminalManagement v1
Classic Platforms Account API This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. PlatformsAccount v6
Classic Platforms Fund API This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. PlatformsFund v6
Classic Platforms Hosted Onboarding Page API This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. PlatformsHostedOnboardingPage v6
Classic Platforms Notification Configuration API This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. PlatformsNotificationConfiguration v6
Disputes API You 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. Disputes v30
POS Mobile API The 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 reader POS Mobile v68
Payments App API The Payments App API is used to Board and manage the Adyen Payments App on your Android mobile devices. PaymentsAppApi v1

Supported Webhook versions

The library supports all webhooks under the following model directories:

Webhooks Description Model Name Supported Version
Authentication Webhooks You can use the same integration for payments made with cards (including 3D Secure), mobile wallets, and local payment methods (for example, iDEAL and Sofort). AcsWebhooks 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. ConfigurationWebhooks v2
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. TransferWebhooks v4
Transaction Webhooks Adyen 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. TransactionWebhooks v4
Report Webhooks You can download reports programmatically by making an HTTP GET request, or manually from your Balance Platform Customer Area ReportWebhooks 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. ManagementWebhooks v3
Notification Webhooks We use webhooks to send you updates about payment status updates, newly available reports, and other events that you can subscribe to. For more information, refer to our documentation Notification v1
Classic Platform Webhooks The Notification API sends notifications to the endpoints specified in a given subscription. Subscriptions are managed through the Notification Configuration API. The API specifications listed here detail the format of each notification. PlatformWebhooks v6

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

Prerequisites

  • Adyen Test Account
  • Adyen API key. For testing, your API credential needs to have the API PCI Payments role.
  • Adyen .NET API Library supports .NET Standard 2.0 and .NET 6.0
  • In order for Adyen .NET API Library to support local terminal api certificate validation the application should be set to .net core 2.1 and above or .net framework 4.6.1 and above

Installation

Simply download and restore nuget packages https://www.nuget.org/packages/Adyen/ or install it from package manager

PM> Install-Package Adyen -Version x.x.x

❗Disclaimer on Enum Values

Please note that the integer value (index) of the enums used in this library may change in future releases. These values are not guaranteed to remain static, and they may be modified, added, or removed as the library evolves.

⚠️ We advise against hard-coding or relying on specific enum integer values in your implementation, as they may break compatibility with future versions of this library. Use instead the string value of the enums.

Upon upgrade check the Release Notes and the associated PRs to understand the changes and any potential impact on your integration.

Using the library

In order to submit http request to Adyen API you need to initialize the client. The following example makes a checkout payment request:

using Adyen;
using Adyen.Model.Checkout;
using Adyen.Service.Checkout;
using Environment = Adyen.Model.Environment;

var config = new Config()
{
    XApiKey = "ADYEN_API_KEY",
    Environment = Environment.Test
};
var client = new Client(config);
var paymentsService = new PaymentsService(client);
var amount = new Model.Checkout.Amount("USD", 1000);
var cardDetails = new CardDetails
{
    EncryptedCardNumber = "test_4111111111111111",
    EncryptedSecurityCode = "test_737",
    EncryptedExpiryMonth = "test_03",
    EncryptedExpiryYear = "test_2030",
    HolderName = "John Smith",
    Type = CardDetails.TypeEnum.Card
};
var paymentRequest = new Model.Checkout.PaymentRequest
{
    Reference = "Your order number ",
    ReturnUrl = @"https://your-company.com/...",
    MerchantAccount = "your-merchant-account",
    Amount = amount,
    PaymentMethod = new CheckoutPaymentMethod(cardDetails)
};
var paymentResponse = paymentsService.Payments(paymentRequest);

Or in case you would like to make an asynchronous /payments request with idempotency key and cancellation token, the last line would be instead:

var requestOptions = new RequestOptions();
requestOptions.IdempotencyKey = "YourGeneratedUniqueGuid";
PaymentResponse paymentResponse = await paymentsService.PaymentsAsync(paymentRequest, requestOptions: requestOptions, cancellationToken: new CancellationToken());

Deserializing JSON Strings

In some setups you might need to deserialize JSON strings to request objects. For example, when using the libraries in combination with Dropin/Components. Please use the built-in deserialization functions:

// Import the required model class
using Adyen.Model.Checkout;

// Deserialize using built-in function
PaymentRequest paymentRequest = PaymentRequest.FromJson("YOUR_JSON_STRING");

Running the tests

Navigate to adyen-dotnet-api-library folder and run the following commands.

dotnet build
dotnet test

[!IMPORTANT] We have split and renamed TerminalCloudApi.cs to:

  1. TerminalApiAsyncService.cs (which sends requests to terminal-api.adyen.com/async) and
  2. TerminalApiSyncService.cs (which sends requests to terminal-api.adyen.com/sync)
  3. TerminalApiLocalService.cs (which sends requests to your custom endpoint, f.e. https://198.51.100.1:8443/nexo)

Using the Cloud Terminal API

In order to submit POS request with Cloud Terminal API, you need to initialize the client with the endpoints that it is closer to your region when going live. The Endpoints are available as contacts in ClientConfig. For more information, visit our documentation

// Example for EU based region
using Adyen;
using Adyen.Constants;

var config = new Config
{
    XApiKey = "ADYEN_API_KEY",
    CloudApiEndPoint = ClientConfig.CloudApiEndPointEULive
};
var client = new Client(config);

To parse the terminal API notifications, you can use the following custom deserializer. This method will throw an exception for non-notification requests.

SaleToPoiMessageSerializer serializer = new SaleToPoiMessageSerializer();
SaleToPOIRequest saleToPoiRequest = serializer.DeserializeNotification(your_terminal_notification);

Example Cloud Terminal API integration /sync-endpoint

using System;
using Adyen.Model;
using Adyen.Model.TerminalApi;
using Adyen.Model.TerminalApi.Message;
using Adyen.Service;
using Environment = Adyen.Model.Environment;
 
namespace Adyen.Terminal
{
   public static class Program
   {
        private static void Main(string[] args)
        {
            var config = new Config() {
                XApiKey = "ADYEN_API_KEY",
                Environment = Environment.Test
            };
            var client = new Client(config, Environment.Test);
        }
       
        // Terminal-api `/sync` - `https://terminal-api-test.adyen.com/sync`
        private static SyncEndpointExample(Client client) {
            ITerminalApiSyncService terminalApiSyncService = new TerminalApiSyncService(client, new SaleToPoiMessageSerializer(), new SaleToPoiMessageSecuredEncryptor(), new SaleToPoiMessageSecuredSerializer());
            SaleToPOIResponse response = terminalApiSyncService.Request(GetPaymentRequest()); // Use: await terminalApiSyncService.RequestAsync(GetPaymentRequest()) for asynchronous communications.
            PaymentResponse paymentResponse = response.MessagePayload as PaymentResponse;
            Console.WriteLine(paymentResponse?.Response?.Result);
        }
       
        // Terminal-api `/async` - `https://terminal-api-test.adyen.com/async`
        private static AsyncEndpointExample(Client client) {
            ITerminalApiAsyncService terminalApiAsyncService = new TerminalApiAsyncService(client, new SaleToPoiMessageSerializer(), new SaleToPoiMessageSecuredEncryptor(), new SaleToPoiMessageSecuredSerializer());
            String response = terminalApiAsyncService.Request(GetPaymentRequest()); // Use: await terminalApiAsyncService.RequestAsync(GetPaymentRequest()) for asynchronous communications.
            Console.WriteLine(response);
        }
       
        private static SaleToPOIRequest GetPaymentRequest()
        {
            var serviceID = "SERVICE_ID"; // ServiceId should be unique for every request
            var saleID = "SALE_ID";
            var POIID = "SERIAL_NUMBER";
            var transactionID = "123459";
            SaleToPOIRequest saleToPOIRequest = new SaleToPOIRequest()
            {
                MessageHeader = new MessageHeader()
                {
                    MessageClass = MessageClassType.Service,
                    MessageCategory = MessageCategoryType.Payment,
                    MessageType = MessageType.Request,
                    ServiceID = serviceID,
                    SaleID = saleID,
                    POIID = POIID
                },
                MessagePayload = new PaymentRequest()
                {
                    SaleData = new SaleData()
                    {
                        SaleTransactionID = new TransactionIdentification()
                        {
                            TransactionID = transactionID,
                            TimeStamp = DateTime.Now
                        }
                    },
                    PaymentTransaction = new PaymentTransaction()
                    {
                        AmountsReq = new AmountsReq()
                        {
                            Currency = "EUR",
                            RequestedAmount = new decimal(13.37)
                        },
                    },
                }
            };
            return saleToPOIRequest;
        }
    }
}

Using the Local Terminal API

The request and response payloads are identical to the Cloud Terminal API, however an additional encryption details object is required to send the requests. You can retrieve these details from the Customer Area, make sure you update your terminal to the latest version if you've updated these keys.

using Adyen;
using Adyen.Security;

var encryptionCredentialDetails = new EncryptionCredentialDetails
{
    KeyVersion = 1,
    AdyenCryptoVersion = 1,
    KeyIdentifier = "CryptoKeyIdentifier12345",
    Password = "p@ssw0rd123456"
};
var config = new Config
{
    Environment = Model.Environment.Test,
    LocalTerminalApiEndpoint = @"https://_terminal_:8443/nexo/" // _terminal_ example: `https://198.51.100.1:8443/nexo` (can be found in the WIFI settings of your terminal)
};
var client = new Client(config);
ITerminalApiLocalService terminalApiLocalService = new TerminalApiLocalService(client);
// Asynchronous call (preferred)
var saleToPOIResponse = await terminalApiLocalService.RequestEncryptedAsync(paymentRequest, encryptionCredentialDetails, new CancellationToken()); // Pass cancellation token or create a new one.
// Synchronous (blocking) call
//var saleToPOIResponse = terminalApiLocalService.RequestEncrypted(paymentRequest, encryptionCredentialDetails);

Alternatively one can use the local terminal API without encryption. This is only allowed in the TEST environment and in order for this to work one has to remove any encryption details from the Customer Area. When sending requests to a local (unknown) endpoint, you may run into System.Net.Http.HttpRequestException: The SSL connection could not be established due to certificate issues. For local testing purposes, developers can override the System.Net.Http.HttpClientHandler and always returns true when validating the certificate.

[!CAUTION] Follow the guide in the Adyen documentation to install the root certificate on TEST and on LIVE.

using Adyen;
using Adyen.Security;

// Override the HttpClientHandler to always return true, for LOCAL TESTING PURPOSES, NEVER run this on live. 
var handler = new System.Net.Http.HttpClientHandler { ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true };
var client = new Client(config, new System.Net.Http.HttpClient(handler));

ITerminalApiLocalService terminalApiLocalService = new TerminalApiLocalService(client, new SaleToPoiMessageSerializer(), new SaleToPoiMessageSecuredEncryptor(), new SaleToPoiMessageSecuredSerializer());
SaleToPOIResponse response = await terminalApiLocalService.RequestEncryptedAsync(PaymentRequest());
PaymentResponse paymentResponse = response.MessagePayload as PaymentResponse;
Console.WriteLine(paymentResponse?.Response?.Result);

To parse the terminal API notifications, use the following custom deserializer. This method will throw an exception for non-notification requests.

var serializer = new SaleToPoiMessageSerializer();
var saleToPoiRequest = serializer.DeserializeNotification(your_terminal_notification);

Note that the AdditionalResponse field, when performing a CardAcquisition request could be either a based64 encoded-string or key-value-pair. You can use the CardAcquisitionUtil.AdditionalResponse(...)-function to deserialize it.

AdditionalResponse additionalResponse = CardAcquisitionUtil.AdditionalResponse(jsonString);

Parsing BalancePlatform and Management Webhooks

In order to parse banking webhooks, first validate the webhooks (recommended) by retrieving the hmac key from the webhook header and the hmac signature from the Balance Platform CA configuration page respectively.

using Adyen.Model.ConfigurationWebhooks;
using Adyen.Webhooks;
using Adyen.Util;

...
var hmacValidator = new HmacValidator();
var handler = new BalancePlatformWebhookHandler();
bool isValid = hmacValidator.IsValidWebhook("hmacSignature", "ADYEN_HMAC_KEY", webhookPayload);

if (isValid) {
    dynamic webhook = handler.GetGenericBalancePlatformWebhook(webhookPayload);
}

If you want to handle specific webhook types you're expecting to receive, check the type and retrieve if the type is correct:

var handler = new BalancePlatformWebhookHandler();
bool isAccountHolderNotification = handler.GetAccountHolderNotificationRequest(json_payload, out AccountHolderNotificationRequest webhook)
// Your logic here based on whether the webhook parsed correctly or not

Validating management webhooks is identical to validating the balance platform webhooks. To parse the management webhooks, however, one calls the following handler:

var handler = new ManagementWebhookHandler();
if(handler.GetMerchantCreatedNotificationRequest(json_payload, out MerchantCreatedNotificationRequest webhook))
{ 
    // Your logic here using the passed through webhook variable
}

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.

Contributing

We encourage you to contribute to this repository, so everyone can benefit from new features, bug fixes, and any other improvements. Have a look at our contributing guidelines to find out how to raise a pull request.

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.

Licence

This repository is available under the MIT license.

See also

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Adyen:

Package Downloads
APF.Core.Transactions.Common

Package Description

UFPayments

UFPayments seamlessly integrates Umbraco Forms with leading payment providers Mollie, Adyen and Stripe

Vendr.Contrib.PaymentProviders.Adyen

Adyen payment provider for Vendr, the eCommerce package for Umbraco

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
26.0.0 1,276 12/16/2024
25.0.0 4,520 12/2/2024
24.0.0 7,660 11/19/2024
23.0.0 9,425 11/5/2024
22.0.0 7,864 10/22/2024
21.0.0 20,639 10/7/2024
20.0.0 17,108 9/10/2024
19.1.0 16,447 8/29/2024
19.0.0 4,568 8/22/2024
18.0.0 37,739 7/18/2024
17.0.0 24,544 7/4/2024
16.2.0 12,211 6/21/2024
16.1.0 13,918 5/30/2024
16.0.0 2,776 5/24/2024
15.0.0 16,382 5/2/2024
14.4.0 39,678 4/11/2024
14.3.0 8,198 4/4/2024
14.2.1 13,308 3/28/2024
14.1.0 51,535 2/29/2024
14.0.1 11,287 2/15/2024
14.0.0 12,892 1/30/2024
13.2.0 68,573 12/19/2023
13.1.0 11,169 12/11/2023
13.0.0 97,799 11/7/2023
12.0.0 8,297 10/23/2023
11.2.1 13,606 10/9/2023
11.2.0 16,223 9/26/2023
11.1.2 16,779 9/13/2023
11.1.1 1,522 9/11/2023
11.1.0 6,987 8/28/2023
11.0.1 2,433 8/22/2023
11.0.0 15,094 8/7/2023
10.1.0 44,477 6/9/2023
10.0.0 48,688 5/12/2023
10.0.0-beta 3,389 3/16/2023
9.2.3 4,772 3/29/2024
9.2.2 138 3/28/2024
9.2.1 112,262 4/5/2023
9.2.0 117,587 2/2/2023
9.1.0 264,820 9/21/2022
9.0.0 128,309 6/8/2022
8.2.0 139,782 4/12/2022
8.1.0 169,911 1/12/2022
8.0.1 75,146 10/19/2021
8.0.0 3,048 10/8/2021
7.3.0 6,448 10/4/2021
7.2.0 135,662 7/8/2021
7.1.0 63,411 5/12/2021
7.0.0 11,193 4/22/2021
6.1.0 129,252 1/27/2021
6.0.0 16,559 1/8/2021
5.7.0 122,738 9/25/2020
5.6.0 84,190 8/20/2020
5.5.0 60,084 6/25/2020
5.4.0 22,614 5/29/2020
5.3.0 60,896 4/1/2020
5.2.1 41,811 3/16/2020
5.2.0 16,209 2/19/2020
5.1.0 10,878 1/31/2020
5.0.0 31,756 1/15/2020
4.0.0 7,660 1/6/2020
3.5.0 36,857 11/13/2019
3.4.0 17,959 10/2/2019
3.3.0 17,027 8/30/2019
3.2.3 11,201 8/8/2019
3.2.2 1,712 8/7/2019
3.2.1 776 8/6/2019
3.2.0 822 8/1/2019
3.1.0 23,337 7/5/2019
3.0.2 2,669 6/20/2019
3.0.1 690 6/19/2019
3.0.0 1,752 6/13/2019