Я пытаюсь внедрить API авторизованного повторного биллинга (ARB) Authorize.net в мою систему резервирования, и при попытке автозагрузки классов я запускаю ошибку. Вот моя пользовательская функция автозагрузки, которая не работает:
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
внутри функции автозагрузки, но ничего не нашел. Любая помощь будет оценена по достоинству.
Я решил проблему, избавившись от функции автозагрузки и включив файл autoload.php
включенный в папку AIM.
require '../AIM-2.0/vendor/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;