UrlGenerator函数错误

时间:2016-09-08 06:36:57

标签: php laravel

我有一个使用Laravel 5.1构建的应用程序

我使用netshell paypal和laravel

我该如何解决此错误

  

UrlGenerator.php第609行中的InvalidArgumentException:操作   App \ Http \ Controllers \ BuyNow @ getDone未定义。

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

use Netshell\Paypal\Facades\Paypal;

use Redirect;
class BuyNow 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('USD');
            $amount->setTotal(30); // 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('mohamed');

            $redirectUrls = PayPal:: RedirectUrls();
            $redirectUrls->setReturnUrl(action('BuyNow@getDone'));
            $redirectUrls->setCancelUrl(action('BuyNow@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 );
        }

        public function getDone(Request $request)
        {
            $id = $request->get('paymentId');
            $token = $request->get('token');
            $payer_id = $request->get('PayerID');

            $payment = PayPal::getById($id, $this->_apiContext);

            $paymentExecution = PayPal::PaymentExecution();

            $paymentExecution->setPayerId($payer_id);
            $executePayment = $payment->execute($paymentExecution, $this->_apiContext);

            // Clear the shopping cart, write to database, send notifications, etc.

            // Thank the user for the purchase
            return view('done');
        }

        public function getCancel()
        {
            // Curse and humiliate the user for cancelling this most sacred payment (yours)
            return view('cancel');
        }


}

在波纹管线中出现错误。

$redirectUrls->setReturnUrl(action('BuyNow@getDone')); 

0 个答案:

没有答案