I am trying to integrate the adyen hpp pages. I basically use the same code like in their example on github: https://github.com/Adyen/adyen-java-sample-code/blob/master/src/com/adyen/examples/hpp/CreatePaymentOnHpp_SHA_256.java
on that example I just set the merchantAccount, skinCode adn the hmac secret code to my data.
Additionally I added some code to create a test url for the hmac calculation:
String queryString = params.keySet().stream()
.map(key -> {
try {
return key + "=" + URLEncoder.encode(params.get(key), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return "Error: could not URL-encode value";
}).collect(Collectors.joining("&"));
String testUrl = "https://ca-test.adyen.com/ca/ca/skin/checkhmac.shtml" + "?" + queryString;
System.out.println(testUrl);
I also created some code to create an url for the hpp. It looks like this:
URIBuilder b = new URIBuilder(hppUrl);
for (Map.Entry<String, String> entry : params.entrySet()) {
b.addParameter(entry.getKey(), URLEncoder.encode(entry.getValue(), "UTF-8"));
}
return b.build().toString();
So the calculation of the HMAC seems to be correct, because the testUrl is always correct. But if I click on the generated link for the hpp, then I always get an error that I should check the HMAC calculation.
I hope someone can give me a hint on how to fix it