2016-01-20 127 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;