While trying to create the hash we are getting the below error :
status=Error&error=Invalid+Hash.++Hash+should+start+with%3a+8AB116
Please assist.
While trying to create the hash we are getting the below error :
status=Error&error=Invalid+Hash.++Hash+should+start+with%3a+8AB116
Please assist.
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
//print_r($values);
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?
i.e.
2A033FC38798D913D42ECB786B9B19645ADEDBDE788862032F1BD82CF3B92DEF84F316385D5B40DBB35F1A4FD7D5BFE73835174136463CDD48C9366B0749C689
Great, that means its probably your secret key which is incorrect! Are you appending it as lowercase or uppercase string?
Can you share the string of concatenated values just before you SHA512 hash it?
e.g.
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:
72CF078AC029AA32E104CB2A872A8B0992ABB07EBD88B9F682F9E84D222B6F15003EDA8199C30F6A0CAD88FEB46422290453118655E2DBE6BBD178A0E49D42A3
Which initiates OK with Paynow. You can also use this tool to cross-check that hash:
https://passwordsgenerator.net/sha512-hash-generator/
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:
If you remove the submit=submit from the form post, it will solve your problem
Okay
After doing so, we are getting the below message
status=Ok&browserurl=https%3a%2f%2fwww.paynow.co.zw%2fPayment%2fConfirmPayment%2f14091678&pollurl=https%3a%2f%2fwww.paynow.co.zw%2fInterface%2fCheckPayment%2f%3fguid%3da21e7455-51e3-40b7-a13b-5e3d2375046a&hash=649CE00A5D014198BD88B4A0195342527CE65AB99EBAFEB9477CB1DD4F9CCB3B959EFC0E3E7F3A06206569D5918FB41C1903DDC83A8615C9A0A6969BDEF4379A
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 ?
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 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