none
想到頭快要炸掉了... Paypal .. RRS feed

  • 問題

  •  

    請教各位前輩

    小弟目前開發購物車~

    想結合Paypal

    無奈..前面都很ok

    但是當小弟啟用Paypal IPN

    想做到接收最後User付完錢後,點下 Return to Merchant 按紐

    指到我的驗證頁....ChrckPaypal.aspx

    Code Snippet

    Imports System.Net
    Imports System.IO
    Partial Class CheckPaypal
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            'Dim numbers As String = Request.QueryString("Item_number")
            'Response.Write(numbers)
            'Post back to either sandbox or live
            Dim strSandbox As String = "https://www.sandbox.paypal.com/cgi-bin/webscr"
            Dim strLive As String = "https://www.paypal.com/cgi-bin/webscr"
            Dim req As HttpWebRequest = CType(WebRequest.Create(strSandbox), HttpWebRequest)

            'Set values for the request back
            req.Method = "POST"
            req.ContentType = "application/x-www-form-urlencoded"
            Dim Param() As Byte = Request.BinaryRead(HttpContext.Current.Request.ContentLength)
            Dim strRequest As String = Encoding.ASCII.GetString(Param)
            strRequest = strRequest + "&cmd=_notify_validate"
            req.ContentLength = strRequest.Length

            'for proxy
            'Dim proxy As New WebProxy(New System.Uri("http://url:port#"))
            'req.proxy = proxy

            'Send the request to Paypal and get the response
            Dim streamOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
            streamOut.Write(strRequest)
            streamOut.Close()
            Dim streamIn As StreamReader = New StreamReader(req.GetResponse().GetResponseStream())
            Dim strResponse As String = streamIn.ReadToEnd()
            streamIn.Close()
            Response.Write(strResponse)
            If strResponse = "VERIFIED" Then
                'check the payment_status is Completed
                'check that txn_id has not been previously processed
                'check that receiver_email is your Primary PayPal email
                'check that payment_amount/payment_currency are correct
                'process payment
                Response.Write("VERIFIED")
            ElseIf strResponse = "INVALID" Then
                'log for manual investigation
                Response.Write("VERIFIED")
            Else
                'Response wasn't VERIFIED or INVALID, log for manual inverstigation
                Response.Write("ERROR")
            End If
        End Sub
    End Class

     

     

    可是很神奇....都沒有值傳過來

    網頁直接Response.Write("ERROR")

    不知是否有前輩也曾經遇到過這問題..

    麻煩各位前輩指導...感恩

    2008年3月5日 上午 07:15

解答

  • 我沒用過 PayPal,但原理上你應該是程式套錯了,建議你多看看他們的說明文件吧,看仔細一點摟。

     

     

    2008年3月5日 上午 09:33

所有回覆