In an attempt to upgrade from MD5 to SHA-512 based transHashSHA2 I have created a test transaction using my sandbox account and have used the c# sample code to verify the output of the hash matches the x_SHA2_Hash that comes back in the silent post back for the transaction, but I have not been able to generate a matching hash.
Steps followed from upgrade guide:
Step 1. Generate a Signature Key and store it in a secure location on your serve
Step 2. Convert the Signature Key into a byte array.
Step 3. Create a message string that starts with a caret ("^"), followed by the following three fields delimited by carets, and terminated with another caret:
• The API Login ID that you send in createTransactionRequest in the name element.
• The transaction ID that we send in createTransactionResponse in the transId element.
• The transaction amount that we send in createTransactionResponse in the amount element.
For example, if your API Login ID is "ANet123", the value of transId is "20987654321", and the value of amount is "9.99", the message string would look like this:
^ANet123^20987654321^9.99^
Step 4. Use HMAC-SHA512 to hash the byte array form of the Signature Key from Step 2 with the message string from Step 3.
Step 5. Compare the value of transHashSHA2 with the output from the HMAC-SHA512 hash mentioned in Step 4.
If my signature key is "828BB6EDE1959" and my API login ID is ABC123, my transaction id is 0 (because test transactions do not have a trans id in the sandbox), and the amount of the payment was $75.00 using the sample code provided in the upgrade guide I could pass in the value generated in step 3 "^ABC123^0^75.00^" and my signature key in to HMACSHA512("828BB6EDE1959", "^ABC123^0^75.00^") and my output should match the underlined value below, correct?
Array ( [x_response_code] => 1 [x_response_reason_code] => 1 [x_response_reason_text] => (TESTMODE) This transaction has been approved. [x_avs_code] => P [x_auth_code] => 000000 [x_trans_id] => 0 [x_method] => CC [x_card_type] => Visa [x_account_number] => XXXX1111 [x_first_name] => [x_last_name] => [x_company] => [x_address] => [x_city] => [x_state] => [x_zip] => [x_country] => [x_phone] => [x_fax] => [x_email] => [x_invoice_num] => 237 [x_description] => [x_type] => auth_capture [x_cust_id] => GPE6178NY [x_ship_to_first_name] => [x_ship_to_last_name] => [x_ship_to_company] => [x_ship_to_address] => [x_ship_to_city] => [x_ship_to_state] => [x_ship_to_zip] => [x_ship_to_country] => [x_amount] => 75.00 [x_tax] => 0.00 [x_duty] => 0.00 [x_freight] => 0.00 [x_tax_exempt] => FALSE [x_po_num] => [x_MD5_Hash] => C13380CAE7E8D7DB47BEAEDE98A5867A [x_SHA2_Hash] => 3732810865C43409F22EB2078D3C292FB284A5AAF587F8E091E93D97672F874EDAC7D3D526324E204EA6EFA2506E831FE3BEE7FB6D78113A3F2757C58EAEF0BB [x_cvv2_resp_code] => [x_cavv_response] => [x_test_request] => true [signature_key] => 828BB6EDE1959 [ref1type1] => [ref1val1] => l [payment_type] => AUTHORIZE_NET [email] => )
01-16-2019 11:23 AM
Thanks @Alicia05.
I am successfully abled to create a valid fingerprint.
But x_SHA2_Hash in the response still not matching the one I am generating even though I refer to Page 73 to create a $messageToHash with 30 values separated by "^".
Can you please do a favor and test if your shas512Hash value is matching the one I am generating using the signature key and messageToHash below:
$signatureKey = "9C5A4D2AFE1D1D5DB3A8FC4C95CDCF49E2B052B4220D0624C54C1C662194BDEF8FE0EA27B313FA62328D9500D123B9DD3CE06644508803ACD04DAEDB24C5D122";
$messageToHash = "^0^false^3^^^^P^^^1.99^^^^^^^^^^^^^^^^^^^^^";
// Hmac SHA-512 hash value I am gettings is:
$hmacSHA512Hash = "4038397293CE5DBBFD5AD21B2F96FF5B6E32EA9F56D310AA95D1D091EBEAD1C35FE5AF96111D7911B2816FCE0DBA2D41A5BD268F766183DC8F3B750B22F68E16";
01-17-2019 01:06 PM
I can't verify your sha with 2 tickets:
1. https://developer.authorize.net/support/hash_upgrade/
Here is a silent post:
$_POST=array (
'x_response_code' => '1',
'x_response_reason_code' => '1',
'x_response_reason_text' => 'This transaction has been approved.',
'x_avs_code' => 'Y',
'x_auth_code' => 'Q835SS',
'x_trans_id' => '40024516943',
'x_method' => 'CC',
'x_card_type' => 'Visa',
'x_account_number' => 'XXXX1111',
'x_first_name' => 'Phuong',
'x_last_name' => 'Nguyen',
'x_company' => '',
'x_address' => '123 Main Street',
'x_city' => 'Springfield',
'x_state' => 'IL',
'x_zip' => '60012',
'x_country' => 'US',
'x_phone' => '',
'x_fax' => '',
'x_email' => '',
'x_invoice_num' => '',
'x_description' => '',
'x_type' => 'auth_capture',
'x_cust_id' => '11281',
'x_ship_to_first_name' => '',
'x_ship_to_last_name' => '',
'x_ship_to_company' => '',
'x_ship_to_address' => '',
'x_ship_to_city' => '',
'x_ship_to_state' => '',
'x_ship_to_zip' => '',
'x_ship_to_country' => '',
'x_amount' => '199.00',
'x_tax' => '0.00',
'x_duty' => '0.00',
'x_freight' => '0.00',
'x_tax_exempt' => 'FALSE',
'x_po_num' => '',
'x_MD5_Hash' => '44239291E7A6D292C83360138503A159',
'x_SHA2_Hash' => '780F3D60E752D83D811CD2600E7D316B074EFC31C16AF22F64A44814483E465BA36C037CF006C166D5D1AADF0C0BDD711C509ACB9C49060791F900691E01E08E',
'x_cvv2_resp_code' => 'P',
'x_cavv_response' => '2',
'x_test_request' => 'false',
)
2019/01/29 09:47:47 [info] [payment] [3hk07t692o82c700nmjmopehf0][Guest][] array
(
'x_response_code' => '1'
'x_response_reason_code' => '1'
'x_response_reason_text' => 'This transaction has been approved.'
'x_avs_code' => 'Y'
'x_auth_code' => 'Q835SS'
'x_trans_id' => '40024516943'
'x_method' => 'CC'
'x_card_type' => 'Visa'
'x_account_number' => 'XXXX1111'
'x_first_name' => 'Phuong'
'x_last_name' => 'Nguyen'
'x_company' => ''
'x_address' => '123 Main Street'
'x_city' => 'Springfield'
'x_state' => 'IL'
'x_zip' => '60012'
'x_country' => 'US'
'x_phone' => ''
'x_fax' => ''
'x_email' => ''
'x_invoice_num' => ''
'x_description' => ''
'x_type' => 'auth_capture'
'x_cust_id' => '11281'
'x_ship_to_first_name' => ''
'x_ship_to_last_name' => ''
'x_ship_to_company' => ''
'x_ship_to_address' => ''
'x_ship_to_city' => ''
'x_ship_to_state' => ''
'x_ship_to_zip' => ''
'x_ship_to_country' => ''
'x_amount' => '199.00'
'x_tax' => '0.00'
'x_duty' => '0.00'
'x_freight' => '0.00'
'x_tax_exempt' => 'FALSE'
'x_po_num' => ''
'x_MD5_Hash' => '44239291E7A6D292C83360138503A159'
'x_SHA2_Hash' => '780F3D60E752D83D811CD2600E7D316B074EFC31C16AF22F64A44814483E465BA36C037CF006C166D5D1AADF0C0BDD711C509ACB9C49060791F900691E01E08E'
'x_cvv2_resp_code' => 'P'
'x_cavv_response' => '2'
'x_test_request' => 'false'
)
Here is my code:
- For verify at #1: 079F5B818BCBF7287DF241BEFAD592D26D8580115086A831F786225EFF02FF0F9B22DBC755F38C39D56B3DAD0A18E447F26469776747B998D7DE651C6E9D5068
$string = '^'.AUTHORIZENET_API_LOGIN_ID.'^'.$_POST['x_trans_id'].'^'.$_POST['x_amount'].'^';
$signatureKey = Yii::app()->params['anet_hash'];
$signatureKey = hex2bin($signatureKey);
$digest = strtoupper(hash_hmac('sha512',$string,$signatureKey));
return hash_equals($digest,$hash);
- For verify at #2:
$arrayHash = [
$_POST['x_trans_id'],
$_POST['x_test_request'],
$_POST['x_response_code '],
$_POST['x_auth_code'],
$_POST['x_cvv2_resp_code'],
$_POST['x_cavv_response'],
$_POST['x_avs_code'],
$_POST['x_method'],
$_POST['x_account_number'],
$_POST['x_amount'],
$_POST['x_company'],
$_POST['x_first_name'],
$_POST['x_last_name'],
$_POST['x_address'],
$_POST['x_city'],
$_POST['x_state'],
$_POST['x_zip'],
$_POST['x_country'],
$_POST['x_phone'],
$_POST['x_fax'],
$_POST['x_email'],
$_POST['x_ship_to_company'],
$_POST['x_ship_to_first_name'],
$_POST['x_ship_to_last_name'],
$_POST['x_ship_to_address'],
$_POST['x_ship_to_city'],
$_POST['x_ship_to_state'],
$_POST['x_ship_to_zip'],
$_POST['x_ship_to_country'],
$_POST['x_invoice_num'],
];
$string = '^'.implode('^', $arrayHash).'^';
$signatureKey = Yii::app()->params['anet_hash'];
$signatureKey = hex2bin($signatureKey);
$digest = strtoupper(hash_hmac('sha512',$string,$signatureKey));
return hash_equals($digest,$hash);
==> result for my sha: 5873397FD4FBAEAB591B6CE3A3BADEBE2997A07583AD4742674C77602685F8D30ECF86931323543CA1B2AB49F18CE4B898CD5B07DA1406903B686CD08AB2DD03
Could you help me? Many thanks!
01-29-2019 09:09 PM - edited 01-29-2019 09:13 PM
Hi Dev Support,
I dont' see any support for my problem. Can you help?
01-31-2019 07:03 PM
If you are using SIM/AIM etc API it uses a different fingerprint than the current API.
SIM uses "x_login^x_fp_sequence^x_fp_timestamp^x_amount^"
02-26-2019 08:25 PM