Hash not generating


While trying to create the hash we are getting the below error :


Please assist.


Also facing this problem , waiting for any help


This either means your secret key is invalid or your method of hash generation is incorrect. Please share code example of how you are generating your hash? (dont share your secret key though)


class Hash
public function CreateHash($values,$IntegrationKey) {
$string = “”;

foreach($values as $key=>$value) {
    if( strtoupper($key) != "HASH" ){
        $string .= $value;

 $string .= $IntegrationKey;
 $hash = hash("sha512", $string);

 return strtoupper($hash);



$foo = new Hash;
$IntegrationKey = “”;
$reference = rand();
$returnurl =“http://www.google.com/search?q=returnurl”;
$resulturl = “http://www.google.com/search?q=resulturl”;
$amount =10;
$int_id = ;
$additionalinfo=“A test ticket transaction”;
$authemail = "someone@gmail.com";

$values = array(

                'id' =>  $int_id,
                'reference' =>  $reference,
                'amount' =>  $amount,    
                'additionalinfo' =>  'A test ticket transaction',    
                'resulturl' => $resulturl,
                'returnurl' =>  $returnurl,
                'status' =>  'Message',
                'authemail' =>  $authemail,
                //just a simple message

echo $has = $foo->CreateHash($values,$IntegrationKey);


If you use the example field values from here https://developers.paynow.co.zw/docs/generating_hash.html#generating-a-hash-for-an-outbound-message and the secret key 3e9fed89-60e1-4ce5-ab6e-6b1eb2d4f977 do you find that you get the same hash as they do in the example?



Yes when we used your values it is generating the same hash you said above


Great, that means its probably your secret key which is incorrect! Are you appending it as lowercase or uppercase string?


We tried both and both doesn’t work.


Please share the first 4 and last 4 characters of your secret key for us to cross-check?


First 4 - 4026
Last 4 - 2803


Can you share the string of concatenated values just before you SHA512 hash it?

13419TEST REF10A test ticket transactionsomeone@gmail.comhttp://www.google.com/search?q=returnurlhttp://www.google.com/search?q=resulturlMessage4026xxxxxxxxxxxxxxxxxx2803

We’re able to initiate transactions on your integration ID (using your secret key) so the issue is definitely client side, we just need to help you work out what it is.


13419TEST REF99.99A test ticket transactionhttp://www.google.com/search?q=returnurlhttp://www.google.com/search?q=resulturlMessage4026xxxxxxxxxxxxxxxx2803


When we generate the SHA512 hash from that string, we get:


Which initiates OK with Paynow. You can also use this tool to cross-check that hash:

Do you get the same hash as above?


We are getting the same hash 72CF078AC029AA32E104CB2A872A8B0992ABB07EBD88B9F682F9E84D222B6F15003EDA8199C30F6A0CAD88FEB46422290453118655E2DBE6BBD178A0E49D42A3

But after proceeding we are getting the error status=Error&error=Invalid+Hash.++Hash+should+start+with%3a+DE226B


The reason is that an additional field is being added to your form post (see below) which isnt being included in your concatenated string before you hash it:

  • id=13419
  • reference=TEST REF
  • amount=99.99
  • additionalinfo=A test ticket transaction
  • returnurl=http://www.google.com/search?q=returnurl
  • resulturl=http://www.google.com/search?q=resulturl
  • status=Message
  • hash=72CF078AC029AA32E104CB2A872A8B0992ABB07EBD88B9F682F9E84D222B6F15003EDA8199C30F6A0CAD88FEB46422290453118655E2DBE6BBD178A0E49D42A3
  • submit=submit

If you remove the submit=submit from the form post, it will solve your problem


After doing so, we are getting the below message


Why does it not redirect to the payment gateway/browseurl itself?

What else is required from our side now to redirect to the payment gateway page/browseurl ?

Don't close topics without sorting the issue fully

Your communication with Paynow at this point is server-to-server. Redirecting your server to the “browser URL” would be fairly pointless, given its your customer who needs to select their payment channel :slight_smile: thus, its your server’s responsibility to redirect the client to the browserurl from the Paynow API response.

Familiarize yourself with returnurl and resulturl fields from the documentation here https://developers.paynow.co.zw/docs/initiate_transaction.html