PayPal POST付款不适用于移动浏览器

时间:2014-10-10 16:28:16

标签: vb.net paypal paypal-sandbox

我有一个用VB.net编写的Web应用程序。我通过paypal实现了付款。 当我通过电脑付款时没有问题,但是当我通过手机付款时,我遇到了一些问题。 我无法在返回页面上阅读paypal参数。 我使用httpwebrequest从paypal读取信息,但变量request.form为空,因此响应为" INVALID"。

有谁可以帮助我???请...

1 个答案:

答案 0 :(得分:0)

这是我的代码:

        Dim objHttp As HttpWebRequest

        objHttp = WebRequest.Create("https://www.sandbox.paypal.com/cgi-bin/webscr")
            objHttp.Method = "POST"

        objHttp.ContentType = "application/x-www-form-urlencoded"

        Dim param As Byte() = Request.BinaryRead(HttpContext.Current.Request.ContentLength)
        Dim strRequest As String = Encoding.ASCII.GetString(param)
        Dim ipnPost As String = strRequest

        strRequest += "&cmd=_notify-validate"
        objHttp.ContentLength = strRequest.Length

        'Send the request to PayPal and get the response
        Dim streamOut As New StreamWriter(objHttp.GetRequestStream(), System.Text.Encoding.ASCII)
        streamOut.Write(strRequest)
        streamOut.Close()

        Dim streamIn As New StreamReader(objHttp.GetResponse().GetResponseStream())
        Dim strResponse As String = streamIn.ReadToEnd()
        streamIn.Close()

        Dim myHttpWebResponse As HttpWebResponse = CType(objHttp.GetResponse(), HttpWebResponse)

        Dim strIdTransazione = Request.Form("txn_id")
        Dim strDscTransazione = Request.Form("payment_status")

        'HttpStatusCode.myHttpWebResponse.StatusCode()

        If myHttpWebResponse.StatusCode <> HttpStatusCode.OK Then

        Else

        end if