简体   繁体   中英

Authorize.net ARB custom autoload not loading MerchantAuthenticationType Class

I'm trying to implement an Authorize.net Automated Recurring Billing (ARB) API into my reservation system and am running into an error when trying to autoload the classes. Here is my custom autoload function that's not working:

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;

However, I'm getting the error: Fatal error: Class 'net\\authorize\\api\\contract\\v1\\MerchantAuthenticationType' not found in /home/user/example.com/cart/reservation/ajax-submit.php on line 122 .

I've tried searching for alternatives of using both use statements inside the autoload function, but found nothing. Any help would be appreciated.

I solved the problem by getting rid of the autoload function and including the autoload.php file included in the AIM folder.

require '../AIM-2.0/vendor/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM