I am trying to integrate a payment platform to my web application but one of the requirements to query a transaction is to send a hashed value (of certain variables) as a header using a get request. This is what I have tried:
string hashcode = "3409877" + "117" + "D3D1D05AFE42AD508";
var hashedBytes = SHA512.Create().ComputeHash(Encoding.UTF8.GetBytes(hashcode));
// Get the hashed string.
var hash = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
hash = hash.ToString().ToUpper();
var amount_kobo = Convert.ToInt32(model.TransactionAmount * 100);
string url = "https://sandbox.interswitchng.com/collections/api/v1/gettransaction.json?productid=117&transactionreference=" + model.TransactionReference + "&amount=" + amount_kobo;
using (var client = new HttpClient())
{
#if DNX451
// ignore server certificate error
//ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
#elif DNXCORE50
// no implementation for the target DNX
#endif
client.BaseAddress = new Uri(url);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("text/html"));
client.DefaultRequestHeaders.Add("Hash",hash);
HttpResponseMessage response = await client.GetAsync(url);
string responsestr = "";
if (response.IsSuccessStatusCode)
{
responsestr = await response.Content.ReadAsStringAsync();
return Json(new { success = true, response = responsestr, hash = hash });
}
}
but my hash is not sent, when I inspect the browser after sending the request I do not see my hash header, also am supposed to send the header as a hash type but I have no idea what to do.
I have tried changing this line to:
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("hash"));
still it doesn't work.
Update Here is a screenshot of the request headers in the browser Request headers
Seems my header is not sent at all.