Magento – PayPal order review page redirect

checkout

I'm trying to setup PayPal express checkout to bypass redirect to Magento review page.
I have followed directions posted on stackoverflow link below but I am still redirected to http://mysite.com/index.php/paypal/express/review/ review page the button has changed to pay now but I am redirected before I can complete checkout.

https://stackoverflow.com/questions/7607180/magento-easy-way-to-remove-paypal-express-review-step/14313748#14313748

Anybody point me in the right direction?

Changed
\app\code\core\Mage\Paypal\Controller\Express\Abstract.php

returnAction() for:
$this->_redirect('//review');

changed:
$this->_redirect('//review');

to:
$this->_redirect('//placeOrder');
Go to: \app\code\core\Mage\Paypal\Controller\Express\Abstract.php

and search in returnAction() for:
$this->_redirect('//review');

There you have to change:
$this->_redirect('//review');

Best Answer

Actually all the solutions mentioned here required to edit the Magento core. This is known as bad practise and does not keep your shop updateable.

What you need to do for a clean solution:

  1. Create a module (in my exampe: Avoe_Paypal) to include the changes
  2. Rewrite Paypal Config
  3. Redirect on paypal express review step which is http://yourdomain.com/paypal/express/review/

1) Create your module

Avoe/Paypal/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Avoe_Paypal>
            <version>0.1.0</version>
        </Avoe_Paypal>
    </modules>

    <global>
        <models>
            <Avoe_Paypal>
                <class>Avoe_Paypal_Model</class>
            </Avoe_Paypal>
            <paypal>
                <rewrite>
                    <config>Avoe_Paypal_Model_Config</config>
                </rewrite>
            </paypal>
        </models>
        <events>
            <controller_action_predispatch_paypal_express_review>
                <observers>
                    <avoe_paypal_predispatch>
                        <type>singleton</type>
                        <class>Avoe_Paypal_Model_Observer</class>
                        <method>paypalExpressReturnPredispatch</method>
                    </avoe_paypal_predispatch>
                </observers>
            </controller_action_predispatch_paypal_express_review>
        </events>
    </global>
</config>

app/etc/Avoe_Paypal.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Avoe_Paypal>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Paypal />
            </depends>
        </Avoe_Paypal>
    </modules>
</config>

2) Rewrite config, add useraction 'commit':

<?php
class Avoe_Paypal_Model_Config extends Mage_Paypal_Model_Config {

    /**
     * Get url for dispatching customer to express checkout start
     * Added useraction 'commit' to remove PayPal Express Checkout review page
     *
     * @param string $token
     * @return string
     */
    public function getExpressCheckoutStartUrl($token)
    {
        return $this->getPaypalUrl(array(
            'cmd'   => '_express-checkout',
            'useraction' => 'commit',
            'token' => $token,
        ));
    }
}

3) Create observer to redirect:

<?php

class Avoe_Paypal_Model_Observer {

    function paypalExpressReturnPredispatch($observer) {
        Mage::app()->getResponse()->setRedirect(Mage::getUrl('*/*/placeOrder'));
    }
}

There is also a small Magento extension which was just released yesterday, to remove the review step:

https://github.com/tim-bezhashvyly/Sandfox_RemovePaypalExpressReviewStep

Related Topic