/adyen-dotnet-api-library

Adyen API Library for .NET

Primary LanguageC#MIT LicenseMIT

Adyen dotnet API Library

nuget nuget .NET Core

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

Integration

The library supports all APIs under the following services:

  • Checkout API: Our latest integration for accepting online payments. Current supported version: v68
  • Payments API: Our classic integration for online payments. Current supported version: v51
  • Recurring API: Endpoints for managing saved payment details. Current supported version: v49
  • Payouts API: Endpoints for sending funds to your customers. Current supported version: v51
  • Adyen BinLookup API: Endpoints for retrieving information, such as cost estimates, and 3D Secure supported version based on a given BIN. Current supported version: v50
  • Utility API: This operation takes the origin domains and returns a JSON object containing the corresponding origin keys for the domains. Current supported version: v67
  • Platforms APIs: Set of APIs when using Adyen for Platforms.
  • Cloud-based Terminal API: Our point-of-sale integration.
  • Local-based Terminal API: Our point-of-sale integration.
  • POS Terminal Management API: Endpoints for managing your point-of-sale payment terminals v1

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

Prerequisites

  • Adyen test account
  • API key. For testing, your API credential needs to have the API PCI Payments role.
  • Adyen dotnet API Library supports .net standard 2.0
  • In order for Adyen dotnet 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

Using the library

General use with API key

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

// Create a paymentsRequest
var amount = new Model.Checkout.Amount("USD", 1000);
var paymentRequest = new Model.Checkout.PaymentRequest
{
      Reference = "Your order number",
      Amount = amount,
      ReturnUrl = @"https://your-company.com/...",
      MerchantAccount = ClientConstants.MerchantAccount,
};
paymentRequest.AddCardData("4111111111111111", "10", "2020", "737", "John Smith");

//Create the http client
var client = new Client("YOUR-XAPI-KEY", Model.Enum.Environment.Test);//or Model.Enum.Environment.Live
var checkout = new Checkout(client);
//Make the call to the service. This example code makes a call to /payments
var paymentResponse = checkout.Payments(paymentRequest);

Example integration

For a closer look at how our dotnet library works, clone our ASP .net example integration. This includes commented code, highlighting key features and concepts, and examples of API calls that can be made using the library.

Running the tests

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

dotnet build
dotnet test

Using the Cloud API for post

In order to submit POS request with Cloud API you need to initialize the client with the Endpoints that it is closer to your region. The Endpoints are available as contacts in ClientConfig For more information please read our documentation

//Example for EU based Endpoint Syncronous
var config = new Config
  {
    XApiKey = "Your merchant XAPI key",
    CloudApiEndPoint = ClientConfig.CloudApiEndPointEULive
  };
var client = new Client(config);

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