1

I'm trying to make a payment module in Magento 2. The module is show in admin Configuration->Sales->Payment method. But when I go to the checkout, only layout renders and the rest of the page is blank. In the system.log, there is a line

main.CRITICAL: Class Platiti\Testpayment\Model\Payment\SampleUnimodul_Platba does not exist [] []

But the class is there. This is my folder structure in app/code: folder structure

payment.xml

<?xml version="1.0" ?>
<payment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Payment:etc/payment.xsd">
    <groups>
        <group id="offline">
            <label>Offline Payment Methods</label>
        </group>
    </groups>
    <methods>
        <method name="sampleunimodul_platba">
            <allow_multiple_address>1</allow_multiple_address>
        </method>
    </methods>
</payment>

config.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <payment>
            <sampleunimodul_platba>
                <active>1</active>
                <model>Platiti\Testpayment\Model\Payment\SampleUnimodul_Platba</model>
                <order_status>pending</order_status>
                <title>SampleUnimodul_Platba</title>
                <allowspecific>0</allowspecific>
                <group>Offline</group>
            </sampleunimodul_platba>
        </payment>
    </default>
</config>

SampleUnimodul_Platba.php

namespace Platiti\Testpayment\Model\Payment;

class SampleUnimodul_Platba extends \Magento\Payment\Model\Method\AbstractMethod
{

    protected $_code = "sampleunimodul_platba";
    protected $_isOffline = true;

    public function isAvailable(
        \Magento\Quote\Api\Data\CartInterface $quote = null
    ) {
        return parent::isAvailable($quote);
    }
}

When I switched to developer mode, this is printed instead of checkout page:

