将事务详细信息发布到远程服务器(aspx vb)

时间:2015-01-09 14:25:43

标签: vb.net

我需要认真的帮助,我的申请中间有库存。 我想将交易详情发布到https://stageserv.interswitchng.com/test_paydirect/pay

这是我的代码

Protected Sub btnPay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPay.Click
    'GET EVENT ID
    EventID = Request.QueryString("eid")
    'CALL SHA512
    Dim SHA512_hash As String = UCase(SHA512Cri(lblTrackingNo.Text & EventID & CustID & AppAmount & "http://www.siteredirecturl.com/get_resp.aspx/AC43543FA32234HB23423AFH843535"))

    Dim url As Uri = New Uri("https://stageserv.interswitchng.com/test_paydirect/pay")
    Dim postData As StringBuilder = New StringBuilder()
    postData.Append("product_id=" + HttpUtility.UrlEncode(EventID) + "&")
    postData.Append("pay_item_id=" + HttpUtility.UrlEncode(CustID) + "&")
    postData.Append("amount=" + HttpUtility.UrlEncode(AppAmount) + "&")
    postData.Append("currency=" + HttpUtility.UrlEncode("566") + "&")
    postData.Append("site_redirect_url=" + HttpUtility.UrlEncode("http://www.siteredirecturl.com/get_resp.aspx") + "&")
    postData.Append("txn_ref=" + HttpUtility.UrlEncode(lblTrackingNo.Text) + "&")
    postData.Append("hash=" + HttpUtility.UrlEncode(SHA512_hash))

    Dim myWebRequest As HttpWebRequest = TryCast(WebRequest.Create(url), HttpWebRequest)
    myWebRequest.Method = "POST"
    Dim byteArray As Byte() = UTF8Encoding.UTF8.GetBytes(postData.ToString())
    myWebRequest.ContentType = "application/x-www-form-urlencoded"
    myWebRequest.ContentLength = byteArray.Length
    Dim dataStream As System.IO.Stream = myWebRequest.GetRequestStream()
    dataStream.Write(byteArray, 0, byteArray.Length)
    dataStream.Close()
End Sub

服务器将对我发布到服务器的代码中提供的“site_redirect_url”执行POST请求,但它不会重定向到“site_redirect_url”。

0 个答案:

没有答案