当调试模式为假时,Payum Laravel 4软件包不起作用

时间:2014-08-19 19:34:57

标签: paypal laravel-4 payum

这很奇怪,因为当调试成立时一切正常,但是当我将调试值更改为false时,它并不适用于paypal。 Laravel日志有:必须设置TOKEN。你执行过SetExpressCheckoutAction吗?

[2014-08-19 19:06:58] production.ERROR: exception 'Payum\Core\Exception\LogicException' with message 'The TOKEN must be set. Have you executed SetExpressCheckoutAction?' in /home/myPath/vendor/payum/payum/src/Payum/Paypal/ExpressCheckout/Nvp/Action/Api/AuthorizeTokenAction.php:27
Stack trace:
#0 /home/myPath/vendor/payum/payum/src/Payum/Core/Payment.php(103): Payum\Paypal\ExpressCheckout\Nvp\Action\Api\AuthorizeTokenAction->execute(Object(Payum\Paypal\ExpressCheckout\Nvp\Request\Api\AuthorizeTokenRequest))
#1 /home/myPath/vendor/payum/payum/src/Payum/Paypal/ExpressCheckout/Nvp/Action/CaptureAction.php(44): Payum\Core\Payment->execute(Object(Payum\Paypal\ExpressCheckout\Nvp\Request\Api\AuthorizeTokenRequest))
#2 /home/myPath/vendor/payum/payum/src/Payum/Core/Payment.php(103): Payum\Paypal\ExpressCheckout\Nvp\Action\CaptureAction->execute(Object(Payum\Core\Request\SecuredCaptureRequest))
#3 /home/myPath/vendor/payum/payum/src/Payum/Core/Action/ExecuteSameRequestWithModelDetailsAction.php(22): Payum\Core\Payment->execute(Object(Payum\Core\Request\SecuredCaptureRequest))
#4 /home/myPath/vendor/payum/payum/src/Payum/Core/Payment.php(103): Payum\Core\Action\ExecuteSameRequestWithModelDetailsAction->execute(Object(Payum\Core\Request\SecuredCaptureRequest))
#5 /home/myPath/vendor/payum/payum-laravel-package/src/Payum/LaravelPackage/Controller/CaptureController.php(19): Payum\Core\Payment->execute(Object(Payum\Core\Request\SecuredCaptureRequest))
#6 [internal function]: Payum\LaravelPackage\Controller\CaptureController->doAction('n2AmCSlsVqkD6Kd...')
#7 /home/myPath/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(231): call_user_func_array(Array, Array)
#8 /home/myPath/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(93): Illuminate\Routing\Controller->callAction('doAction', Array)
#9 /home/myPath/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(62): Illuminate\Routing\ControllerDispatcher->call(Object(Payum\LaravelPackage\Controller\CaptureController), Object(Illuminate\Routing\Route), 'doAction')
#10 /home/myPath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(934): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'Payum\\LaravelPa...', 'doAction')
#11 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}('n2AmCSlsVqkD6Kd...')
#12 /home/myPath/vendor/laravel/framework/src/Illuminate/Routing/Route.php(105): call_user_func_array(Object(Closure), Array)
#13 /home/myPath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1000): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#14 /home/myPath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(968): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#15 /home/myPath/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(738): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#16 /home/myPath/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(708): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#17 /home/myPath/vendor/laravel/framework/src/Illuminate/Http/FrameGuard.php(38): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#18 /home/myPath/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Illuminate\Http\FrameGuard->handle(Object(Illuminate\Http\Request), 1, true)
#19 /home/myPath/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#20 /home/myPath/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#21 /home/myPath/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#22 /home/myPath/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(606): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#23 /home/myPath/www/index.php(49): Illuminate\Foundation\Application->run()
#24 {main} [] []

我的代码: payum / payum-laravel封装/ config.php中:

<?php

use Payum\Core\Storage\FilesystemStorage;
use Payum\Paypal\ExpressCheckout\Nvp\Api;
use Payum\Paypal\ExpressCheckout\Nvp\PaymentFactory as PaypalPaymentFactory;

$detailsClass = 'Payum\Core\Model\ArrayObject';
$tokenClass = 'Payum\Core\Model\Token';

$paypalPayment = PaypalPaymentFactory::create(new Api(array(
    'username' => 'MY_USER_NAME',
    'password' => 'MY_PASS',
    'signature' => 'MY_SIGN',
    'sandbox' => true
)));

return array(
    'token_storage' => new FilesystemStorage(__DIR__.'/../../../../storage/payments', $tokenClass, 'hash'),
    'payments' => array(
        'paypal_es' => $paypalPayment,
    ),
    'storages' => array(
        $detailsClass => new FilesystemStorage(__DIR__.'/../../../../storage/payments', $detailsClass),
    )
);

控制器/ PaypalController.php

<?php

use Payum\Paypal\ExpressCheckout\Nvp\Api;

class PaypalController extends BaseController
{
    public function prepareExpressCheckout()
    {

       $paymentName = 'paypal_es';

       $storage = \App::make('payum')->getStorage('Payum\Core\Model\ArrayObject');

         /** @var $paymentDetails PaymentDetails */
           $paymentDetails = $storage->createModel();
           $paymentDetails['PAYMENTREQUEST_0_CURRENCYCODE'] = 'EUR';
           $paymentDetails['PAYMENTREQUEST_0_AMT'] = '1.21';
           $paymentDetails['NOSHIPPING'] = Api::NOSHIPPING_NOT_DISPLAY_ADDRESS;
           $paymentDetails['REQCONFIRMSHIPPING'] = Api::REQCONFIRMSHIPPING_NOT_REQUIRED;
           $paymentDetails['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = Api::PAYMENTREQUEST_ITERMCATEGORY_DIGITAL;
           $paymentDetails['L_PAYMENTREQUEST_0_AMT0'] = '1.21';
           $paymentDetails['L_PAYMENTREQUEST_0_QTY0'] = '1';
           $paymentDetails['L_PAYMENTREQUEST_0_NAME0'] = 'Modulo 1';
           $paymentDetails['L_PAYMENTREQUEST_0_DESC0'] = 'Descripción Módulo 1';
           $storage->updateModel($paymentDetails);

            $captureToken = \App::make('payum.security.token_factory')->createCaptureToken($paymentName, $paymentDetails, 'payment_done');

           $paymentDetails['RETURNURL'] = $captureToken->getTargetUrl();
           $paymentDetails['CANCELURL'] = $captureToken->getTargetUrl();
         //  $paymentDetails['INVNUM'] = $paymentDetails->getId();
           $storage->updateModel($paymentDetails);

       return \Redirect::to($captureToken->getTargetUrl());
    }

    /**
     * @return \Payum\Core\Security\GenericTokenFactoryInterface
     */
    protected function getTokenFactory()
    {
        return \App::make('payum.security.token_factory');
    }
}

有人可以帮助我吗?

0 个答案:

没有答案