Magento2: Klarna prevents payment methods to load in admin

Created on 7 May 2020  路  10Comments  路  Source: magento/magento2

Preconditions (*)

  1. Magento 2.3.5-p1

Steps to reproduce (*)

  1. Create an order in the backend.

Expected result (*)

  1. Payment Methods is loading.

Actual result (*)

  1. Payment methods block is empty.

In the frontend its working, but in the admin it isn't.

Schermafbeelding 2020-05-07 om 11 06 27

Update 1:

Seems to be an issue with the integrated Klarna module. When disabling Klarna everything starts to work again.

Update 2:

[2020-05-07 09:04:09] main.ERROR: Missing required attribute(s) on create: "purchase_currency". {"exception":"[object] (Klarna\Core\Model\Api\Exception(code: 0): Missing required attribute(s) on create: \"purchase_currency\". at /var/www/vhosts/domain.com/httpdocs/vendor/klarna/module-kp/Model/Api/Request/Builder.php:288)"} []

Update 3:

1 exception(s):
Exception #0 (Magento\Framework\Exception\NoSuchEntityException): No such entity with quote_id = 204357

Exception #0 (Magento\Framework\Exception\NoSuchEntityException): No such entity with quote_id = 204357
<pre>#1 Klarna\Kp\Model\QuoteRepository->getActiveByQuote(&Magento\Quote\Model\Quote\Interceptor#0000000032db4a7400000000235772da#) called at [vendor/klarna/module-kp/Model/SessionInitiator.php:113]
#2 Klarna\Kp\Model\SessionInitiator->checkMethodAvailable(&Magento\Quote\Model\Quote\Interceptor#0000000032db4a7400000000235772da#, 'klarna_kp') called at [vendor/klarna/module-kp/Model/SessionInitiator.php:69]
#3 Klarna\Kp\Model\SessionInitiator->checkAvailable(&Magento\Quote\Model\Quote\Interceptor#0000000032db4a7400000000235772da#, 'klarna_kp') called at [vendor/klarna/module-kp/Model/Payment/Kp.php:498]
#4 Klarna\Kp\Model\Payment\Kp->isAvailable(&Magento\Quote\Model\Quote\Interceptor#0000000032db4a7400000000235772da#) called at [vendor/magento/module-payment/Block/Form/Container.php:156]
#5 Magento\Payment\Block\Form\Container->getMethods() called at [generated/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form/Interceptor.php:89]
#6 Magento\Sales\Block\Adminhtml\Order\Create\Billing\Method\Form\Interceptor->getMethods() called at [vendor/magento/module-payment/Block/Form/Container.php:77]
#7 Magento\Payment\Block\Form\Container->_prepareLayout() called at [vendor/magento/framework/View/Element/AbstractBlock.php:286]
#8 Magento\Framework\View\Element\AbstractBlock->setLayout(&Magento\Framework\View\Layout\Interceptor#0000000032db5ede00000000235772da#) called at [generated/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form/Interceptor.php:271]
#9 Magento\Sales\Block\Adminhtml\Order\Create\Billing\Method\Form\Interceptor->setLayout(&Magento\Framework\View\Layout\Interceptor#0000000032db5ede00000000235772da#) called at [vendor/magento/framework/View/Layout/Generator/Block.php:149]
#10 Magento\Framework\View\Layout\Generator\Block->process(&Magento\Framework\View\Layout\Reader\Context#0000000032db4ba700000000235772da#, &Magento\Framework\View\Layout\Generator\Context#0000000032db4bf400000000235772da#) called at [vendor/magento/framework/View/Layout/GeneratorPool.php:81]
#11 Magento\Framework\View\Layout\GeneratorPool->process(&Magento\Framework\View\Layout\Reader\Context#0000000032db4ba700000000235772da#, &Magento\Framework\View\Layout\Generator\Context#0000000032db4bf400000000235772da#) called at [vendor/magento/framework/View/Layout.php:352]
#12 Magento\Framework\View\Layout->generateElements() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:89]
#13 Magento\Framework\View\Layout\Interceptor->generateElements() called at [vendor/magento/framework/View/Layout/Builder.php:129]
#14 Magento\Framework\View\Layout\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Page/Builder.php:55]
#15 Magento\Framework\View\Page\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Layout/Builder.php:65]
#16 Magento\Framework\View\Layout\Builder->build() called at [vendor/magento/framework/View/Layout.php:259]
#17 Magento\Framework\View\Layout->build() called at [vendor/magento/framework/View/Layout.php:884]
#18 Magento\Framework\View\Layout->getBlock('menu') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:414]
#19 Magento\Framework\View\Layout\Interceptor->getBlock('menu') called at [vendor/magento/module-backend/Model/View/Result/Page.php:26]
#20 Magento\Backend\Model\View\Result\Page->setActiveMenu('Magento_Sales::s...') called at [generated/code/Magento/Backend/Model/View/Result/Page/Interceptor.php:24]
#21 Magento\Backend\Model\View\Result\Page\Interceptor->setActiveMenu('Magento_Sales::s...') called at [vendor/magento/module-sales/Controller/Adminhtml/Order/Create/Index.php:26]
#22 Magento\Sales\Controller\Adminhtml\Order\Create\Index->execute() called at [generated/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index/Interceptor.php:24]
#23 Magento\Sales\Controller\Adminhtml\Order\Create\Index\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:108]
#24 Magento\Framework\App\Action\Action->dispatch(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#) called at [vendor/magento/module-backend/App/AbstractAction.php:231]
#25 Magento\Backend\App\AbstractAction->dispatch(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#26 Magento\Sales\Controller\Adminhtml\Order\Create\Index\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#27 Magento\Sales\Controller\Adminhtml\Order\Create\Index\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#) called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143]
#28 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(&Magento\Sales\Controller\Adminhtml\Order\Create\Index\Interceptor#0000000032db5e1800000000235772da#, &Closure#0000000032db5e0300000000235772da#, &Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#29 Magento\Sales\Controller\Adminhtml\Order\Create\Index\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#30 Magento\Sales\Controller\Adminhtml\Order\Create\Index\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#), NULL) called at [generated/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index/Interceptor.php:39]
#31 Magento\Sales\Controller\Adminhtml\Order\Create\Index\Interceptor->dispatch(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#) called at [vendor/magento/framework/App/FrontController.php:162]
#32 Magento\Framework\App\FrontController->processRequest(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#, &Magento\Sales\Controller\Adminhtml\Order\Create\Index\Interceptor#0000000032db5e1800000000235772da#) called at [vendor/magento/framework/App/FrontController.php:98]
#33 Magento\Framework\App\FrontController->dispatch(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#34 Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#35 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#36 Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#), array(array('default_store_se...', 'page_cache_from_...', 'storeCookieValid...', 'install', 'configHash', 'mstCoreDispatch'))) called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#37 Magento\Framework\App\FrontController\Interceptor->dispatch(&Magento\Framework\App\Request\Http#0000000032db5a5000000000235772da#) called at [vendor/magento/framework/App/Http.php:116]
#38 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#39 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http#0000000032db5a4600000000235772da#) called at [pub/index.php:40]
</pre>
Format is valid Reported on 2.3.5-p1

