Mage_GoogleCheckout_Model_Api_Xml_Checkout Class Reference

Inheritance diagram for Mage_GoogleCheckout_Model_Api_Xml_Checkout:

Mage_GoogleCheckout_Model_Api_Xml_Abstract Varien_Object

List of all members.

Public Member Functions

 checkout ()

Protected Member Functions

 _getApiUrl ()
 _getItemsXml ()
 _getDigitalContentXml ($isVirtual)
 _getMerchantPrivateItemDataXml ($item)
 _getMerchantPrivateDataXml ()
 _getCartExpirationXml ()
 _getMerchantCheckoutFlowSupportXml ()
 _getRequestBuyerPhoneNumberXml ()
 _getMerchantCalculationsXml ()
 _getVirtualOrderShippingXml ()
 _getShippingMethodsXml ()
 _getCarrierCalculatedShippingXml ()
 _getFlatRateShippingXml ()
 _getAllowedCountries ($allowSpecific, $specific)
 _getMerchantCalculatedShippingXml ()
 _getPickupXml ()
 _getTaxTableXml ($rules, $type)
 _getAllTaxTablesXml ()
 _getCustomerTaxClass ()
 _getShippingTaxRules ()
 _getTaxRules ()
 _getRequestInitialAuthDetailsXml ()
 _getParameterizedUrlsXml ()
 _getPlatformIdXml ()
 _getAnalyticsDataXml ()
 _getEditCartUrl ()
 _getContinueShoppingUrl ()
 _getNotificationsUrl ()
 _getCalculationsUrl ()
 _getParameterizedUrl ()
 _isOrderVirtual ()

Protected Attributes

 $_currency
 $_shippingCalculated = false


Detailed Description

Definition at line 27 of file Checkout.php.


Member Function Documentation

_getAllowedCountries ( allowSpecific,
specific 
) [protected]

Definition at line 355 of file Checkout.php.

00356     {
00357         $xml = '';
00358         if ($allowSpecific == 1) {
00359             if($specific) {
00360                 foreach (explode(',', $specific) as $country) {
00361                     $xml .= "<postal-area><country-code>{$country}</country-code></postal-area>\n";
00362                 }
00363             }
00364         }
00365 
00366         if ($xml) {
00367             return $xml;
00368         }
00369 
00370         return '<world-area />';
00371     }

_getAllTaxTablesXml (  )  [protected]

Definition at line 570 of file Checkout.php.

00571     {
00572         if (Mage::getStoreConfigFlag('google/checkout/disable_default_tax_tables', $this->getQuote()->getStoreId())) {
00573             return '<tax-tables merchant-calculated="true" />';
00574         }
00575 
00576 
00577         $xml = <<<EOT
00578             <tax-tables merchant-calculated="true">
00579                 {$this->_getTaxTableXml($this->_getShippingTaxRules(), 'default')}
00580 
00581                 <!-- default-tax-table>
00582                     <tax-rules>
00583                         <default-tax-rule>
00584                         </default-tax-rule>
00585                     </tax-rules>
00586                 </default-tax-table -->
00587 
00588                 <alternate-tax-tables>
00589                     <alternate-tax-table name="none" standalone="true">
00590                         <alternate-tax-rules>
00591                             <alternate-tax-rule>
00592                                 <tax-area>
00593                                     <world-area/>
00594                                 </tax-area>
00595                                 <rate>0</rate>
00596                             </alternate-tax-rule>
00597                         </alternate-tax-rules>
00598                     </alternate-tax-table>
00599                     {$this->_getTaxTableXml($this->_getTaxRules(), 'alternate')}
00600                 </alternate-tax-tables>
00601             </tax-tables>
00602 EOT;
00603         return $xml;
00604     }

_getAnalyticsDataXml (  )  [protected]

Definition at line 681 of file Checkout.php.

