Results 1 to 13 of 13

Thread: Posting Data to Another URL

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    85

    Posting Data to Another URL

    Hello,

    I am developing an ASP.NET shopping cart that uses PayPal for payment processing. I would like to find a way to post the shopping cart variables to PayPal without displaying them in the URL.

    I have been searching for hours without being able to find a solution to this question. It works fine when I pass the variables through the URL, but I don't want my customers to be able to see the variables that I'm passing to PayPal. I'd appreciate any help or advice.

  2. #2
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Doesnt the Session object persist even when navigating out of the site you developed?

    I would just store the values in the session.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    85

    Session object

    Then how do I pass the session variables to PayPal, and how will PayPal process them?

  4. #4
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    I have no idea. How exactly do you expect paypal to take your variables? What exactly are you trying to do? I dont really understand. I assumed you were trying to fill in some fields on a paypal page or something...
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Are you doing this in your form tag?
    method="post"

    Also, maybe paypal doesn't support this method. Maybe they only support querystring values (which is what you see in the address bar). You should check with them.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    85
    Sorry, if I wasn't clear earlier. I am just trying to send PayPal the information pertaining the my customer's shopping cart (such as item ID, name, quantity, price, etc.)

    I can do it through the URL, but I don't want my customers to be able to see the variables (I don't want anyone trying to change the price or the quantities). I just need to know how to POST the variables without actually putting them in the URL.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    85
    PayPal does support the POST method as I have seen sites that do not use the querystring method to pass shopping cart variables to PayPal.

    Can you explain using the Session variable method. I know what they are and how to implement them, but I don't get how storing my customer's shopping cart in session variables allows PayPal to use and process them.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    85
    Well,

    I have figured out how to post the data to PayPal (without using the querystring method), but now how do I open the PayPal page for my customers?

    Here is my code

    Code:
                Dim strURL As String = "https://www.paypal.com/xclick/?"""
    
                Dim strRedirect As String = "cmd=_cart"
                strRedirect += "&business=" + Server.UrlEncode("[email protected]")
                strRedirect += "&invoice=" + Server.UrlEncode(10000) + "&item_name=AME Magazine&item_number=10003"
    
                Dim myWriter As StreamWriter
                Dim objRequest As HttpWebRequest = CType(WebRequest.Create(strURL), HttpWebRequest)
                objRequest.Method = "POST"
                objRequest.ContentLength = strRedirect.Length
                objRequest.ContentType = "application/x-www-form-urlencoded"
                Try
    
                    myWriter = New StreamWriter(objRequest.GetRequestStream())
                    myWriter.Write(strRedirect)
                Catch
                    'error message
                    Console.WriteLine(e.ToString)
                Finally
                    myWriter.Close()
                End Try
    
                Dim objResponse As HttpWebResponse = CType(objRequest.GetResponse(), HttpWebResponse)
                Dim newsr As New StreamReader(objResponse.GetResponseStream())
                Dim respText As String = newsr.ReadToEnd()
    respText returns the html of the PayPal page but I can't just response.write(respText) because the customer actually has to be redirected to the PayPal page in order for it to work properly.

  9. #9
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Response.Redirect(respText)

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    85
    response.redirect(respText) does not work because respText is not a URL, it is the HTML code from the PayPal page.

  11. #11
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Try something like this. (it is from memory, may not be exact)

    Dim myLitControl As New LiteralControl()
    myLitControl.Text = respText
    Me.Controls.Add(myLitControl)


    You can also use a placeholder on your page, then add the literalcontrol tot hat placeholder I believe.

  12. #12
    Lively Member
    Join Date
    Aug 2002
    Location
    outerspace
    Posts
    126
    Doesnt paypal have a webservice?
    "All those who wonder are not lost" -j.r.r tolkien

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    85
    Thanks Hellswraith, but I know how to display the html string I get from PayPal, I wanted to know if there was a way that I could, not just display the page, but actually redirect my customers to the PayPal page after I POST the values.

    As far as I know, robdotnet00, PayPal does not have a webservice.

    Anyways, I solved this problem by developing another page that creates a custom form based on the customer's current shopping cart. This is just a regular html form that Posts the hidden variables to the PayPal site.

    It's one more page that my customers will have to click through, but at least it works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width