Changeset 128 for branches/2.0singleton/lib/PayPal.inc.php
- Timestamp:
- May 26, 2006 9:29:19 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0singleton/lib/PayPal.inc.php
r42 r128 74 74 function setButtonDefaults($type, $options) 75 75 { 76 $app =& App::getInstance(); 77 76 78 if (!is_array($options) || empty($options)) { 77 App::logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);79 $app->logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__); 78 80 return false; 79 81 } … … 82 84 $this->_default_button_options['_global'] = array_merge($this->_default_button_options['_global'], $options); 83 85 } else if (!isset($this->_default_button_options[$type])) { 84 App::logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__);86 $app->logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__); 85 87 return false; 86 88 } … … 104 106 function newButton($type, $name, $options=null) 105 107 { 108 $app =& App::getInstance(); 109 106 110 if (!isset($this->_default_button_options[$type])) { 107 App::logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__);111 $app->logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__); 108 112 return false; 109 113 } 110 114 111 115 if (!is_array($options) || empty($options)) { 112 App::logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);116 $app->logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__); 113 117 return false; 114 118 } 115 119 116 120 if (isset($this->_buttons[$name])) { 117 App::logMsg(sprintf('Overwriting existing button name: %s', getDump($this->_buttons[$name])), LOG_DEBUG, __FILE__, __LINE__);121 $app->logMsg(sprintf('Overwriting existing button name: %s', getDump($this->_buttons[$name])), LOG_DEBUG, __FILE__, __LINE__); 118 122 } 119 123 … … 137 141 function getLink($name) 138 142 { 143 $app =& App::getInstance(); 144 139 145 if (!isset($this->_buttons[$name])) { 140 App::logMsg(sprintf('Button does not exist: %s', $name), LOG_WARNING, __FILE__, __LINE__);146 $app->logMsg(sprintf('Button does not exist: %s', $name), LOG_WARNING, __FILE__, __LINE__); 141 147 return false; 142 148 } … … 207 213 function setParam($params) 208 214 { 215 $app =& App::getInstance(); 216 209 217 if (isset($params) && is_array($params)) { 210 218 // Merge new parameters with old overriding only those passed. 211 219 $this->_params = array_merge($this->_params, $params); 212 220 } else { 213 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);221 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 214 222 } 215 223 } … … 224 232 function getParam($param) 225 233 { 234 $app =& App::getInstance(); 235 226 236 if (isset($this->_params[$param])) { 227 237 return $this->_params[$param]; 228 238 } else { 229 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);239 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 230 240 return null; 231 241 } … … 259 269 function processIPN() 260 270 { 271 $app =& App::getInstance(); 272 261 273 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__);274 $app->logMsg(sprintf('Processing PayPal IPN in test mode: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__); 263 275 $url = parse_url('https://www.sandbox.paypal.com/cgi-bin/webscr'); 264 276 } else { 265 App::logMsg(sprintf('Processing PayPal IPN: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__);277 $app->logMsg(sprintf('Processing PayPal IPN: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__); 266 278 $url = parse_url($this->getParam('paypal_url')); 267 279 } … … 287 299 288 300 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__);301 $app->logMsg(sprintf('Connection to PayPal URL %s failed with error: %s (%s)', $ssl . $url['host'], $errstr, $errnum), LOG_WARNING, __FILE__, __LINE__); 290 302 return false; 291 303 } else { … … 304 316 fclose($fp); 305 317 306 App::logMsg(sprintf('IPN response received: %s', $this->_ipn_response), LOG_NOTICE, __FILE__, __LINE__);318 $app->logMsg(sprintf('IPN response received: %s', $this->_ipn_response), LOG_NOTICE, __FILE__, __LINE__); 307 319 return true; 308 320 } … … 318 330 function verifiedIPN() 319 331 { 332 $app =& App::getInstance(); 333 320 334 if (!isset($this->_ipn_response)) { 321 App::logMsg(sprintf('Cannot verify IPN, response not received.', null), LOG_WARNING, __FILE__, __LINE__);335 $app->logMsg(sprintf('Cannot verify IPN, response not received.', null), LOG_WARNING, __FILE__, __LINE__); 322 336 return false; 323 337 } 324 338 325 339 if (empty($this->_ipn_response)) { 326 App::logMsg(sprintf('Cannot verify IPN, response empty.', null), LOG_WARNING, __FILE__, __LINE__);340 $app->logMsg(sprintf('Cannot verify IPN, response empty.', null), LOG_WARNING, __FILE__, __LINE__); 327 341 return false; 328 342 } 329 343 330 344 if (preg_match('/VERIFIED/', $this->_ipn_response)) { 331 App::logMsg(sprintf('IPN verified!', null), LOG_DEBUG, __FILE__, __LINE__);345 $app->logMsg(sprintf('IPN verified!', null), LOG_DEBUG, __FILE__, __LINE__); 332 346 return true; 333 347 } 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__);348 $app->logMsg(sprintf('IPN invalid.', null), LOG_DEBUG, __FILE__, __LINE__); 349 return false; 350 } else { 351 $app->logMsg(sprintf('IPN unknown.', null), LOG_WARNING, __FILE__, __LINE__); 338 352 return false; 339 353 }
Note: See TracChangeset
for help on using the changeset viewer.