This is the officially supported PHP library for using Adyen's APIs.
The library supports all APIs under the following services:
- Checkout API: Our latest integration for accepting online payments. Current supported version: v67
- 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
- Platforms APIs: Set of APIs when using Adyen for Platforms.
- Account API Current supported version: v5
- Fund API Current supported version: v5
- Notification Configuration API Current supported version: v5
- Cloud-based Terminal API: Our point-of-sale integration.
- Referrals API: Endpoints to automate submitting referrals for Adyen risk rules.
For more information, refer to our documentation or the API Explorer.
- Adyen test account
- API key. For testing, your API credential needs to have the API PCI Payments role.
- PHP 5.6 or later for production
- PHP 7.3 or later for development
- cURL with SSL support.
- The JSON PHP extension.
- See composer require list for the complete list of dependencies
If using PHP versions 5.3, 5.4, or 5.5, download our library version 6.3.0.
You can use Composer. Follow the installation instructions if you do not already have composer installed.
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.
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 API KEY");
$client->setEnvironment(\Adyen\Environment::TEST);
$client->setTimeout(30);
$service = new \Adyen\Service\Checkout($client);
$json = '{
"card": {
"encryptedCardNumber" => "test_4111111111111111",
"encryptedExpiryMonth" => "test_03",
"encryptedExpiryYear" => "test_2030",
"encryptedSecurityCode" => "test_737"
"holderName": "John Smith"
},
"amount": {
"value": 1500,
"currency": "EUR"
},
"reference": "payment-test",
"merchantAccount": "YOUR MERCHANT ACCOUNT"
}';
$params = json_decode($json, true);
$result = $service->payments($params);
$client = new \Adyen\Client();
$client->setXApiKey("YOUR API KEY");
$client->setEnvironment(\Adyen\Environment::LIVE);
$client->setTimeout(30);
...
$client = new \Adyen\Client();
$client->setUsername("YOUR USERNAME");
$client->setPassword("YOUR PASSWORD");
$client->setEnvironment(\Adyen\Environment::TEST);
$client->setTimeout(30);
$service = new \Adyen\Service\Payment($client);
$json = '{
"card": {
"number": "4111111111111111",
"expiryMonth": "10",
"expiryYear": "2020",
"cvc": "737",
"holderName": "John Smith"
},
"amount": {
"value": 1500,
"currency": "EUR"
},
"reference": "payment-test",
"merchantAccount": "YOUR MERCHANT ACCOUNT"
}';
$params = json_decode($json, true);
$result = $service->authorise($params);
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.
For the test cases you need the PCI permission enabled on you account. There are no test cases for CSE because credit card data is encrypted through our javascript library. By default the test will then be skipped. If you have these permissions fill in your account details in the config/test.ini file to let the test work. To make the automatic testing cases work for your account change the credentials in the config/test.ini file.
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.
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.
This repository is available under the MIT license.