Hello,
We are getting the key in the response of the directpost method "x_SHA2_Hash". The value we get for "x_SHA2_Hash" does not match with the key that is generated using following code.
private function generateSha2Hash(string $signatureKey): string { $hashFields = [ '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', ]; $message = '^'; foreach ($hashFields as $field) { $message .= ($this->getData($field) ?? '') . '^'; } return strtoupper(hash_hmac('sha512', $message, pack('H*', $signatureKey))); }
The key mismatches when we have Latin symbols with diacritics e.g àâãäăāåąæéèêëěēėę. in the street address or first name or last name..
Can anyone from the community help me to resolve this issue ?
Thanks & Regards,
08-29-2019 03:06 AM
08-29-2019 11:12 AM
As you are at least the 6th person to post this issue on the forum, I have decided to post my solution here. It may be a few days as I am very busy, but stay tuned.
08-29-2019 04:15 PM
09-04-2019 05:59 AM - edited 09-04-2019 06:00 AM