Error with ApiContextfunctoin in netshel paypal


Error with ApiContextfunctoin in netshel paypal

如何解决这个错误:

BadMethodCallException in Controller.php line 107: Method [ApiContext]
does not exist.

这是代码:

<?php
namespace App'Http'Controllers;
use Illuminate'Http'Request;
use App'Http'Requests;
class paypalel extends Controller {
    private $_apiContext;
    public function __construct()
    {
        $this->_apiContext = PayPal::ApiContext(
            config('services.paypal.client_id'),
            config('services.paypal.secret')
        );
        $this->_apiContext->setConfig(array(
            'mode' => 'sandbox',
            'service.EndPoint' => 'https://api.sandbox.paypal.com',
            'http.ConnectionTimeOut' => 30,
            'log.LogEnabled' => true,
            'log.FileName' => storage_path('logs/paypal.log'),
            'log.LogLevel' => 'FINE'
        ));
    }
    public function getCheckout() {
        $payer = PayPal::Payer();
        $payer->setPaymentMethod('paypal');
        $amount = PayPal:: Amount();
        $amount->setCurrency('EUR');
        $amount->setTotal(42); // This is the simple way,
        // you can alternatively describe everything in the order separately;
        // Reference the PayPal PHP REST SDK for details.
        $transaction = PayPal::Transaction();
        $transaction->setAmount($amount);
        $transaction->setDescription('What are you selling?');
        $redirectUrls = PayPal:: RedirectUrls();
        $redirectUrls->setReturnUrl(action('paypalel@getDone'));
        $redirectUrls->setCancelUrl(action('paypalel@getCancel'));
        $payment = PayPal::Payment();
        $payment->setIntent('sale');
        $payment->setPayer($payer);
        $payment->setRedirectUrls($redirectUrls);
        $payment->setTransactions(array($transaction));
        $response = $payment->create($this->_apiContext);
        $redirectUrl = $response->links[1]->href;
        return Redirect::to( $redirectUrl ); 
    } 
}

这行有一个拼写错误

 $this->_apiContext = Paypalel::ApiContext(

我想应该是

$this->_apiContext = PayPal::ApiContext(

我希望这将解决你的问题

在类声明之前添加以下行

  use PayPal;
  use Redirect;