/** * Set api context * * @param $website * @return $this */ public function setApiContext($website = null) { $this->_apiContext = new ApiContext(new OAuthTokenCredential(Mage::getStoreConfig('iways_paypalplus/api/client_id', $website), Mage::getStoreConfig('iways_paypalplus/api/client_secret', $website))); $this->_mode = Mage::getStoreConfig('iways_paypalplus/api/mode', $website); $this->_apiContext->setConfig(array('http.ConnectionTimeOut' => 30, 'http.Retry' => 1, 'mode' => $this->_mode, 'log.LogEnabled' => Mage::getStoreConfig('dev/log/active', $website), 'log.FileName' => Mage::getBaseDir('log') . DS . 'PayPal.log', 'log.LogLevel' => 'INFO')); $this->_apiContext->addRequestHeader('PayPal-Partner-Attribution-Id', 'Magento_Cart_PayPalPlus'); return $this; }
protected function apiContext() { $credential = new OAuthTokenCredential($this->get_config('PAYPAL_CLIENT_ID_' . strtoupper($this->get_config('PAYPAL_MODE'))), $this->get_config('PAYPAL_SECRET_' . strtoupper($this->get_config('PAYPAL_MODE')))); $credential::$expiryBufferTime = defined('SESSION_LIFE_CUSTOMERS') ? SESSION_LIFE_CUSTOMERS : 1440; $apiContext = new ApiContext($credential); $auth_cache_file = SQL_CACHEDIR . 'pp_auth_' . $this->get_config('PAYPAL_MODE') . '.cache'; if (!is_file($auth_cache_file)) { file_put_contents($auth_cache_file, ''); } $apiContext->setConfig(array('mode' => $this->get_config('PAYPAL_MODE'), 'log.LogEnabled' => $this->get_config('PAYPAL_LOG_ENALBLED') == '1' ? true : false, 'log.FileName' => DIR_FS_LOG . 'mod_paypal_' . $this->get_config('PAYPAL_MODE') . '_' . date('Y-m-d') . '.log', 'log.LogLevel' => $this->loglevel, 'validation.level' => 'log', 'cache.enabled' => is_writeable(SQL_CACHEDIR) ? true : false, 'cache.FileName' => $auth_cache_file)); if (strpos($this->code, 'paypalplus') !== false) { $apiContext->addRequestHeader('PayPal-Partner-Attribution-Id', 'ModifiedeCommerce_Cart_REST_Plus'); } else { $apiContext->addRequestHeader('PayPal-Partner-Attribution-Id', 'ModifiedeCommerce_Cart_REST_EC'); } return $apiContext; }