I'm integrating CashU Payment gateway.
I need to Post some data using POST method. then I want to redirect to payment gateway site.
I have done so far
[HttpPost]
public ActionResult Index(string getAmount)
{
// some more process
var getResponce = ExecutePost(getTokenCode);
}
private string ExecutePost(string tokenCode)
{
var cashuLink = ConfigurationManager.AppSettings["CashULink"].ToString();
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(cashuLink);
var postData = "Transaction_Code="+tokenCode;
postData += "&test_mode=1";
var data = Encoding.ASCII.GetBytes(postData);
webReq.Method = "POST";
webReq.ContentType = "application/x-www-form-urlencoded";
webReq.ContentLength = data.Length;
using (var stream = webReq.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)webReq.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
return responseString;
}
My ExecutePost method is returing a Html page string in string formate. But I want to redirect on payment gateway site.