Magento 2 Redirecting to Payment Gateway Error

给你一囗甜甜゛ 提交于 2019-12-31 03:51:10

问题


i have convert my Magento 1 payment module using a converter. I guess i need to modify the codes to suit Magento 2. And I am stuck at the checkout process, redirecting to the Payment gateway.

Below is my error when magento is trying to redirect to http://localhost:8083/mm/pdcptb/pdcptb/redirect/

There has been an error processing your request

Exception printing is disabled by default for security reasons.

Error log record number: 979987430

The console in the firebug shows:

"NetworkError: 503 Service Unavailable - http://localhost:8083/mm/pdcptb/pdcptb/redirect/"

and below is the error log file:

a:4:{i:0;s:20:"Invalid block type: ";i:1;s:11118:"#0 C:\Apache24\htdocs\mm\vendor\magento\framework\View\Layout\Generator\Block.php(237): Magento\Framework\View\Layout\Generator\Block->getBlockInstance('', Array)
#1 C:\Apache24\htdocs\mm\vendor\magento\framework\View\Layout.php(760): Magento\Framework\View\Layout\Generator\Block->createBlock('', '_0', Array)
#2 C:\Apache24\htdocs\mm\vendor\magento\framework\View\Layout.php(743): Magento\Framework\View\Layout->_createBlock('', '_0', Array)
#3 C:\Apache24\htdocs\mm\var\generation\Magento\Framework\View\Layout\Interceptor.php(349): Magento\Framework\View\Layout->createBlock('', '', Array)
#4 C:\Apache24\htdocs\mm\app\code\Asiapay\Pdcptb\Controller\Pdcptb\Redirect.php(39): Magento\Framework\View\Layout\Interceptor->createBlock('')
#5 C:\Apache24\htdocs\mm\var\generation\Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor.php(24): Asiapay\Pdcptb\Controller\Pdcptb\Redirect->execute()
#6 C:\Apache24\htdocs\mm\vendor\magento\framework\App\Action\Action.php(102): Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor->execute()
#7 [internal function]: Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#8 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Interceptor.php(74): call_user_func_array(Array, Array)
#9 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(70): Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor->___callParent('dispatch', Array)
#10 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Asiapay\\Pdcptb\\...', 'dispatch', Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Array, 'designLoader')

#11 C:\Apache24\htdocs\mm\vendor\magento\framework\App\Action\Plugin\Design.php(39): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#12 [internal function]: Magento\Framework\App\Action\Plugin\Design->aroundDispatch(Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#13 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(68): call_user_func_array(Array, Array)
#14 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Asiapay\\Pdcptb\\...', 'dispatch', Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Array, 'contextPlugin')
#15 C:\Apache24\htdocs\mm\vendor\magento\module-store\App\Action\Plugin\Context.php(106): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#16 [internal function]: Magento\Store\App\Action\Plugin\Context->aroundDispatch(Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#17 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(68): call_user_func_array(Array, Array)
#18 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Asiapay\\Pdcptb\\...', 'dispatch', Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Array, 'storeCheck')
#19 C:\Apache24\htdocs\mm\vendor\magento\module-store\App\Action\Plugin\StoreCheck.php(44): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#20 [internal function]: Magento\Store\App\Action\Plugin\StoreCheck->aroundDispatch(Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

#21 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(68):call_user_func_array(Array, Array)
#22 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Asiapay\\Pdcptb\\...', 'dispatch', Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Array, 'customer-app-ac...')
#23 C:\Apache24\htdocs\mm\vendor\magento\module-customer\Model\App\Action\ContextPlugin.php(61): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#24 [internal function]: Magento\Customer\Model\App\Action\ContextPlugin->aroundDispatch(Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#25 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(68): call_user_func_array(Array, Array)
#26 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Asiapay\\Pdcptb\\...', 'dispatch', Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Array, 'tax-app-action-...')
#27 C:\Apache24\htdocs\mm\vendor\magento\module-tax\Model\App\Action\ContextPlugin.php(91): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#28 [internal function]: Magento\Tax\Model\App\Action\ContextPlugin->aroundDispatch(Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#29 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(68): call_user_func_array(Array, Array)
#30 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Asiapay\\Pdcptb\\...', 'dispatch', Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Array, 'weee-app-action...')

#31 C:\Apache24\htdocs\mm\vendor\magento\module-weee\Model\App\Action\ContextPlugin.php(112): Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#32 [internal function]: Magento\Weee\Model\App\Action\ContextPlugin->aroundDispatch(Object(Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#33 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Interceptor.php(141): call_user_func_array(Array, Array)
#34 C:\Apache24\htdocs\mm\var\generation\Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor.php(39): Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor->___callPlugins('dispatch', Array, Array)
#35 C:\Apache24\htdocs\mm\vendor\magento\framework\App\FrontController.php(55): Asiapay\Pdcptb\Controller\Pdcptb\Redirect\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#36 [internal function]: Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#37 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Interceptor.php(74): call_user_func_array(Array, Array)
#38 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#39 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'requestPreproce...')
#40 C:\Apache24\htdocs\mm\vendor\magento\module-store\App\FrontController\Plugin\RequestPreprocessor.php(89): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))

#41 [internal function]: Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#42 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(68): call_user_func_array(Array, Array)
#43 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#44 C:\Apache24\htdocs\mm\vendor\magento\framework\Module\Plugin\DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#45 [internal function]: Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#46 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(68): call_user_func_array(Array, Array)
#47 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#48 C:\Apache24\htdocs\mm\vendor\magento\module-page-cache\Model\App\FrontController\BuiltinPlugin.php(73): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#49 [internal function]: Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

#50 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Chain\Chain.php(68): call_user_func_array(Array, Array)
#51 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#52 C:\Apache24\htdocs\mm\vendor\magento\module-page-cache\Model\App\FrontController\VarnishPlugin.php(55): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#53 [internal function]: Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#54 C:\Apache24\htdocs\mm\vendor\magento\framework\Interception\Interceptor.php(141): call_user_func_array(Array, Array)
#55 C:\Apache24\htdocs\mm\var\generation\Magento\Framework\App\FrontController\Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#56 C:\Apache24\htdocs\mm\vendor\magento\framework\App\Http.php(115): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#57 C:\Apache24\htdocs\mm\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http->launch()
#58 C:\Apache24\htdocs\mm\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#59 {main}";s:3:"url";s:27:"/mm/pdcptb/pdcptb/redirect/";s:11:"script_name";s:13:"/mm/index.php";}

Below is the code of module/name/Controller/Pdcptb/Redirect.php

<?php

namespace Asiapay\Pdcptb\Controller\Pdcptb;

use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Controller\Result\RawFactory;
use Magento\Framework\View\LayoutFactory;

class Redirect extends AbstractPdcptb
{
/**
 * @var RawFactory
 */
protected $_resultRawFactory;

/**
 * @var LayoutFactory
 */
protected $_viewLayoutFactory;

public function __construct(Context $context, 
    RawFactory $resultRawFactory, 
    LayoutFactory $viewLayoutFactory)
{
    $this->_resultRawFactory = $resultRawFactory;
    $this->_viewLayoutFactory = $viewLayoutFactory;

    parent::__construct($context);
}

/**
 * When a customer chooses Pdcptb on Checkout/Payment page
 */
public function execute()
{
    $session = ObjectManager::getInstance()->get('Magento\Checkout\Model\Session');
    $session->setPdcptbQuoteId($session->getQuoteId());
    $this->_resultRawFactory->create()->setContents($this->_viewLayoutFactory->create()->createBlock('')->toHtml());
    $session->unsQuoteId();
}
}

I guess the error is caused by my modules files. But i'm not sure why they have error. Can anybody guide me to solve this issue? I am not really strong at OO.

来源:https://stackoverflow.com/questions/38319940/magento-2-redirecting-to-payment-gateway-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!