00682     {
00683         if (!($analytics = $this->getApi()->getAnalyticsData())) {
00684             return '';
00685         }
00686         $xml = <<<EOT
00687             <analytics-data><![CDATA[{$analytics}]]></analytics-data>
00688 EOT;
00689         return $xml;
00690     }

_getApiUrl (  )  [protected]

Reimplemented from Mage_GoogleCheckout_Model_Api_Xml_Abstract.

Definition at line 32 of file Checkout.php.

00033     {
00034         $url = $this->_getBaseApiUrl();
00035         $url .= 'merchantCheckout/Merchant/'.$this->getMerchantId();
00036         return $url;
00037     }

_getCalculationsUrl (  )  [protected]

Definition at line 707 of file Checkout.php.

00708     {
00709         return $this->_getCallbackUrl();
00710     }

_getCarrierCalculatedShippingXml (  )  [protected]

Definition at line 242 of file Checkout.php.

00243     {
00244         /*
00245         we want to send ONLY ONE shipping option to google
00246         */
00247         if ($this->_shippingCalculated) {
00248             return '';
00249         }
00250 
00251         $active = Mage::getStoreConfigFlag('google/checkout_shipping_carrier/active', $this->getQuote()->getStoreId());
00252         $methods = Mage::getStoreConfig('google/checkout_shipping_carrier/methods', $this->getQuote()->getStoreId());
00253         if (!$active || !$methods) {
00254             return '';
00255         }
00256 
00257         $country = Mage::getStoreConfig('shipping/origin/country_id', $this->getQuote()->getStoreId());
00258         $region = Mage::getStoreConfig('shipping/origin/region_id', $this->getQuote()->getStoreId());
00259         $postcode = Mage::getStoreConfig('shipping/origin/postcode', $this->getQuote()->getStoreId());
00260         $city = Mage::getStoreConfig('shipping/origin/city', $this->getQuote()->getStoreId());
00261 
00262         $sizeUnit = 'IN';#Mage::getStoreConfig('google/checkout_shipping_carrier/default_unit');
00263         $defPrice = (float)Mage::getStoreConfig('google/checkout_shipping_carrier/default_price', $this->getQuote()->getStoreId());
00264         $width = Mage::getStoreConfig('google/checkout_shipping_carrier/default_width', $this->getQuote()->getStoreId());
00265         $height = Mage::getStoreConfig('google/checkout_shipping_carrier/default_height', $this->getQuote()->getStoreId());
00266         $length = Mage::getStoreConfig('google/checkout_shipping_carrier/default_length', $this->getQuote()->getStoreId());
00267 
00268         $addressCategory = Mage::getStoreConfig('google/checkout_shipping_carrier/address_category', $this->getQuote()->getStoreId());
00269 
00270         $defPrice = Mage::helper('tax')->getShippingPrice($defPrice, false, false);
00271 
00272 //      $taxRate = $this->_getShippingTaxRate();
00273 //      <additional-variable-charge-percent>{$taxRate}</additional-variable-charge-percent>
00274 
00275         $xml = <<<EOT
00276                 <carrier-calculated-shipping>
00277                     <shipping-packages>
00278                         <shipping-package>
00279                             <ship-from id="Origin">
00280                                 <city>{$city}</city>
00281                                 <region>{$region}</region>
00282                                 <postal-code>{$postcode}</postal-code>
00283                                 <country-code>{$country}</country-code>
00284                             </ship-from>
00285                             <width unit="{$sizeUnit}" value="{$width}"/>
00286                             <height unit="{$sizeUnit}" value="{$height}"/>
00287                             <length unit="{$sizeUnit}" value="{$length}"/>
00288                             <delivery-address-category>{$addressCategory}</delivery-address-category>
00289                         </shipping-package>
00290                     </shipping-packages>
00291                     <carrier-calculated-shipping-options>
00292 EOT;
00293 
00294         foreach (explode(',', $methods) as $method) {
00295             list($company, $type) = explode('/', $method);
00296             $xml .= <<<EOT
00297                         <carrier-calculated-shipping-option>
00298                             <shipping-company>{$company}</shipping-company>
00299                             <shipping-type>{$type}</shipping-type>
00300                             <price currency="{$this->getCurrency()}">{$defPrice}</price>
00301                         </carrier-calculated-shipping-option>
00302 EOT;
00303         }
00304 
00305         $xml .= <<<EOT
00306                     </carrier-calculated-shipping-options>
00307                 </carrier-calculated-shipping>
00308 EOT;
00309         $this->_shippingCalculated = true;
00310         return $xml;
00311     }

