title: MIGS VPC Integration E5000: Cannot form a matching secure hash based on the merchant's request using either of the two merchant's secrets
body: <p>I am using Migs Virtual Payment Client Integration and Using 2-Party (API method).</p>
  
  <p>Error  : <strong>E5000</strong>: Cannot form a matching secure hash based on the merchant's request using either of the two merchant's secrets</p>
  
  <p>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.</p>
  
  <p><strong>Questions :</strong></p>
  
  <p><strong>a)</strong> 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).</p>
  
  <p><strong>b)</strong> Also let me know that if i am missing Some Parameters to send in the Request to create SecureHash and in Final Request.</p>
  
  <p><strong>c)</strong> Also check the functions that are used for generating the <strong>SecureHash</strong> are proper or not.</p>
  
  <p>Please let me know if i am doing some Mistake .</p>
  
  <p>Below are the Related Details.</p>
  
  <p>1) <strong>Request to generate SecureHash</strong> :"vpc_AccessCode=XXXXXXXX&amp;vpc_Amount=100&amp;vpc_CardExp=1810&amp;vpc_CardNum=5313581000123430&amp;vpc_Command=pay&amp;vpc_MerchTxnRef=TC_2014712466141&amp;vpc_Merchant=TESTMXXXXXXXX&amp;vpc_OrderInfo=TC_2014712466141&amp;vpc_Version=1"</p>
  
  <p>2) Demo <strong>SecureHashSecret</strong> = "CD14026NOT5E91GG5D1MOM4972440CDE"</p>
  
  <p><strong>3)</strong> SECURE Hash generated from Above <strong>Request</strong> and <strong>SecureHashSecret</strong></p>
  
  <p>"CCD0D0113315403E375791E99AFA3F8906EE47C0ED6818464368420048DC541E"</p>
  
  <p><strong>4)</strong> <strong>Test URL</strong> : "<a href="https://migs.mastercard.com.au/vpcdps" rel="nofollow">https://migs.mastercard.com.au/vpcdps</a>"</p>
  
  <p><strong>5)</strong> <strong>Final Request to Send on above URL</strong></p>
  
  <p>"vpc_AccessCode=XXXXXXXX&amp;vpc_Amount=100&amp;vpc_CardExp=1310&amp;vpc_CardNum=5313581000123430&amp;vpc_Command=pay&amp;vpc_MerchTxnRef=TC_2014712466141&amp;vpc_Merchant=TESTMXXXXXXXX&amp;vpc_OrderInfo=TC_2014712466141&amp;vpc_Version=1&amp;vpc_SecureHash=CCD0D0113315403E375791E99AFA3F8906EE47C0ED6818464368420048DC541E&amp;vpc_SecureHashType=SHA256"</p>
  
  <p><strong>6)</strong> I am using the Below Code For Sending the Request and Getting the Response.</p>
  
  <p>System.Net.WebClient webClient = new System.Net.WebClient();</p>
  
  <pre><code>        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);
  </code></pre>
  
  <p><strong>7)</strong> <strong>Functions</strong> used  to Generate <strong>SecureHash</strong></p>
  
  <p>public static string ToHMACSHA256(string input, string key)</p>
  
  <pre><code>{
  
      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);
  
  }
  </code></pre>
  
  <p>private static string ByteToString(byte[] buff)</p>
  
  <pre><code>{
  
      string sbinary = "";
  
      for (int i = 0; i &lt; buff.Length; i++)
        { 
            sbinary += buff[i].ToString("X2"); // hex format
        }
  
      return (sbinary);
  
  }
  </code></pre>
  
  <p>Please get me the Solutions for the Above Error Asap. Thanks in Advance</p>
  
  <p>Thanks &amp; Regards</p>
  
  <p>Sunny Pathai</p>