Paypal return id comes fail.what should i do?? I have tried a lot..but not working..
- public string Cart_ConfirmOrder(string UnitId)
- {
- int Quantity = 0;
- string name = "";
- try
- {
- Session["Quantity"] = Quantity;
- Session["UnitID"] = name;
- Session["payamount"] = ConfigurationManager.AppSettings["payamount"].ToString();
-
-
- string redirecturl = "";
- redirecturl +=
- redirecturl += "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" + ConfigurationManager.AppSettings["BusinessEmail"].ToString();
-
-
- redirecturl += "&item_name=" + name;
-
-
- redirecturl += "&amount=" + ConfigurationManager.AppSettings["payamount"].ToString();
-
-
- redirecturl += "&quantity=" + Quantity;
-
-
-
- redirecturl += "&tax=" + 0;
-
- redirecturl += "&return=" +
- ConfigurationManager.AppSettings["ReturnUrl"].ToString();
-
- redirecturl += "&cancel_return=" +
- ConfigurationManager.AppSettings["CancelPurchaseUrl"].ToString();
-
-
-
- return redirecturl;
-
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- public ActionResult GetResponse()
- {
- string TransactionIDc = Request.QueryString.Get("tx");
- string transactionID = "";
- var formVals = new Dictionary<string, string>();
- formVals.Add("cmd", "_notify-synch");
- formVals.Add("at", "AO6pILVgzXKfGZ4XyTdge9Zgmio.AbNUckZNoSqVHzWaFf8gWR0BPzqP");
- formVals.Add("tx", Request["tx"]);
-
- string response = GetPayPalResponse(formVals, true);
- if (response.Contains("SUCCESS"))
- {
- transactionID = GetPDTValue(response, "txn_id");
- string sAmountPaid = GetPDTValue(response, "mc_gross");
- string deviceID = GetPDTValue(response, "custom");
- string payerEmail = GetPDTValue(response, "payer_email");
- string Item = GetPDTValue(response, "item_name");
- }
- else
- {
- }
- }
- string GetPayPalResponse(Dictionary<string, string> formVals, bool useSandbox)
- {
-
- string paypalUrl = useSandbox ? "https://www.sandbox.paypal.com/cgi-bin/webscr"
- : "https://www.paypal.com/cgi-bin/webscr";
-
- HttpWebRequest req = (HttpWebRequest)WebRequest.Create(paypalUrl);
-
-
- req.Method = "POST";
- req.ContentType = "application/x-www-form-urlencoded";
-
- byte[] param = Request.BinaryRead(Request.ContentLength);
- string strRequest = Encoding.ASCII.GetString(param);
-
- StringBuilder sb = new StringBuilder();
- sb.Append(strRequest);
-
- foreach (string key in formVals.Keys)
- {
- sb.AppendFormat("&{0}={1}", key, formVals[key]);
- }
- strRequest += sb.ToString();
- req.ContentLength = strRequest.Length;
-
-
-
-
-
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
- string response = "";
- using (StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII))
- {
-
- streamOut.Write(strRequest);
- streamOut.Close();
- using (StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream()))
- {
- response = streamIn.ReadToEnd();
- }
- }
-
- return response;
- }
- string GetPDTValue(string pdt, string key)
- {
-
- string[] keys = pdt.Split('\n');
- string thisVal = "";
- string thisKey = "";
- foreach (string s in keys)
- {
- string[] bits = s.Split('=');
- if (bits.Length > 1)
- {
- thisVal = bits[1];
- thisKey = bits[0];
- if (thisKey.Equals(key, StringComparison.InvariantCultureIgnoreCase))
- break;
- }
- }
- return thisVal;
-
- }
here "response" return FAIL after order complete.
I have changed the IPN notification setting in paypal also