Unable to post to paypal using HttpWebRequest in asp.net

Posted on 2006-04-04
Medium Priority
Last Modified: 2012-05-05
I am trying to post information to paypal in order for customers to pay for merchandise on a site that I am developing. I am passing the information over so the paypal site can grab the info. I am using the HttpWebRequest and what is happening is that it is not redirecting to the paypal site. Here is the code that I am using.

Protected Sub lbAddress_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbAddress.Click

        Dim objRequest As HttpWebRequest
        Dim strRequest As String
        Dim arrRequest As Byte()
        Dim objUTF8Encoding As UTF8Encoding
        Dim strmRequest As Stream

        objRequest = CType(WebRequest.Create("https://www.paypal.com/cgi-bin/webscr"), HttpWebRequest)
        objRequest.Method = "POST"
        objRequest.ContentType = "application/x-www-form-urlencoded"

        strRequest = "?" & Server.UrlEncode("cmd=_cart &upload=1 &business=login@youremail.com&item_name_1=Item1 &amount_1=10.00")
        objUTF8Encoding = New UTF8Encoding
        arrRequest = objUTF8Encoding.GetBytes(strRequest)
        objRequest.ContentLength = arrRequest.Length
        strmRequest = objRequest.GetRequestStream()
        strmRequest.Write(arrRequest, 0, arrRequest.Length)

    End Sub

I have been trying to get this to work for a couple hours now and am totally stumped.

Question by:ryapos
1 Comment

Accepted Solution

enwhysee earned 2000 total points
ID: 16380567
I'm not sure if it helps, but I found a detailed code sample here...

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Screencast - Getting to Know the Pipeline
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question