【问题标题】:HttpWebRequest.GetResponse returning html tag from payment gatewayHttpWebRequest.GetResponse 从支付网关返回 html 标记
【发布时间】: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();
}

enter image description here

现在我不明白的是,我得到的响应是与我的页面相同的 HTML 以及表单标签的 action 属性中的所有参数,我不知道这是什么以及我必须做什么它。谁能帮我解决这个问题。 我正在附上我收到的回复,也请看一下

谢谢

click on the link to view response

【问题讨论】:

  • 您发布的回复是您在result 变量中获得的内容吗?

标签: c# asp.net httpwebrequest httpwebresponse


【解决方案1】:

文档说明:

记住 - 商家应该开发一个不发送数据的表单 到他的网站,但直接将表单提交给 PayFort。

你正在做他们要求你做的事情。

我不认为这是为了用作 API。您的表单应该将信息直接提交到他们的系统。然后,他们将使用 return_url 参数在您的工作流程中显示下一页。该 URL 将包含结果的详细信息。

您可以随时与他们联系并要求提供替代的、后端友好的集成。

【讨论】:

    猜你喜欢
    • 2019-05-30
    • 2012-11-12
    • 2020-04-01
    • 1970-01-01
    • 2011-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多