Authorize.net ARB 自定义自动加载不加载商家身份验证类型类


Authorize.net ARB custom autoload not loading MerchantAuthenticationType Class

我正在尝试在我的预订系统中实现 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 .

我尝试在自动加载函数中搜索同时使用use语句的替代方案,但一无所获。任何帮助将不胜感激。

我通过摆脱自动加载功能并包含 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;