【问题标题】:Missing Classes in Authorize.net PHP SDKAuthorize.net PHP SDK 中缺少类
【发布时间】:2016-05-28 20:25:36
【问题描述】:

我正在尝试使用他们的 API 从 Authorize.net 生成自定义报告,但无法正确加载 SDK。

我在开发者委员会HERE 上创建了一个帖子,并向他们的支持团队发送了一封电子邮件请求。该问题应该已通过临时补丁HERE 修复。但错误仍然存​​在。

有人对如何解决此问题有任何想法吗?

我的代码:

<?php
error_reporting(-1); ini_set('display_errors', 'On');
date_default_timezone_set('UTC');

/* autoload through composer */
//require 'vendor/autoload.php';

/* autoload through git clone */
//require 'git/sdk-php/autoload.php';

/* autoload through .zip download */
require 'download/sdk-php-master/autoload.php';

use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController; 

function getSettledBatchList($startDate, $endDate) {
    $api_id         = "MY_API_ID";
    $account_key    = "MY_ACCOUNT_KEY";
    $start_dt       = new DateTime($startDate);
    $end_dt         = new DateTime($endDate);

    $merchAuth      = new AnetAPI\MerchantAuthenticationType();
    $merchAuth->setName($api_id);
    $merchAuth->setTransactionKey($account_key);

    $request        = new AnetAPI\GetSettledBatchListRequest();
    $request->setMerchantAuthentication($merchAuth);
    $request->setIncludeStatistics(true);
    $request->setFirstSettlementDate($start_dt);
    $request->setLastSettlementDate($end_dt);

    $controller     = new AnetController\GetSettledBatchListController($request);
    $response       = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);

    if(($response != null) && ($response->getMessages()->getResultCode() == "Ok")){
        /* Do Nothing For Now */
    }else{
        $errorMessages = $response->getMessages()->getMessage();
        echo "Response : " . $errorMessages[0]->getCode() . "  " .$errorMessages[0]->getText() . "\n";
    }
    return $response;
}

$api_response   = getSettledBatchList('2016-05-01T00:00:00Z', '2016-05-10T00:00:00Z');
var_dump($api_response); 

?>

错误:

/* Loaded with git clone https://github.com/AuthorizeNet/sdk-php.git */

Warning: include(sdk-php/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php): failed to open stream: No such file or directory in sdk-php/autoload.php on line 16 

Warning: include(): Failed opening '/sdk-php/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php' for inclusion (include_path='.:') in sdk-php/autoload.php on line 16 

Fatal error: Class 'JMS\Serializer\Annotation\Type' not found in /sdk-php/lib/net/authorize/util/SensitiveDataConfigType.php on line 6


/* Loaded by downloading .zip from github page */

Warning: include(/sdk-php-master/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php): failed to open stream: No such file or directory in /sdk-php-master/autoload.php on line 16 

Warning: include(): Failed opening '/sdk-php-master/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php' for inclusion (include_path='.:') in /sdk-php-master/autoload.php on line 16 

Fatal error: Class 'JMS\Serializer\Annotation\Type' not found in /sdk-php-master/lib/net/authorize/util/SensitiveDataConfigType.php on line 6


/* Loaded with Composer using recommended composer.json */

Fatal error: Class 'Goetas\Xsd\XsdToPhp\Jms\Handler\BaseTypesHandler' not found in /vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php on line 82

在这一点上,我对所有想法持开放态度。谢谢!

【问题讨论】:

    标签: php sdk authorize.net


    【解决方案1】:

    简单的错误。该补丁针对的是更新了 Goetas 所需开发版本的 composer.json 文件。没有意识到我需要在运行 composer update 之前更新我的 composer.json。

    Updated composer.json Language

    【讨论】:

      【解决方案2】:

      我刚刚遇到了同样的问题,我意识到问题是我在错误的autoload.php 上使用了require,我认为你也在这样做。

      您现在可能已经想到了,但如果其他人有这个问题,解决方案是这样的:

      您必须加载/要求 autoload.php 位于 vendor 文件夹中,而不是 sdk(根)文件夹中的那个。

      【讨论】:

        猜你喜欢
        • 2016-08-06
        • 2019-10-04
        • 2017-12-08
        • 1970-01-01
        • 2016-04-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-28
        相关资源
        最近更新 更多