Class Platiti\Testpayment\Model\Payment\SampleUnimodul_Platba does not exist
#0 /var/www/html/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct('Platiti\\Testpay...')
#1 /var/www/html/vendor/magento/framework/ObjectManager/Definition/Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor('Platiti\\Testpay...')
#2 /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(71): Magento\Framework\ObjectManager\Definition\Runtime->getParameters('Platiti\\Testpay...')
#3 /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Platiti\\Testpay...', Array)
#4 /var/www/html/vendor/magento/module-payment/Model/Method/Factory.php(40): Magento\Framework\ObjectManager\ObjectManager->create('Platiti\\Testpay...', Array)
#5 /var/www/html/vendor/magento/module-payment/Helper/Data.php(138): Magento\Payment\Model\Method\Factory->create('Platiti\\Testpay...')
#6 /var/www/html/vendor/magento/module-payment/Model/MethodList.php(46): Magento\Payment\Helper\Data->getStoreMethods(1, Object(Magento\Quote\Model\Quote))
#7 /var/www/html/vendor/magento/module-quote/Model/PaymentMethodManagement.php(108): Magento\Payment\Model\MethodList->getAvailableMethods(Object(Magento\Quote\Model\Quote))
#8 /var/www/html/vendor/magento/module-checkout/Model/DefaultConfigProvider.php(608): Magento\Quote\Model\PaymentMethodManagement->getList('1')
#9 /var/www/html/vendor/magento/module-checkout/Model/DefaultConfigProvider.php(296): Magento\Checkout\Model\DefaultConfigProvider->getPaymentMethods()
#10 [internal function]: Magento\Checkout\Model\DefaultConfigProvider->getConfig()
#11 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(146): call_user_func_array(Array, Array)
#12 /var/www/html/var/generation/Magento/Checkout/Model/DefaultConfigProvider/Interceptor.php(26): Magento\Checkout\Model\DefaultConfigProvider\Interceptor->___callPlugins('getConfig', Array, Array)
#13 /var/www/html/vendor/magento/module-checkout/Model/CompositeConfigProvider.php(32): Magento\Checkout\Model\DefaultConfigProvider\Interceptor->getConfig()
#14 /var/www/html/vendor/magento/module-checkout/Block/Onepage.php(91): Magento\Checkout\Model\CompositeConfigProvider->getConfig()
#15 /var/www/html/vendor/magento/module-checkout/view/frontend/templates/onepage.phtml(26): Magento\Checkout\Block\Onepage->getCheckoutConfig()
#16 /var/www/html/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/html/v...')
#17 /var/www/html/vendor/magento/framework/View/Element/Template.php(255): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Checkout\Block\Onepage), '/var/www/html/v...', Array)
#18 /var/www/html/vendor/magento/framework/View/Element/Template.php(279): Magento\Framework\View\Element\Template->fetchView('/var/www/html/v...')
#19 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(657): Magento\Framework\View\Element\Template->_toHtml()
#20 /var/www/html/vendor/magento/framework/View/Layout.php(542): Magento\Framework\View\Element\AbstractBlock->toHtml()
#21 /var/www/html/vendor/magento/framework/View/Layout.php(518): Magento\Framework\View\Layout->_renderBlock('checkout.root')
#22 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('checkout.root')
#23 /var/www/html/vendor/magento/framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('checkout.root')
#24 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('checkout.root', true)
#25 /var/www/html/vendor/magento/framework/View/Layout.php(569): Magento\Framework\View\Layout\Interceptor->renderElement('checkout.root')
#26 /var/www/html/vendor/magento/framework/View/Layout.php(520): Magento\Framework\View\Layout->_renderContainer('content')
#27 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('content')
#28 /var/www/html/vendor/magento/framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('content')
#29 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('content', true)
#30 /var/www/html/vendor/magento/framework/View/Layout.php(569): Magento\Framework\View\Layout\Interceptor->renderElement('content')
#31 /var/www/html/vendor/magento/framework/View/Layout.php(520): Magento\Framework\View\Layout->_renderContainer('main')
#32 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('main')
#33 /var/www/html/vendor/magento/framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('main')
#34 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('main', true)
#35 /var/www/html/vendor/magento/framework/View/Layout.php(569): Magento\Framework\View\Layout\Interceptor->renderElement('main')
#36 /var/www/html/vendor/magento/framework/View/Layout.php(520): Magento\Framework\View\Layout->_renderContainer('columns')
#37 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('columns')
#38 /var/www/html/vendor/magento/framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('columns')
#39 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('columns', true)
#40 /var/www/html/vendor/magento/framework/View/Layout.php(569): Magento\Framework\View\Layout\Interceptor->renderElement('columns')
#41 /var/www/html/vendor/magento/framework/View/Layout.php(520): Magento\Framework\View\Layout->_renderContainer('main.content')
#42 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('main.content')
#43 /var/www/html/vendor/magento/framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('main.content')
#44 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('main.content', true)
#45 /var/www/html/vendor/magento/framework/View/Layout.php(569): Magento\Framework\View\Layout\Interceptor->renderElement('main.content')
#46 /var/www/html/vendor/magento/framework/View/Layout.php(520): Magento\Framework\View\Layout->_renderContainer('page.wrapper')
#47 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper')
#48 /var/www/html/vendor/magento/framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('page.wrapper')
#49 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('page.wrapper', true)
#50 /var/www/html/vendor/magento/framework/View/Layout.php(569): Magento\Framework\View\Layout\Interceptor->renderElement('page.wrapper')
#51 /var/www/html/vendor/magento/framework/View/Layout.php(520): Magento\Framework\View\Layout->_renderContainer('root')
#52 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('root')
#53 /var/www/html/vendor/magento/framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('root')
#54 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('root', true)
#55 /var/www/html/vendor/magento/framework/View/Layout.php(938): Magento\Framework\View\Layout\Interceptor->renderElement('root')
#56 [internal function]: Magento\Framework\View\Layout->getOutput()
#57 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(146): call_user_func_array(Array, Array)
#58 /var/www/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(494): Magento\Framework\View\Layout\Interceptor->___callPlugins('getOutput', Array, Array)
#59 /var/www/html/vendor/magento/framework/View/Result/Page.php(241): Magento\Framework\View\Layout\Interceptor->getOutput()
#60 /var/www/html/vendor/magento/framework/View/Result/Layout.php(162): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))
#61 [internal function]: Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#62 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
#63 /var/www/html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', Array)
#64 /var/www/html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'renderResult', Object(Magento\Framework\View\Result\Page\Interceptor), Array, 'result-varnish-...')
#65 /var/www/html/vendor/magento/module-page-cache/Model/Controller/Result/VarnishPlugin.php(74): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))
#66 [internal function]: Magento\PageCache\Model\Controller\Result\VarnishPlugin->aroundRenderResult(Object(Magento\Framework\View\Result\Page\Interceptor), Object(Closure), Object(Magento\Framework\App\Response\Http\Interceptor))
#67 /var/www/html/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
#68 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'renderResult', Object(Magento\Framework\View\Result\Page\Interceptor), Array, 'result-builtin-...')
#69 /var/www/html/vendor/magento/module-page-cache/Model/Controller/Result/BuiltinPlugin.php(67): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))
#70 [internal function]: Magento\PageCache\Model\Controller\Result\BuiltinPlugin->aroundRenderResult(Object(Magento\Framework\View\Result\Page\Interceptor), Object(Closure), Object(Magento\Framework\App\Response\Http\Interceptor))
#71 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(142): call_user_func_array(Array, Array)
#72 /var/www/html/var/generation/Magento/Framework/View/Result/Page/Interceptor.php(130): Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', Array, Array)
#73 /var/www/html/vendor/magento/framework/App/Http.php(119): Magento\Framework\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#74 /var/www/html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#75 /var/www/html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#76 {main}

Why can't Magento see the Class? Did I miss something?

1

1 Answer 1

2

Try emptying your var/generation/ folder then re-flush cache.

EDIT:

The extra underscore in SampleUnimodul_Platba should be removed so the class name is SampleUnimodulPlatba. Rename the php to match.

7
  • Cache already flused, but since I switched to developer mode, the generation folder is not here, as the files are propably generated only for one use. Commented Oct 3, 2017 at 15:36
  • Your error dump makes many references to var/generation. Empty that out anyway just in case. Commented Oct 3, 2017 at 15:38
  • Your module class is "SampleUnimodul_Platba". Try dropping the underscore and renaming the file. Commented Oct 3, 2017 at 15:41
  • Just realised in previous comment, I was in /var instead of magento/var. Okay, I deleted the folder and flushed cache, but still no changes. Commented Oct 3, 2017 at 15:42
  • Removing the underscore actually did the trick. Please edit your answer so I can mark it as solution. Commented Oct 3, 2017 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.