【发布时间】:2018-01-17 21:04:21
【问题描述】:
我正在尝试通过此链接 (https://docs.payfort.com/docs/merchant-page-two/build/index.html) 将支付网关集成到我的 asp.net 网站中。
以下是我的示例代码:
protected void btnPay_Click(object sender, EventArgs e)
{
ASCIIEncoding encoding = new ASCIIEncoding();
string data = string.Format("service_command={0}&access_code={1}&merchant_identifier={2}&merchant_reference={3}&language={4}&signature={5}&token_name={6}&expiry_date={7}&card_number={8}&card_security_code={9}&card_holder_name={10}&remember_me={11}&return_url={12}",
"TOKENIZATION", "zx0IPmPy5jp1vAz", "CycHZxVj", "XYZ9239-yu898","en", "d7c185c475ac0e3", "Op9Vmp", "1705", "4005550000000001","123", "John Smith","NO", "http://localhost:1093/Default.aspx");
byte[] bytes = encoding.GetBytes(data);
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create("https://sbcheckout.payfort.com/FortAPI/paymentPage");
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
httpRequest.ContentLength = bytes.Length;
using (Stream stream = httpRequest.GetRequestStream())
{
stream.Write(bytes, 0, bytes.Length);
stream.Close();
}
StreamReader rdr = new StreamReader(httpRequest.GetResponse().GetResponseStream());
string result = rdr.ReadToEnd();
rdr.Close();
httpRequest.GetResponse().Close();
}
现在我不明白的是,我得到的响应是与我的页面相同的 HTML 以及表单标签的 action 属性中的所有参数,我不知道这是什么以及我必须做什么它。谁能帮我解决这个问题。 我正在附上我收到的回复,也请看一下。
谢谢
【问题讨论】:
-
您发布的回复是您在
result变量中获得的内容吗?
标签: c# asp.net httpwebrequest httpwebresponse