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_Paypal_Adminhtml_Paypal_ReportsController
  • Mage_Paypal_Block_Adminhtml_Settlement_Details
  • Mage_Paypal_Block_Adminhtml_Settlement_Details_Form
  • Mage_Paypal_Block_Adminhtml_Settlement_Report
  • Mage_Paypal_Block_Adminhtml_Settlement_Report_Grid
  • Mage_Paypal_Block_Adminhtml_System_Config_ApiWizard
  • Mage_Paypal_Block_Adminhtml_System_Config_Field_Country
  • Mage_Paypal_Block_Adminhtml_System_Config_Field_Hidden
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Expanded
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Group
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Hint
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Location
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Payment
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Store
  • Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Advanced
  • Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Info
  • Mage_Paypal_Block_Express_Form
  • Mage_Paypal_Block_Express_Review
  • Mage_Paypal_Block_Express_Review_Billing
  • Mage_Paypal_Block_Express_Review_Details
  • Mage_Paypal_Block_Express_Review_Shipping
  • Mage_Paypal_Block_Express_Shortcut
  • Mage_Paypal_Block_Hosted_Pro_Form
  • Mage_Paypal_Block_Hosted_Pro_Iframe
  • Mage_Paypal_Block_Hosted_Pro_Info
  • Mage_Paypal_Block_Iframe
  • Mage_Paypal_Block_Logo
  • Mage_Paypal_Block_Payflow_Advanced_Form
  • Mage_Paypal_Block_Payflow_Advanced_Iframe
  • Mage_Paypal_Block_Payflow_Advanced_Info
  • Mage_Paypal_Block_Payflow_Link_Form
  • Mage_Paypal_Block_Payflow_Link_Iframe
  • Mage_Paypal_Block_Payflow_Link_Info
  • Mage_Paypal_Block_Payment_Info
  • Mage_Paypal_Block_Standard_Form
  • Mage_Paypal_Block_Standard_Redirect
  • Mage_Paypal_Controller_Express_Abstract
  • Mage_Paypal_ExpressController
  • Mage_Paypal_Helper_Data
  • Mage_Paypal_Helper_Hss
  • Mage_Paypal_HostedproController
  • Mage_Paypal_IpnController
  • Mage_Paypal_Model_Api_Abstract
  • Mage_Paypal_Model_Api_Nvp
  • Mage_Paypal_Model_Api_Standard
  • Mage_Paypal_Model_Cart
  • Mage_Paypal_Model_Cert
  • Mage_Paypal_Model_Config
  • Mage_Paypal_Model_Direct
  • Mage_Paypal_Model_Express
  • Mage_Paypal_Model_Express_Checkout
  • Mage_Paypal_Model_Hostedpro
  • Mage_Paypal_Model_Hostedpro_Request
  • Mage_Paypal_Model_Info
  • Mage_Paypal_Model_Ipn
  • Mage_Paypal_Model_Method_Agreement
  • Mage_Paypal_Model_Mysql4_Cert
  • Mage_Paypal_Model_Mysql4_Report_Settlement
  • Mage_Paypal_Model_Mysql4_Report_Settlement_Row
  • Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection
  • Mage_Paypal_Model_Mysql4_Setup
  • Mage_Paypal_Model_Observer
  • Mage_Paypal_Model_Payflow_Request
  • Mage_Paypal_Model_Payflowadvanced
  • Mage_Paypal_Model_Payflowlink
  • Mage_Paypal_Model_Payflowpro
  • Mage_Paypal_Model_Payment_Transaction
  • Mage_Paypal_Model_Pro
  • Mage_Paypal_Model_Report_Settlement
  • Mage_Paypal_Model_Report_Settlement_Row
  • Mage_Paypal_Model_Resource_Cert
  • Mage_Paypal_Model_Resource_Report_Settlement
  • Mage_Paypal_Model_Resource_Report_Settlement_Row
  • Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection
  • Mage_Paypal_Model_Resource_Setup
  • Mage_Paypal_Model_Session
  • Mage_Paypal_Model_Standard
  • Mage_Paypal_Model_System_Config_Backend_Cert
  • Mage_Paypal_Model_System_Config_Backend_Cron
  • Mage_Paypal_Model_System_Config_Backend_MerchantCountry
  • Mage_Paypal_Model_System_Config_Source_BuyerCountry
  • Mage_Paypal_Model_System_Config_Source_FetchingSchedule
  • Mage_Paypal_Model_System_Config_Source_Logo
  • Mage_Paypal_Model_System_Config_Source_MerchantCountry
  • Mage_Paypal_Model_System_Config_Source_PaymentActions
  • Mage_Paypal_Model_System_Config_Source_PaymentActions_Express
  • Mage_Paypal_Model_System_Config_Source_RequireBillingAddress
  • Mage_Paypal_Model_System_Config_Source_UrlMethod
  • Mage_Paypal_PayflowadvancedController
  • Mage_Paypal_PayflowController
  • Mage_Paypal_StandardController

