类 不要使用 Adyen php-api-library 自动加载?

Classes don't autoload with Adyen php-api-library?

我正在尝试让 Adyen php-api-库正常工作,但我收到消息: 致命错误:Class 'Service\Payment' 未找到

错误消息让我相信 class 付款未加载,但我如何确定/修复此问题?我以为作曲家会做这个工作。

我正在本地开发 XAMPP (mac) - 我已经安装了作曲家 - 简单 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);

GitHub 上的文档是错误的。我看了看来源。 class 在命名空间 "Adyen\Service".

按如下方式更改您的代码:

$service = new Adyen\Service\Payment($client);