_getCartExpirationXml (  )  [protected]

Definition at line 166 of file Checkout.php.

00167     {
00168         $xml = <<<EOT
00169 EOT;
00170         return $xml;
00171     }

_getContinueShoppingUrl (  )  [protected]

Definition at line 697 of file Checkout.php.

00698     {
00699         return Mage::getUrl('googlecheckout/redirect/continue');
00700     }

_getCustomerTaxClass (  )  [protected]

Definition at line 606 of file Checkout.php.

00607     {
00608         $customerGroup = $this->getQuote()->getCustomerGroupId();
00609         if (!$customerGroup) {
00610             $customerGroup = Mage::getStoreConfig('customer/create_account/default_group', $this->getQuote()->getStoreId());
00611         }
00612         return Mage::getModel('customer/group')->load($customerGroup)->getTaxClassId();
00613     }

_getDigitalContentXml ( isVirtual  )  [protected]

Definition at line 124 of file Checkout.php.

00125     {
00126         if (!$isVirtual) {
00127             return '';
00128         }
00129 
00130         $active = Mage::getStoreConfigFlag('google/checkout_shipping_virtual/active', $this->getQuote()->getStoreId());
00131         if (!$active) {
00132             return '';
00133         }
00134 
00135         $schedule = Mage::getStoreConfig('google/checkout_shipping_virtual/schedule', $this->getQuote()->getStoreId());
00136         $method = Mage::getStoreConfig('google/checkout_shipping_virtual/method', $this->getQuote()->getStoreId());
00137 
00138         $xml = "<display-disposition>{$schedule}</display-disposition>";
00139 
00140         if ($method == 'email') {
00141             $xml .= "<email-delivery>true</email-delivery>";
00142         } elseif ($method == 'key_url') {
00143         } elseif ($method == 'description_based') {
00144         }
00145 
00146         $xml = "<digital-content>{$xml}</digital-content>";
00147 
00148         return $xml;
00149     }

_getEditCartUrl (  )  [protected]

Definition at line 692 of file Checkout.php.

00693     {
00694         return Mage::getUrl('googlecheckout/redirect/cart');
00695     }

_getFlatRateShippingXml (  )  [protected]

Definition at line 313 of file Checkout.php.

00314     {
00315         /*
00316         we want to send ONLY ONE shipping option to google
00317         */
00318         if ($this->_shippingCalculated) {
00319             return '';
00320         }
00321 
00322         if (!Mage::getStoreConfigFlag('google/checkout_shipping_flatrate/active', $this->getQuote()->getStoreId())) {
00323             return '';
00324         }
00325 
00326         for ($xml='', $i=1; $i<=3; $i++) {
00327             $allowSpecific = Mage::getStoreConfigFlag('google/checkout_shipping_flatrate/sallowspecific_'.$i, $this->getQuote()->getStoreId());
00328             $specificCountries = Mage::getStoreConfig('google/checkout_shipping_flatrate/specificcountry_'.$i, $this->getQuote()->getStoreId());
00329             $allowedAreasXml = $this->_getAllowedCountries($allowSpecific, $specificCountries);
00330 
00331             $title = Mage::getStoreConfig('google/checkout_shipping_flatrate/title_'.$i, $this->getQuote()->getStoreId());
00332             $price = Mage::getStoreConfig('google/checkout_shipping_flatrate/price_'.$i, $this->getQuote()->getStoreId());
00333             $price = number_format($price, 2, '.','');
00334             $price = Mage::helper('tax')->getShippingPrice($price, false, false);
00335 
00336             if (empty($title) || $price <= 0) {
00337                 continue;
00338             }
00339 
00340             $xml .= <<<EOT
00341                 <flat-rate-shipping name="{$title}">
00342                     <shipping-restrictions>
00343                         <allowed-areas>
00344                         {$allowedAreasXml}
00345                         </allowed-areas>
00346                     </shipping-restrictions>
00347                     <price currency="{$this->getCurrency()}">{$price}</price>
00348                 </flat-rate-shipping>
00349 EOT;
00350         }
00351         $this->_shippingCalculated = true;
00352         return $xml;
00353     }

