i am changing to code to integrate HMAC_SHA512 using java API
But i get Error code 99 Transaction cannot be accepted after the new change
I am using the TEST https://secure.authorize.net/gateway/transact.dll
As mentioned i am sending the inputstring '^' delimeter
^API LOGIN ID^TransactionID^AMT^
Please let me know what is dong wrong and any more inforemation you want from me
Solved! Go to Solution.
01-25-2019 08:50 AM
I do send the Hexa value Hex.encodeHex() API to get the Hexvalue
01-29-2019 09:01 AM
01-29-2019 10:31 AM
Originally the value in x_fp_hash(fingerprint generated was using MD5 hash, that used transaction key)
Now i am following the guide to to upgrade to HmacSHA512 that says to use the SecurityKey .
I created a new SecurityKey.
I am creating the new value for finger print using securitykey and HmacSHA512 hashing
This value is set in the x_fp_hash hidden field of paymentform and submitted https://secure2.authorize.net/gateway/transact.dll
The moment i submit i receive erro code 99. That means my fingerprint does not match with that of merchant. However if i revert the code old way it launches payment form.
the java code
key is security key and data is APILOGINID^TransactiodID^timestampe^amt^
Mac sha512_HMAC = Mac.getInstance("HmacSHA512");
SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA512");
sha512_HMAC.init(secret_key);
return Hex.encodeHexString(sha512_HMAC.doFinal(data.getBytes("UTF-8")));
Please help let me know what am i doing wrong?
FYI The old way is SIM implementation.
01-29-2019 12:09 PM
I got it working with new HASH the issue was conversion of the long key to byte array.
Method to convert the SecurityKey
public static byte[] hex2bin(String hex) throws NumberFormatException {
if (hex.length() % 2 > 0) {
throw new NumberFormatException("Hexadecimal input string must have an even length.");
}
byte[] r = new byte[hex.length() / 2];
for (int i = hex.length(); i > 0;) {
r[i / 2 - 1] = (byte) (digit(hex.charAt(--i)) | (digit(hex.charAt(--i)) << 4));
}
return r;
}
public String encode(byte[] key, String data) {
try {
//String hexaString = Hex.encodeHexString(key.getBytes()) ;
Mac sha512_HMAC = Mac.getInstance("HmacSHA512");
SecretKeySpec secret_key = new SecretKeySpec(key,"HmacSHA512");
sha512_HMAC.init(secret_key);
return Hex.encodeHexString(sha512_HMAC.doFinal(data.getBytes("UTF-8")));
// return new String(Hex.encodeHex(sha512_HMAC.doFinal(data.getBytes("UTF-8"))));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
Thanks for the help
01-29-2019 12:56 PM
Java is an situated third-age programming language that is utilized in application improvement for various stages and turns out practically for portable applications, work area applications, PCs, route frameworks or checking gadgets, and so on.
To comprehend the top to bottom characteristics of Java as a programming language, you should have a fundamental thought of the wording for these 3 highlights for example object-arranged, simultaneous, and autonomous.
06-19-2022 10:15 PM
Learn the fundamentals As with one factor, knowing the fundamentals of Java is the only place to start out. this may be one issue you'll begin promptly – looking for the fundamentals online could also be an associate degree large facilitate to kick-start your Java programming. Like several things, it area unit is typically a little amount overwhelming at the beginning. If you're an entire beginner, code will seem to be bunk. Java Classes in Pune
06-27-2022 04:55 AM