Mage_Paypal_StandardController Class Reference

Inheritance diagram for Mage_Paypal_StandardController:

Mage_Core_Controller_Front_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 getOrder ()
 getStandard ()
 redirectAction ()
 cancelAction ()
 successAction ()
 ipnAction ()

Protected Member Functions

 _expireAjax ()

Protected Attributes

 $_order


Detailed Description

Definition at line 35 of file StandardController.php.


Member Function Documentation

_expireAjax (  )  [protected]

Definition at line 55 of file StandardController.php.

00056     {
00057         if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems()) {
00058             $this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
00059             exit;
00060         }
00061     }

cancelAction (  ) 

When a customer cancel payment from paypal.

Definition at line 88 of file StandardController.php.

00089     {
00090         $session = Mage::getSingleton('checkout/session');
00091         $session->setQuoteId($session->getPaypalStandardQuoteId(true));
00092 
00093         // cancel order
00094         if ($session->getLastRealOrderId()) {
00095             $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
00096             if ($order->getId()) {
00097                 $order->cancel()->save();
00098             }
00099         }
00100 
00101         /*we are calling getPaypalStandardQuoteId with true parameter, the session object will reset the session if parameter is true.
00102         so we don't need to manually unset the session*/
00103         //$session->unsPaypalStandardQuoteId();
00104 
00105         //need to save quote as active again if the user click on cacanl payment from paypal
00106         //Mage::getSingleton('checkout/session')->getQuote()->setIsActive(true)->save();
00107         //and then redirect to checkout one page
00108         $this->_redirect('checkout/cart');
00109     }

getOrder (  ) 

Get order

Returns:
Mage_Sales_Model_Order

Definition at line 48 of file StandardController.php.

00049     {
00050         if ($this->_order == null) {
00051         }
00052         return $this->_order;
00053     }

getStandard (  ) 

Get singleton with paypal strandard order transaction information

Returns:
Mage_Paypal_Model_Standard

Definition at line 68 of file StandardController.php.

00069     {
00070         return Mage::getSingleton('paypal/standard');
00071     }

ipnAction (  ) 

when paypal returns via ipn cannot have any output here validate IPN data if data is valid need to update the database that the user has

Definition at line 137 of file StandardController.php.

00138     {
00139         if (!$this->getRequest()->isPost()) {
00140             $this->_redirect('');
00141             return;
00142         }
00143 
00144         if($this->getStandard()->getDebug()){
00145             $debug = Mage::getModel('paypal/api_debug')
00146                 ->setApiEndpoint($this->getStandard()->getPaypalUrl())
00147                 ->setRequestBody(print_r($this->getRequest()->getPost(),1))
00148                 ->save();
00149         }
00150 
00151         $this->getStandard()->setIpnFormData($this->getRequest()->getPost());
00152         $this->getStandard()->ipnPostSubmit();
00153     }

redirectAction (  ) 

When a customer chooses Paypal on Checkout/Payment page

Definition at line 77 of file StandardController.php.

00078     {
00079         $session = Mage::getSingleton('checkout/session');
00080         $session->setPaypalStandardQuoteId($session->getQuoteId());
00081         $this->getResponse()->setBody($this->getLayout()->createBlock('paypal/standard_redirect')->toHtml());
00082         $session->unsQuoteId();
00083     }

successAction (  ) 

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.

set the quote as inactive after back from paypal

Definition at line 117 of file StandardController.php.

00118     {
00119         $session = Mage::getSingleton('checkout/session');
00120         $session->setQuoteId($session->getPaypalStandardQuoteId(true));
00121         /**
00122          * set the quote as inactive after back from paypal
00123          */
00124         Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
00125 
00126         //Mage::getSingleton('checkout/session')->unsQuoteId();
00127 
00128         $this->_redirect('checkout/onepage/success', array('_secure'=>true));
00129     }


Member Data Documentation

$_order [protected]

Order instance

Definition at line 41 of file StandardController.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:33 2009 for Magento by  doxygen 1.5.8