public static string GetVerifySignature(PayData objMaster) { try { var ShaReqeustVar = "91wG1283xoSln4Db9Y7IPZ&?"; var myArray = new Dictionary <string, string>(); myArray.Add("access_code", "a9U2M7lKbzlSOKzkyMli"); myArray.Add("fort_id", objMaster.fort_id); myArray.Add("language", "en"); myArray.Add("merchant_identifier", "957fafda"); myArray.Add("merchant_reference", objMaster.merchant_reference); myArray.Add("query_command", "CHECK_STATUS"); var baseString = ""; foreach (var item in myArray) { baseString += item.Key + "=" + item.Value; } var shastring = ShaReqeustVar + baseString + ShaReqeustVar; var shaPhrase = SHA256Util.sha256_hash(shastring); return(shaPhrase); } catch { return(""); } }
protected void Button1_Click(object sender, EventArgs e) { PayData paydata = new PayData { merchant_reference = "XYX8777-yu898", fort_id = "169996200000132829", }; var signature = AjaxCaller.GetVerifySignature(paydata); paydata.signature = signature; string baseAddress = "https://sbpaymentservices.payfort.com/FortAPI/paymentApi"; string responseStream = ""; using (var client = new HttpClient()) { // TODO - Send HTTP requests client.BaseAddress = new Uri(baseAddress); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); string json = JsonConvert.SerializeObject(paydata); HttpContent content = new StringContent(json); HttpResponseMessage responseNew = client.PostAsync(baseAddress, content).GetAwaiter().GetResult(); if (responseNew.IsSuccessStatusCode) { responseStream = responseNew.Content.ReadAsStringAsync().GetAwaiter().GetResult(); Console.WriteLine(responseStream); txtCheckStatusResponse.Text = responseStream; } } }