簡體   English   中英

HttpWebRequest.GetResponse從支付網關返回html標簽

[英]HttpWebRequest.GetResponse returning html tag from payment gateway

我正在嘗試通過此鏈接( 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,並且具有form標簽的action屬性中的所有參數,我不知道這是什么,我該怎么做。 誰能幫我這個忙。 我附上我得到的答復,也請看一下

謝謝

點擊鏈接查看回復

該文檔指出:

切記-商家應該開發一種表格,該表格不會將數據發送到他的網站,而是直接將表格提交給PayFort。

您正在執行他們要求您不要執行的操作。

我認為這不是要用作API。 您的表格應將信息直接提交給他們的系統。 然后,他們將使用return_url參數顯示工作流程中的下一頁。 該URL將包含結果的詳細信息。

您可以隨時與他們聯系,並要求進行備用的,后端友好的集成。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM