My original post (first post in this thread) has the code for latest php SDK. Tested on API calls, should work with AIM but hasn't been tested.
Here is the tested code for SIM/DPM. Few notes: First SIM code I posted had not been tested and I in error put an extra ^ at the beginning of the string. The code below is correct and works. For the verification component, this is probably not the best way to do it but it has been tested and works. I do not use these integration methods but finally decided to write a script to test.
//response verification code for DPM/SIM
//This code goes on your silent post URL
$anetResponse = file_get_contents('php://input');
$response = array(
'x_trans_id'=>'', 'x_test_request'=>'', 'x_response_code'=>'',
'x_auth_code'=>'','x_cvv2_resp_code'=>'', 'x_cavv_response'=>'',
'x_avs_code'=>'', 'x_method'=>'', 'x_account_number'=>'', 'x_amount'=>'',
'x_company'=>'','x_first_name'=>'','x_last_name'=>'','x_address'=>'',
'x_city'=>'','x_state'=>'', 'x_zip'=>'','x_country'=>'', 'x_phone'=>'',
'x_fax'=>'','x_email'=>'', 'x_ship_to_company'=>'', 'x_ship_to_first_name'=>'',
'x_ship_to_last_name'=>'', 'x_ship_to_address'=>'', 'x_ship_to_city'=>'',
'x_ship_to_state'=>'', 'x_ship_to_zip'=>'','x_ship_to_country'=>'',
'x_invoice_num'=>'');
$string = '^';
$responseCheck = explode('&',$anetResponse);
foreach($responseCheck as $key=> $value){
$newKey = strstr($value,'=',true);
$newVal = strstr($value,'=');
$newVal = str_replace('=','',$newVal);
$newVal = urldecode($newVal);
if(array_key_exists($newKey,$response)){
$response[$newKey]= $newVal;
}
if($newKey=="x_SHA2_Hash"){
$hash = $newVal;
}
}
foreach($response as $key => $value){
$string .= $value .='^';
}
$signatureKey = "Copy and Paste Your Signature Key Here.";
$signatureKey = hex2bin($signatureKey);
$validation = strtoupper(HASH_HMAC('sha512',$string,$signatureKey));
if(hash_equals($hash,$validation)){
//Insert code to be executed if response
//is validated here.
}
//end of response verification
//sha512 transaction fingerprint for DPM, SIM
date_default_timezone_set('UTC');
//^may not be necessary depending on your configuration
$login = "Copy and Paste your Login Here";
$signatureKey = "Paste Signature Key Here";
$signatureKey = hex2bin($signatureKey);
$amount = "43.23";
//or
$amount = $amount
//this assumes you have previously assigned the transaction
//amount to a variable called $amount in your script
$sequence = "123";
//you can use a variety of numbers
//example in your docs uses 3 digit numbers
$timeStamp = strtotime("now");
$currency = "USD";
//looks like that you only use this
//if you specify currency type in your form request
//you can use another value if you do things in a different currency
//use one of the two strings below.
$string = "$login^$sequence^$timeStamp^$amount^";
//the above is what you use if you don't submit
//x_currency_code in your request
$string2 = "$login^$sequence^$timeStamp^$amount^$currency";
//you use this if you specify currency
$digest = strtoupper(HASH_HMAC('sha512',$string,$signatureKey));
//or
$digest = strtoupper(HASH_HMAC('sha512',$string2,$signatureKey));
//this value is submitted in your request under "x_fp_hash"
//Look in the SIM/DPM developer guide on for what "x_" to to use for $sequence, etc.
//page 29.