Prev | Current Page 749 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

1',
'x_test_request' => AUTHORIZE_NET_TEST_REQUEST,
'x_delim_data' => 'TRUE',
CHAPTER 20 ?–  PROCESSING CREDIT CARD TRANSACTIONS 643
'x_delim_char' => '|',
'x_relay_response' => 'FALSE');
$request = array_merge($request_init, $request);
foreach($request as $key => $value )
$this->_mRequest .= $key . '=' . urlencode($value) . '&';
}
// Send an HTTP POST request to Authorize.net using cURL
public function GetResponse()
{
// Initialize a cURL session
$ch = curl_init();
// Prepare for an HTTP POST request
curl_setopt($ch, CURLOPT_POST, 1);
// Prepare the request to be POSTed
curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($this->_mRequest, '& '));
// Set the URL where we want to POST our data
curl_setopt($ch, CURLOPT_URL, $this->_mUrl);
/* Do not verify the Common name of the peer certificate in the SSL
handshake */
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
// Prevent cURL from verifying the peer's certificate
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
/* We want cURL to directly return the transfer instead of
printing it */
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Perform a cURL session
$result = curl_exec($ch);
// Close a cURL session
curl_close ($ch);
// Return the response
return $result;
}
}
?>
CHAPTER 20 ?–  PROCESSING CREDIT CARD TRANSACTIONS 644
2. Add the following at the end of include/config.php file, modifying the constant data with the details of
your Authorize.


Pages:
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761