/**
* @inheritdoc
*/
private function setConfig()
{
// ### Api context
// Use an ApiContext object to authenticate
// API calls. The clientId and clientSecret for the
// OAuthTokenCredential class can be retrieved from
// developer.paypal.com
$this->_apiContext = new ApiContext(new OAuthTokenCredential($this->clientId, $this->clientSecret));
// #### SDK configuration
// Comment this line out and uncomment the PP_CONFIG_PATH
// 'define' block if you want to use static file
// based configuration
$this->_apiContext->setConfig(ArrayHelper::merge(['mode' => self::MODE_SANDBOX, 'http.ConnectionTimeOut' => 30, 'http.Retry' => 1, 'log.LogEnabled' => YII_DEBUG ? 1 : 0, 'log.FileName' => Yii::getAlias('@runtime/logs/paypal.log'), 'log.LogLevel' => self::LOG_LEVEL_FINE, 'validation.level' => 'log', 'cache.enabled' => 'true'], $this->config));
// Set file name of the log if present
if (isset($this->config['log.FileName']) && isset($this->config['log.LogEnabled']) && (bool) $this->config['log.LogEnabled'] == true) {
$logFileName = \Yii::getAlias($this->config['log.FileName']);
if ($logFileName) {
if (!file_exists($logFileName)) {
if (!touch($logFileName)) {
throw new ErrorException('Can\'t create paypal.log file at: ' . $logFileName);
}
}
}
$this->config['log.FileName'] = $logFileName;
}
return $this->_apiContext;
}