_getItemsXml (  )  [protected]

Definition at line 70 of file Checkout.php.

00071     {
00072         $xml = <<<EOT
00073         <items>
00074 
00075 EOT;
00076         $weightUnit = 'LB';
00077         foreach ($this->getQuote()->getAllItems() as $item) {
00078             if ($item->getParentItem()) {
00079                 continue;
00080             }
00081             $taxClass = ($item->getTaxClassId() == 0 ? 'none' : $item->getTaxClassId());
00082             $weight = (float) $item->getWeight();
00083 
00084             $xml .= <<<EOT
00085             <item>
00086                 <merchant-item-id><![CDATA[{$item->getSku()}]]></merchant-item-id>
00087                 <item-name><![CDATA[{$item->getName()}]]></item-name>
00088                 <item-description><![CDATA[{$item->getDescription()}]]></item-description>
00089                 <unit-price currency="{$this->getCurrency()}">{$item->getBaseCalculationPrice()}</unit-price>
00090                 <quantity>{$item->getQty()}</quantity>
00091                 <item-weight unit="{$weightUnit}" value="{$weight}" />
00092                 <tax-table-selector>{$taxClass}</tax-table-selector>
00093                 {$this->_getDigitalContentXml($item->getIsVirtual())}
00094                 {$this->_getMerchantPrivateItemDataXml($item)}
00095             </item>
00096 
00097 EOT;
00098         }
00099 
00100         $shippingDiscount = (float)$this->getQuote()->getShippingAddress()->getBaseDiscountAmount();
00101         $billingDiscount = (float)$this->getQuote()->getBillingAddress()->getBaseDiscountAmount();
00102         if ($discount = $billingDiscount + $shippingDiscount) {
00103             $discount = -$discount;
00104             $xml .= <<<EOT
00105             <item>
00106                 <merchant-item-id>_INTERNAL_DISCOUNT_</merchant-item-id>
00107                 <item-name>{$this->__('Cart Discount')}</item-name>
00108                 <item-description>{$this->__('Virtual item to reflect discount total')}</item-description>
00109                 <unit-price currency="{$this->getCurrency()}">{$discount}</unit-price>
00110                 <quantity>1</quantity>
00111                 <item-weight unit="{$weightUnit}" value="0.00" />
00112                 <tax-table-selector>none</tax-table-selector>
00113                 {$this->_getDigitalContentXml($this->getQuote()->isVirtual())}
00114             </item>
00115 
00116 EOT;
00117         }
00118         $xml .= <<<EOT
00119         </items>
00120 EOT;
00121         return $xml;
00122     }

_getMerchantCalculatedShippingXml (  )  [protected]

Definition at line 373 of file Checkout.php.

