cancel
Showing results for 
Search instead for 
Did you mean: 

Who Me Too'd this topic

Using Transaction Hash Upgrade Guide x_SHA2_Hash does not match output from sample code

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] => 
)

 

Alicia05
Member
Who Me Too'd this topic