Ignore:
Timestamp:
May 26, 2006 9:29:19 PM (18 years ago)
Author:
scdev
Message:

finished /lib folder

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0singleton/lib/PayPal.inc.php

    r42 r128  
    7474    function setButtonDefaults($type, $options)
    7575    {
     76        $app =& App::getInstance();
     77
    7678        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__);
    7880            return false;
    7981        }
     
    8284            $this->_default_button_options['_global'] = array_merge($this->_default_button_options['_global'], $options);
    8385        } 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__);
    8587            return false;
    8688        }
     
    104106    function newButton($type, $name, $options=null)
    105107    {
     108        $app =& App::getInstance();
     109
    106110        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__);
    108112            return false;
    109113        }
    110114
    111115        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__);
    113117            return false;
    114118        }
    115119
    116120        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__);
    118122        }
    119123
     
    137141    function getLink($name)
    138142    {
     143        $app =& App::getInstance();
     144
    139145        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__);
    141147            return false;
    142148        }
     
    207213    function setParam($params)
    208214    {
     215        $app =& App::getInstance();
     216
    209217        if (isset($params) && is_array($params)) {
    210218            // Merge new parameters with old overriding only those passed.
    211219            $this->_params = array_merge($this->_params, $params);
    212220        } 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__);
    214222        }
    215223    }
     
    224232    function getParam($param)
    225233    {
     234        $app =& App::getInstance();
     235
    226236        if (isset($this->_params[$param])) {
    227237            return $this->_params[$param];
    228238        } 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__);
    230240            return null;
    231241        }
     
    259269    function processIPN()
    260270    {
     271        $app =& App::getInstance();
     272
    261273        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__);
    263275            $url = parse_url('https://www.sandbox.paypal.com/cgi-bin/webscr');
    264276        } 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__);
    266278            $url = parse_url($this->getParam('paypal_url'));
    267279        }
     
    287299
    288300        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__);
    290302            return false;
    291303        } else {
     
    304316            fclose($fp);
    305317
    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__);
    307319            return true;
    308320        }
     
    318330    function verifiedIPN()
    319331    {
     332        $app =& App::getInstance();
     333
    320334        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__);
    322336            return false;
    323337        }
    324338
    325339        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__);
    327341            return false;
    328342        }
    329343
    330344        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__);
    332346            return true;
    333347        } 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__);
    338352            return false;
    339353        }
Note: See TracChangeset for help on using the changeset viewer.