0

我正在尝试让 Adyen php-api-library 工作,但我收到消息:致命错误:找不到类“服务\付款”

错误消息让我相信课程付款没有被加载,但我如何确保/解决这个问题?我认为作曲家会完成这项工作。

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

测试.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);
4

1 回答 1

2

GitHub 上的文档是错误的。我看了看源码。该类位于命名空间“Adyen\Service”中。

更改您的代码如下:

$service = new Adyen\Service\Payment($client);
于 2018-11-10T15:00:08.597 回答