status=Error&error=Invalid+Hash.++Hash+should+start+with%3a+6D985D
is getting what I do
status=Error&error=Invalid+Hash.++Hash+should+start+with%3a+6D985D
is getting what I do
String url = "https://www.paynow.co.zw/interface/initiatetransaction";
String merchantId = "merchantId";
String merchantKey = "merchantKey";
String reference = "Invoice123";
String amount = "10.00";
String returnUrl = "https://www.paynow.co.zw/Home/Home";
String resultUrl = "https://www.paynow.co.zw/Home/Home";
String email = "mohammedadil@teleoss.co";
String status = "Message";
// Step 1: Build hash string with URL-encoded values
String postString = "id=" + merchantId
+ "&reference=" + reference
+ "&amount=" + amount
+ "&returnurl=" + URLEncoder.encode(returnUrl, "UTF-8")
+ "&resulturl=" + URLEncoder.encode(resultUrl, "UTF-8")
+ "&authemail=" + URLEncoder.encode(email, "UTF-8")
+ "&status=" + status;
// Step 2: Create SHA-512 hash
String hash = DigestUtils.sha512Hex(postString + merchantKey);
// Step 3: Prepare POST body (no URL encoding here, Spring handles it)
MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
body.add("id", merchantId);
body.add("reference", reference);
body.add("amount", amount);
body.add("returnurl", returnUrl);
body.add("resulturl", resultUrl);
body.add("authemail", email);
body.add("status", status);
body.add("hash", hash);
System.out.println("Post String for Hash: " + postString);
System.out.println("Generated Hash: " + hash);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(body, headers);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.postForEntity(url, request, String.class);
return ResponseEntity.ok(response.getBody());
We highly recommend that you use our Java SDK for integration
or follow the guide here for Hash Generation