*/ class Mage_Paypal_StandardController extends Mage_Core_Controller_Front_Action { /** * Order instance */ protected $_order; /** * Get order * * @return Mage_Sales_Model_Order */ public function getOrder() { if ($this->_order == null) { } return $this->_order; } /** * Send expire header to ajax response * */ protected function _expireAjax() { if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems()) { $this->getResponse()->setHeader('HTTP/1.1','403 Session Expired'); exit; } } /** * Get singleton with paypal strandard order transaction information * * @return Mage_Paypal_Model_Standard */ public function getStandard() { return Mage::getSingleton('paypal/standard'); } /** * When a customer chooses Paypal on Checkout/Payment page * */ public function redirectAction() { $session = Mage::getSingleton('checkout/session'); $session->setPaypalStandardQuoteId($session->getQuoteId()); $this->getResponse()->setBody($this->getLayout()->createBlock('paypal/standard_redirect')->toHtml()); $session->unsQuoteId(); $session->unsRedirectUrl(); } /** * When a customer cancel payment from paypal. */ public function cancelAction() { $session = Mage::getSingleton('checkout/session'); $session->setQuoteId($session->getPaypalStandardQuoteId(true)); if ($session->getLastRealOrderId()) { $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId()); if ($order->getId()) { $order->cancel()->save(); } Mage::helper('paypal/checkout')->restoreQuote(); } $this->_redirect('checkout/cart'); } /** * when paypal returns * The order information at this point is in POST * variables. However, you don't want to "process" the order until you * get validation from the IPN. */ public function successAction() { $session = Mage::getSingleton('checkout/session'); $session->setQuoteId($session->getPaypalStandardQuoteId(true)); Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save(); $this->_redirect('checkout/onepage/success', array('_secure'=>true)); } }