Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samadhan - Authorize net connection error issue solved #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions authorizenet/authorizenet/lib/shared/AuthorizeNetRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@
*/
abstract class AuthorizeNetRequest
{

protected $_api_login;
protected $_transaction_key;
protected $_post_string;
public $VERIFY_PEER = true; // Set to false if getting connection errors.
protected $_post_string;
public $VERIFY_PEER = false; // Set to false if getting connection errors.
protected $_sandbox = true;
protected $_log_file = false;

/**
* Set the _post_string
*/
abstract protected function _setPostString();

/**
* Handle the response string
*/
abstract protected function _handleResponse($string);

/**
* Get the post url. We need this because until 5.3 you
* you could not access child constants in a parent class.
*/
abstract protected function _getPostUrl();

/**
* Constructor.
*
Expand All @@ -45,7 +45,7 @@ public function __construct($api_login_id = false, $transaction_key = false)
$this->_sandbox = (defined('AUTHORIZENET_SANDBOX') ? AUTHORIZENET_SANDBOX : true);
$this->_log_file = (defined('AUTHORIZENET_LOG_FILE') ? AUTHORIZENET_LOG_FILE : false);
}

/**
* Alter the gateway url.
*
Expand All @@ -55,7 +55,7 @@ public function setSandbox($bool)
{
$this->_sandbox = $bool;
}

/**
* Set a log file.
*
Expand All @@ -65,7 +65,7 @@ public function setLogFile($filepath)
{
$this->_log_file = $filepath;
}

/**
* Return the post string.
*
Expand All @@ -75,7 +75,7 @@ public function getPostString()
{
return $this->_post_string;
}

/**
* Posts the request to AuthorizeNet & returns response.
*
Expand All @@ -96,25 +96,25 @@ protected function _sendRequest()
} else {
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
}

if (preg_match('/xml/',$post_url)) {
curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
}

$response = curl_exec($curl_request);

if ($this->_log_file) {

if ($curl_error = curl_error($curl_request)) {
file_put_contents($this->_log_file, "----CURL ERROR----\n$curl_error\n\n", FILE_APPEND);
}
// Do not log requests that could contain CC info.
// file_put_contents($this->_log_file, "----Request----\n{$this->_post_string}\n", FILE_APPEND);

file_put_contents($this->_log_file, "----Response----\n$response\n\n", FILE_APPEND);
}
curl_close($curl_request);

return $this->_handleResponse($response);
}

Expand Down