Exceptions

  • Mage_Paypal_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_Paypal
 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:  * Paypal expess checkout shortcut link
 29:  */
 30: class Mage_Paypal_Block_Express_Shortcut extends Mage_Core_Block_Template
 31: {
 32:     /**
 33:      * Position of "OR" label against shortcut
 34:      */
 35:     const POSITION_BEFORE = 'before';
 36:     const POSITION_AFTER = 'after';
 37: 
 38:     /**
 39:      * Whether the block should be eventually rendered
 40:      *
 41:      * @var bool
 42:      */
 43:     protected $_shouldRender = true;
 44: 
 45:     /**
 46:      * Payment method code
 47:      *
 48:      * @var string
 49:      */
 50:     protected $_paymentMethodCode = Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS;
 51: 
 52:     /**
 53:      * Start express action
 54:      *
 55:      * @var string
 56:      */
 57:     protected $_startAction = 'paypal/express/start';
 58: 
 59:     /**
 60:      * Express checkout model factory name
 61:      *
 62:      * @var string
 63:      */
 64:     protected $_checkoutType = 'paypal/express_checkout';
 65: 
 66:     protected function _beforeToHtml()
 67:     {
 68:         $result = parent::_beforeToHtml();
 69:         $config = Mage::getModel('paypal/config', array($this->_paymentMethodCode));
 70:         $isInCatalog = $this->getIsInCatalogProduct();
 71:         $quote = ($isInCatalog || '' == $this->getIsQuoteAllowed())
 72:             ? null : Mage::getSingleton('checkout/session')->getQuote();
 73: 
 74:         // check visibility on cart or product page
 75:         $context = $isInCatalog ? 'visible_on_product' : 'visible_on_cart';
 76:         if (!$config->$context) {
 77:             $this->_shouldRender = false;
 78:             return $result;
 79:         }
 80: 
 81:         if ($isInCatalog) {
 82:             // Show PayPal shortcut on a product view page only if product has nonzero price
 83:             /** @var $currentProduct Mage_Catalog_Model_Product */
 84:             $currentProduct = Mage::registry('current_product');
 85:             if (!is_null($currentProduct)) {
 86:                 $productPrice = (float)$currentProduct->getFinalPrice();
 87:                 if (empty($productPrice) && !$currentProduct->isGrouped()) {
 88:                     $this->_shouldRender = false;
 89:                     return $result;
 90:                 }
 91:             }
 92:         }
 93:         // validate minimum quote amount and validate quote for zero grandtotal
 94:         if (null !== $quote && (!$quote->validateMinimumAmount()
 95:             || (!$quote->getGrandTotal() && !$quote->hasNominalItems()))) {
 96:             $this->_shouldRender = false;
 97:             return $result;
 98:         }
 99: 
100:         // check payment method availability
101:         $methodInstance = Mage::helper('payment')->getMethodInstance($this->_paymentMethodCode);
102:         if (!$methodInstance || !$methodInstance->isAvailable($quote)) {
103:             $this->_shouldRender = false;
104:             return $result;
105:         }
106: 
107:         // set misc data
108:         $this->setShortcutHtmlId($this->helper('core')->uniqHash('ec_shortcut_'))
109:             ->setCheckoutUrl($this->getUrl($this->_startAction))
110:         ;
111: 
112:         // use static image if in catalog
113:         if ($isInCatalog || null === $quote) {
114:             $this->setImageUrl($config->getExpressCheckoutShortcutImageUrl(Mage::app()->getLocale()->getLocaleCode()));
115:         } else {
116:             $this->setImageUrl(Mage::getModel($this->_checkoutType, array(
117:                 'quote'  => $quote,
118:                 'config' => $config,
119:             ))->getCheckoutShortcutImageUrl());
120:         }
121: 
122:         // ask whether to create a billing agreement
123:         $customerId = Mage::getSingleton('customer/session')->getCustomerId(); // potential issue for caching
124:         if (Mage::helper('paypal')->shouldAskToCreateBillingAgreement($config, $customerId)) {
125:             $this->setConfirmationUrl($this->getUrl($this->_startAction,
126:                 array(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1)
127:             ));
128:             $this->setConfirmationMessage(Mage::helper('paypal')->__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'));
129:         }
130: 
131:         return $result;
132:     }
133: 
134:     /**
135:      * Render the block if needed
136:      *
137:      * @return string
138:      */
139:     protected function _toHtml()
140:     {
141:         if (!$this->_shouldRender) {
142:             return '';
143:         }
144:         return parent::_toHtml();
145:     }
146: 
147:     /**
148:      * Check is "OR" label position before shortcut
149:      *
150:      * @return bool
151:      */
152:     public function isOrPositionBefore()
153:     {
154:         return ($this->getIsInCatalogProduct() && !$this->getShowOrPosition())
155:             || ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_BEFORE);
156: 
157:     }
158: 
159:     /**
160:      * Check is "OR" label position after shortcut
161:      *
162:      * @return bool
163:      */
164:     public function isOrPositionAfter()
165:     {
166:         return (!$this->getIsInCatalogProduct() && !$this->getShowOrPosition())
167:             || ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_AFTER);
168:     }
169: }
170: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0