00374     {
00375         /*
00376         we want to send ONLY ONE shipping option to google
00377         */
00378         if ($this->_shippingCalculated) {
00379             return '';
00380         }
00381 
00382         $active = Mage::getStoreConfigFlag('google/checkout_shipping_merchant/active', $this->getQuote()->getStoreId());
00383         $methods = Mage::getStoreConfig('google/checkout_shipping_merchant/allowed_methods', $this->getQuote()->getStoreId());
00384 
00385         if (!$active || !$methods) {
00386             return '';
00387         }
00388 
00389         $methods = unserialize($methods);
00390 
00391         $xml = '';
00392         foreach ($methods['method'] as $i=>$method) {
00393             if (!$i || !$method) {
00394                 continue;
00395             }
00396             list($carrierCode, $methodCode) = explode('/', $method);
00397             if ($carrierCode) {
00398                 $carrier = Mage::getModel('shipping/shipping')->getCarrierByCode($carrierCode);
00399                 if ($carrier) {
00400                     $allowedMethods = $carrier->getAllowedMethods();
00401 
00402                     if (isset($allowedMethods[$methodCode])) {
00403                         $method = Mage::getStoreConfig('carriers/'.$carrierCode.'/title', $this->getQuote()->getStoreId());
00404                         $method .= ' - '.$allowedMethods[$methodCode];
00405                     }
00406 
00407                     $defaultPrice = $methods['price'][$i];
00408                     $defaultPrice = Mage::helper('tax')->getShippingPrice($defaultPrice, false, false);
00409 
00410                     $allowedAreasXml = $this->_getAllowedCountries($carrier->getConfigData('sallowspecific'), $carrier->getConfigData('specificcountry'));
00411 
00412                     $xml .= <<<EOT
00413                         <merchant-calculated-shipping name="{$method}">
00414                             <address-filters>
00415                                 <allowed-areas>
00416                                     {$allowedAreasXml}
00417                                 </allowed-areas>
00418                             </address-filters>
00419                             <price currency="{$this->getCurrency()}">{$defaultPrice}</price>
00420                         </merchant-calculated-shipping>
00421 EOT;
00422                 }
00423             }
00424         }
00425         $this->_shippingCalculated = true;
00426         return $xml;
00427     }

_getMerchantCalculationsXml (  )  [protected]

Definition at line 200 of file Checkout.php.

00201     {
00202         $xml = <<<EOT
00203             <merchant-calculations>
00204                 <merchant-calculations-url><![CDATA[{$this->_getCalculationsUrl()}]]></merchant-calculations-url>
00205             </merchant-calculations>
00206 EOT;
00207         return $xml;
00208     }

_getMerchantCheckoutFlowSupportXml (  )  [protected]

Definition at line 173 of file Checkout.php.

00174     {
00175         $xml = <<<EOT
00176         <merchant-checkout-flow-support>
00177             <edit-cart-url><![CDATA[{$this->_getEditCartUrl()}]]></edit-cart-url>
00178             <continue-shopping-url><![CDATA[{$this->_getContinueShoppingUrl()}]]></continue-shopping-url>
00179             {$this->_getRequestBuyerPhoneNumberXml()}
00180             {$this->_getMerchantCalculationsXml()}
00181             {$this->_getShippingMethodsXml()}
00182             {$this->_getAllTaxTablesXml()}
00183             {$this->_getParameterizedUrlsXml()}
00184             {$this->_getPlatformIdXml()}
00185             {$this->_getAnalyticsDataXml()}
00186         </merchant-checkout-flow-support>
00187 EOT;
00188         return $xml;
00189     }

_getMerchantPrivateDataXml (  )  [protected]

Definition at line 156 of file Checkout.php.

00157     {
00158         $xml = <<<EOT
00159             <merchant-private-data>
00160                 <quote-id><![CDATA[{$this->getQuote()->getId()}]]></quote-id>
00161             </merchant-private-data>
00162 EOT;
00163         return $xml;
00164     }

_getMerchantPrivateItemDataXml ( item  )  [protected]

Definition at line 151 of file Checkout.php.

00152     {
00153         $xml = "<merchant-private-item-data><quote-item-id>{$item->getId()}</quote-item-id></merchant-private-item-data>";
00154         return $xml;
00155     }

_getNotificationsUrl (  )  [protected]

