Paypal Express付款执行

时间:2015-02-12 14:48:11

标签: asp.net vb.net paypal paypal-ipn paypal-sandbox

我正在开发vb.net,截至目前我没有使用任何API来接收交易细节我只使用IPN和PDT变量来获取我的详细信息然而我开始注意到,当使用Paypal Sandbox时为了测试,在我完成结账过程之后,我确实收到了详细信息的所有变量,但是在我的测试帐户中,没有显示任何交易。

我是否需要使用REST API才能实际批准并执行交易付款才能完成交易?我已经假设整个交易已经成功完成,因为我收到了所有细节,但现在我注意到我的帐户中没有显示任何交易,我不确定最新情况如何?

以下是我用于查看交易详情的代码

Dim authToken As String = "c37yqZU7UdVWesSoipRHFOwB3fFLv1CfOKWz10hqp0ULz6dYKrlCNuxp9d0"
    Dim txToken As String = Request.QueryString("tx")
    txToken = "2F816064M1280054A" '"6AX4295820157674V" '"5PD1935338742763G" ' '"70Y83841KE749971T"  '"74C31896AA9005743""2RY90202U2008611C" '"0F824628H9566062P" '"5ET57654YS955312K" '
    Dim strRequest As String = "cmd=_notify-synch&tx=" & txToken & "&at=" & authToken




    'Dim Payerinfo As New PayerInfo
    'Dim trans As New Transaction
    'Dim tra As New PayPal.PayPalAPIInterfaceService.Model.GetTransactionDetailsReq




    '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)
    'req.Headers = valHeader
    'Set values for the request back
    req.Method = "POST"
    req.ContentType = "application/x-www-form-urlencoded"
    req.ContentLength = strRequest.Length

    '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()

    If Not String.IsNullOrEmpty(strResponse) Then

        Dim results As New Dictionary(Of String, String)
        Dim reader As New StringReader(strResponse)
        Dim line As String = reader.ReadLine()
        If line = "SUCCESS" Then
            'FormView1.Visible = False
            While True
                Dim aLine As String
                aLine = reader.ReadLine
                If aLine IsNot Nothing Then
                    Dim strArr() As String
                    strArr = aLine.Split("=")
                    results.Add(strArr(0), strArr(1))
                Else
                    Exit While
                End If
            End While
            ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
            'when code below is uncommented remove these two end if's below


            Response.Write("<li> " + results("payer_id") + "</li>")
            Response.Write("<li> " + results("txn_id") + "</li>")
            ' Displays all the keys for results, helps to see what the keys are named for writing to text file
            For Each kvp As KeyValuePair(Of String, String) In results
                Dim v1 As String = kvp.Key
                Dim v2 As String = kvp.Value
                Response.Write(v1.ToString _
                        + ":  " + v2 + "<br /> ")
            Next

        End If

0 个答案:

没有答案
相关问题