We provide server-side API libraries in several languages. Because the libraries are connected to managed package systems (Composer, Gradle, Maven, npm, NuGet, PyPi, RubyGems) they are easy to include in your project. Installing a library is not required, but will save you development time, because a library:
Uses an API version that is up to date.
Has generated models to help you construct requests.
For a point-of-sale integration with Terminal API, the libraries are wrappers around Terminal API. They include the models to create Terminal API requests.
- With a cloud Terminal API integration, you can use the PHP, Java, Node, C#, or Go libraries.
With a local Terminal API integration, you can use the Node, Java, or C# libraries. These also take care of protecting local communications.
Sends the request to Adyen using its built-in HTTP client, so you don't have to create your own.
The source code for all our libraries and example integrations is available on our GitHub.
- PHP 7.3 or later.
- Curl with SSL support.
- The JSON PHP extension.
composer require adyen/php-api-library
In your PHP script, make sure you include the autoloader:
require __DIR__ . '/vendor/autoload.php';
Alternatively, you can download the release on GitHub.
Using the library
Set up a client and set the credentials to the Adyen platform.
If you don't know your
X-API-KEY, you can obtain it from the Customer Area, as described in How to get the API key.
Set up the client as a singleton resource; you'll use it for the API calls that you make to Adyen:
$client = new \Adyen\Client(); $client->setXApiKey("YOUR X-API-KEY"); $client->setEnvironment(\Adyen\Environment::TEST);
When you want to process on the live environment, include your live URL prefix:
$client->setEnvironment(\Adyen\Environment::LIVE, "Your live URL prefix"); //Live environment
To make your first payment, follow the instructions on our API integration guide.
Clone our example integration
For a closer look at how our PHP library works, clone our Laravel example integration. This includes commented code, highlighting key features and concepts, and examples of API calls that can be made using the library.