Magento – Paypal payment canceled and empty shopping cart

One Problem, which was from the beginning in Magento, was the annoying empty cart canceled a payment at an external payment processor such as. PayPal.

It runs like this:

The customer fills the shopping cart and proceed to checkout. There he selects PayPal as payment method and then completes the order. He will now be redirected to PayPal, where they can complete the payment.

But there are unfortunately a problem with PayPal. The most common problem is an incorrect login data or forgotten data. However, the customer cancels the payment from PayPal and click on “Cancel and Return to [Shop]”.

Now he unfortunately comes to an empty shopping cart and must make the order again.

There are two problems:

1. The customer has to make the effort to complete order new (and unfortunately it have little customer like)

2. This creates a canceled order in the backend.

Problem 1 however, the normal OnePageCheckout rel. be easily solved. There are several approaches, I decided for this one:

Copy the OnepageController.php file from the directory app / code / core / Mage / Checkout / controllers / in the directory app / code / local / Mage / Checkout / controllers /

Then look for the line

        $this->getOnepage()->getQuote()->save();
        /**
         * when there is redirect to third party, we don't want to save order yet.
         * we will save the order in return action.
         */
        if (isset($redirectUrl)) {
            $result['redirect'] = $redirectUrl;
        }

        $this->getResponse()->setBody(Magus::helper('core')->jsonEncode($result));
    }

and replace this by

//        $this->getOnepage()->getQuote()->save();
/**
 * when there is redirect to third party, we don't want to save order yet.
 * we will save the order in return action.
 */
        if (isset($redirectUrl)) {
          $result['redirect'] = $redirectUrl;
          $this->getOnepage()->getQuote()->setIsActive(1) ;
          }
          $this->getOnepage()->getQuote()->save();
          $this->getResponse()->setBody(Magus::helper('core')->jsonEncode($result));
        }

Now it is not sent in demolition of the payment by PayPal in the checkout to select another payment method but at least in the still-filled cart.

Unfortunately I have no solution for problem 2 found, Thus, at each chipped payment process a canceled order in the backend is stored.

Used in Magento Version 1.7. Ask, Comments, Proposals? Us directly or as a comment.

Published by Covos

Since 2009 I have been working intensively with Magento. I started with the creation and operation of B2C stores. This was extended through my work in the logistics sector. This resulted first specialized B2E systems. Today I work day-a day with exciting B2C, B2B- and B2E projects and reports in this blog about challenges and give insider tips.

3 comments on “Magento – Paypal payment canceled and empty shopping cart”

  1. “Copy the OnepageController.php file from the directory app / code / core / Mage / Checkout / controllers / in the directory app / code / local / Mage / Checkout / controllers /”

    After that always, ALWAYS, when ever there is a new Magento patch released, read the patch code, check if it changes OnepageController.php and if so manually implement changes to your local version of the file.

    Better solution is to use observer.

Leave a Reply

Your email address will not be published. Required fields are marked *