private respon HTTPPostReponse(string requestURL, Dictionary <string, string> postDataParams) { try { using (var client = new WebClient()) { var postValues = new NameValueCollection(); foreach (KeyValuePair <string, string> dic in postDataParams) { postValues[dic.Key] = dic.Value; } var response = client.UploadValues(requestURL, postValues); string xml = Encoding.UTF8.GetString(response); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlSerializer serializer = new XmlSerializer(typeof(respon)); using (TextReader reader = new StringReader(xml)) { respon result = (respon)serializer.Deserialize(reader); return(result); } } } catch (Exception ex) { throw; } }
public respon payment() { _PARAMS.Remove("ccn"); #region Generate sha256 Code : signInfo String signature = ""; signature = (String)_PARAMS["merNo"] + (String)_PARAMS["gatewayNo"] + (String)_PARAMS["orderNo"] + (String)_PARAMS["orderCurrency"] + (String)_PARAMS["orderAmount"] + (String)_PARAMS["firstName"] + (String)_PARAMS["lastName"] + (String)_PARAMS["cardNo"] + (String)_PARAMS["cardExpireYear"] + (String)_PARAMS["cardExpireMonth"] + (String)_PARAMS["cardSecurityCode"] + (String)_PARAMS["email"] + _SECRET_KEY; if (_PARAMS.ContainsKey("signInfo")) { _PARAMS.Remove("signInfo"); } string strSHA256 = Generatesha256(_SECRET_KEY, signature); _PARAMS.Add("signInfo", strSHA256); #endregion Generate sha256 Code (signInfo) try { // For logging of rhe Params try { string strDic = string.Join(";", _PARAMS.Select(x => x.Key + "=" + x.Value).ToArray()); } catch { } respon TrustPayReponse = new respon(); TrustPayReponse = HTTPPostReponse(_API_URL, _PARAMS); return(TrustPayReponse); } catch (Exception e) { throw e; } }
//void fillListRespon() //{ // try // { // lbxEmployee.DataSource = db.respons.Select(u => u.name).ToList(); // } // catch (Exception ex) // { // MessageBox.Show(ex.ToString(), "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error); // } //} private void btnAddEmploee_Click(object sender, EventArgs e) { string error = string.Empty; if (txtNameEmplyee.Text.Trim() == string.Empty) { error += "إدخل اسم المتعهد\n"; } if (error != string.Empty) { MessageBox.Show(error, "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { try { var resp = new respon() { name = txtNameEmplyee.Text }; db.respons.Add(resp); db.SaveChanges(); txtNameEmplyee.Text = string.Empty; //lbxEmployee.Items.Clear(); lbxEmployee.DataSource = db.respons.Select(u => u.name).ToList(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }