Invalid Hash When Initiating a RemoteTransaction


#1

I am trying to initiate an Express Mobile transaction specifically ecocash. I am using postman for testing purposes and i am encountering the following error

>status=Error&error=Invalid+Hash.++Hash+should+start+with%3a+3BFAB6

Find attachd the code


#2

Hi Mr_D
Lets try eliminate the obvious before we get to the sensitive stuff like id’s. What ever you are using to generate your Harsh try the text below

1201TEST REF99.99A test ticket transactionhttp://www.google.com/search?q=returnurlhttp://www.google.com/search?q=resulturlMessage3e9fed89-60e1-4ce5-ab6e-6b1eb2d4f977

Let me know if you get this

2A033FC38798D913D42ECB786B9B19645ADEDBDE788862032F1BD82CF3B92DEF84F316385D5B40DBB35F1A4FD7D5BFE73835174136463CDD48C9366B0749C689


#3

Thank you for the prompt response @Harvey . Yes i am getting 2A033FC38798D913D42ECB786B9B19645ADEDBDE788862032F1BD82CF3B92DEF84F316385D5B40DBB35F1A4FD7D5BFE73835174136463CDD48C9366B0749C689


#4

Great so its not your hashing algorithm , I am going to download postman and try duplicate your error . While i do that I notice in your screenshot you used “form-data” option. I just read through this post “in postman, send your key value pairs in the body of the request as `x-www-form-urlencoded” . Try that and let me know .General Discussion - Java Integration.


#5

Thanks @Harvey… Unfortunately i have encountered the same error

Regards


#6

I have managed to duplicate your error . I m going to go into the source code and check two things
1.should the auth email be part of the harsh
2.The order of the values in the concatenated string.
Will get back to you soon


#7

I have resolved the error on my end. A few pointers. It is expected that the last key-value pair in your request is the hash. Everything above it is used in generating the hash. In your case the steps would look like this

Step 1
method:ecocash
phone:0771111111
id:xxxx
reference:TEST REF
amount:99.99
returnurl:http://www.google.com/search?q=returnurl
resulturl:http://www.google.com/search?q=resulturl
authemail:[email protected]
status:Message

step 2 concatenate values as a string (note keys are not included)
ecocash0771111111xxxxTEST REF99.99http://www.google.com/search?q=returnurlhttp://www.google.com/[email protected]

step 3 append integration key
ecocash0771111111xxxxTEST REF99.99http://www.google.com/search?q=returnurlhttp://www.google.com/[email protected][intergration key]

step 4 - sha512 hash


#8

Thank you Harvey. I have done what you said but still no joy on my side… Same Error


#9

I hope you did not give up on me @Harvey:sweat_smile: . I am still stuck.


#10

Hi there no I have not. I have been trying to figure out a way to share testing info , so far I am looking at Postman’s "share " feature. As a side note why are you not using the SDK’s?


#11

While generating the hash, the order of concatenation of the values matters.
So when generating the hash for initiating mobile money transactions, the order should be:

[Integration ID]TEST REF99.99http://www.google.com/search?q=returnurlhttp://www.google.com/[email protected][Integration Key]


#12

Continuing the discussion from Invalid Hash When Initiating a RemoteTransaction:

Thank you very much @Harvey… Without getting into details i will just say that my hands are tied, project constraints, therefore i can’t use any of the SDK’s.

I will be patiently waiting for your help.


#13

Thanks @lucia. Unfortunately, im still stuck…lol


#14

Hi Mr_D lets give this one more try
Follow this link to import postman collection

https://www.getpostman.com/collections/01be6fa1f4d783aa8c7f

Use this details to create a hash , change merchant id and secret

[merchant id]TEST REF99.99A test ticket transactionhttp://www.google.com/search?q=returnurlhttp://www.google.com/[email protected][secret key]


#15

That’s a sign of victory… Thanks Harvey… Works like a charm in postman.


#16

I love your persistence @Harvey:raised_hands:


#17

@Harvey … Kindly explain what was wrong with my initial implementation. My goal is that i want to submit the request using Ajax post so i might also be haunted by my previous errors. How best can i perform an ajax post? Regards


#18

Postman has a feature to generate code , just under the save button there is a “code” button


#19

Thanks very much @Harvey … My code is now working!!! Thank you!!!:slightly_smiling_face: