Changeset 136 for trunk/lib/PayPal.inc.php
- Timestamp:
- Jun 3, 2006 7:47:48 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/PayPal.inc.php
r42 r136 1 1 <?php 2 2 /** 3 * The PayPal:: class provides functions for creating PayPal buttons and for 3 * PayPal.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 6 * The PayPal class provides functions for creating PayPal buttons and for 4 7 * receiving PayPal's Instant Payment Notification (IPN) service. 5 8 * … … 74 77 function setButtonDefaults($type, $options) 75 78 { 79 $app =& App::getInstance(); 80 76 81 if (!is_array($options) || empty($options)) { 77 App::logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);82 $app->logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__); 78 83 return false; 79 84 } … … 82 87 $this->_default_button_options['_global'] = array_merge($this->_default_button_options['_global'], $options); 83 88 } else if (!isset($this->_default_button_options[$type])) { 84 App::logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__);89 $app->logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__); 85 90 return false; 86 91 } … … 104 109 function newButton($type, $name, $options=null) 105 110 { 111 $app =& App::getInstance(); 112 106 113 if (!isset($this->_default_button_options[$type])) { 107 App::logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__);114 $app->logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__); 108 115 return false; 109 116 } 110 117 111 118 if (!is_array($options) || empty($options)) { 112 App::logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);119 $app->logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__); 113 120 return false; 114 121 } 115 122 116 123 if (isset($this->_buttons[$name])) { 117 App::logMsg(sprintf('Overwriting existing button name: %s', getDump($this->_buttons[$name])), LOG_DEBUG, __FILE__, __LINE__);124 $app->logMsg(sprintf('Overwriting existing button name: %s', getDump($this->_buttons[$name])), LOG_DEBUG, __FILE__, __LINE__); 118 125 } 119 126 … … 137 144 function getLink($name) 138 145 { 146 $app =& App::getInstance(); 147 139 148 if (!isset($this->_buttons[$name])) { 140 App::logMsg(sprintf('Button does not exist: %s', $name), LOG_WARNING, __FILE__, __LINE__);149 $app->logMsg(sprintf('Button does not exist: %s', $name), LOG_WARNING, __FILE__, __LINE__); 141 150 return false; 142 151 } … … 207 216 function setParam($params) 208 217 { 218 $app =& App::getInstance(); 219 209 220 if (isset($params) && is_array($params)) { 210 221 // Merge new parameters with old overriding only those passed. 211 222 $this->_params = array_merge($this->_params, $params); 212 223 } else { 213 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);224 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 214 225 } 215 226 } … … 224 235 function getParam($param) 225 236 { 237 $app =& App::getInstance(); 238 226 239 if (isset($this->_params[$param])) { 227 240 return $this->_params[$param]; 228 241 } else { 229 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);242 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 230 243 return null; 231 244 } … … 259 272 function processIPN() 260 273 { 274 $app =& App::getInstance(); 275 261 276 if (getPost('test_ipn') == '1' || $this->getParam('test_mode')) { 262 App::logMsg(sprintf('Processing PayPal IPN in test mode: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__);277 $app->logMsg(sprintf('Processing PayPal IPN in test mode: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__); 263 278 $url = parse_url('https://www.sandbox.paypal.com/cgi-bin/webscr'); 264 279 } else { 265 App::logMsg(sprintf('Processing PayPal IPN: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__);280 $app->logMsg(sprintf('Processing PayPal IPN: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__); 266 281 $url = parse_url($this->getParam('paypal_url')); 267 282 } … … 287 302 288 303 if (!$fp) { 289 App::logMsg(sprintf('Connection to PayPal URL %s failed with error: %s (%s)', $ssl . $url['host'], $errstr, $errnum), LOG_WARNING, __FILE__, __LINE__);304 $app->logMsg(sprintf('Connection to PayPal URL %s failed with error: %s (%s)', $ssl . $url['host'], $errstr, $errnum), LOG_WARNING, __FILE__, __LINE__); 290 305 return false; 291 306 } else { … … 304 319 fclose($fp); 305 320 306 App::logMsg(sprintf('IPN response received: %s', $this->_ipn_response), LOG_NOTICE, __FILE__, __LINE__);321 $app->logMsg(sprintf('IPN response received: %s', $this->_ipn_response), LOG_NOTICE, __FILE__, __LINE__); 307 322 return true; 308 323 } … … 318 333 function verifiedIPN() 319 334 { 335 $app =& App::getInstance(); 336 320 337 if (!isset($this->_ipn_response)) { 321 App::logMsg(sprintf('Cannot verify IPN, response not received.', null), LOG_WARNING, __FILE__, __LINE__);338 $app->logMsg(sprintf('Cannot verify IPN, response not received.', null), LOG_WARNING, __FILE__, __LINE__); 322 339 return false; 323 340 } 324 341 325 342 if (empty($this->_ipn_response)) { 326 App::logMsg(sprintf('Cannot verify IPN, response empty.', null), LOG_WARNING, __FILE__, __LINE__);343 $app->logMsg(sprintf('Cannot verify IPN, response empty.', null), LOG_WARNING, __FILE__, __LINE__); 327 344 return false; 328 345 } 329 346 330 347 if (preg_match('/VERIFIED/', $this->_ipn_response)) { 331 App::logMsg(sprintf('IPN verified!', null), LOG_DEBUG, __FILE__, __LINE__);348 $app->logMsg(sprintf('IPN verified!', null), LOG_DEBUG, __FILE__, __LINE__); 332 349 return true; 333 350 } else if (preg_match('/INVALID/', $this->_ipn_response)) { 334 App::logMsg(sprintf('IPN invalid.', null), LOG_DEBUG, __FILE__, __LINE__);335 return false; 336 } else { 337 App::logMsg(sprintf('IPN unknown.', null), LOG_WARNING, __FILE__, __LINE__);351 $app->logMsg(sprintf('IPN invalid.', null), LOG_DEBUG, __FILE__, __LINE__); 352 return false; 353 } else { 354 $app->logMsg(sprintf('IPN unknown.', null), LOG_WARNING, __FILE__, __LINE__); 338 355 return false; 339 356 }
Note: See TracChangeset
for help on using the changeset viewer.