【发布时间】:2015-08-05 02:37:45
【问题描述】:
我整天都在尝试在 CodeIgniter 中配置 Omnipay,我想我终于破解了它,但我卡在了信用卡验证部分。出于某种原因,当我运行我的时,我收到错误消息Fatal error: Class 'CreditCard' not found in C:\xampp\htdocs\trabajo\emarket\application\controllers\inicio.php on line 37
这是我的控制器:
use Omnipay\Omnipay;
class Inicio extends CI_Controller {
public function index()
{
$gateway = Omnipay::create('PayPal_Pro');
$gateway->setUsername('######');
$gateway->setPassword('######');
$gateway->setSignature('#####');
$gateway->setTestMode(true);
$gateway->initialize();
$cardInput = array(
'firstName' => 'buyer',
'lastName' => 'one million',
'number' => '4032031186341789',
'company' => 'Visa',
'billingAddress1' => 'bill me here',
'billingAddress2' => 'or maybe here',
'billingPhone' => '4085873015',
'billingCity' => 'chicago',
'billingState' => 'illinois',
'billingPostCode' => '646960',
'shippingAddress1' => 'ship it here',
'shippingAddress2' => 'or ship here',
'shippingPhone' => '98789987',
'shippingCity' => 'chicago',
'shippingState' => 'illinois',
'shippingPostCode' => '989898',
);
$card = new CreditCard($cardInput);
}
}
感谢您抽出宝贵时间,非常感谢您对我做错的地方提出一些建议。
【问题讨论】:
-
尝试添加
use Omnipay\Common\CreditCard -
@Tpojka 非常感谢,解决了!这是否意味着每次我想调用一个类时,我都必须以这种方式将它添加到我正在处理的每个文件中?
-
通常是的。我假设您正在使用作曲家,并且某些软件包具有自动加载文件,您应该将其包括在内,以防对所有类进行处理。检查this answer。
-
请写评论作为答案,我会接受 :) 是的,我从 index.php 调用自动加载文件这就是为什么我认为我不需要添加每个类分别地。这不是很方便,是吗?
-
“公司”字段是购买者代表的公司,而不是发卡机构。别忘了还需要设置国家/地区(美国),州需要是两个字符的代码(IL)。
标签: codeigniter paypal-sandbox omnipay