Definition at line 702 of file Checkout.php.

00703     {
00704         return $this->_getCallbackUrl();
00705     }

_getParameterizedUrl (  )  [protected]

Definition at line 712 of file Checkout.php.

00713     {
00714         return Mage::getUrl('googlecheckout/api/beacon');
00715     }

_getParameterizedUrlsXml (  )  [protected]

Definition at line 662 of file Checkout.php.

00663     {
00664         return '';
00665         $xml = <<<EOT
00666             <parameterized-urls>
00667                 <parameterized-url url="{$this->_getParameterizedUrl()}" />
00668             </parameterized-urls>
00669 EOT;
00670         return $xml;
00671     }

_getPickupXml (  )  [protected]

Definition at line 429 of file Checkout.php.

00430     {
00431         if (!Mage::getStoreConfig('google/checkout_shipping_pickup/active', $this->getQuote()->getStoreId())) {
00432             return '';
00433         }
00434 
00435         $title = Mage::getStoreConfig('google/checkout_shipping_pickup/title', $this->getQuote()->getStoreId());
00436         $price = Mage::getStoreConfig('google/checkout_shipping_pickup/price', $this->getQuote()->getStoreId());
00437         $price = Mage::helper('tax')->getShippingPrice($price, false, false);
00438 
00439         $xml = <<<EOT
00440                 <pickup name="{$title}">
00441                     <price currency="{$this->getCurrency()}">{$price}</price>
00442                 </pickup>
00443 EOT;
00444         return $xml;
00445     }

_getPlatformIdXml (  )  [protected]

Definition at line 673 of file Checkout.php.

00674     {
00675         $xml = <<<EOT
00676             <platform-id>473325629220583</platform-id>
00677 EOT;
00678         return $xml;
00679     }

_getRequestBuyerPhoneNumberXml (  )  [protected]

Definition at line 191 of file Checkout.php.

00192     {
00193         $requestPhone = Mage::getStoreConfig('google/checkout/request_phone', $this->getQuote()->getStoreId()) ? 'true' : 'false';
00194         $xml = <<<EOT
00195             <request-buyer-phone-number>{$requestPhone}</request-buyer-phone-number>
00196 EOT;
00197         return $xml;
00198     }

_getRequestInitialAuthDetailsXml (  )  [protected]

Definition at line 654 of file Checkout.php.

00655     {
00656         $xml = <<<EOT
00657         <request-initial-auth-details>true</request-initial-auth-details>
00658 EOT;
00659         return $xml;
00660     }

_getShippingMethodsXml (  )  [protected]

Definition at line 225 of file Checkout.php.

00226     {
00227         if ($this->_isOrderVirtual()) {
00228             return $this->_getVirtualOrderShippingXml();
00229         }
00230 
00231         $xml = <<<EOT
00232             <shipping-methods>
00233                 {$this->_getCarrierCalculatedShippingXml()}
00234                 {$this->_getFlatRateShippingXml()}
00235                 {$this->_getMerchantCalculatedShippingXml()}
00236                 {$this->_getPickupXml()}
00237             </shipping-methods>
00238 EOT;
00239         return $xml;
00240     }

_getShippingTaxRules (  )  [protected]

Definition at line 615 of file Checkout.php.

00616     {
00617         $customerTaxClass = $this->_getCustomerTaxClass();
00618         if ($shippingTaxClass = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $this->getQuote()->getStoreId())) {
00619             if (Mage::helper('tax')->getTaxBasedOn() == 'origin') {
00620                 $request = Mage::getSingleton('tax/calculation')->getRateRequest();
00621                 $request
00622                     ->setCustomerClassId($customerTaxClass)
00623                     ->setProductClassId($shippingTaxClass);
00624 
00625                 return Mage::getSingleton('tax/calculation')->getRate($request);
00626             }
00627             $customerRules = Mage::getSingleton('tax/calculation')->getRatesByCustomerAndProductTaxClasses($customerTaxClass, $shippingTaxClass);
00628             $rules = array();
00629             foreach ($customerRules as $rule) {
00630                 $rules[$rule['product_class']][] = $rule;
00631             }
00632             return $rules;
00633         } else {
00634             return array();
00635         }
00636     }

