[Stripe] «Cannot override final method Df\Payment\Block\Info::_prepareSpecificInformation() in mage2pro/stripe/Block/Info.php on line 40»

Hi, I’m trying to upgrade to 2.1.3 but I get an error:

[XX@XX-09 public_html]$ php bin/magento setup:di:compile
Compilation was started.
Repositories code generation... 1/7 [====>-----------------------]  14% 1 sec 83.5 MiBPHP Fatal error:  Cannot override final method Df\Payment\Block\Info::_prepareSpecificInformation() in /chroot/home/user/domain.com/html/vendor/mage2pro/stripe/Block/Info.php on line 40
PHP Fatal error:  Class 'Dfe\Stripe\Block\Zend_Date_DateObject' not found in /chroot/home/user/domain.com/html/vendor/magento/zendframework1/library/Zend/Date.php on line 37

Any idea how to go about fixing this?

The error is a result of some form of the upgrade instruction violation, because the \Dfe\Stripe\Block\Info class in the latest 1.6.13 release of the Stripe extension does not override the \Df\Payment\Block\Info::_prepareSpecificInformation() method, and even does not contain the line 40 because it only contains 20 lines.

Hi Dmitry

I followed the instructions in the update instructions, still same result. Only thing I can’t do is composer self-update because our production server is a shared server.

[hecklerd@sipsjc3-09 public_html]$ rm -rf var/di var/generation && bin/magento setup:di:compile
Compilation was started.
Repositories code generation... 1/7 [====>-----------------------]  14% 1 sec 83.8 MiBPHP Fatal error:  Cannot override final method Df\Payment\Block\Info::_prepareSpecificInformation() in /chroot/home/hecklerd/hecklerdesign.com/html/vendor/mage2pro/stripe/Block/Info.php on line 40
PHP Fatal error:  Class 'Dfe\Stripe\Block\Zend_Date_DateObject' not found in /chroot/home/hecklerd/hecklerdesign.com/html/vendor/magento/zendframework1/library/Zend/Date.php on line 37

And, the info file does have 40 lines on my end exactly.

vendor/mage2pro/stripe/Block/Info.php

<?php
// 2016-08-20
namespace Dfe\Stripe\Block;
use Dfe\Stripe\Method;
use Dfe\Stripe\Response;
use Magento\Framework\DataObject;
use Magento\Sales\Model\Order\Payment\Transaction as T;
/** @method Method m() */
class Info extends \Df\Payment\Block\Info {
        /**
         * 2016-08-20
         * @override
         * @see \Magento\Payment\Block\ConfigurableInfo::_prepareSpecificInformation()
         * @used-by \Magento\Payment\Block\Info::getSpecificInformation()
         * @param DataObject|null $transport
         * @return DataObject
         */
        protected function _prepareSpecificInformation($transport = null) {
                /** @var DataObject $result */
                $result = parent::_prepareSpecificInformation($transport);
                if ($this->isBackend()) {
                        $result['Stripe ID'] = $this->m()->formatTransactionId($this->res()->id());
                }
                $result[$this->isBackend() ? 'Card Number' : 'Number'] = $this->res()->card();
                if ($this->isBackend()) {
                        $result->addData([
                                'Card Expires' => $this->res()->expires()
                                ,'Card Country' => $this->res()->country()
                        ]);
                }
                $this->markTestMode($result);
                return $result;
        }

        /**
         * 2016-08-20
         * @return Response
         */
        private function res() {return dfc($this, function() {return Response::i($this->transF());});}
}

If I can’t figure out a solution, do you know how I would go about uninstalling the extension and dependancies from composer? We have another payment processor working now, so don’t necessarily need stripe any way.

I think you have ignored not only the composer self-update command, but the composer update --prefer-source command too.
It is the cause of your error.

In any case when your are unable to follow a step of an official instruction, it is much wiser to report it, when to ignore the step and break your site.

Hi Dmitry

I didn’t ignore the step, and here’s a video showing that I did do composer update --prefer-source, it was a new try so everything had updated already. https://youtu.be/IlwFGg4F05o

Do you have uninstall instructions, the client switched to using braintree for payments any way and we don’t really need it.

I do also need a couple other extensions (price format & facebook login), I will see if I can get those now or Monday.

Give me SSH access, and I will check it myself.

Dmitry,

I tried upgrading our staging server to 2.1.3 while following your instructions carefully along with magneto’s upgrade instructions, I didn’t run into the compilation issue again.

When I ran into the issue on production server, I ran composer update --prefer-source after already upgrading magento, but if I include --prefer-source while upgrading magento itself the first time, that seems to not cause the compilation issue.

You were right.

Thanks for your help and patience. Much appreciated.