Recently, I upload my Magento 2 site to production server, and everything looks fine, except by Cart and Checkout. When I enter to these, the server throw me a HTTP ERROR 500, and the page keep blank.

In Php Error Log, is displayed this error:

PHP Fatal error:  Uncaught Error: Cannot instantiate interface Magento\Vault\Api\Data\PaymentTokenInterfaceFactory in vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:93
Stack trace:
#0 vendor/magento/framework/ObjectManager/Factory/Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Vault\\A...', Array)
#1 vendor/magento/framework/ObjectManager/Factory/Compiled.php(130): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Vault\\A...')
#2 vendor/magento/framework/ObjectManager/Factory/Compiled.php(67): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\\Vault\\A...')
#3 vendor/magento/framework/ObjectManager/ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Paypal\\...', Array)
in vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93

The other sections display well, only cart and checkout have this problem. Additional, this occurs only in Production. In my developer server, all is fine.

  • hmm got that same error in a fresh magento2.2.0 installation
    – roman204
    Sep 28 '17 at 14:33

At first, please, provide Magento version of your application.

Starting Magento >= 2.1.3 version the Magento\Vault\Api\Data\PaymentTokenInterfaceFactory is no more autogenerated factory (the autogenerated code is "private" and can be changed in any patch release).

Instead of using PaymentTokenInterfaceFactory you should specify concrete factory for payment token. Magento provides two factories out of the box:

  • \Magento\Vault\Model\AccountPaymentTokenFactory - for payment methods which work with payment profiles like PayPal, Authorize.net, CyberSource

  • \Magento\Vault\Model\CreditCardTokenFactory - for payment methods, which tokenize credit card details, like Braintree.

More details about both factories and their purposes you can find in Magento payments documentation.

Magento Vault does not provide default preference for PaymentTokenInterfaceFactory interface because only payment integration knows about the type of token.

UPD: Starting from 2.2.0 release the \Magento\Vault\Api\Data\PaymentTokenInterfaceFactory has been deprecated and \Magento\Vault\Api\Data\PaymentTokenFactoryInterface should be used instead. The documentation has been updated as well.

  • Well, I have the Magento 2.1.1 version, but... Yout comment throw me to the right path to notice my error. I will comment what I do, but I will consider your comment as answer, because in this case I think that it will be the "normal" solution to others. Thanks! Mar 3 '17 at 17:56


  • Make sure the PHP module intl is installed;
  • rm var/generation/*
  • rm var/di/*
  • rm var/cache/*

    bin/magento setup:upgrade

    bin/magento setup:di:compile

  • Hi, thanks for your answer. intl is installed, and I tried remove generation, di, cache, and after upgrade and compile, but the error persists. Mar 2 '17 at 23:27
  • Hi, You can check your di.xml file if you did not leave something broken in a comment or close the <preference> Mar 2 '17 at 23:38

I feel a little embarrassing right know. Thanks to joni jones comment about Magento 2.1.3 and PaymentTokenInterfaceFactory , I could see that, in fact, that was the source of my problem. But, the strange is that I have the 2.1.1 version when I develop the site in my developer server, instead of 2.1.3.

So, I put an investigate, and Apparently the hosting guys installed a newer version of Magento on the production server. I do not know if it was 2.1.3, but it was definitely not 2.1.1. So, when I upload my site to production, I had code of 2.1.1 and 2.1.3 scrambled, and that obviously caused conflicts.

I deleted everything, and re-upload all my 2.1.1 site again, and the site is now visible. What a silly mistake. In normal situations, if someone is presented with this error, I think the joni's solution would be correct.

Thanks for everything.


Try This to clear cache and generation files

sudo rm -rf var/cache/* var/di/* var/generation/*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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