Authorize.net ARB自定义自动加载不加载MerchantAuthenticationType类

时间:2016-01-20 21:39:02

标签: php api autoload authorize.net spl-autoload-register

我正在尝试在我的预订系统中实施Authorize.net自动重复计费(ARB)API,并在尝试自动加载类时遇到错误。这是我的自定义自动加载功能无效:

function aim2_autoload($class) {
    if (file_exists('../AIM-2.0/vendor/'.$class.'.php')) {
        require '../AIM-2.0/vendor/'.$class.'.php';
    }
    if (file_exists('../AIM-2.0/vendor/authorizenet/authorizenet/lib/'.$class.'.php')) {
        require '../AIM-2.0/vendor/authorizenet/authorizenet/lib/'.$class.'.php';
    }
    if (file_exists('../AIM-2.0/vendor/authorizenet/authorizenet/lib/shared/'.$class.'.php')) {
        require '../AIM-2.0/vendor/authorizenet/authorizenet/lib/shared/'.$class.'.php';
    }
    if (file_exists('../AIM-2.0/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/'.$class.'.php')) {
        require '../AIM-2.0/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/'.$class.'.php';
    }
    if (file_exists('../AIM-2.0/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/'.$class.'.php')) {
        require '../AIM-2.0/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/'.$class.'.php';
    }
}
spl_autoload_register('aim2_autoload');
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;

然而,我收到错误: Fatal error: Class 'net\authorize\api\contract\v1\MerchantAuthenticationType' not found in /home/user/example.com/cart/reservation/ajax-submit.php on line 122

我已经尝试在autoload函数中搜索使用两个use语句的替代方法,但一无所获。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

我通过删除自动加载功能并包含AIM文件夹中包含的autoload.php文件解决了这个问题。

require '../AIM-2.0/vendor/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;