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:  * Config model that is aware of all Mage_Paypal payment methods
  29:  * Works with PayPal-specific system configuration
  30:  */
  31: class Mage_Paypal_Model_Config
  32: {
  33:     /**
  34:      * PayPal Standard
  35:      * @var string
  36:      */
  37:     const METHOD_WPS         = 'paypal_standard';
  38: 
  39:     /**
  40:      * PayPal Website Payments Pro - Express Checkout
  41:      * @var string
  42:      */
  43:     const METHOD_WPP_EXPRESS = 'paypal_express';
  44: 
  45:     /**
  46:      * PayPal Website Payments Pro - Direct Payments
  47:      * @var string
  48:      */
  49:     const METHOD_WPP_DIRECT  = 'paypal_direct';
  50: 
  51:     /**
  52:      * Direct Payments (Payflow Edition)
  53:      * @var string
  54:      */
  55:     const METHOD_WPP_PE_DIRECT  = 'paypaluk_direct';
  56: 
  57:     /**
  58:      * Express Checkout (Payflow Edition)
  59:      * @var string
  60:      */
  61:     const METHOD_WPP_PE_EXPRESS  = 'paypaluk_express';
  62: 
  63:     /**
  64:      * Payflow Pro Gateway
  65:      * @var string
  66:      */
  67:     const METHOD_PAYFLOWPRO         = 'verisign';
  68: 
  69:     const METHOD_PAYFLOWLINK        = 'payflow_link';
  70:     const METHOD_PAYFLOWADVANCED    = 'payflow_advanced';
  71: 
  72:     const METHOD_HOSTEDPRO          = 'hosted_pro';
  73: 
  74:     const METHOD_BILLING_AGREEMENT  = 'paypal_billing_agreement';
  75: 
  76:     /**
  77:      * Buttons and images
  78:      * @var string
  79:      */
  80:     const EC_FLAVOR_DYNAMIC = 'dynamic';
  81:     const EC_FLAVOR_STATIC  = 'static';
  82:     const EC_BUTTON_TYPE_SHORTCUT = 'ecshortcut';
  83:     const EC_BUTTON_TYPE_MARK     = 'ecmark';
  84:     const PAYMENT_MARK_37x23   = '37x23';
  85:     const PAYMENT_MARK_50x34   = '50x34';
  86:     const PAYMENT_MARK_60x38   = '60x38';
  87:     const PAYMENT_MARK_180x113 = '180x113';
  88: 
  89:     const DEFAULT_LOGO_TYPE = 'wePrefer_150x60';
  90: 
  91:     /**
  92:      * Payment actions
  93:      * @var string
  94:      */
  95:     const PAYMENT_ACTION_SALE  = 'Sale';
  96:     const PAYMENT_ACTION_ORDER = 'Order';
  97:     const PAYMENT_ACTION_AUTH  = 'Authorization';
  98: 
  99:     /**
 100:      * Authorization amounts for Account Verification
 101:      *
 102:      * @deprecated since 1.6.2.0
 103:      * @var int
 104:      */
 105:     const AUTHORIZATION_AMOUNT_ZERO = 0;
 106:     const AUTHORIZATION_AMOUNT_ONE = 1;
 107:     const AUTHORIZATION_AMOUNT_FULL = 2;
 108: 
 109:     /**
 110:      * Require Billing Address
 111:      * @var int
 112:      */
 113:     const REQUIRE_BILLING_ADDRESS_NO = 0;
 114:     const REQUIRE_BILLING_ADDRESS_ALL = 1;
 115:     const REQUIRE_BILLING_ADDRESS_VIRTUAL = 2;
 116: 
 117:     /**
 118:      * Fraud management actions
 119:      * @var string
 120:      */
 121:     const FRAUD_ACTION_ACCEPT = 'Acept';
 122:     const FRAUD_ACTION_DENY   = 'Deny';
 123: 
 124:     /**
 125:      * Refund types
 126:      * @var string
 127:      */
 128:     const REFUND_TYPE_FULL = 'Full';
 129:     const REFUND_TYPE_PARTIAL = 'Partial';
 130: 
 131:     /**
 132:      * Express Checkout flows
 133:      * @var string
 134:      */
 135:     const EC_SOLUTION_TYPE_SOLE = 'Sole';
 136:     const EC_SOLUTION_TYPE_MARK = 'Mark';
 137: 
 138:     /**
 139:      * Payment data transfer methods (Standard)
 140:      *
 141:      * @var string
 142:      */
 143:     const WPS_TRANSPORT_IPN      = 'ipn';
 144:     const WPS_TRANSPORT_PDT      = 'pdt';
 145:     const WPS_TRANSPORT_IPN_PDT  = 'ipn_n_pdt';
 146: 
 147:     /**
 148:      * Billing Agreement Signup
 149:      *
 150:      * @var string
 151:      */
 152:     const EC_BA_SIGNUP_AUTO     = 'auto';
 153:     const EC_BA_SIGNUP_ASK      = 'ask';
 154:     const EC_BA_SIGNUP_NEVER    = 'never';
 155: 
 156:     /**
 157:      * Default URL for centinel API (PayPal Direct)
 158:      *
 159:      * @var string
 160:      */
 161:     public $centinelDefaultApiUrl = 'https://paypal.cardinalcommerce.com/maps/txns.asp';
 162: 
 163:     /**
 164:      * Current payment method code
 165:      * @var string
 166:      */
 167:     protected $_methodCode = null;
 168: 
 169:     /**
 170:      * Current store id
 171:      *
 172:      * @var int
 173:      */
 174:     protected $_storeId = null;
 175: 
 176:     /**
 177:      * Instructions for generating proper BN code
 178:      *
 179:      * @var array
 180:      */
 181:     protected $_buildNotationPPMap = array(
 182:         'paypal_standard'  => 'WPS',
 183:         'paypal_express'   => 'EC',
 184:         'paypal_direct'    => 'DP',
 185:         'paypaluk_express' => 'EC',
 186:         'paypaluk_direct'  => 'DP',
 187:     );
 188: 
 189:     /**
 190:      * Style system config map (Express Checkout)
 191:      *
 192:      * @var array
 193:      */
 194:     protected $_ecStyleConfigMap = array(
 195:         'page_style'    => 'page_style',
 196:         'paypal_hdrimg' => 'hdrimg',
 197:         'paypal_hdrbordercolor' => 'hdrbordercolor',
 198:         'paypal_hdrbackcolor'   => 'hdrbackcolor',
 199:         'paypal_payflowcolor'   => 'payflowcolor',
 200:     );
 201: 
 202:     /**
 203:      * Currency codes supported by PayPal methods
 204:      *
 205:      * @var array
 206:      */
 207:     protected $_supportedCurrencyCodes = array('AUD', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN',
 208:         'NOK', 'NZD', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'USD', 'TWD', 'THB');
 209: 
 210:     /**
 211:      * Merchant country supported by PayPal
 212:      *
 213:      * @var array
 214:      */
 215:     protected $_supportedCountryCodes = array(
 216:         'AE','AR','AT','AU','BE','BG','BR','CA','CH','CL','CR','CY','CZ','DE','DK','DO','EC','EE','ES','FI','FR','GB',
 217:         'GF','GI','GP','GR','HK','HU','ID','IE','IL','IN','IS','IT','JM','JP','KR','LI','LT','LU','LV','MQ','MT','MX',
 218:         'MY','NL','NO','NZ','PH','PL','PT','RE','RO','SE','SG','SI','SK','SM','TH','TR','TW','US','UY','VE','VN','ZA');
 219: 
 220:     /**
 221:      * Buyer country supported by PayPal
 222:      *
 223:      * @var array
 224:      */
 225:     protected $_supportedBuyerCountryCodes = array(
 226:         'AF ', 'AX ', 'AL ', 'DZ ', 'AS ', 'AD ', 'AO ', 'AI ', 'AQ ', 'AG ', 'AR ', 'AM ', 'AW ', 'AU ', 'AT ', 'AZ ',
 227:         'BS ', 'BH ', 'BD ', 'BB ', 'BY ', 'BE ', 'BZ ', 'BJ ', 'BM ', 'BT ', 'BO ', 'BA ', 'BW ', 'BV ', 'BR ', 'IO ',
 228:         'BN ', 'BG ', 'BF ', 'BI ', 'KH ', 'CM ', 'CA ', 'CV ', 'KY ', 'CF ', 'TD ', 'CL ', 'CN ', 'CX ', 'CC ', 'CO ',
 229:         'KM ', 'CG ', 'CD ', 'CK ', 'CR ', 'CI ', 'HR ', 'CU ', 'CY ', 'CZ ', 'DK ', 'DJ ', 'DM ', 'DO ', 'EC ', 'EG ',
 230:         'SV ', 'GQ ', 'ER ', 'EE ', 'ET ', 'FK ', 'FO ', 'FJ ', 'FI ', 'FR ', 'GF ', 'PF ', 'TF ', 'GA ', 'GM ', 'GE ',
 231:         'DE ', 'GH ', 'GI ', 'GR ', 'GL ', 'GD ', 'GP ', 'GU ', 'GT ', 'GG ', 'GN ', 'GW ', 'GY ', 'HT ', 'HM ', 'VA ',
 232:         'HN ', 'HK ', 'HU ', 'IS ', 'IN ', 'ID ', 'IR ', 'IQ ', 'IE ', 'IM ', 'IL ', 'IT ', 'JM ', 'JP ', 'JE ', 'JO ',
 233:         'KZ ', 'KE ', 'KI ', 'KP ', 'KR ', 'KW ', 'KG ', 'LA ', 'LV ', 'LB ', 'LS ', 'LR ', 'LY ', 'LI ', 'LT ', 'LU ',
 234:         'MO ', 'MK ', 'MG ', 'MW ', 'MY ', 'MV ', 'ML ', 'MT ', 'MH ', 'MQ ', 'MR ', 'MU ', 'YT ', 'MX ', 'FM ', 'MD ',
 235:         'MC ', 'MN ', 'MS ', 'MA ', 'MZ ', 'MM ', 'NA ', 'NR ', 'NP ', 'NL ', 'AN ', 'NC ', 'NZ ', 'NI ', 'NE ', 'NG ',
 236:         'NU ', 'NF ', 'MP ', 'NO ', 'OM ', 'PK ', 'PW ', 'PS ', 'PA ', 'PG ', 'PY ', 'PE ', 'PH ', 'PN ', 'PL ', 'PT ',
 237:         'PR ', 'QA ', 'RE ', 'RO ', 'RU ', 'RW ', 'SH ', 'KN ', 'LC ', 'PM ', 'VC ', 'WS ', 'SM ', 'ST ', 'SA ', 'SN ',
 238:         'CS ', 'SC ', 'SL ', 'SG ', 'SK ', 'SI ', 'SB ', 'SO ', 'ZA ', 'GS ', 'ES ', 'LK ', 'SD ', 'SR ', 'SJ ', 'SZ ',
 239:         'SE ', 'CH ', 'SY ', 'TW ', 'TJ ', 'TZ ', 'TH ', 'TL ', 'TG ', 'TK ', 'TO ', 'TT ', 'TN ', 'TR ', 'TM ', 'TC ',
 240:         'TV ', 'UG ', 'UA ', 'AE ', 'GB ', 'US ', 'UM ', 'UY ', 'UZ ', 'VU ', 'VE ', 'VN ', 'VG ', 'VI ', 'WF ', 'EH ',
 241:         'YE ', 'ZM ', 'ZW'
 242:     );
 243: 
 244:     /**
 245:      * Locale codes supported by misc images (marks, shortcuts etc)
 246:      *
 247:      * @var array
 248:      * @link https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECButtonIntegration#id089QD0O0TX4__id08AH904I0YK
 249:      */
 250:     protected $_supportedImageLocales = array('de_DE', 'en_AU', 'en_GB', 'en_US', 'es_ES', 'es_XC', 'fr_FR',
 251:         'fr_XC', 'it_IT', 'ja_JP', 'nl_NL', 'pl_PL', 'zh_CN', 'zh_XC',
 252:     );
 253: 
 254:     /**
 255:      * Set method and store id, if specified
 256:      *
 257:      * @param array $params
 258:      */
 259:     public function __construct($params = array())
 260:     {
 261:         if ($params) {
 262:             $method = array_shift($params);
 263:             $this->setMethod($method);
 264:             if ($params) {
 265:                 $storeId = array_shift($params);
 266:                 $this->setStoreId($storeId);
 267:             }
 268:         }
 269:     }
 270: 
 271:     /**
 272:      * Method code setter
 273:      *
 274:      * @param string|Mage_Payment_Model_Method_Abstract $method
 275:      * @return Mage_Paypal_Model_Config
 276:      */
 277:     public function setMethod($method)
 278:     {
 279:         if ($method instanceof Mage_Payment_Model_Method_Abstract) {
 280:             $this->_methodCode = $method->getCode();
 281:         } elseif (is_string($method)) {
 282:             $this->_methodCode = $method;
 283:         }
 284:         return $this;
 285:     }
 286: 
 287:     /**
 288:      * Payment method instance code getter
 289:      *
 290:      * @return string
 291:      */
 292:     public function getMethodCode()
 293:     {
 294:         return $this->_methodCode;
 295:     }
 296: 
 297:     /**
 298:      * Store ID setter
 299:      *
 300:      * @param int $storeId
 301:      * @return Mage_Paypal_Model_Config
 302:      */
 303:     public function setStoreId($storeId)
 304:     {
 305:         $this->_storeId = (int)$storeId;
 306:         return $this;
 307:     }
 308: 
 309:     /**
 310:      * Check whether method active in configuration and supported for merchant country or not
 311:      *
 312:      * @param string $method Method code
 313:      * @return bool
 314:      */
 315:     public function isMethodActive($method)
 316:     {
 317:         if ($this->isMethodSupportedForCountry($method)
 318:             && Mage::getStoreConfigFlag("payment/{$method}/active", $this->_storeId)
 319:         ) {
 320:             return true;
 321:         }
 322:         return false;
 323:     }
 324: 
 325:     /**
 326:      * Check whether method available for checkout or not
 327:      * Logic based on merchant country, methods dependence
 328:      *
 329:      * @param string $method Method code
 330:      * @return bool
 331:      */
 332:     public function isMethodAvailable($methodCode = null)
 333:     {
 334:         if ($methodCode === null) {
 335:             $methodCode = $this->getMethodCode();
 336:         }
 337: 
 338:         $result = true;
 339: 
 340:         if (!$this->isMethodActive($methodCode)) {
 341:             $result = false;
 342:         }
 343: 
 344:         switch ($methodCode) {
 345:             case self::METHOD_WPS:
 346:                 if (!$this->businessAccount) {
 347:                     $result = false;
 348:                     break;
 349:                 }
 350:                 // check for direct payments dependence
 351:                 if ($this->isMethodActive(self::METHOD_WPP_DIRECT)
 352:                     || $this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
 353:                     $result = false;
 354:                 }
 355:                 break;
 356:             case self::METHOD_WPP_EXPRESS:
 357:                 // check for direct payments dependence
 358:                 if ($this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
 359:                     $result = false;
 360:                 } elseif ($this->isMethodActive(self::METHOD_WPP_DIRECT)) {
 361:                     $result = true;
 362:                 }
 363:                 break;
 364:             case self::METHOD_WPP_PE_EXPRESS:
 365:                 // check for direct payments dependence
 366:                 if ($this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
 367:                     $result = true;
 368:                 } elseif (!$this->isMethodActive(self::METHOD_WPP_PE_DIRECT)
 369:                           && !$this->isMethodActive(self::METHOD_PAYFLOWPRO)) {
 370:                     $result = false;
 371:                 }
 372:                 break;
 373:             case self::METHOD_BILLING_AGREEMENT:
 374:                 $result = $this->isWppApiAvailabe();
 375:                 break;
 376:             case self::METHOD_WPP_DIRECT:
 377:             case self::METHOD_WPP_PE_DIRECT:
 378:                 break;
 379:         }
 380:         return $result;
 381:     }
 382: 
 383:     /**
 384:      * Config field magic getter
 385:      * The specified key can be either in camelCase or under_score format
 386:      * Tries to map specified value according to set payment method code, into the configuration value
 387:      * Sets the values into public class parameters, to avoid redundant calls of this method
 388:      *
 389:      * @param string $key
 390:      * @return string|null
 391:      */
 392:     public function __get($key)
 393:     {
 394:         $underscored = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $key));
 395:         $value = Mage::getStoreConfig($this->_getSpecificConfigPath($underscored), $this->_storeId);
 396:         $value = $this->_prepareValue($underscored, $value);
 397:         $this->$key = $value;
 398:         $this->$underscored = $value;
 399:         return $value;
 400:     }
 401: 
 402:     /**
 403:      * Perform additional config value preparation and return new value if needed
 404:      *
 405:      * @param string $key Underscored key
 406:      * @param string $value Old value
 407:      * @return string Modified value or old value
 408:      */
 409:     protected function _prepareValue($key, $value)
 410:     {
 411:         // Always set payment action as "Sale" for Unilateral payments in EC
 412:         if ($key == 'payment_action'
 413:             && $value != self::PAYMENT_ACTION_SALE
 414:             && $this->_methodCode == self::METHOD_WPP_EXPRESS
 415:             && $this->shouldUseUnilateralPayments())
 416:         {
 417:             return self::PAYMENT_ACTION_SALE;
 418:         }
 419:         return $value;
 420:     }
 421: 
 422:     /**
 423:      * Return merchant country codes supported by PayPal
 424:      *
 425:      * @return array
 426:      */
 427:     public function getSupportedMerchantCountryCodes()
 428:     {
 429:         return $this->_supportedCountryCodes;
 430:     }
 431: 
 432:     /**
 433:      * Return buyer country codes supported by PayPal
 434:      *
 435:      * @return array
 436:      */
 437:     public function getSupportedBuyerCountryCodes()
 438:     {
 439:         return $this->_supportedBuyerCountryCodes;
 440:     }
 441: 
 442:     /**
 443:      * Return merchant country code, use default country if it not specified in General settings
 444:      *
 445:      * @return string
 446:      */
 447:     public function getMerchantCountry()
 448:     {
 449:         $countryCode = Mage::getStoreConfig($this->_mapGeneralFieldset('merchant_country'), $this->_storeId);
 450:         if (!$countryCode) {
 451:             $countryCode = Mage::helper('core')->getDefaultCountry($this->_storeId);
 452:         }
 453:         return $countryCode;
 454:     }
 455: 
 456:     /**
 457:      * Check whether method supported for specified country or not
 458:      * Use $_methodCode and merchant country by default
 459:      *
 460:      * @return bool
 461:      */
 462:     public function isMethodSupportedForCountry($method = null, $countryCode = null)
 463:     {
 464:         if ($method === null) {
 465:             $method = $this->getMethodCode();
 466:         }
 467:         if ($countryCode === null) {
 468:             $countryCode = $this->getMerchantCountry();
 469:         }
 470:         $countryMethods = $this->getCountryMethods($countryCode);
 471:         if (in_array($method, $countryMethods)) {
 472:             return true;
 473:         }
 474:         return false;
 475:     }
 476: 
 477:     /**
 478:      * Return list of allowed methods for specified country iso code
 479:      *
 480:      * @param string $countryCode 2-letters iso code
 481:      * @return array
 482:      */
 483:     public function getCountryMethods($countryCode = null)
 484:     {
 485:         $countryMethods = array(
 486:             'other' => array(
 487:                 self::METHOD_WPS,
 488:                 self::METHOD_WPP_EXPRESS,
 489:                 self::METHOD_BILLING_AGREEMENT,
 490:             ),
 491:             'US' => array(
 492:                 self::METHOD_PAYFLOWADVANCED,
 493:                 self::METHOD_WPP_DIRECT,
 494:                 self::METHOD_WPS,
 495:                 self::METHOD_PAYFLOWPRO,
 496:                 self::METHOD_PAYFLOWLINK,
 497:                 self::METHOD_WPP_EXPRESS,
 498:                 self::METHOD_BILLING_AGREEMENT,
 499:                 self::METHOD_WPP_PE_EXPRESS,
 500:             ),
 501:             'CA' => array(
 502:                 self::METHOD_WPP_DIRECT,
 503:                 self::METHOD_WPS,
 504:                 self::METHOD_PAYFLOWPRO,
 505:                 self::METHOD_PAYFLOWLINK,
 506:                 self::METHOD_WPP_EXPRESS,
 507:                 self::METHOD_BILLING_AGREEMENT,
 508:             ),
 509:             'GB' => array(
 510:                 self::METHOD_WPP_DIRECT,
 511:                 self::METHOD_WPS,
 512:                 self::METHOD_WPP_PE_DIRECT,
 513:                 self::METHOD_HOSTEDPRO,
 514:                 self::METHOD_WPP_EXPRESS,
 515:                 self::METHOD_BILLING_AGREEMENT,
 516:                 self::METHOD_WPP_PE_EXPRESS,
 517:             ),
 518:             'AU' => array(
 519:                 self::METHOD_WPS,
 520:                 self::METHOD_PAYFLOWPRO,
 521:                 self::METHOD_HOSTEDPRO,
 522:                 self::METHOD_WPP_EXPRESS,
 523:                 self::METHOD_BILLING_AGREEMENT,
 524:             ),
 525:             'NZ' => array(
 526:                 self::METHOD_WPS,
 527:                 self::METHOD_PAYFLOWPRO,
 528:                 self::METHOD_WPP_EXPRESS,
 529:                 self::METHOD_BILLING_AGREEMENT,
 530:             ),
 531:             'JP' => array(
 532:                 self::METHOD_WPS,
 533:                 self::METHOD_HOSTEDPRO,
 534:                 self::METHOD_WPP_EXPRESS,
 535:                 self::METHOD_BILLING_AGREEMENT,
 536:             ),
 537:             'FR' => array(
 538:                 self::METHOD_WPS,
 539:                 self::METHOD_HOSTEDPRO,
 540:                 self::METHOD_WPP_EXPRESS,
 541:                 self::METHOD_BILLING_AGREEMENT,
 542:             ),
 543:             'IT' => array(
 544:                 self::METHOD_WPS,
 545:                 self::METHOD_HOSTEDPRO,
 546:                 self::METHOD_WPP_EXPRESS,
 547:                 self::METHOD_BILLING_AGREEMENT,
 548:             ),
 549:             'ES' => array(
 550:                 self::METHOD_WPS,
 551:                 self::METHOD_HOSTEDPRO,
 552:                 self::METHOD_WPP_EXPRESS,
 553:                 self::METHOD_BILLING_AGREEMENT,
 554:             ),
 555:             'HK' => array(
 556:                 self::METHOD_WPS,
 557:                 self::METHOD_HOSTEDPRO,
 558:                 self::METHOD_WPP_EXPRESS,
 559:                 self::METHOD_BILLING_AGREEMENT,
 560:             ),
 561:         );
 562:         if ($countryCode === null) {
 563:             return $countryMethods;
 564:         }
 565:         return isset($countryMethods[$countryCode]) ? $countryMethods[$countryCode] : $countryMethods['other'];    }
 566: 
 567:     /**
 568:      * Get url for dispatching customer to express checkout start
 569:      *
 570:      * @param string $token
 571:      * @return string
 572:      */
 573:     public function getExpressCheckoutStartUrl($token)
 574:     {
 575:         return $this->getPaypalUrl(array(
 576:             'cmd'   => '_express-checkout',
 577:             'token' => $token,
 578:         ));
 579:     }
 580: 
 581:     /**
 582:      * Get url that allows to edit checkout details on paypal side
 583:      *
 584:      * @param $token
 585:      * @return string
 586:      */
 587:     public function getExpressCheckoutEditUrl($token)
 588:     {
 589:         return $this->getPaypalUrl(array(
 590:             'cmd'        => '_express-checkout',
 591:             'useraction' => 'continue',
 592:             'token'      => $token,
 593:         ));
 594:     }
 595: 
 596:     /**
 597:      * Get url for additional actions that PayPal may require customer to do after placing the order.
 598:      * For instance, redirecting customer to bank for payment confirmation.
 599:      *
 600:      * @param string $token
 601:      * @return string
 602:      */
 603:     public function getExpressCheckoutCompleteUrl($token)
 604:     {
 605:         return $this->getPaypalUrl(array(
 606:             'cmd'   => '_complete-express-checkout',
 607:             'token' => $token,
 608:         ));
 609:     }
 610: 
 611:     /**
 612:      * Retrieve url for initialization of billing agreement
 613:      *
 614:      * @param string $token
 615:      * @return string
 616:      */
 617:     public function getStartBillingAgreementUrl($token)
 618:     {
 619:         return $this->getPaypalUrl(array(
 620:             'cmd'   => '_customer-billing-agreement',
 621:             'token' => $token,
 622:         ));
 623:     }
 624: 
 625:      /**
 626:      * PayPal web URL generic getter
 627:      *
 628:      * @param array $params
 629:      * @return string
 630:      */
 631:     public function getPaypalUrl(array $params = array())
 632:     {
 633:         return sprintf('https://www.%spaypal.com/webscr%s',
 634:             $this->sandboxFlag ? 'sandbox.' : '',
 635:             $params ? '?' . http_build_query($params) : ''
 636:         );
 637:     }
 638: 
 639:     /**
 640:      * Whether Express Checkout button should be rendered dynamically
 641:      *
 642:      * @return bool
 643:      */
 644:     public function areButtonsDynamic()
 645:     {
 646:         return $this->buttonFlavor === self::EC_FLAVOR_DYNAMIC;
 647:     }
 648: 
 649:     /**
 650:      * Express checkout shortcut pic URL getter
 651:      * PayPal will ignore "pal", if there is no total amount specified
 652:      *
 653:      * @param string $localeCode
 654:      * @param float $orderTotal
 655:      * @param string $pal encrypted summary about merchant
 656:      * @see Paypal_Model_Api_Nvp::callGetPalDetails()
 657:      */
 658:     public function getExpressCheckoutShortcutImageUrl($localeCode, $orderTotal = null, $pal = null)
 659:     {
 660:         if ($this->areButtonsDynamic()) {
 661:             return $this->_getDynamicImageUrl(self::EC_BUTTON_TYPE_SHORTCUT, $localeCode, $orderTotal, $pal);
 662:         }
 663:         if ($this->buttonType === self::EC_BUTTON_TYPE_MARK) {
 664:             return $this->getPaymentMarkImageUrl($localeCode);
 665:         }
 666:         return sprintf('https://www.paypal.com/%s/i/btn/btn_xpressCheckout.gif',
 667:             $this->_getSupportedLocaleCode($localeCode));
 668:     }
 669: 
 670:     /**
 671:      * Get PayPal "mark" image URL
 672:      * Supposed to be used on payment methods selection
 673:      * $staticSize is applicable for static images only
 674:      *
 675:      * @param string $localeCode
 676:      * @param float $orderTotal
 677:      * @param string $pal
 678:      * @param string $staticSize
 679:      */
 680:     public function getPaymentMarkImageUrl($localeCode, $orderTotal = null, $pal = null, $staticSize = null)
 681:     {
 682:         if ($this->areButtonsDynamic()) {
 683:             return $this->_getDynamicImageUrl(self::EC_BUTTON_TYPE_MARK, $localeCode, $orderTotal, $pal);
 684:         }
 685: 
 686:         if (null === $staticSize) {
 687:             $staticSize = $this->paymentMarkSize;
 688:         }
 689:         switch ($staticSize) {
 690:             case self::PAYMENT_MARK_37x23:
 691:             case self::PAYMENT_MARK_50x34:
 692:             case self::PAYMENT_MARK_60x38:
 693:             case self::PAYMENT_MARK_180x113:
 694:                 break;
 695:             default:
 696:                 $staticSize = self::PAYMENT_MARK_37x23;
 697:         }
 698:         return sprintf('https://www.paypal.com/%s/i/logo/PayPal_mark_%s.gif',
 699:             $this->_getSupportedLocaleCode($localeCode), $staticSize);
 700:     }
 701: 
 702:     /**
 703:      * Get "What Is PayPal" localized URL
 704:      * Supposed to be used with "mark" as popup window
 705:      *
 706:      * @param Mage_Core_Model_Locale $locale
 707:      */
 708:     public function getPaymentMarkWhatIsPaypalUrl(Mage_Core_Model_Locale $locale = null)
 709:     {
 710:         $countryCode = 'US';
 711:         if (null !== $locale) {
 712:             $shouldEmulate = (null !== $this->_storeId) && (Mage::app()->getStore()->getId() != $this->_storeId);
 713:             if ($shouldEmulate) {
 714:                 $locale->emulate($this->_storeId);
 715:             }
 716:             $countryCode = $locale->getLocale()->getRegion();
 717:             if ($shouldEmulate) {
 718:                 $locale->revert();
 719:             }
 720:         }
 721:         return sprintf('https://www.paypal.com/%s/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside',
 722:             strtolower($countryCode)
 723:         );
 724:     }
 725: 
 726:     /**
 727:      * Getter for Solution banner images
 728:      *
 729:      * @param string $localeCode
 730:      * @param bool $isVertical
 731:      * @param bool $isEcheck
 732:      */
 733:     public function getSolutionImageUrl($localeCode, $isVertical = false, $isEcheck = false)
 734:     {
 735:         return sprintf('https://www.paypal.com/%s/i/bnr/%s_solution_PP%s.gif',
 736:             $this->_getSupportedLocaleCode($localeCode),
 737:             $isVertical ? 'vertical' : 'horizontal', $isEcheck ? 'eCheck' : ''
 738:         );
 739:     }
 740: 
 741:     /**
 742:      * Getter for Payment form logo images
 743:      *
 744:      * @param string $localeCode
 745:      */
 746:     public function getPaymentFormLogoUrl($localeCode)
 747:     {
 748:         $locale = $this->_getSupportedLocaleCode($localeCode);
 749: 
 750:         $imageType = 'logo';
 751:         $domain = 'paypal.com';
 752:         list (,$country) = explode('_', $locale);
 753:         $countryPrefix = $country . '/';
 754: 
 755:         switch ($locale) {
 756:             case 'en_GB':
 757:                 $imageName = 'horizontal_solution_PP';
 758:                 $imageType = 'bnr';
 759:                 $countryPrefix = '';
 760:                 break;
 761:             case 'de_DE':
 762:                 $imageName = 'lockbox_150x47';
 763:                 break;
 764:             case 'fr_FR':
 765:                 $imageName = 'bnr_horizontal_solution_PP_327wx80h';
 766:                 $imageType = 'bnr';
 767:                 $locale = 'en_US';
 768:                 $domain = 'paypalobjects.com';
 769:                 break;
 770:             case 'it_IT':
 771:                 $imageName = 'bnr_horizontal_solution_PP_178wx80h';
 772:                 $imageType = 'bnr';
 773:                 $domain = 'paypalobjects.com';
 774:                 break;
 775:             default:
 776:                 $imageName='PayPal_mark_60x38';
 777:                 $countryPrefix = '';
 778:                 break;
 779:         }
 780:         return sprintf('https://www.%s/%s/%si/%s/%s.gif', $domain, $locale, $countryPrefix, $imageType, $imageName);
 781:     }
 782: 
 783:     /**
 784:      * Return supported types for PayPal logo
 785:      *
 786:      * @return array
 787:      */
 788:     public function getAdditionalOptionsLogoTypes()
 789:     {
 790:         return array(
 791:             'wePrefer_150x60'       => Mage::helper('paypal')->__('We prefer PayPal (150 X 60)'),
 792:             'wePrefer_150x40'       => Mage::helper('paypal')->__('We prefer PayPal (150 X 40)'),
 793:             'nowAccepting_150x60'   => Mage::helper('paypal')->__('Now accepting PayPal (150 X 60)'),
 794:             'nowAccepting_150x40'   => Mage::helper('paypal')->__('Now accepting PayPal (150 X 40)'),
 795:             'paymentsBy_150x60'     => Mage::helper('paypal')->__('Payments by PayPal (150 X 60)'),
 796:             'paymentsBy_150x40'     => Mage::helper('paypal')->__('Payments by PayPal (150 X 40)'),
 797:             'shopNowUsing_150x60'   => Mage::helper('paypal')->__('Shop now using (150 X 60)'),
 798:             'shopNowUsing_150x40'   => Mage::helper('paypal')->__('Shop now using (150 X 40)'),
 799:         );
 800:     }
 801: 
 802:     /**
 803:      * Return PayPal logo URL with additional options
 804:      *
 805:      * @param string $localeCode Supported locale code
 806:      * @param string $type One of supported logo types
 807:      * @return string|bool Logo Image URL or false if logo disabled in configuration
 808:      */
 809:     public function getAdditionalOptionsLogoUrl($localeCode, $type = false)
 810:     {
 811:         $configType = Mage::getStoreConfig($this->_mapGenericStyleFieldset('logo'), $this->_storeId);
 812:         if (!$configType) {
 813:             return false;
 814:         }
 815:         $type = $type ? $type : $configType;
 816:         $locale = $this->_getSupportedLocaleCode($localeCode);
 817:         $supportedTypes = array_keys($this->getAdditionalOptionsLogoTypes());
 818:         if (!in_array($type, $supportedTypes)) {
 819:             $type = self::DEFAULT_LOGO_TYPE;
 820:         }
 821:         return sprintf('https://www.paypalobjects.com/%s/i/bnr/bnr_%s.gif', $locale, $type);
 822:     }
 823: 
 824:     /**
 825:      * BN code getter
 826:      *
 827:      * @param string $countryCode ISO 3166-1
 828:      */
 829:     public function getBuildNotationCode($countryCode = null)
 830:     {
 831:         $product = 'WPP';
 832:         if ($this->_methodCode && isset($this->_buildNotationPPMap[$this->_methodCode])) {
 833:             $product = $this->_buildNotationPPMap[$this->_methodCode];
 834:         }
 835:         if (null === $countryCode) {
 836:             $countryCode = $this->_matchBnCountryCode($this->getMerchantCountry());
 837:         }
 838:         if ($countryCode) {
 839:             $countryCode = '_' . $countryCode;
 840:         }
 841:         return sprintf('Varien_Cart_%s%s', $product, $countryCode);
 842:     }
 843: 
 844:     /**
 845:      * Express Checkout button "flavors" source getter
 846:      *
 847:      * @return array
 848:      */
 849:     public function getExpressCheckoutButtonFlavors()
 850:     {
 851:         return array(
 852:             self::EC_FLAVOR_DYNAMIC => Mage::helper('paypal')->__('Dynamic'),
 853:             self::EC_FLAVOR_STATIC  => Mage::helper('paypal')->__('Static'),
 854:         );
 855:     }
 856: 
 857:     /**
 858:      * Express Checkout button types source getter
 859:      *
 860:      * @return array
 861:      */
 862:     public function getExpressCheckoutButtonTypes()
 863:     {
 864:         return array(
 865:             self::EC_BUTTON_TYPE_SHORTCUT => Mage::helper('paypal')->__('Shortcut'),
 866:             self::EC_BUTTON_TYPE_MARK     => Mage::helper('paypal')->__('Acceptance Mark Image'),
 867:         );
 868:     }
 869: 
 870:     /**
 871:      * Payment actions source getter
 872:      *
 873:      * @return array
 874:      */
 875:     public function getPaymentActions()
 876:     {
 877:         $paymentActions = array(
 878:             self::PAYMENT_ACTION_AUTH => Mage::helper('paypal')->__('Authorization'),
 879:             self::PAYMENT_ACTION_SALE => Mage::helper('paypal')->__('Sale')
 880:         );
 881:         if (!is_null($this->_methodCode) && $this->_methodCode == self::METHOD_WPP_EXPRESS) {
 882:             $paymentActions[self::PAYMENT_ACTION_ORDER] = Mage::helper('paypal')->__('Order');
 883:         }
 884:         return $paymentActions;
 885:     }
 886: 
 887:     /**
 888:      * Require Billing Address source getter
 889:      *
 890:      * @return array
 891:      */
 892:     public function getRequireBillingAddressOptions()
 893:     {
 894:         return array(
 895:             self::REQUIRE_BILLING_ADDRESS_ALL       => Mage::helper('paypal')->__('Yes'),
 896:             self::REQUIRE_BILLING_ADDRESS_NO        => Mage::helper('paypal')->__('No'),
 897:             self::REQUIRE_BILLING_ADDRESS_VIRTUAL   => Mage::helper('paypal')->__('For Virtual Quotes Only'),
 898:         );
 899:     }
 900: 
 901:     /**
 902:      * Mapper from PayPal-specific payment actions to Magento payment actions
 903:      *
 904:      * @return string|null
 905:      */
 906:     public function getPaymentAction()
 907:     {
 908:         switch ($this->paymentAction) {
 909:             case self::PAYMENT_ACTION_AUTH:
 910:                 return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
 911:             case self::PAYMENT_ACTION_SALE:
 912:                 return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
 913:             case self::PAYMENT_ACTION_ORDER:
 914:                 return Mage_Payment_Model_Method_Abstract::ACTION_ORDER;
 915:         }
 916:     }
 917: 
 918:     /**
 919:      * Returns array of possible Authorization Amounts for Account Verification
 920:      *
 921:      * @deprecated since 1.6.2.0
 922:      * @return array
 923:      */
 924:     public function getAuthorizationAmounts()
 925:     {
 926:         return array();
 927:     }
 928: 
 929:     /**
 930:      * Express Checkout "solution types" source getter
 931:      * "sole" = "Express Checkout for Auctions" - PayPal allows guest checkout
 932:      * "mark" = "Normal Express Checkout" - PayPal requires to checkout with PayPal buyer account only
 933:      *
 934:      * @return array
 935:      */
 936:     public function getExpressCheckoutSolutionTypes()
 937:     {
 938:         return array(
 939:             self::EC_SOLUTION_TYPE_SOLE => Mage::helper('paypal')->__('Yes'),
 940:             self::EC_SOLUTION_TYPE_MARK => Mage::helper('paypal')->__('No'),
 941:         );
 942:     }
 943: 
 944:     /**
 945:      * Retrieve express checkout billing agreement signup options
 946:      *
 947:      * @return array
 948:      */
 949:     public function getExpressCheckoutBASignupOptions()
 950:     {
 951:         return array(
 952:             self::EC_BA_SIGNUP_AUTO  => Mage::helper('paypal')->__('Auto'),
 953:             self::EC_BA_SIGNUP_ASK   => Mage::helper('paypal')->__('Ask Customer'),
 954:             self::EC_BA_SIGNUP_NEVER => Mage::helper('paypal')->__('Never')
 955:         );
 956:     }
 957: 
 958:     /**
 959:      * Whether to ask customer to create billing agreements
 960:      * Unilateral payments are incompatible with the billing agreements
 961:      *
 962:      * @return bool
 963:      */
 964:     public function shouldAskToCreateBillingAgreement()
 965:     {
 966:         return ($this->allow_ba_signup === self::EC_BA_SIGNUP_ASK) && !$this->shouldUseUnilateralPayments();
 967:     }
 968: 
 969:     /**
 970:      * Check whether only Unilateral payments (Accelerated Boarding) possible for Express method or not
 971:      *
 972:      * @return bool
 973:      */
 974:     public function shouldUseUnilateralPayments()
 975:     {
 976:         return $this->business_account && !$this->isWppApiAvailabe();
 977:     }
 978: 
 979:     /**
 980:      * Check whether WPP API credentials are available for this method
 981:      *
 982:      * @return bool
 983:      */
 984:     public function isWppApiAvailabe()
 985:     {
 986:         return $this->api_username && $this->api_password && ($this->api_signature || $this->api_cert);
 987:     }
 988: 
 989:     /**
 990:      * Payment data delivery methods getter for PayPal Standard
 991:      *
 992:      * @return array
 993:      */
 994:     public function getWpsPaymentDeliveryMethods()
 995:     {
 996:         return array(
 997:             self::WPS_TRANSPORT_IPN      => Mage::helper('adminhtml')->__('IPN (Instant Payment Notification) Only'),
 998:             // not supported yet:
 999: //            self::WPS_TRANSPORT_PDT      => Mage::helper('adminhtml')->__('PDT (Payment Data Transfer) Only'),
1000: //            self::WPS_TRANSPORT_IPN_PDT  => Mage::helper('adminhtml')->__('Both IPN and PDT'),
1001:         );
1002:     }
1003: 
1004:     /**
1005:      * Return list of supported credit card types by Paypal Direct gateway
1006:      *
1007:      * @return array
1008:      */
1009:     public function getWppCcTypesAsOptionArray()
1010:     {
1011:         $model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('AE', 'VI', 'MC', 'SM', 'SO', 'DI'));
1012:         return $model->toOptionArray();
1013:     }
1014: 
1015:     /**
1016:      * Return list of supported credit card types by Paypal Direct (Payflow Edition) gateway
1017:      *
1018:      * @return array
1019:      */
1020:     public function getWppPeCcTypesAsOptionArray()
1021:     {
1022:         $model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('VI', 'MC', 'SM', 'SO', 'OT', 'AE'));
1023:         return $model->toOptionArray();
1024:     }
1025: 
1026:     /**
1027:      * Return list of supported credit card types by Payflow Pro gateway
1028:      *
1029:      * @return array
1030:      */
1031:     public function getPayflowproCcTypesAsOptionArray()
1032:     {
1033:         $model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('AE', 'VI', 'MC', 'JCB', 'DI'));
1034:         return $model->toOptionArray();
1035:     }
1036: 
1037:     /**
1038:      * Check whether the specified payment method is a CC-based one
1039:      *
1040:      * @param string $code
1041:      * @return bool
1042:      */
1043:     public static function getIsCreditCardMethod($code)
1044:     {
1045:         switch ($code) {
1046:             case self::METHOD_WPP_DIRECT:
1047:             case self::METHOD_WPP_PE_DIRECT:
1048:             case self::METHOD_PAYFLOWPRO:
1049:             case self::METHOD_PAYFLOWLINK:
1050:             case self::METHOD_PAYFLOWADVANCED:
1051:             case self::METHOD_HOSTEDPRO:
1052:                 return true;
1053:         }
1054:         return false;
1055:     }
1056: 
1057:     /**
1058:      * Check whether specified currency code is supported
1059:      *
1060:      * @param string $code
1061:      * @return bool
1062:      */
1063:     public function isCurrencyCodeSupported($code)
1064:     {
1065:         if (in_array($code, $this->_supportedCurrencyCodes)) {
1066:             return true;
1067:         }
1068:         if ($this->getMerchantCountry() == 'BR' && $code == 'BRL') {
1069:             return true;
1070:         }
1071:         if ($this->getMerchantCountry() == 'MY' && $code == 'MYR') {
1072:             return true;
1073:         }
1074:         return false;
1075:     }
1076: 
1077:     /**
1078:      * Export page style current settings to specified object
1079:      *
1080:      * @param Varien_Object $to
1081:      */
1082:     public function exportExpressCheckoutStyleSettings(Varien_Object $to)
1083:     {
1084:         foreach ($this->_ecStyleConfigMap as $key => $exportKey) {
1085:             if ($this->$key) {
1086:                 $to->setData($exportKey, $this->$key);
1087:             }
1088:         }
1089:     }
1090: 
1091:     /**
1092:      * Dynamic PayPal image URL getter
1093:      * Also can render dynamic Acceptance Mark
1094:      *
1095:      * @param string $type
1096:      * @param string $localeCode
1097:      * @param float $orderTotal
1098:      * @param string $pal
1099:      */
1100:     protected function _getDynamicImageUrl($type, $localeCode, $orderTotal, $pal)
1101:     {
1102:         $params = array(
1103:             'cmd'        => '_dynamic-image',
1104:             'buttontype' => $type,
1105:             'locale'     => $this->_getSupportedLocaleCode($localeCode),
1106:         );
1107:         if ($orderTotal) {
1108:             $params['ordertotal'] = sprintf('%.2F', $orderTotal);
1109:             if ($pal) {
1110:                 $params['pal'] = $pal;
1111:             }
1112:         }
1113:         return sprintf('https://fpdbs%s.paypal.com/dynamicimageweb?%s',
1114:             $this->sandboxFlag ? '.sandbox' : '', http_build_query($params)
1115:         );
1116:     }
1117: 
1118:     /**
1119:      * Check whether specified locale code is supported. Fallback to en_US
1120:      *
1121:      * @param string $localeCode
1122:      * @return string
1123:      */
1124:     protected function _getSupportedLocaleCode($localeCode = null)
1125:     {
1126:         if (!$localeCode || !in_array($localeCode, $this->_supportedImageLocales)) {
1127:             return 'en_US';
1128:         }
1129:         return $localeCode;
1130:     }
1131: 
1132:     /**
1133:      * Map any supported payment method into a config path by specified field name
1134:      *
1135:      * @param string $fieldName
1136:      * @return string|null
1137:      */
1138:     protected function _getSpecificConfigPath($fieldName)
1139:     {
1140:         $path = null;
1141:         switch ($this->_methodCode) {
1142:             case self::METHOD_WPS:
1143:                 $path = $this->_mapStandardFieldset($fieldName);
1144:                 break;
1145:             case self::METHOD_WPP_EXPRESS:
1146:             case self::METHOD_WPP_PE_EXPRESS:
1147:                 $path = $this->_mapExpressFieldset($fieldName);
1148:                 break;
1149:             case self::METHOD_WPP_DIRECT:
1150:             case self::METHOD_WPP_PE_DIRECT:
1151:                 $path = $this->_mapDirectFieldset($fieldName);
1152:                 break;
1153:             case self::METHOD_BILLING_AGREEMENT:
1154:             case self::METHOD_HOSTEDPRO:
1155:                 $path = $this->_mapMethodFieldset($fieldName);
1156:                 break;
1157:         }
1158: 
1159:         if ($path === null) {
1160:             switch ($this->_methodCode) {
1161:                 case self::METHOD_WPP_EXPRESS:
1162:                 case self::METHOD_WPP_DIRECT:
1163:                 case self::METHOD_BILLING_AGREEMENT:
1164:                 case self::METHOD_HOSTEDPRO:
1165:                     $path = $this->_mapWppFieldset($fieldName);
1166:                     break;
1167:                 case self::METHOD_WPP_PE_EXPRESS:
1168:                 case self::METHOD_WPP_PE_DIRECT:
1169:                     $path = $this->_mapWpukFieldset($fieldName);
1170:                     break;
1171:             }
1172:         }
1173: 
1174:         if ($path === null) {
1175:             $path = $this->_mapGeneralFieldset($fieldName);
1176:         }
1177:         if ($path === null) {
1178:             $path = $this->_mapGenericStyleFieldset($fieldName);
1179:         }
1180:         return $path;
1181:     }
1182: 
1183:     /**
1184:      * Check wheter specified country code is supported by build notation codes for specific countries
1185:      *
1186:      * @param $code
1187:      * @return string|null
1188:      */
1189:     private function _matchBnCountryCode($code)
1190:     {
1191:         switch ($code) {
1192:             // GB == UK
1193:             case 'GB':
1194:                 return 'UK';
1195:             // Australia, Austria, Belgium, Canada, China, France, Germany, Hong Kong, Italy
1196:             case 'AU': case 'AT': case 'BE': case 'CA': case 'CN': case 'FR': case 'DE': case 'HK': case 'IT':
1197:             // Japan, Mexico, Netherlands, Poland, Singapore, Spain, Switzerland, United Kingdom, United States
1198:             case 'JP': case 'MX': case 'NL': case 'PL': case 'SG': case 'ES': case 'CH': case 'UK': case 'US':
1199:                 return $code;
1200:         }
1201:     }
1202: 
1203:     /**
1204:      * Map PayPal Standard config fields
1205:      *
1206:      * @param string $fieldName
1207:      * @return string|null
1208:      */
1209:     protected function _mapStandardFieldset($fieldName)
1210:     {
1211:         switch ($fieldName)
1212:         {
1213:             case 'line_items_summary':
1214:             case 'sandbox_flag':
1215:                 return 'payment/' . self::METHOD_WPS . "/{$fieldName}";
1216:             default:
1217:                 return $this->_mapMethodFieldset($fieldName);
1218:         }
1219:     }
1220: 
1221:     /**
1222:      * Map PayPal Express config fields
1223:      *
1224:      * @param string $fieldName
1225:      * @return string|null
1226:      */
1227:     protected function _mapExpressFieldset($fieldName)
1228:     {
1229:         switch ($fieldName)
1230:         {
1231:             case 'transfer_shipping_options':
1232:             case 'solution_type':
1233:             case 'visible_on_cart':
1234:             case 'visible_on_product':
1235:             case 'require_billing_address':
1236:             case 'authorization_honor_period':
1237:             case 'order_valid_period':
1238:             case 'child_authorization_number':
1239:             case 'allow_ba_signup':
1240:                 return "payment/{$this->_methodCode}/{$fieldName}";
1241:             default:
1242:                 return $this->_mapMethodFieldset($fieldName);
1243:         }
1244:     }
1245: 
1246:     /**
1247:      * Map PayPal Direct config fields
1248:      *
1249:      * @param string $fieldName
1250:      * @return string|null
1251:      */
1252:     protected function _mapDirectFieldset($fieldName)
1253:     {
1254:         switch ($fieldName)
1255:         {
1256:             case 'useccv':
1257:             case 'centinel':
1258:             case 'centinel_is_mode_strict':
1259:             case 'centinel_api_url':
1260:                 return "payment/{$this->_methodCode}/{$fieldName}";
1261:             default:
1262:                 return $this->_mapMethodFieldset($fieldName);
1263:         }
1264:     }
1265: 
1266:     /**
1267:      * Map PayPal Website Payments Pro common config fields
1268:      *
1269:      * @param string $fieldName
1270:      * @return string|null
1271:      */
1272:     protected function _mapWppFieldset($fieldName)
1273:     {
1274:         switch ($fieldName)
1275:         {
1276:             case 'api_authentication':
1277:             case 'api_username':
1278:             case 'api_password':
1279:             case 'api_signature':
1280:             case 'api_cert':
1281:             case 'sandbox_flag':
1282:             case 'use_proxy':
1283:             case 'proxy_host':
1284:             case 'proxy_port':
1285:             case 'button_flavor':
1286:                 return "paypal/wpp/{$fieldName}";
1287:             default:
1288:                 return null;
1289:         }
1290:     }
1291: 
1292:     /**
1293:      * Map PayPal Website Payments Pro common config fields
1294:      *
1295:      * @param string $fieldName
1296:      * @return string|null
1297:      */
1298:     protected function _mapWpukFieldset($fieldName)
1299:     {
1300:         $pathPrefix = 'paypal/wpuk';
1301:         // Use PUMP credentials from Verisign for EC when Direct Payments are unavailable
1302:         if ($this->_methodCode == self::METHOD_WPP_PE_EXPRESS
1303:             && !$this->isMethodAvailable(self::METHOD_WPP_PE_DIRECT)) {
1304:             $pathPrefix = 'payment/verisign';
1305:         }
1306:         switch ($fieldName) {
1307:             case 'partner':
1308:             case 'user':
1309:             case 'vendor':
1310:             case 'pwd':
1311:             case 'sandbox_flag':
1312:             case 'use_proxy':
1313:             case 'proxy_host':
1314:             case 'proxy_port':
1315:                 return $pathPrefix . '/' . $fieldName;
1316:             default:
1317:                 return null;
1318:         }
1319:     }
1320: 
1321:     /**
1322:      * Map PayPal common style config fields
1323:      *
1324:      * @param string $fieldName
1325:      * @return string|null
1326:      */
1327:     protected function _mapGenericStyleFieldset($fieldName)
1328:     {
1329:         switch ($fieldName) {
1330:             case 'logo':
1331:             case 'page_style':
1332:             case 'paypal_hdrimg':
1333:             case 'paypal_hdrbackcolor':
1334:             case 'paypal_hdrbordercolor':
1335:             case 'paypal_payflowcolor':
1336:                 return "paypal/style/{$fieldName}";
1337:             default:
1338:                 return null;
1339:         }
1340:     }
1341: 
1342:     /**
1343:      * Map PayPal General Settings
1344:      *
1345:      * @param string $fieldName
1346:      * @return string|null
1347:      */
1348:     protected function _mapGeneralFieldset($fieldName)
1349:     {
1350:         switch ($fieldName)
1351:         {
1352:             case 'business_account':
1353:             case 'merchant_country':
1354:                 return "paypal/general/{$fieldName}";
1355:             default:
1356:                 return null;
1357:         }
1358:     }
1359: 
1360:     /**
1361:      * Map PayPal General Settings
1362:      *
1363:      * @param string $fieldName
1364:      * @return string|null
1365:      */
1366:     protected function _mapMethodFieldset($fieldName)
1367:     {
1368:         if (!$this->_methodCode) {
1369:             return null;
1370:         }
1371:         switch ($fieldName)
1372:         {
1373:             case 'active':
1374:             case 'title':
1375:             case 'payment_action':
1376:             case 'allowspecific':
1377:             case 'specificcountry':
1378:             case 'line_items_enabled':
1379:             case 'cctypes':
1380:             case 'sort_order':
1381:             case 'debug':
1382:             case 'verify_peer':
1383:                 return "payment/{$this->_methodCode}/{$fieldName}";
1384:             default:
1385:                 return null;
1386:         }
1387:     }
1388: 
1389:     /**
1390:      * Payment API authentication methods source getter
1391:      *
1392:      * @return array
1393:      */
1394:     public function getApiAuthenticationMethods()
1395:     {
1396:         return array(
1397:             '0' => Mage::helper('paypal')->__('API Signature'),
1398:             '1' => Mage::helper('paypal')->__('API Certificate')
1399:         );
1400:     }
1401: 
1402:     /**
1403:      * Api certificate getter
1404:      *
1405:      * @return string
1406:      */
1407:     public function getApiCertificate()
1408:     {
1409:         $websiteId = Mage::app()->getStore($this->_storeId)->getWebsiteId();
1410:         return Mage::getModel('paypal/cert')->loadByWebsite($websiteId, false)->getCertPath();
1411:     }
1412: }
1413: 
1414: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0