4yousee / adyen-lib-with-mock
A PHP client library for accessing Adyen APIs with mock for integration test
Requires
- php: >=5.6
- ext-ctype: *
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- monolog/monolog: >=1.16
Requires (Dev)
- dms/phpunit-arraysubset-asserts: 0.2.1
- friendsofphp/php-cs-fixer: *
- php-coveralls/php-coveralls: 2.4.2
- phpunit/phpunit: 9.5.1
- squizlabs/php_codesniffer: 3.5.8
- dev-develop
- 9.0.0
- 8.1.0
- 8.0.0
- 7.1.0
- 7.0.0
- 6.3.0
- 6.2.0
- 6.1.0
- 6.0.1
- 6.0.0
- 5.0.1
- 5.0.0
- 4.2.0
- 4.1.0
- 4.0.0
- 3.1.0
- 3.0.0
- 2.1.0
- 2.0.0
- 1.6.1
- 1.6.0
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- dev-v6.3.0-mock-enviroment
- dev-feature/mock-env
- dev-master
- dev-dependabot/add-v2-config-file
- dev-codacy-setup
- dev-PW-1942-psp_search_url
- dev-feature/update-to-latest-api-version
- dev-PW-1188
- dev-feature/release-1.5.1
- dev-minor-fixes
This package is not auto-updated.
Last update: 2024-11-22 12:47:59 UTC
README
The Adyen API Library for PHP lets you easily work with Adyen's API.
Integration
The Library supports all APIs under the following services:
- checkout
- checkout utility
- payments
- modifications
- payouts
- recurring
- marketpay
- Terminal API (Cloud based)
- Referrals API
Requirements
PHP >=5.6 for production PHP >=7.3 for development
Legacy version support
In case that you are using one of the older PHP versions 5.3, 5.4 or 5.5 you can download the previous library version 6 which can be found in the releases page. We are going to bump or patch version 6 if there is a request from merchants or if it's used for one of our plugins.
Installation
You can use Composer or simply Download the Release
Composer
The preferred method is via composer. Follow the installation instructions if you do not already have composer installed.
Once composer is installed, execute the following command in your project root to install this library:
composer require adyen/php-api-library
Usage
To make the automatic testing cases work for your account change the credentials in the config/test.ini file.
Examples
Create Payment Request on Test:
$client = new \Adyen\Client(); $client->setApplicationName("Adyen PHP Api Library Example"); $client->setUsername("YOUR USERNAME"); $client->setPassword("YOUR PASSWORD"); $client->setXApiKey("YOUR API KEY"); $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 CSE use
{ "amount": { "value": 1499, "currency": "GBP" }, "reference": "payment-test", "merchantAccount": "YOUR MERCHANT ACCOUNT", "additionalData": { "card.encrypted.json": "THE ENCRYPTED DATA" } }
Refund example:
$client = new \Adyen\Client(); $client->setApplicationName("Adyen PHP Api Library Example"); $client->setUsername("YOUR USERNAME"); $client->setPassword("YOUR PASSWORD"); $client->setXApiKey("YOUR API KEY"); $client->setEnvironment(\Adyen\Environment::TEST); $client->setTimeout(30); // intialize modification service $service = new \Adyen\Service\Modification($client); // set the amount you want to refund $modificationAmount = array('currency' => 'CURRENCY', 'value' => 'VALUE'); // required are merchantAccount, ModificationAmount(currency,value), reference and originalReference $params = array( "merchantAccount" => 'YOUR MERCHANT ACCOUNT', "modificationAmount" => $modificationAmount, "reference" => 'YOUR OWN REFERENCE', "originalReference" => 'PSPREFERENCE OF THE PAYMENT YOU WANT TO REFUND' ); $result = $service->refund($params); // $result['response'] = [refund-received]
Documentation
- https://docs.adyen.com/developers/development-resources/libraries
- https://docs.adyen.com/developers/checkout
Tests
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.
Support
If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. 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.
Licence
MIT license. For more information, see the LICENSE file.