3

When I use PayPal Plus(PayPal, credit cards) ,the checkout success page is not shown. Instead is redirected to checkout/cart/. enter image description here

The redirection happens in this file:

Magento\Checkout\Controller\Onepage\Success

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Checkout\Model\Session;

/**
 * Test if checkout session valid for success action
 *
 * @api
 */
class SuccessValidator
{
    /**
     * @var \Magento\Checkout\Model\Session
     */
    protected $checkoutSession;

    /**
     * @param \Magento\Checkout\Model\Session $checkoutSession
     * @codeCoverageIgnore
     */
    public function __construct(
        \Magento\Checkout\Model\Session $checkoutSession
    ) {
        $this->checkoutSession = $checkoutSession;
    }

    /**
     * @return bool
     */
    public function isValid()
    {

        if (!$this->checkoutSession->getLastSuccessQuoteId()) {
            return false;
        }

        if (!$this->checkoutSession->getLastQuoteId() || !$this->checkoutSession->getLastOrderId()) {
            return false;
        }
        return true;
    }
}

I found out that all three :

$this->checkoutSession->getLastSuccessQuoteId() $this->checkoutSession->getLastQuoteId() this->checkoutSession->getLastOrderId() return null. Obviously there is something to do with the session but this is the furthest I could go. The orders are completed and successful.Its just the order confirmation page that is not shown.

  • Did you check the log? Is there any error? – Khoa TruongDinh Nov 24 '18 at 6:45
  • @KhoaTruongDinh There is no error.. – Borche Glafche Nov 26 '18 at 9:08
  • confirm log is enable from admin? And the payment method also provide the options of debug. Enable that option and then check log folder. – Dhiren Vasoya Nov 26 '18 at 14:10
  • @DhirenVasoya there are no errors – Borche Glafche Nov 26 '18 at 14:23
  • You may go through these fixes for better understanding. stackoverflow.com/questions/5417419/… – Ajwad Syed Nov 27 '18 at 12:56
1

I found a solution.

The problem was that

$this->checkoutSession->getLastSuccessQuoteId()
$this->checkoutSession->getLastQuoteId()
this->checkoutSession->getLastOrderId()

Somehow were lost before paypal redirects to /checkout/onepage/success.

When the order is created, I pass the id of the order to the /checkout/onepage/success. Than I:

$this->checkoutSession->setLastSuccessQuoteId(order->getQouteId())
$this->checkoutSession->setLastQuoteId(order->getQouteId())
this->checkoutSession->setLastOrderId(order->getEntityId())

At this point, everything works fine.

  • 1
    Just a note about this as I just had the issue myself while working on a payment integration: if you play with orders, validating them, debugging order state & so on it might happen that you go through a state when Magento will clear the last successful quote ID and so on; however it might be just a transient state issue, and once you play out your full payment workflow from start to finish, it'll work out well. – Olivier Lance Dec 17 '18 at 2:12
1

Look very carefully to your var/log/system.log.

In my case, I was missing some important information there and the problem was Redis. The session was being locked by some other process and didn't allow Magento to update the cart/quote session there.

I just noticed that when added a breakpoint to \Magento\Checkout\Controller\Onepage\Success::execute and looking at my tail -f var/log/* terminal tab.

Update: I faced the problem again and Redis config was the problem. I just changed the break_after_frontend from 5 to 15 in app/etc/env.php as I described here. It worked for me.

1

Ok, so we had the same problem, after card payment on PG instead of landing on success page there was a redirect to empty cart (order was successful).

Reason was session was cleared as well. Main cause for that happen to be full_page cache being flushed.

Why that happened, since that page shouldn't be in fpc? Well, magento and its fantastic di system.

We made preference for Onepage\Success block, and while everything else worked, layout definition in checkout_onepage_success.xml had specified no caching for original block, and not ours.

Specifying no caching for our block in layout removed the issue.

Hopefully smne will not lose same amount of time and life as i did.

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.