【问题标题】:Authorize.net ARB custom autoload not loading MerchantAuthenticationType ClassAuthorize.net ARB 自定义自动加载不加载 MerchantAuthenticationType 类
【发布时间】:2016-04-26 22:51:09
【问题描述】:

我正在尝试在我的预订系统中实施 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 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.

我尝试寻找在 autoload 函数中同时使用 use 语句的替代方法,但一无所获。任何帮助将不胜感激。

【问题讨论】:

    标签: php api autoload authorize.net spl-autoload-register


    【解决方案1】:

    我通过去掉自动加载功能并在 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; 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-17
      • 2012-11-08
      • 1970-01-01
      • 2019-11-06
      • 1970-01-01
      • 2019-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多