[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZPaypalGateway class 4 // 5 // Created on: <18-Jul-2004 14:18:58 dl> 6 // 7 // SOFTWARE NAME: eZ Paypal Payment Gateway 8 // SOFTWARE RELEASE: 1.0 9 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 10 // SOFTWARE LICENSE: GNU General Public License v2.0 11 // NOTICE: > 12 // This program is free software; you can redistribute it and/or 13 // modify it under the terms of version 2.0 of the GNU General 14 // Public License as published by the Free Software Foundation. 15 // 16 // This program is distributed in the hope that it will be useful, 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 // GNU General Public License for more details. 20 // 21 // You should have received a copy of version 2.0 of the GNU General 22 // Public License along with this program; if not, write to the Free 23 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 24 // MA 02110-1301, USA. 25 // 26 // 27 // 28 29 /*! \file ezpaypalgateway.php 30 */ 31 32 /*! 33 \class eZPaypalGateway ezpaypalgateway.php 34 \brief The class eZPaypalGateway implements 35 functions to perform redirection to the PayPal 36 payment server. 37 */ 38 39 include_once ( 'kernel/shop/classes/ezpaymentobject.php' ); 40 include_once ( 'kernel/shop/classes/ezredirectgateway.php' ); 41 42 //__DEBUG__ 43 include_once ( 'kernel/classes/workflowtypes/event/ezpaymentgateway/ezpaymentlogger.php' ); 44 //___end____ 45 46 define( "EZ_PAYMENT_GATEWAY_TYPE_PAYPAL", "ezpaypal" ); 47 48 class eZPaypalGateway extends eZRedirectGateway 49 { 50 /*! 51 Constructor. 52 */ 53 function eZPaypalGateway() 54 { 55 //__DEBUG__ 56 $this->logger = eZPaymentLogger::CreateForAdd( "var/log/eZPaypalType.log" ); 57 $this->logger->writeTimedString( 'eZPaypalGateway::eZPaypalGateway()' ); 58 //___end____ 59 } 60 61 /*! 62 Creates new eZPaypalGateway object. 63 */ 64 function &createPaymentObject( &$processID, &$orderID ) 65 { 66 //__DEBUG__ 67 $this->logger->writeTimedString("createPaymentObject"); 68 //___end____ 69 70 return eZPaymentObject::createNew( $processID, $orderID, 'Paypal' ); 71 } 72 73 /*! 74 Creates redirectional url to paypal server. 75 */ 76 function &createRedirectionUrl( &$process ) 77 { 78 //__DEBUG__ 79 $this->logger->writeTimedString("createRedirectionUrl"); 80 //___end____ 81 82 $paypalINI =& eZINI::instance( 'paypal.ini' ); 83 84 $paypalServer = $paypalINI->variable( 'ServerSettings', 'ServerName'); 85 $requestURI = $paypalINI->variable( 'ServerSettings', 'RequestURI'); 86 $business = urlencode( $paypalINI->variable( 'PaypalSettings', 'Business' ) ); 87 88 $processParams =& $process->attribute( 'parameter_list' ); 89 $orderID = $processParams['order_id']; 90 91 $indexDir = eZSys::indexDir(); 92 $localHost = eZSys::serverURL(); 93 $localURI = eZSys::serverVariable( 'REQUEST_URI' ); 94 95 $order =& eZOrder::fetch( $orderID ); 96 $amount = urlencode( $order->attribute( 'total_inc_vat' ) ); 97 98 include_once ( 'lib/ezlocale/classes/ezlocale.php' ); 99 $locale =& eZLocale::instance(); 100 $currency = urlencode( $locale->currencyShortName() ); 101 $countryCode = urlencode($locale->countryCode()); 102 103 $maxDescLen = $paypalINI->variable( 'PaypalSettings', 'MaxDescriptionLength'); 104 $itemName = urlencode( $this->createShortDescription( $order, $maxDescLen ) ); 105 106 $accountInfo = $order->attribute( 'account_information' ); 107 $first_name = urlencode( $accountInfo['first_name'] ); 108 $last_name = urlencode( $accountInfo['last_name'] ); 109 $street = urlencode( $accountInfo['street2'] ); 110 $zip = urlencode( $accountInfo['zip'] ); 111 $state = urlencode( $accountInfo['state'] ); 112 $place = urlencode( $accountInfo['place'] ); 113 $image_url = "$localHost" . urlencode( $paypalINI->variable( 'PaypalSettings', 'LogoURI' ) ); 114 $background = urlencode( $paypalINI->variable( 'PaypalSettings', 'BackgroundColor' ) ); 115 $pageStyle = urlencode( $paypalINI->variable( 'PaypalSettings', 'PageStyle' ) ); 116 $noNote = urlencode( $paypalINI->variable( 'PaypalSettings', 'NoNote' ) ); 117 $noteLabel = ($noNote == 1) ? '' : urlencode( $paypalINI->variable( 'PaypalSettings', 'NoteLabel' ) ); 118 $noShipping = 1; 119 120 $url = $paypalServer . $requestURI . 121 "?cmd=_ext-enter" . 122 "&redirect_cmd=_xclick" . 123 "&business=$business" . 124 "&item_name=$itemName" . 125 "&custom=$orderID" . 126 "&amount=$amount" . 127 "¤cy_code=$currency" . 128 "&first_name=$first_name" . 129 "&last_name=$last_name" . 130 "&address1=$street" . 131 "&zip=$zip" . 132 "&state=$state" . 133 "&city=$place" . 134 "&image_url=$image_url" . 135 "&cs=$background" . 136 "&page_style=$pageStyle" . 137 "&no_shipping=$noShipping" . 138 "&cn=$noteLabel" . 139 "&no_note=$noNote" . 140 "&lc=$countryCode" . 141 "¬ify_url=$localHost" . $indexDir . "/paypal/notify_url/". 142 "&return=$localHost" . $indexDir . "/shop/checkout/" . 143 "&cancel_return=$localHost" . $indexDir . "/shop/basket/"; 144 145 //__DEBUG__ 146 $this->logger->writeTimedString("business = $business"); 147 $this->logger->writeTimedString("item_name = $itemName"); 148 $this->logger->writeTimedString("custom = $orderID"); 149 $this->logger->writeTimedString("no_shipping = $noShipping"); 150 $this->logger->writeTimedString("localHost = $localHost"); 151 $this->logger->writeTimedString("amount = $amount"); 152 $this->logger->writeTimedString("currency_code = $currency"); 153 $this->logger->writeTimedString("notify_url = $localHost" . $indexDir . "/paypal/notify_url/"); 154 $this->logger->writeTimedString("return = $localHost" . $indexDir . "/shop/checkout/"); 155 $this->logger->writeTimedString("cancel_return = $localHost" . $indexDir ."/shop/basket/"); 156 //___end____ 157 158 return $url; 159 } 160 } 161 162 eZPaymentGatewayType::registerGateway( EZ_PAYMENT_GATEWAY_TYPE_PAYPAL, "ezpaypalgateway", "Paypal" ); 163 164 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |