I am trying to get the Adyen php-api-library working, but i get the message: Fatal error: Class 'Service\Payment' not found
The error message makes me to believe the class payment is not being loaded, but how do i make sure / fix this?? I thought composer would do the job.
I am devolping on a local XAMPP (mac) - i have installed with composer - simple test.php
> composer require adyen/php-api-library Using version ^1.5 for
> adyen/php-api-library ./composer.json has been created Loading
> composer repositories with package information Updating dependencies
> (including require-dev) Package operations: 3 installs, 0 updates, 0
> removals
> - Installing psr/log (1.0.2): Loading from cache
> - Installing monolog/monolog (1.24.0): Downloading (100%)
> - Installing adyen/php-api-library (1.5.3): Downloading (100%) monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log
> messages to AWS services like DynamoDB) monolog/monolog suggests
> installing doctrine/couchdb (Allow sending log messages to a CouchDB
> server) monolog/monolog suggests installing ext-amqp (Allow sending
> log messages to an AMQP server (1.0+ required)) monolog/monolog
> suggests installing ext-mongo (Allow sending log messages to a MongoDB
> server) monolog/monolog suggests installing graylog2/gelf-php (Allow
> sending log messages to a GrayLog2 server) monolog/monolog suggests
> installing mongodb/mongodb (Allow sending log messages to a MongoDB
> server via PHP Driver) monolog/monolog suggests installing
> php-amqplib/php-amqplib (Allow sending log messages to an AMQP server
> using php-amqplib) monolog/monolog suggests installing
> php-console/php-console (Allow sending log messages to Google Chrome)
> monolog/monolog suggests installing rollbar/rollbar (Allow sending log
> messages to Rollbar) monolog/monolog suggests installing
> ruflin/elastica (Allow sending log messages to an Elastic Search
> server) monolog/monolog suggests installing sentry/sentry (Allow
> sending log messages to a Sentry server) Writing lock file Generating
> autoload files
test.php
require __DIR__ . '/vendor/autoload.php';
$client = new \Adyen\Client();
$client->setApplicationName("Adyen PHP Api Library Example");
$client->setUsername("xxxx");
$client->setPassword("xxxxx");
$client->setXApiKey("xxxxxxxxxxx");
$client->setEnvironment(\Adyen\Environment::TEST);
$service = new Service\Payment($client);
$json = '{
"card": {
"number": "4111111111111111",
"expiryMonth": "03",
"expiryYear": "2030",
"cvc": "737",
"holderName": "John Smith"
},
"amount": {
"value": 1500,
"currency": "EUR"
},
"reference": "payment-test",
"merchantAccount": "ourshopcom"
}';
$params = json_decode($json, true);
$result = $service->authorise($params);
The docs on the GitHub for that is wrong. I looked at the source. That class is in namespace "Adyen\Service".
Change your code as follows:
$service = new Adyen\Service\Payment($client);