Advertisement

05.26.2008 at 01:12PM PDT, ID: 23433285
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

Need some help with Paypal IPN

Asked by gogetsome in Payment Processing Recommendation and Integrating, E-Commerce, .Net Editors & IDEs

Tags:

Hello, I am attempting to do IPN for the first time and really could use some help.
With my code below, I can sucessfully take a payment. I want to be able to use IPN to take appropriate action on if the transaction is a success.
The transaction is successful yet the user is redirected to the page which should be the failure page.
Any help would be great!

Here is a sample of the code I use to send to paypal:

Dim amount As Decimal = 0.5
        Dim orderId As String = 1002
        Dim siteName As String = "nice"
        Dim ReturnURL As String = "nice/store/Notify.aspx"
        Dim CancelledURL As String = "nice/store/Cancelled.aspx"

        ' Create the PayPal redirect location
        Dim redirect As String = ""
        redirect += "https://www.paypal.com/xclick/business=Scott@nice.com"
        redirect += "&item_name=" + siteName + " Order " + orderId
        redirect += "&item_number=" + orderId
        redirect += "&amount=" + [String].Format("{0:0.00} ", amount)
        redirect += "&currency=USD"
        redirect += "&return=http://" + ReturnURL
        redirect += "&cancel_return=http://" + CancelledURL

        ' Redirect to the payment page
        Response.Redirect(redirect)

The payment is successfull then we do the IPN set to the notify.aspx page. The following code is supposed to set a session with "OK" if the payment is varified and redirect to the thankyou.aspx. BUT even though the payment is good the user is direced to the cancelled.aspx


Here is the Notify.aspx code:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        '-- Capture posted form values from PayPal
        Dim FormValues As String = Request.Form.ToString()

        ' Create the postback to PayPal to verify sent information
        Dim PostBackRequest As HttpWebRequest
        PostBackRequest = WebRequest.Create("https://www.paypal.com/cgi-bin/webscr")
        PostBackRequest.Method = "POST"
        PostBackRequest.ContentType = "application/x-www-form-urlencoded"
        Dim PostBackString As String = FormValues + "&cmd=_notify-validate"
        PostBackRequest.ContentLength = PostBackString.Length

        ' Send the postback reply to PayPal
        Dim PostBackWriter As StreamWriter
        PostBackWriter = New StreamWriter(PostBackRequest.GetRequestStream(), Encoding.ASCII)
        PostBackWriter.Write(PostBackString)
        PostBackWriter.Close()

        ' Receive final verification from PayPal
        Dim ResponseReader As StreamReader
        ResponseReader = New StreamReader(PostBackRequest.GetResponse().GetResponseStream())
        Dim ResponseString As String = ResponseReader.ReadToEnd()
        ResponseReader.Close()

        If ResponseString = "VERIFIED" Then
            'Set a flag and transfer to sales success page
            Session("Verified") = "OK"
            Response.Redirect("ThankYou.aspx")
        Else
            'Set flag and transfer to sales failure page
            Session("Verified") = ""
            Response.Redirect("Cancelled.aspx")
        End If


    End Sub


How can I debug this? What should I or what can i do to fix this?Start Free Trial
[+][-]06.04.2008 at 10:58PM PDT, ID: 21716686

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Payment Processing Recommendation and Integrating, E-Commerce, .Net Editors & IDEs
Tags: asp.net
Sign Up Now!
Solution Provided By: neeraj523
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628