Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_GoogleCheckout_ApiController
  • Mage_GoogleCheckout_Block_Adminhtml_Shipping_Applicable_Countries
  • Mage_GoogleCheckout_Block_Adminhtml_Shipping_Merchant
  • Mage_GoogleCheckout_Block_Form
  • Mage_GoogleCheckout_Block_Link
  • Mage_GoogleCheckout_Block_Redirect
  • Mage_GoogleCheckout_Helper_Data
  • Mage_GoogleCheckout_Model_Api
  • Mage_GoogleCheckout_Model_Api_Debug
  • Mage_GoogleCheckout_Model_Api_Xml_Abstract
  • Mage_GoogleCheckout_Model_Api_Xml_Calculate
  • Mage_GoogleCheckout_Model_Api_Xml_Callback
  • Mage_GoogleCheckout_Model_Api_Xml_Checkout
  • Mage_GoogleCheckout_Model_Api_Xml_Order
  • Mage_GoogleCheckout_Model_Mysql4_Api_Debug
  • Mage_GoogleCheckout_Model_Mysql4_Api_Debug_Collection
  • Mage_GoogleCheckout_Model_Mysql4_Notification
  • Mage_GoogleCheckout_Model_Mysql4_Setup
  • Mage_GoogleCheckout_Model_Mysql4_Tax
  • Mage_GoogleCheckout_Model_Notification
  • Mage_GoogleCheckout_Model_Observer
  • Mage_GoogleCheckout_Model_Payment
  • Mage_GoogleCheckout_Model_Resource_Api_Debug
  • Mage_GoogleCheckout_Model_Resource_Api_Debug_Collection
  • Mage_GoogleCheckout_Model_Resource_Notification
  • Mage_GoogleCheckout_Model_Resource_Setup
  • Mage_GoogleCheckout_Model_Resource_Tax
  • Mage_GoogleCheckout_Model_Shipping
  • Mage_GoogleCheckout_Model_Source_Checkout_Image
  • Mage_GoogleCheckout_Model_Source_Locale
  • Mage_GoogleCheckout_Model_Source_Shipping_Carrier
  • Mage_GoogleCheckout_Model_Source_Shipping_Category
  • Mage_GoogleCheckout_Model_Source_Shipping_Units
  • Mage_GoogleCheckout_Model_Source_Shipping_Virtual_Method
  • Mage_GoogleCheckout_Model_Source_Shipping_Virtual_Schedule
  • Mage_GoogleCheckout_RedirectController

