Thursday, October 13, 2016

Remove Review Page in Magento PayPal Express Checkout


Magento is most used PHP based e-commerce platform which is used for create shopping website and for that payment system is most important part of any e-commerce system. Magento also provide some most used payment methods like PayPal, Authorized, COD, Check payment also also many extensions available for easy implement new payment method in website.
When you use the PayPal payment method than mostly used 'PayPal Express Checkout' for fast, secure and easy checkout. but after complete PayPal checkout it's redirecting to Magento payment review page.
If you use 'PayPal standard checkout' them after complete payment from PayPal, it's redirecting to a checkout success page and if your Magento version is greater than 1.9 than you can skin review page from the admin panel by set `Skip Order Review Step` YES.
If your Magento version is less than 1.9 than you can skin that page after changes on below files.
First open `app\code\core\Mage\Paypal\Model\Config.php` file and changes below in getExpressCheckoutStartUrl function from

public function getExpressCheckoutStartUrl($token)
{
    return $this->getPaypalUrl(array(
        'cmd'   => '_express-checkout',
        'token' => $token,
    ));
}
to
public function getExpressCheckoutStartUrl($token)
{
    return $this->getPaypalUrl(array(
        'cmd'   => '_express-checkout',
        'useraction' => 'commit',
        'token' => $token,
    ));
}
 
Than create observe event in global scope as below in any custom extension's `confix.xml` file or create own.
 
<controller_action_predispatch_paypal_express_review>
  <observers>
    <newsinfo_removepaypalexpressreview>
      <type>singleton</type>
      <class>Newsinfo_Modulename_Model_Observer</class>
      <method>controllerPaypalExpressReview</method>
    </newsinfo_removepaypalexpressreview>
  </observers>
</controller_action_predispatch_paypal_express_review>
<controller_action_predispatch_paypal_express_placeOrder>
  <observers>
    <newsinfo_removepaypalexpressreview>
      <type>singleton</type>
      <class>Newsinfo_Modulename_Model_Observer</class>
      <method>controllerPaypalExpressPlaceOrder</method>
    </newsinfo_removepaypalexpressreview>
  </observers>
</controller_action_predispatch_paypal_express_placeOrder>

Than create 'Observer.php' file in Model folder and add below code(You put below functions in exiting Observe.php file)

class Newsinfo_Modulename_Model_Observer //Set Class According to Your Extension
{
 public function controllerPaypalExpressReview(Varien_Event_Observer $observer)
 {
  Mage::app()->getResponse()->setRedirect(Mage::getUrl('*/*/placeOrder'));
 }
 public function controllerPaypalExpressPlaceOrder(Varien_Event_Observer $observer)
 {
  $agreements = Mage::helper('checkout')->getRequiredAgreementIds();
  $postagreements = array_fill_keys($agreements, 1);
  Mage::app()->getRequest()->setPost('agreement', $postagreements);
 }
}

No comments :

Post a Comment