paypal - 在 Laravel 5 中使用 Omnipay Paypal 时缺少 CreditCard 类

标签 paypal laravel-5 omnipay

这是我的 composer 中包含的 repo:

omnipay & paypal

在我的 config/laravel-omnipay.php 中:

'gateways' => [
    'paypal' => [
        'driver'  => 'PayPal_Rest',
        'options' => [
            'solutionType'   => '',
            'landingPage'    => '',
            'headerImageUrl' => ''
        ]
    ]
]

这是在我的 Controller 中:

// omnipay start
        $gateway = Omnipay::create('PayPal_Rest');

        // Initialise the gateway
        $gateway->initialize(array(
            'clientId' => 'xxxxxx',
            'secret'   => 'xxxxxx',
           'testMode' => true, // Or false when you are ready for live transactions
        ));

        // Create a credit card object
        // DO NOT USE THESE CARD VALUES -- substitute your own
        $card = new CreditCard(array(
                   'firstName'              => $request->firstname,
                   'lastName'               => $request->lastname,
                   'number'                 => $request->cardnumber,
                   'expiryMonth'            => $month_year[0],
                   'expiryYear'             => $month_year[1],
                   'cvv'                    => $request->ccv,
                   'billingAddress1'        => $request->address
                   /*
                   'billingCountry'         => 'AU',
                   'billingCity'            => 'Scrubby Creek',
                   'billingPostcode'        => '4999',
                   'billingState'           => 'QLD',*/
        ));

        // Do an authorisation transaction on the gateway
        $transaction = $gateway->authorize(array(
           'amount'        => '100',
           'currency'      => 'USD',
           'description'   => $eventName->event_title,
           'card'          => $card,
        ));
        $response = $transaction->send();
        if ($response->isSuccessful()) {
           echo "Authorize transaction was successful!\n";
           // Find the authorization ID
           $auth_id = $response->getTransactionReference();
        }

我遇到了这个错误:

Class 'App\Http\Controllers\CreditCard' not found

注意:如果我使用 RestGateway 替换 PayPal_Rest,则会收到此错误:

Class '\Omnipay\RestGateway\Gateway' not found

搜索了很长时间的答案,但没有找到适合我的解决方案。所以,不完全确定如何进行。

最佳答案

你需要把它放在你的类文件的顶部:

use Omnipay\Common\CreditCard;

关于paypal - 在 Laravel 5 中使用 Omnipay Paypal 时缺少 CreditCard 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34053542/

相关文章:

使用虚假卡详细信息的 PayPal 收费卡

ruby-on-rails - 创建定期付款配置文件时出现 Paypal 无效 token 错误

php - cURL错误60 : SSL certificate in Laravel 5 while Facebook authentication如何解决

Laravel 5.7 Auth::loginUsingId() 在生成 CSRF token 后不起作用

codeigniter - 如何使用 omnipay 通过 CodeIgniter 实现在线支付?

paypal - fatal error : Uncaught PayPal\Exception\PayPalConnectionException: Got Http response code 403

paypal - 如何在 Paypal 中访问第三方交易信息

paypal - 如何使用 Laravel 设置 Omnipay?

mysql - Laravel 表定义不正确;只能有一个自动列,并且必须将其定义为键

php - 使用 Omnipay 进行密码支付