Exceptions

  • Mage_GoogleCheckout_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_GoogleCheckout
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * @category    Mage
 29:  * @package     Mage_GoogleCheckout
 30:  * @author      Magento Core Team <core@magentocommerce.com>
 31:  */
 32: class Mage_GoogleCheckout_RedirectController extends Mage_Core_Controller_Front_Action
 33: {
 34:     /**
 35:      *  Send request to Google Checkout and return Response Api
 36:      *
 37:      *  @return Mage_GoogleCheckout_Model_Api_Xml_Checkout
 38:      */
 39:     protected function _getApi ()
 40:     {
 41:         $session = Mage::getSingleton('checkout/session');
 42:         $api = Mage::getModel('googlecheckout/api');
 43:         /* @var $quote Mage_Sales_Model_Quote */
 44:         $quote = $session->getQuote();
 45: 
 46:         if (!$quote->hasItems()) {
 47:             $this->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
 48:             $api->setError(true);
 49:         }
 50: 
 51:         $storeQuote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore()->getId());
 52:         $storeQuote->merge($quote);
 53:         $storeQuote
 54:             ->setItemsCount($quote->getItemsCount())
 55:             ->setItemsQty($quote->getItemsQty())
 56:             ->setChangedFlag(false);
 57:         $storeQuote->save();
 58: 
 59:         $baseCurrency = $quote->getBaseCurrencyCode();
 60:         $currency = Mage::app()->getStore($quote->getStoreId())->getBaseCurrency();
 61: 
 62: 
 63:         /*
 64:          * Set payment method to google checkout, so all price rules will work out this case
 65:          * and will use right sales rules
 66:          */
 67:         if ($quote->isVirtual()) {
 68:             $quote->getBillingAddress()->setPaymentMethod('googlecheckout');
 69:         } else {
 70:             $quote->getShippingAddress()->setPaymentMethod('googlecheckout');
 71:         }
 72: 
 73:         $quote->collectTotals()->save();
 74: 
 75:         if (!$api->getError()) {
 76:             $api = $api->setAnalyticsData($this->getRequest()->getPost('analyticsdata'))
 77:                 ->checkout($quote);
 78: 
 79:             $response = $api->getResponse();
 80:             if ($api->getError()) {
 81:                 Mage::getSingleton('checkout/session')->addError($api->getError());
 82:             } else {
 83:                 $quote->setIsActive(false)->save();
 84:                 $session->replaceQuote($storeQuote);
 85:                 Mage::getModel('checkout/cart')->init()->save();
 86:                 if (Mage::getStoreConfigFlag('google/checkout/hide_cart_contents')) {
 87:                     $session->setGoogleCheckoutQuoteId($session->getQuoteId());
 88:                     $session->setQuoteId(null);
 89:                 }
 90:             }
 91:         }
 92:         return $api;
 93:     }
 94: 
 95:     public function checkoutAction()
 96:     {
 97:         $session = Mage::getSingleton('checkout/session');
 98:         Mage::dispatchEvent('googlecheckout_checkout_before', array('quote' => $session->getQuote()));
 99:         $api = $this->_getApi();
100: 
101:         if ($api->getError()) {
102:             $url = Mage::getUrl('checkout/cart');
103:         } else {
104:             $url = $api->getRedirectUrl();
105:         }
106:         $this->getResponse()->setRedirect($url);
107:     }
108: 
109:     /**
110:      * When a customer chooses Google Checkout on Checkout/Payment page
111:      *
112:      */
113:     public function redirectAction()
114:     {
115:         $api = $this->_getApi();
116: 
117:         if ($api->getError()) {
118:             $this->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
119:             return;
120:         } else {
121:             $url = $api->getRedirectUrl();
122:             $this->loadLayout();
123:             $this->getLayout()->getBlock('googlecheckout_redirect')->setRedirectUrl($url);
124:             $this->renderLayout();
125:         }
126:     }
127: 
128:     public function cartAction()
129:     {
130:         if (Mage::getStoreConfigFlag('google/checkout/hide_cart_contents')) {
131:             $session = Mage::getSingleton('checkout/session');
132:             if ($session->getQuoteId()) {
133:                 $session->getQuote()->delete();
134:             }
135:             $session->setQuoteId($session->getGoogleCheckoutQuoteId());
136:             $session->setGoogleCheckoutQuoteId(null);
137:         }
138: 
139:         $this->_redirect('checkout/cart');
140:     }
141: 
142:     public function continueAction()
143:     {
144:         $session = Mage::getSingleton('checkout/session');
145: 
146:         if ($quoteId = $session->getGoogleCheckoutQuoteId()) {
147:             $quote = Mage::getModel('sales/quote')->load($quoteId)
148:                 ->setIsActive(false)->save();
149:         }
150:         $session->clear();
151: 
152:         if (Mage::getStoreConfigFlag('google/checkout/hide_cart_contents')) {
153:             $session->setGoogleCheckoutQuoteId(null);
154:         }
155: 
156:         $url = Mage::getStoreConfig('google/checkout/continue_shopping_url');
157:         if (empty($url)) {
158:             $this->_redirect('');
159:         } elseif (substr($url, 0, 4) === 'http') {
160:             $this->getResponse()->setRedirect($url);
161:         } else {
162:             $this->_redirect($url);
163:         }
164:     }
165: 
166:     /**
167:      * Redirect to login page
168:      *
169:      */
170:     public function redirectLogin()
171:     {
172:         $this->setFlag('', 'no-dispatch', true);
173:         $this->getResponse()->setRedirect(
174:             Mage::helper('core/url')->addRequestParam(
175:                 Mage::helper('customer')->getLoginUrl(),
176:                 array('context' => 'checkout')
177:             )
178:         );
179:     }
180: 
181: }
182: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0