[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZPaypalChecker 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 ezpaypalchecker.php 30 */ 31 32 /*! 33 \class eZPaypalChecker ezpaypalchecker.php 34 \brief The class eZPaypalChecker implements 35 functions to perform verification of the 36 paypal's callback. 37 */ 38 39 include_once ( 'kernel/shop/classes/ezpaymentcallbackchecker.php' ); 40 41 class eZPaypalChecker extends eZPaymentCallbackChecker 42 { 43 /*! 44 Constructor. 45 */ 46 function eZPaypalChecker( $iniFile ) 47 { 48 $this->eZPaymentCallbackChecker( $iniFile ); 49 $this->logger =& eZPaymentLogger::CreateForAdd( 'var/log/eZPaypalChecker.log' ); 50 } 51 52 /*! 53 Asks paypal's server to validate callback. 54 */ 55 function requestValidation() 56 { 57 $server = $this->ini->variable( 'ServerSettings', 'ServerName'); 58 //$serverPort = $this->ini->variable( 'ServerSettings', 'ServerPort'); 59 $serverPort = 80; 60 $requestURI = $this->ini->variable( 'ServerSettings', 'RequestURI'); 61 $request = $this->buildRequestString(); 62 $response = $this->sendPOSTRequest( $server, $serverPort, $requestURI, $request); 63 64 $this->logger->writeTimedString( $response, 'requestValidation. response from server is' ); 65 66 if( $response && strcasecmp( $response, 'VERIFIED' ) == 0 ) 67 { 68 return true; 69 } 70 71 $this->logger->writeTimedString( 'invalid response' ); 72 return false; 73 } 74 75 /*! 76 Convinces of completion of the payment. 77 */ 78 function checkPaymentStatus() 79 { 80 if( $this->checkDataField( 'payment_status', 'Completed' ) ) 81 { 82 return true; 83 } 84 85 $this->logger->writeTimedString( 'checkPaymentStatus faild' ); 86 return false; 87 } 88 89 // overrides 90 /*! 91 Creates resquest string which is used to 92 confirm paypal's callback. 93 */ 94 function &buildRequestString() 95 { 96 $request = "cmd=_notify-validate"; 97 foreach( $this->callbackData as $key => $value ) 98 { 99 $request .= "&$key=".urlencode( $value ); 100 } 101 return $request; 102 } 103 104 function &handleResponse( &$socket ) 105 { 106 if( $socket ) 107 { 108 while ( !feof( $socket ) ) 109 { 110 $response = fgets ( $socket, 1024 ); 111 } 112 113 fclose( $socket ); 114 return $response; 115 } 116 117 $this->logger->writeTimedString( "socket = $socket is invalid.", 'handlePOSTResponse faild' ); 118 return null; 119 } 120 } 121 122 ?>
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 |