3

Paypal Express checkout is not working for guest checkout. guest checkout is enabled. i have checked error logs and found below issue.

Let me know if any one have a solution for this.

main.CRITICAL: Exception message: We can't initialize Express Checkout.
Trace: #0 /vendor/magento/module-paypal/Controller/Express/AbstractExpress/Review.php(21): Magento\Paypal\Controller\Express\AbstractExpress->_initCheckout()
#1 /generated/code/Magento/Paypal/Controller/Express/Review/Interceptor.php(24): Magento\Paypal\Controller\Express\AbstractExpress\Review->execute()
#2 /vendor/magento/framework/App/Action/Action.php(107): Magento\Paypal\Controller\Express\Review\Interceptor->execute()
#3 /vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#4 /vendor/magento/framework/Interception/Interceptor.php(138): Magento\Paypal\Controller\Express\Review\Interceptor->___callParent('dispatch', Array)
#5 /vendor/magento/framework/Interception/Interceptor.php(153): Magento\Paypal\Controller\Express\Review\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#6 /generated/code/Magento/Paypal/Controller/Express/Review/Interceptor.php(104): Magento\Paypal\Controller\Express\Review\Interceptor->___callPlugins('dispatch', Array, Array)
#7 /vendor/magento/framework/App/FrontController.php(55): Magento\Paypal\Controller\Express\Review\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#8 /vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#9 /vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#10 vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#11 /vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#12 /vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#13 /vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#14 /vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#15 /generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, NULL)
#16 /vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#17 /generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()
#18 /vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch()
#19 /index.php(46): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#20 {main} [] []
1

This message only happens in 1 circumstance, /vendor/magento/module-paypal/Controller/Express/AbstractExpress:136 "Quote does not have items" or "Quote has error". The initial returned code is 403 (unauthorized) but gets overridden to 500 when the exception is thrown.

This can be caused by the cart not having the items added to it, losing the items, the quote failing to save correctly, or the quote does not existing because someone url-hacked the paypal module and initialized it without a cart (possibly not intentionally).

Unfortunately, without that visitor's data (no-quote, quote data, browsing path in HTTP logs) it is impossible to determine which of these scenarios caused the error. However, errors reading the quote data should be logged in other locations as they are errors in themselves.

For an example, I have the same error, and in my HTTP logs I have a visitor hitting refresh on a completed order, which tries to load and render a stale quote that no longer exists. In the following HTTP log block, an identified visitor (1) returns from Paypal with token, (2) completes the order, (3) receives the confirmation from Paypal, (4) reloads the review page with the expired token

[10/Dec/2018:16:15:02] "GET /paypal/express/review/ HTTP/1.1" 200 6449 "https:// ... token=ABC123 " "ip=xyz" (initial review)
[10/Dec/2018:16:15:14] "POST /paypal/express/placeOrder/ HTTP/1.1" 302 5 "https:... " "ip=xyz" (order completed)
[10/Dec/2018:16:15:19] "POST /paypal/ipn/ HTTP/1.1" 200 5 "-" "PayPal IPN ( https://www.paypal.com/ipn )" ("paypal-logs:token=ABC123") (IPN response for success, order and quote closed)
[10/Dec/2018:16:16:08] "GET /paypal/express/review/ HTTP/1.1" 302 5 "https:... token=ABC123 " "ip=xyz" (page refresh on past order review)

The paypal log time stamps of both the completed transaction and error in reloading, match the HTTP logs above.

[2018-12-10 16:16:08] main.CRITICAL: Exception message: We can't initialize Express Checkout.
Trace: #0 /usr/share/nginx/html/magento/vendor/magento/module-paypal/Controller/Express/AbstractExpress/Review.php(21): Magento\Paypal\Controller\Express\AbstractExpress->_initCheckout()
...

So this user caused it by clicking back on their browser and hitting reload on the review page.

In a previous situation a visitor managed to get to the paypal checkout with 0 items in the cart for a $0 order and was sent back. This was diagnosed by the paypal-logs having a request for amount=0, and a time-stamped quote in the database with no items in the cart, which SHOULD never happen, but did.

So far, all my research into this problem results in the same conclusion: nothing to worry about, could be handled better.

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.