Mage_GoogleCheckout_RedirectController Class Reference

Inheritance diagram for Mage_GoogleCheckout_RedirectController:

Mage_Core_Controller_Front_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 checkoutAction ()
 redirectAction ()
 cartAction ()
 continueAction ()

Protected Member Functions

 _getApi ()


Detailed Description

Definition at line 32 of file RedirectController.php.


Member Function Documentation

_getApi (  )  [protected]

Send request to Google Checkout and return Responce Api

Returns:
object Mage_GoogleCheckout_Model_Api_Xml_Checkout

Definition at line 40 of file RedirectController.php.

00041     {
00042         $session = Mage::getSingleton('checkout/session');
00043 
00044         $api = Mage::getModel('googlecheckout/api');
00045 
00046         if (!$session->getQuote()->hasItems()) {
00047             $this->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
00048             $api->setError(true);
00049         }
00050 
00051         $storeQuote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore()->getId());
00052         $storeQuote->merge($session->getQuote());
00053         $storeQuote
00054             ->setItemsCount($session->getQuote()->getItemsCount())
00055             ->setItemsQty($session->getQuote()->getItemsQty())
00056             ->setChangedFlag(false);
00057         $storeQuote->save();
00058 
00059         $baseCurrency = $session->getQuote()->getBaseCurrencyCode();
00060         $currency = Mage::app()->getStore($session->getQuote()->getStoreId())->getBaseCurrency();
00061         $session->getQuote()
00062             ->setForcedCurrency($currency)
00063             ->collectTotals()
00064             ->save();
00065 
00066         if (!$api->getError()) {
00067             $api = $api->setAnalyticsData($this->getRequest()->getPost('analyticsdata'))
00068                 ->checkout($session->getQuote());
00069 
00070             $response = $api->getResponse();
00071             if ($api->getError()) {
00072                 Mage::getSingleton('checkout/session')->addError($api->getError());
00073             } else {
00074                 $session->replaceQuote($storeQuote);
00075                 Mage::getModel('checkout/cart')->init()->save();
00076                 if (Mage::getStoreConfigFlag('google/checkout/hide_cart_contents')) {
00077                     $session->setGoogleCheckoutQuoteId($session->getQuoteId());
00078                     $session->setQuoteId(null);
00079                 }
00080             }
00081         }
00082         return $api;
00083     }

cartAction (  ) 

Definition at line 116 of file RedirectController.php.

00117     {
00118         if (Mage::getStoreConfigFlag('google/checkout/hide_cart_contents')) {
00119             $session = Mage::getSingleton('checkout/session');
00120             if ($session->getQuoteId()) {
00121                 $session->getQuote()->delete();
00122             }
00123             $session->setQuoteId($session->getGoogleCheckoutQuoteId());
00124             $session->setGoogleCheckoutQuoteId(null);
00125         }
00126 
00127         $this->_redirect('checkout/cart');
00128     }

checkoutAction (  ) 

Definition at line 85 of file RedirectController.php.

00086     {
00087         $api = $this->_getApi();
00088 
00089         if ($api->getError()) {
00090             $url = Mage::getUrl('checkout/cart');
00091         } else {
00092             $url = $api->getRedirectUrl();
00093         }
00094         $this->getResponse()->setRedirect($url);
00095     }

continueAction (  ) 

Definition at line 130 of file RedirectController.php.

00131     {
00132         $session = Mage::getSingleton('checkout/session');
00133 
00134         if ($quoteId = $session->getGoogleCheckoutQuoteId()) {
00135             $quote = Mage::getModel('sales/quote')->load($quoteId)
00136                 ->setIsActive(false)->save();
00137             $session->unsQuoteId();
00138         }
00139 
00140 //        if (Mage::getStoreConfigFlag('google/checkout/hide_cart_contents')) {
00141 //            $session->unsGoogleCheckoutQuoteId();
00142 //        }
00143 
00144         $url = Mage::getStoreConfig('google/checkout/continue_shopping_url');
00145         if (empty($url)) {
00146             $this->_redirect('');
00147         } elseif (substr($url, 0, 4)==='http') {
00148             $this->getResponse()->setRedirect($url);
00149         } else {
00150             $this->_redirect($url);
00151         }
00152     }

redirectAction (  ) 

When a customer chooses Google Checkout on Checkout/Payment page

Definition at line 101 of file RedirectController.php.

00102     {
00103         $api = $this->_getApi();
00104 
00105         if ($api->getError()) {
00106             $this->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
00107             return;
00108         } else {
00109             $url = $api->getRedirectUrl();
00110             $this->loadLayout();
00111             $this->getLayout()->getBlock('googlecheckout_redirect')->setRedirectUrl($url);
00112             $this->renderLayout();
00113         }
00114     }


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

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