交易成功完成后,Paypal确认

时间:2014-02-17 11:45:36

标签: asp.net vb.net paypal

我已经在Buy Now按钮上将我的网站重定向到了Paypal,但是在成功完成交易后我应该在哪里放置我的代码。 有人可以帮忙吗?我需要在我的投标中将我的状态改为付款。

 Dim temp As String = Request.QueryString("user").ToString
    Dim temp1 As Integer = Convert.ToInt32(temp)
    Dim LastName As String
    Dim WinningPrice As String
    Dim email As String
    Dim country As String
    Dim Name As String
    Dim FirstName As String
    Using con1 As New SqlConnection(_start)
        'Build your SQL String'
        Dim sql1 As String = "SELECT Item.Name, BID.WinningPrice, Member.LastName, Member.FirstName,Member.Email, Member.Country FROM  Item INNER JOIN Seller ON Item.SellerID = Seller.SellerID INNER JOIN Auction ON Item.ItemID = Auction.ItemID INNER JOIN BID ON Auction.AuctionID = BID.AuctionID INNER JOIN Member ON Seller.MemberID = Member.MemberID WHERE (Member.Status = 'Available') AND (Seller.SellerStatus = 'Available') AND (BID.Status = 'Won') AND (Auction.Status = 'Expired') and BID.BidID=@bidid"
        'Open your connection'
        con1.Open()

        'Build your Command to execute'
        Dim myCommand1 As New SqlCommand(sql1, con1)

        'Grab your parameter'

        'Add your parameter'
        myCommand1.Parameters.Add("@bidid", SqlDbType.Int).Value = temp1
        Dim reader As SqlDataReader = myCommand1.ExecuteReader()

        If reader.HasRows Then
            If reader.Read() Then
                ' etc
                Name = reader.GetString(0)
                WinningPrice = Convert.ToString(reader.GetDouble(1))
                LastName = reader.GetString(2)
                FirstName = reader.GetString(3)
                email = reader.GetString(4)
                country = reader.GetString(5)

                Dim price As Object
                'Converting String Money Value Into Decimal
                price = Convert.ToDouble(WinningPrice)
                'declaring empty String
                Dim returnURL As String = ""
                returnURL += "https://www.paypal.com/xclick/business=" + email
                'Passing Item Name as dynamic
                returnURL += Convert.ToString("&item_name=") & Name
                'Assigning Name as Statically to Parameter

                returnURL += Convert.ToString("&first_name") & FirstName

                'Assigning Name as Statically to Parameter

                returnURL += Convert.ToString("&last_name") & LastName
                'Assigning City as Statically to Parameter



                returnURL += Convert.ToString("&country") & country
                'Passing Amount as Dynamic
                returnURL += "&amount=" + price.ToString
                'Passing Currency as your 
                returnURL += "&currency=USD"
                'If transactioin has been successfully performed, redirect SuccessURL page- this page will be designed by developer
                returnURL += "&return=" + ConfigurationManager.AppSettings("SuccessURL").ToString()
                'retturn Url if Customer Wants To Cancel the Transaction

                'If transactioin has been failed, redirect FailedURL page- this page will be designed by developer
                returnURL += "&cancel_return=" + ConfigurationManager.AppSettings("FailedURL").ToString()



                Response.Redirect(returnURL)

            End If
        End If
    End Using

1 个答案:

答案 0 :(得分:0)

您正在传递SuccessUrl参数;当paypal完成时,它将向该页面发送通知 - 因此您应该将代码放在SuccessUrl的Page_Load事件中,以解析返回的查询parms,并执行您需要执行的任何本地处理。