net for testing purposes. Review the AIM Implementation Guidefor the complete list of such credit
card numbers.
We send an array with transaction details as a parameter to SetRequest(), which then joins this array with
another array that contains the Authorize.net account details:
public function SetRequest($request)
{
$this->_mRequest = '';
$request_init =
array ('x_login' => AUTHORIZE_NET_LOGIN_ID,
'x_tran_key' => AUTHORIZE_NET_TRANSACTION_KEY,
'x_version' => '3.1',
'x_test_request' => AUTHORIZE_NET_TEST_REQUEST,
'x_delim_data' => 'TRUE',
'x_delim_char' => '|',
'x_relay_response' => 'FALSE');
$request = array_merge($request_init, $request);
The array data is merged into a name-value string that can be sent to Authorize.net. The values are encoded for
inclusion in the URL using the urlencode() function:
foreach($request as $key => $value )
$this->_mRequest .= $key . '=' . urlencode($value) . '&';
}
The GetResponse() method of AuthorizeNetRequest does the actual request, using the cURL library.
// Send an HTTP POST request to Authorize.net using cURL
public function GetResponse()
{
...
// 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 648
}
}
?>
When executing the GetResponse() function to perform an AUTH_ONLY transaction, the response will contain a transaction
ID.
Pages:
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764