// Capture
$transaction =
array ('x_ref_trans_id' => $ref_trans_id, // Transaction id
'x_method' => 'CC', // Payment method
'x_type' => 'PRIOR_AUTH_CAPTURE'); // Transaction type
We??™ll transform these arrays into a string of name-value pairs and submit them to the
Authorize.net server. The response comes in the form of a string whose values are separated
by a configurable character. Later, in Figure 20-3, you can see a sample response for an AUTH_ONLY
request (in the left part of the window) and a sample response for a PRIOR_AUTH_CAPTURE request
(in the right part of the window).
We??™ll write a simple test with this transaction type before implementing any modifications
to TShirtShop. Follow the steps in the exercise to test Authorize.net.
Exercise: Testing Authorize.net
1. Create a new file named authorize_net_request.php in the business folder, and add the following
code to it:
class AuthorizeNetRequest
{
// Authorize Server URL
private $_mUrl;
// Will hold the current request to be sent to Authorize.net
private $_mRequest;
// Constructor initializes the class with URL of Authorize.net
public function __construct($url)
{
// Authorize.net URL
$this->_mUrl = $url;
}
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.
Pages:
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760