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:  *  Website Payments Pro Hosted Solution request model to get token.
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_Paypal
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: 
 35: class Mage_Paypal_Model_Hostedpro_Request extends Varien_Object
 36: {
 37:     /**
 38:      * Request's order model
 39:      *
 40:      * @var Mage_Sales_Model_Order
 41:      */
 42:     protected $_order;
 43: 
 44:     /**
 45:      * Request's Hosted Pro payment method model
 46:      *
 47:      * @var Mage_Paypal_Model_Hostedpro
 48:      */
 49:     protected $_paymentMethod;
 50: 
 51:     /**
 52:      * Name formate for button variables
 53:      *
 54:      * @var string
 55:      */
 56:     protected $_buttonVarFormat = 'L_BUTTONVAR%d';
 57: 
 58:     /**
 59:      * Request Parameters which dont have to wrap as button vars
 60:      *
 61:      * @var array
 62:      */
 63:     protected $_notButtonVars = array (
 64:         'METHOD', 'BUTTONCODE', 'BUTTONTYPE');
 65: 
 66:     /**
 67:      * Build and return request array from object data
 68:      *
 69:      * @return array
 70:      */
 71:     public function getRequestData()
 72:     {
 73:         $requestData = array();
 74:         if (!empty($this->_data)) {
 75:             // insert params to request as additional button variables,
 76:             // except special params from _notButtonVars list
 77:             $i = 0;
 78:             foreach ($this->_data as $key => $value) {
 79:                 if (in_array($key, $this->_notButtonVars)) {
 80:                     $requestData[$key] = $value;
 81:                 } else {
 82:                     $varKey = sprintf($this->_buttonVarFormat, $i);
 83:                     $requestData[$varKey] = $key . '=' . $value;
 84:                     $i++;
 85:                 }
 86:             }
 87:         }
 88: 
 89:         return $requestData;
 90:     }
 91: 
 92:     /**
 93:      * Append payment data to request
 94:      *
 95:      * @param Mage_Paypal_Model_Hostedpro $paymentMethod
 96:      * @return Mage_Paypal_Model_Hostedpro_Request
 97:      */
 98:     public function setPaymentMethod($paymentMethod)
 99:     {
100:         $this->_paymentMethod = $paymentMethod;
101:         $requestData = $this->_getPaymentData($paymentMethod);
102:         $this->addData($requestData);
103: 
104:         return $this;
105:     }
106: 
107:     /**
108:      * Append order data to request
109:      *
110:      * @param Mage_Sales_Model_Order $order
111:      * @return Mage_Paypal_Model_Hostedpro_Request
112:      */
113:     public function setOrder($order)
114:     {
115:         $this->_order = $order;
116:         $requestData = $this->_getOrderData($order);
117:         $this->addData($requestData);
118: 
119:         return $this;
120:     }
121: 
122:     /**
123:      * Get peymet request data as array
124:      *
125:      * @param Mage_Paypal_Model_Hostedpro $paymentMethod
126:      * @return array
127:      */
128:     protected function _getPaymentData(Mage_Paypal_Model_Hostedpro $paymentMethod)
129:     {
130:         $request = array(
131:             'paymentaction' => strtolower($paymentMethod->getConfigData('payment_action')),
132:             'notify_url'    => $paymentMethod->getNotifyUrl(),
133:             'cancel_return' => $paymentMethod->getCancelUrl(),
134:             'return'        => $paymentMethod->getReturnUrl(),
135:             'lc'            => $paymentMethod->getMerchantCountry(),
136: 
137:             'template'              => 'templateD',
138:             'showBillingAddress'    => 'false',
139:             'showShippingAddress'   => 'false',
140:             'showBillingEmail'      => 'false',
141:             'showBillingPhone'      => 'false',
142:             'showCustomerName'      => 'false',
143:             'showCardInfo'          => 'true',
144:             'showHostedThankyouPage'=> 'false'
145:         );
146: 
147:         return $request;
148:     }
149: 
150:     /**
151:      * Get order request data as array
152:      *
153:      * @param Mage_Sales_Model_Order $order
154:      * @return array
155:      */
156:     protected function _getOrderData(Mage_Sales_Model_Order $order)
157:     {
158:         $request = array(
159:             'subtotal'      => $this->_formatPrice(
160:                 $this->_formatPrice($order->getPayment()->getBaseAmountAuthorized()) -
161:                 $this->_formatPrice($order->getBaseTaxAmount()) -
162:                 $this->_formatPrice($order->getBaseShippingAmount())
163:             ),
164:             'tax'           => $this->_formatPrice($order->getBaseTaxAmount()),
165:             'shipping'      => $this->_formatPrice($order->getBaseShippingAmount()),
166:             'invoice'       => $order->getIncrementId(),
167:             'address_override' => 'false',
168:             'currency_code'    => $order->getBaseCurrencyCode(),
169:             'buyer_email'      => $order->getCustomerEmail()
170:         );
171: 
172:         // append to request billing address data
173:         if ($billingAddress = $order->getBillingAddress()) {
174:             $request = array_merge($request, $this->_getBillingAddress($billingAddress));
175:         }
176: 
177:         // append to request shipping address data
178:         if ($shippingAddress = $order->getShippingAddress()) {
179:             $request = array_merge($request, $this->_getShippingAddress($shippingAddress));
180:         }
181: 
182:         return $request;
183:     }
184: 
185:     /**
186:      * Get shipping address request data
187:      *
188:      * @param Varien_Object $address
189:      * @return array
190:      */
191:     protected function _getShippingAddress(Varien_Object $address)
192:     {
193:         $request = array(
194:             'first_name'=> $address->getFirstname(),
195:             'last_name' => $address->getLastname(),
196:             'city'      => $address->getCity(),
197:             'state'     => $address->getRegion(),
198:             'zip'       => $address->getPostcode(),
199:             'country'   => $address->getCountry(),
200:         );
201: 
202:         // convert streets to tow lines format
203:         $street = Mage::helper('customer/address')
204:             ->convertStreetLines($address->getStreet(), 2);
205: 
206:         $request['address1'] = isset($street[0]) ? $street[0]: '';
207:         $request['address2'] = isset($street[1]) ? $street[1]: '';
208: 
209:         return $request;
210:     }
211: 
212:     /**
213:      * Get billing address request data
214:      *
215:      * @param Varien_Object $address
216:      * @return array
217:      */
218:     protected function _getBillingAddress(Varien_Object $address)
219:     {
220:         $request = array(
221:             'billing_first_name'=> $address->getFirstname(),
222:             'billing_last_name' => $address->getLastname(),
223:             'billing_city'      => $address->getCity(),
224:             'billing_state'     => $address->getRegion(),
225:             'billing_zip'       => $address->getPostcode(),
226:             'billing_country'   => $address->getCountry(),
227:         );
228: 
229:         // convert streets to tow lines format
230:         $street = Mage::helper('customer/address')
231:             ->convertStreetLines($address->getStreet(), 2);
232: 
233:         $request['billing_address1'] = isset($street[0]) ? $street[0]: '';
234:         $request['billing_address2'] = isset($street[1]) ? $street[1]: '';
235: 
236:         return $request;
237:     }
238: 
239:     /**
240:      * Format price string
241:      *
242:      * @param mixed $string
243:      * @return mixed
244:      */
245:     protected function _formatPrice($string)
246:     {
247:         return sprintf('%.2F', $string);
248:     }
249: }
250: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0