我正在尝试在我的预订系统中实现 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 netauthorizeapicontractv1 as AnetAPI;
use netauthorizeapicontroller as AnetController;
但是,我收到错误: Fatal error: Class 'netauthorizeapicontractv1MerchantAuthenticationType' 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 netauthorizeapicontractv1 as AnetAPI;
use netauthorizeapicontroller as AnetController;