_getTaxRules (  )  [protected]

Definition at line 638 of file Checkout.php.

00639     {
00640         $customerTaxClass = $this->_getCustomerTaxClass();
00641         if (Mage::helper('tax')->getTaxBasedOn() == 'origin') {
00642             $request = Mage::getSingleton('tax/calculation')->getRateRequest();
00643             return Mage::getSingleton('tax/calculation')->getRatesForAllProductTaxClasses($request->setCustomerClassId($customerTaxClass));
00644         } else {
00645             $customerRules = Mage::getSingleton('tax/calculation')->getRatesByCustomerTaxClass($customerTaxClass);
00646             $rules = array();
00647             foreach ($customerRules as $rule) {
00648                 $rules[$rule['product_class']][] = $rule;
00649             }
00650             return $rules;
00651         }
00652     }

_getTaxTableXml ( rules,
type 
) [protected]

Definition at line 447 of file Checkout.php.

00448     {
00449         $xml = '';
00450         if (is_array($rules)) {
00451             foreach ($rules as $group=>$taxRates) {
00452                 if ($type != 'default') {
00453                     $nameAttribute = "name=\"{$group}\"";
00454                     $standaloneAttribute = "standalone=\"true\"";
00455                     $rulesTag = "{$type}-tax-rules";
00456                     $shippingTaxed = false;
00457                 } else {
00458                     $nameAttribute = '';
00459                     $standaloneAttribute = '';
00460                     $rulesTag = "tax-rules";
00461                     $shippingTaxed = true;
00462                 }
00463 
00464 
00465                 $xml .= <<<EOT
00466                         <{$type}-tax-table {$nameAttribute} {$standaloneAttribute}>
00467                             <{$rulesTag}>
00468 EOT;
00469                 if (is_array($taxRates)) {
00470                     foreach ($taxRates as $rate) {
00471                         $xml .= <<<EOT
00472                                     <{$type}-tax-rule>
00473                                         <tax-area>
00474 
00475 EOT;
00476                         if ($rate['country']==='US') {
00477                             if (!empty($rate['postcode']) && $rate['postcode']!=='*') {
00478                                 $xml .= <<<EOT
00479                                             <us-zip-area>
00480                                                 <zip-pattern>{$rate['postcode']}</zip-pattern>
00481                                             </us-zip-area>
00482 
00483 EOT;
00484                             } elseif (!empty($rate['state'])) {
00485                                 $xml .= <<<EOT
00486                                             <us-state-area>
00487                                                 <state>{$rate['state']}</state>
00488                                             </us-state-area>
00489 
00490 EOT;
00491                             } else {
00492                                 $xml .= <<<EOT
00493                                             <us-zip-area>
00494                                                 <zip-pattern>*</zip-pattern>
00495                                             </us-zip-area>
00496 
00497 EOT;
00498                             }
00499                         } else {
00500                             if (!empty($rate['postcode'])) {
00501                                 $xml .= <<<EOT
00502                                             <postal-area>
00503                                                 <country-code>{$rate['country']}</country-code>
00504 EOT;
00505                                 if (!empty($rate['postcode']) && $rate['postcode']!=='*') {
00506                                     $xml .= <<<EOT
00507                                                 <postal-code-pattern>{$rate['postcode']}</postal-code-pattern>
00508 
00509 EOT;
00510                                 }
00511                                 $xml .= <<<EOT
00512                                             </postal-area>
00513 
00514 EOT;
00515                             }
00516                         }
00517                         $xml .= <<<EOT
00518                                         </tax-area>
00519                                         <rate>{$rate['value']}</rate>
00520 EOT;
00521                         if ($shippingTaxed) {
00522                             $xml .= '<shipping-taxed>true</shipping-taxed>';
00523                         }
00524                         $xml .= "</{$type}-tax-rule>";
00525                     }
00526 
00527                 } else {
00528                     $taxRate = $taxRates/100;
00529                     $xml .= <<<EOT
00530                                 <{$type}-tax-rule>
00531                                     <tax-area>
00532                                         <world-area/>
00533                                     </tax-area>
00534                                     <rate>{$taxRate}</rate>
00535 EOT;
00536                         if ($shippingTaxed) {
00537                             $xml .= '<shipping-taxed>true</shipping-taxed>';
00538                         }
00539                     $xml .= "</{$type}-tax-rule>";
00540                 }
00541 
00542                 $xml .= <<<EOT
00543                             </$rulesTag>
00544                         </{$type}-tax-table>
00545 EOT;
00546             }
00547         } else {
00548             if (is_numeric($rules)) {
00549                 $taxRate = $rules/100;
00550 
00551                 $xml .= <<<EOT
00552                         <{$type}-tax-table>
00553                             <tax-rules>
00554                                 <{$type}-tax-rule>
00555                                     <tax-area>
00556                                         <world-area/>
00557                                     </tax-area>
00558                                     <rate>{$taxRate}</rate>
00559                                     <shipping-taxed>true</shipping-taxed>
00560                                 </{$type}-tax-rule>
00561                             </tax-rules>
00562                         </{$type}-tax-table>
00563 EOT;
00564             }
00565         }
00566 
00567         return $xml;
00568     }

