Hi,
SHA-512 hash mismatch when we enter special characters in the hosted payment page fields such as Address.
String xAddress = "712 Savoie �Rd";
x_SHA2_Hash=EB4E5F5BED46568B8BD7F7577BEE19DDAC9616B16613E1CFAEA5E606ABA6496A5150289FF8D98AA3FC65F54B85360C3CB0CAB2C7379A965CC841FB135B079495
Data String to generate hash :
String data = "^" + xTransId + "^" + xTestRequest + "^" + xResponseCode + "^"
+ xAuthCode + "^" + xCvv2RespCode + "^" + xCavvResponse + "^" + xAvsCode + "^"
+ xMethod + "^" + xAccountNumber + "^" + xAmount + "^" + xCompany + "^"
+ xFirstName + "^" + xLastName + "^" + xAddress + "^" + xCity + "^" + xState
+ "^" + xZip + "^" + xCountry + "^" + xPhone + "^" + xFax + "^" + xEmail + "^"
+ xShipToCompany + "^" + xShipToFirstName + "^" + xShipToLastName + "^"
+ xShipToAddress + "^" + xShipToCity + "^" + xShipToState + "^" + xShipToZip
+ "^" + xShipToCountry + "^" + xInvoiceNum + "^";
Hash generated:
F8FFE2918ABC5FCB3D01E878D5A22B51804BE2DCF97DD13D3971344AF7DE5D38F785B5374E396A502B8D8827E661E75B1DAFB359F50EE66B8234531B2A8A9C27
It is an issue with character encoding but we don't know how Auth.net handles the encoding before generating the hash which they send in the response.
Will really appreciate any help from the community to resolve this issue.
Thanks
04-13-2020 05:01 AM
Hi vijayvanga,
You should only use ISO 8859-1 characters. For more information on how to use the transHashSha2 value, please visit the Transaction Hash Upgrade Guide.
I hope this is helpful to you.
Regards,
Elaine
04-14-2020 07:26 AM
04-16-2020 09:00 AM
04-16-2020 09:06 AM
I have converted the PHP code to Java, Still I am getting hash mismatch below is code which I have converted to java. Please can you help is there I am missing anything.
String allString = xTransId + "," + xTestRequest + "," + xResponseCode + "," + xAuthCode + "," + xCvv2RespCode + "," + xCavvResponse + "," + xAvsCode
+ "," + xMethod + "," + xAccountNumber + "," + xAmount + "," + xCompany + "," + xFirstName + "," + xLastName + "," + xAddress + "," + xCity + "," + xState
+ "," + xZip + "," + xCountry + "," + xPhone + "," + xFax + "," + xEmail + "," + xShipToCompany + "," + xShipToFirstName + "," + xShipToLastName
+ "," + xShipToAddress + "," + xShipToCity + "," + xShipToState + "," + xShipToZip
+ "," + xShipToCountry + "," + xInvoiceNum;
String[] splitString = allString.split(",");
LinkedList<String> linklist = new LinkedList<String>();
HashMap<String, String> map = convertSpecialCharcters();
for(String split : splitString)
{
String newSplit = URLEncoder.encode(split, "ISO-8859-1");
for (Map.Entry<String, String> entry : map.entrySet())
{
newSplit = newSplit.replace(entry.getKey(), entry.getValue());
}
String[] explode = newSplit.split("%26");
String explodedValue = "";
for(String explodeValue : explode)
{
int i = explodeValue.indexOf("%3D");
if(i > 1)
explodeValue = explodeValue.substring(i);
explodeValue = explodeValue.replace("%3D", "");
explodeValue = explodeValue.replace("%2540", "@");
explodedValue = explodedValue + explodeValue;
}
linklist.add(explodedValue);
}
String data = "^";
for (String stringData : linklist)
{
data = data + stringData + "^";
}
String value = getHashedValue(data);
System.out.println("Hash ----- " + hash);
System.out.println("Value ---- " + value.toUpperCase());
System.out.println(hash.equalsIgnoreCase(value));
Thanks
Vijaykumar Vanga
04-28-2020 03:58 AM
05-14-2020 08:01 AM
I have tested and working PHP code for Official Website . The below post was modified but should work. You just need to adapt the code to java.
06-23-2020 11:45 PM