实际上,我需要将一些隐藏字段发送到页面,然后将其加载到浏览器窗口中。
这是根据第6页:http://www.docstoc.com/docs/10745827/Sage-Pay-Form-Protocol-and-Integration-Guidelines所述的SagePay窗体集成
我已经在使用WebRequest创建帖子了,但是我该如何发送他们需要的4个隐藏字段呢?
另外,如何将返回的html加载到浏览器中;该html来自SagePay,客户在其中输入他们的信用卡详细信息?
public string SendRequest(string url, string postData)
{
var uri = new Uri(url);
var request = WebRequest.Create(uri);
var encoding = new UTF8Encoding();
var requestData = encoding.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.Timeout = (300 * 1000); //TODO: Move timeout to config
request.ContentLength = requestData.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(requestData, 0, requestData.Length);
}
var response = request.GetResponse();
string result;
using (var reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII))
{
result = reader.ReadToEnd();
}
return result;
}发布于 2010-10-13 04:41:55
只需将4个隐藏字段添加到postData字符串中。这可以在此方法中或在请求中即时完成。
“隐藏”方面仅在浏览器的GUI方面是隐藏的。
https://stackoverflow.com/questions/3918817
复制相似问题