_getVirtualOrderShippingXml (  )  [protected]

Definition at line 210 of file Checkout.php.

00211     {
00212         $title = Mage::helper('googlecheckout')->__('Free Shipping');
00213 
00214         $xml = <<<EOT
00215             <shipping-methods>
00216                 <flat-rate-shipping name="{$title}">
00217                     <shipping-restrictions><allowed-areas><world-area /></allowed-areas></shipping-restrictions>
00218                     <price currency="{$this->getCurrency()}">0</price>
00219                 </flat-rate-shipping>
00220             </shipping-methods>
00221 EOT;
00222         return $xml;
00223     }

_isOrderVirtual (  )  [protected]

Definition at line 717 of file Checkout.php.

00718     {
00719         $orderIsVirual = true;
00720         foreach ($this->getQuote()->getAllItems() as $item) {
00721             if (!$item->getIsVirtual()) {
00722                 $orderIsVirual = false;
00723                 break;
00724             }
00725         }
00726         return $orderIsVirual;
00727     }

checkout (  ) 

Definition at line 39 of file Checkout.php.

00040     {
00041         $quote = $this->getQuote();
00042 
00043         if (!($quote instanceof Mage_Sales_Model_Quote)) {
00044             Mage::throwException('Invalid quote');
00045         }
00046 
00047         $xml = <<<EOT
00048 <checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">
00049     <shopping-cart>
00050 {$this->_getItemsXml()}
00051 {$this->_getMerchantPrivateDataXml()}
00052 {$this->_getCartExpirationXml()}
00053     </shopping-cart>
00054     <checkout-flow-support>
00055 {$this->_getMerchantCheckoutFlowSupportXml()}
00056     </checkout-flow-support>
00057     <order-processing-support>
00058 {$this->_getRequestInitialAuthDetailsXml()}
00059     </order-processing-support>
00060 </checkout-shopping-cart>
00061 EOT;
00062 #echo "<xmp>".$xml."</xmp>";
00063         $result = $this->_call($xml);
00064 
00065         $this->setRedirectUrl($result->{'redirect-url'});
00066 
00067         return $this;
00068     }


Member Data Documentation

$_currency [protected]

Definition at line 29 of file Checkout.php.

$_shippingCalculated = false [protected]

Definition at line 30 of file Checkout.php.


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