2016-01-20 107 views
1

我试图在我的预订系统中实现Authorize.net自动循环计费(ARB)API,并在尝试自动加载类时遇到错误。这是我无法运作的自定义自动加载功能:Authorize.net ARB自定义自动加载无法加载MerchantAuthenticationType类

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语句的替代方法,但什么也没找到。任何帮助,将不胜感激。

回答

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;