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 Standard checkout request API
 29:  */
 30: class Mage_Paypal_Model_Api_Standard extends Mage_Paypal_Model_Api_Abstract
 31: {
 32:     /**
 33:      * Global interface map and export filters
 34:      * @var array
 35:      */
 36:     protected $_globalMap = array(
 37:         // commands
 38:         'business'      => 'business_account',
 39:         'notify_url'    => 'notify_url',
 40:         'return'        => 'return_url',
 41:         'cancel_return' => 'cancel_url',
 42:         'bn'            => 'build_notation_code',
 43:         'paymentaction' => 'payment_action',
 44:         // payment
 45:         'invoice'       => 'order_id',
 46:         'currency_code' => 'currency_code',
 47:         'amount'        => 'amount',
 48:         'shipping'      => 'shipping_amount',
 49:         'tax'           => 'tax_amount',
 50:         'discount_amount' => 'discount_amount',
 51:         // misc
 52:         'item_name'        => 'cart_summary',
 53:         // page design settings
 54:         'page_style'             => 'page_style',
 55:         'cpp_header_image'       => 'hdrimg',
 56:         'cpp_headerback_color'   => 'hdrbackcolor',
 57:         'cpp_headerborder_color' => 'hdrbordercolor',
 58:         'cpp_payflow_color'      => 'payflowcolor',
 59: //        'cs' => '', // TODO
 60:         'lc'                     => 'locale',
 61:     );
 62:     protected $_exportToRequestFilters = array(
 63:         'amount'   => '_filterAmount',
 64:         'shipping' => '_filterAmount',
 65:         'tax'      => '_filterAmount',
 66:         'discount_amount' => '_filterAmount',
 67:     );
 68: 
 69:     /**
 70:      * Interface for common and "aggregated order" specific fields
 71:      * @var array
 72:      */
 73:     protected $_commonRequestFields = array(
 74:         'business', 'invoice', 'currency_code', 'paymentaction', 'return', 'cancel_return', 'notify_url', 'bn',
 75:         'page_style', 'cpp_header_image', 'cpp_headerback_color', 'cpp_headerborder_color', 'cpp_payflow_color',
 76:         'amount', 'shipping', 'tax', 'discount_amount', 'item_name', 'lc',
 77:     );
 78: 
 79:    /**
 80:      * Fields that should be replaced in debug with '***'
 81:      *
 82:      * @var array
 83:      */
 84:     protected $_debugReplacePrivateDataKeys = array('business');
 85: 
 86:     /**
 87:      * Line items export mapping settings
 88:      * @var array
 89:      */
 90:     protected $_lineItemTotalExportMap = array(
 91:         Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL => 'amount',
 92:         Mage_Paypal_Model_Cart::TOTAL_DISCOUNT => 'discount_amount',
 93:         Mage_Paypal_Model_Cart::TOTAL_TAX      => 'tax',
 94:         Mage_Paypal_Model_Cart::TOTAL_SHIPPING => 'shipping',
 95:     );
 96:     protected $_lineItemExportItemsFormat = array(
 97:         'id'     => 'item_number_%d',
 98:         'name'   => 'item_name_%d',
 99:         'qty'    => 'quantity_%d',
100:         'amount' => 'amount_%d',
101:     );
102: 
103:     protected $_lineItemExportItemsFilters = array(
104:          'qty'      => '_filterQty'
105:     );
106: 
107:     /**
108:      * Address export to request map
109:      * @var array
110:      */
111:     protected $_addressMap = array(
112:         'city'       => 'city',
113:         'country'    => 'country_id',
114:         'email'      => 'email',
115:         'first_name' => 'firstname',
116:         'last_name'  => 'lastname',
117:         'zip'        => 'postcode',
118:         'state'      => 'region',
119:         'address1'   => 'street',
120:         'address2'   => 'street2',
121:     );
122: 
123:     /**
124:      * Generate PayPal Standard checkout request fields
125:      * Depending on whether there are cart line items set, will aggregate everything or display items specifically
126:      * Shipping amount in cart line items is implemented as a separate "fake" line item
127:      */
128:     public function getStandardCheckoutRequest()
129:     {
130:         $request = $this->_exportToRequest($this->_commonRequestFields);
131:         $request['charset'] = 'utf-8';
132: 
133:         $isLineItems = $this->_exportLineItems($request);
134:         if ($isLineItems) {
135:             $request = array_merge($request, array(
136:                 'cmd'    => '_cart',
137:                 'upload' => 1,
138:             ));
139:             if (isset($request['tax'])) {
140:                 $request['tax_cart'] = $request['tax'];
141:             }
142:             if (isset($request['discount_amount'])) {
143:                 $request['discount_amount_cart'] = $request['discount_amount'];
144:             }
145:         } else {
146:             $request = array_merge($request, array(
147:                 'cmd'           => '_ext-enter',
148:                 'redirect_cmd'  => '_xclick',
149:             ));
150:         }
151: 
152:         // payer address
153:         $this->_importAddress($request);
154:         $this->_debug(array('request' => $request)); // TODO: this is not supposed to be called in getter
155:         return $request;
156:     }
157: 
158:     /**
159:      * Merchant account email getter
160:      * @return string
161:      */
162:     public function getBusinessAccount()
163:     {
164:         return $this->_getDataOrConfig('business_account');
165:     }
166: 
167:     /**
168:      * Payment action getter
169:      * @return string
170:      */
171:     public function getPaymentAction()
172:     {
173:         return strtolower(parent::getPaymentAction());
174:     }
175: 
176:     /**
177:      * @deprecated after 1.4.1.0
178:      *
179:      * @param array $request
180:      */
181:     public function debugRequest($request)
182:     {
183:         return;
184:     }
185: 
186:     /**
187:      * Add shipping total as a line item.
188:      * For some reason PayPal ignores shipping total variables exactly when line items is enabled
189:      * Note that $i = 1
190:      *
191:      * @param array $request
192:      * @param int $i
193:      * @return true|null
194:      */
195:     protected function _exportLineItems(array &$request, $i = 1)
196:     {
197:         if (!$this->_cart) {
198:             return;
199:         }
200:         if ($this->getIsLineItemsEnabled()) {
201:             $this->_cart->isShippingAsItem(true);
202:         }
203:         return parent::_exportLineItems($request, $i);
204:     }
205: 
206:     /**
207:      * Import address object, if set, to the request
208:      *
209:      * @param array $request
210:      */
211:     protected function _importAddress(&$request)
212:     {
213:         $address = $this->getAddress();
214:         if (!$address) {
215:             if ($this->getNoShipping()) {
216:                 $request['no_shipping'] = 1;
217:             }
218:             return;
219:         }
220: 
221:         $request = Varien_Object_Mapper::accumulateByMap($address, $request, array_flip($this->_addressMap));
222: 
223:         // Address may come without email info (user is not always required to enter it), so add email from order
224:         if (!$request['email']) {
225:             $order = $this->getOrder();
226:             if ($order) {
227:                 $request['email'] = $order->getCustomerEmail();
228:             }
229:         }
230: 
231:         $regionCode = $this->_lookupRegionCodeFromAddress($address);
232:         if ($regionCode) {
233:             $request['state'] = $regionCode;
234:         }
235:         $this->_importStreetFromAddress($address, $request, 'address1', 'address2');
236:         $this->_applyCountryWorkarounds($request);
237: 
238:         $request['address_override'] = 1;
239:     }
240: 
241:     /**
242:      * Adopt specified request array to be compatible with Paypal
243:      * Puerto Rico should be as state of USA and not as a country
244:      *
245:      * @param array $request
246:      */
247:     protected function _applyCountryWorkarounds(&$request)
248:     {
249:         if (isset($request['country']) && $request['country'] == 'PR') {
250:             $request['country'] = 'US';
251:             $request['state']   = 'PR';
252:         }
253:     }
254: }
255: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0