Most helpful comment

Hi @jorgb90 @dni @fahu @deepaksnair,

I got the fix by Klarna and it works for us.

This is the message by Klarna:

"I am sending you in the attachment with the logs our technicians provided to us.

This issue will also be fixed in a later release, but for now you can make suggested changes.
Advise is to try it on a test environment first.
Highlighted words in the document are:
class
implements
private
this
try
this
catch
return false
return"

This is the code:

diff --git a/module-kp/Model/SessionInitiator.php b/module-kp/Model/SessionInitiator.php
index 190cc64..be5dc4f 100644
--- a/module-kp/Model/SessionInitiator.php
+++ b/module-kp/Model/SessionInitiator.php
@@ -110,7 +110,11 @@ class SessionInitiator implements SessionInitiatorInterface
      */
     private function checkMethodAvailable(CartInterface $quote, string $code)
     {
-        $kQuote = $this->quoteRepository->getActiveByQuote($quote);
+        try {
+            $kQuote = $this->quoteRepository->getActiveByQuote($quote);
+        } catch (NoSuchEntityException $e) {
+            return false;
+        }
         return (in_array($code, $kQuote->getPaymentMethods()));
     }
 }

All 10 comments

Hi @jorgb90. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@jorgb90 do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hi @ajijshekh123. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Updated the start post with an exception log.

Hello @jorgb90. We had the exact same issue. Same Magento version. Same everything.

We had updated the Klarna version via the Composer to Klarna 9.0.1, no change. Same behavior 1:1 as described by you. Sent a ticket to Klarna.

Hello @jorgb90 , having same issue , able to create order from frontend but from admin same error log comes. I have checked that Klarna_Kp version 6.4.1 is working fine but issue is in version 6.5.0, not sure where it happened in between.
Screenshot from 2020-06-08 20-42-41

same issue here, any news?

Issue Update from Magento: This issue will be resolved in Magento 2.3.5-p2 and 2.4.0, which will be released in early August. You can also reach out to [email protected] for support with this issue in the meantime.

Hello @jorgb90 @dni @BenItt
fyi: @mharron-adobe

Based on https://github.com/magento/magento2/issues/28132#issuecomment-644801670 the issue has been fixed. The fix will be available in 2.3.5-p2 and 2.4.0 releases.

To avoid double work, I close this issue.

With which commit / issue has this been fixed?

Hi @jorgb90 @dni @fahu @deepaksnair,

I got the fix by Klarna and it works for us.

This is the message by Klarna:

"I am sending you in the attachment with the logs our technicians provided to us.

This issue will also be fixed in a later release, but for now you can make suggested changes.
Advise is to try it on a test environment first.
Highlighted words in the document are:
class
implements
private
this
try
this
catch
return false
return"

This is the code:

diff --git a/module-kp/Model/SessionInitiator.php b/module-kp/Model/SessionInitiator.php
index 190cc64..be5dc4f 100644
--- a/module-kp/Model/SessionInitiator.php
+++ b/module-kp/Model/SessionInitiator.php
@@ -110,7 +110,11 @@ class SessionInitiator implements SessionInitiatorInterface
      */
     private function checkMethodAvailable(CartInterface $quote, string $code)
     {
-        $kQuote = $this->quoteRepository->getActiveByQuote($quote);
+        try {
+            $kQuote = $this->quoteRepository->getActiveByQuote($quote);
+        } catch (NoSuchEntityException $e) {
+            return false;
+        }
         return (in_array($code, $kQuote->getPaymentMethods()));
     }
 }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jzalenski picture jzalenski  路  3Comments

PascalBrouwers picture PascalBrouwers  路  3Comments

kirashet666 picture kirashet666  路  3Comments

andreaskoch picture andreaskoch  路  3Comments

MauroNigrele picture MauroNigrele  路  3Comments