I am using Migs Virtual Payment Client Integration and Using 2-Party (API method).
Error : E5000: Cannot form a matching secure hash based on the merchant's request using either of the two merchant's secrets
In the Reference Guide it is Stated to use HMac Sha256 for Generating a SecureHash Parameter that is sent in the Request and MIGS will Decode that request accordingly.
Questions :
a) I want to know that the Request i am creating is proper or not (i.e All the Parameters which are passed are in correct order).
b) Also let me know that if i am missing Some Parameters to send in the Request to create SecureHash and in Final Request.
c) Also check the functions that are used for generating the SecureHash are proper or not.
Please let me know if i am doing some Mistake .
Below are the Related Details.
1) Request to generate SecureHash :"vpc_AccessCode=XXXXXXXX&vpc_Amount=100&vpc_CardExp=1810&vpc_CardNum=5313581000123430&vpc_Command=pay&vpc_MerchTxnRef=TC_2014712466141&vpc_Merchant=TESTMXXXXXXXX&vpc_OrderInfo=TC_2014712466141&vpc_Version=1"
2) Demo SecureHashSecret = "CD14026NOT5E91GG5D1MOM4972440CDE"
3) SECURE Hash generated from Above Request and SecureHashSecret
"CCD0D0113315403E375791E99AFA3F8906EE47C0ED6818464368420048DC541E"
4) Test URL : "https://migs.mastercard.com.au/vpcdps"
5) Final Request to Send on above URL
"vpc_AccessCode=XXXXXXXX&vpc_Amount=100&vpc_CardExp=1310&vpc_CardNum=5313581000123430&vpc_Command=pay&vpc_MerchTxnRef=TC_2014712466141&vpc_Merchant=TESTMXXXXXXXX&vpc_OrderInfo=TC_2014712466141&vpc_Version=1&vpc_SecureHash=CCD0D0113315403E375791E99AFA3F8906EE47C0ED6818464368420048DC541E&vpc_SecureHashType=SHA256"
6) I am using the Below Code For Sending the Request and Getting the Response.
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
byte[] response = webClient.UploadData(hfVirtualPaymentClientURL.Value.Trim(), "POST", Encoding.ASCII.GetBytes(strRequest));
string responseData = System.Text.Encoding.ASCII.GetString(response, 0, response.Length);
7) Functions used to Generate SecureHash
public static string ToHMACSHA256(string input, string key)
{
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] keyByte = encoding.GetBytes(key);
byte[] inputBytes = encoding.GetBytes(input);
HMACSHA256 hmacsha256 = new HMACSHA256(keyByte);
byte[] hashmessage;
hashmessage = hmacsha256.ComputeHash(inputBytes);
return ByteToString(hashmessage);
}
private static string ByteToString(byte[] buff)
{
string sbinary = "";
for (int i = 0; i < buff.Length; i++)
{
sbinary += buff[i].ToString("X2"); // hex format
}
return (sbinary);
}
Please get me the Solutions for the Above Error Asap. Thanks in Advance
Thanks & Regards
Sunny Pathai