473,669 Members | 2,514 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pay Pal - Using HttpWebRequest

I want to use Pay Pal in my web site.

What I want to do is attach the following code to a button

<code>
ASCIIEncoding encoding = new ASCIIEncoding() ;
string postData = "cmd=" + "business";
postData += ("&business= " + "in**@myemailac count.com");
postData += ("&item_name =" + "Test");
postData += ("&currency_cod e=" + "GBP");
postData += ("&amount=" + "0.00");
postData += ("&return=" +
"http://www.myserver.co m/paymentReceived .aspx");
postData += ("&rm=" + "2");
byte[] data = encoding.GetByt es(postData);
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest )WebRequest.Cre ate("https://www.paypal.com/cgi-bin/webscr");
myRequest.Metho d = "POST";
myRequest.Conte ntType = "applicatio n/x-www-form-urlencoded";
myRequest.Conte ntLength = data.Length;
Stream newStream = myRequest.GetRe questStream();
// Send the data.
newStream.Write (data, 0, data.Length);
newStream.Close ();
<code/>

Whilst this should (in theory at least) work, I'm not getting any
response from the Stream, ie; the Pay Pal website is not displayed.

I've tried using the Component One Pay Pal component, but the URL is
liable to get played - bad idea!

Can any one help?

Thanks in advance.

Feb 7 '06 #1
4 3501
paypal has licensing regulations that you need to be concerned about before
going this route. I suggest you speak with their support dept. first.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------

"Code Monkey" <dl********@gma il.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
I want to use Pay Pal in my web site.

What I want to do is attach the following code to a button

<code>
ASCIIEncoding encoding = new ASCIIEncoding() ;
string postData = "cmd=" + "business";
postData += ("&business= " + "in**@myemailac count.com");
postData += ("&item_name =" + "Test");
postData += ("&currency_cod e=" + "GBP");
postData += ("&amount=" + "0.00");
postData += ("&return=" +
"http://www.myserver.co m/paymentReceived .aspx");
postData += ("&rm=" + "2");
byte[] data = encoding.GetByt es(postData);
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest )WebRequest.Cre ate("https://www.paypal.com/cgi-bin/webscr"); myRequest.Metho d = "POST";
myRequest.Conte ntType = "applicatio n/x-www-form-urlencoded";
myRequest.Conte ntLength = data.Length;
Stream newStream = myRequest.GetRe questStream();
// Send the data.
newStream.Write (data, 0, data.Length);
newStream.Close ();
<code/>

Whilst this should (in theory at least) work, I'm not getting any
response from the Stream, ie; the Pay Pal website is not displayed.

I've tried using the Component One Pay Pal component, but the URL is
liable to get played - bad idea!

Can any one help?

Thanks in advance.

Feb 7 '06 #2
Code Monkey,
Paypal has a developer section of their site that highlights plenty of
sample code, including for ASP.NET. I'd take a look there first.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Code Monkey" wrote:
I want to use Pay Pal in my web site.

What I want to do is attach the following code to a button

<code>
ASCIIEncoding encoding = new ASCIIEncoding() ;
string postData = "cmd=" + "business";
postData += ("&business= " + "in**@myemailac count.com");
postData += ("&item_name =" + "Test");
postData += ("¤cy_code= " + "GBP");
postData += ("&amount=" + "0.00");
postData += ("&return=" +
"http://www.myserver.co m/paymentReceived .aspx");
postData += ("&rm=" + "2");
byte[] data = encoding.GetByt es(postData);
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest )WebRequest.Cre ate("https://www.paypal.com/cgi-bin/webscr");
myRequest.Metho d = "POST";
myRequest.Conte ntType = "applicatio n/x-www-form-urlencoded";
myRequest.Conte ntLength = data.Length;
Stream newStream = myRequest.GetRe questStream();
// Send the data.
newStream.Write (data, 0, data.Length);
newStream.Close ();
<code/>

Whilst this should (in theory at least) work, I'm not getting any
response from the Stream, ie; the Pay Pal website is not displayed.

I've tried using the Component One Pay Pal component, but the URL is
liable to get played - bad idea!

Can any one help?

Thanks in advance.

Feb 7 '06 #3
Thanks for all the MVPs' non-help - god help my flamed ass now! But I
fully appreciate what could potentially happen.

<code>
string formPostData = "cmd=_xclic k";
formPostData += "&b**********@e mailaccount.com ";
formPostData += "&item_name=Tes t";
formPostData += "&quantity= 1";
formPostData += "&currency_code =GBP";
formPostData += "&amount=0. 01";
formPostData += "&return=ht tp://myserver.com/paymentOK.aspx" ;
formPostData += "&rm=2";
formPostData += "&no_shipping=1 "; //turns off shipping
information
formPostData += "&cs=0";

WebClient client = new WebClient();
client.Headers. Add("Content-Type",
"applicatio n/x-www-form-urlencoded");
byte[] postByteArray = Encoding.ASCII. GetBytes(formPo stData);
byte[] responseArray =
client.UploadDa ta("https://www.paypal.com/cgi-bin/webscr", "POST",
postByteArray);
string response = Encoding.UTF8.G etString(respon seArray);

Response.Write( response);

</code>

That works OK. From there on, the customer logs in, and any further
user interaction is done under SSL on the PayPal site. Maybe I should
have explained what I was trying to do first of all!

Feb 8 '06 #4
That wasn't a flame fyi.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------

"Code Monkey" <dl********@gma il.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Thanks for all the MVPs' non-help - god help my flamed ass now! But I
fully appreciate what could potentially happen.

<code>
string formPostData = "cmd=_xclic k";
formPostData += "&b**********@e mailaccount.com ";
formPostData += "&item_name=Tes t";
formPostData += "&quantity= 1";
formPostData += "&currency_code =GBP";
formPostData += "&amount=0. 01";
formPostData += "&return=ht tp://myserver.com/paymentOK.aspx" ;
formPostData += "&rm=2";
formPostData += "&no_shipping=1 "; //turns off shipping
information
formPostData += "&cs=0";

WebClient client = new WebClient();
client.Headers. Add("Content-Type",
"applicatio n/x-www-form-urlencoded");
byte[] postByteArray = Encoding.ASCII. GetBytes(formPo stData);
byte[] responseArray =
client.UploadDa ta("https://www.paypal.com/cgi-bin/webscr", "POST",
postByteArray);
string response = Encoding.UTF8.G etString(respon seArray);

Response.Write( response);

</code>

That works OK. From there on, the customer logs in, and any further
user interaction is done under SSL on the PayPal site. Maybe I should
have explained what I was trying to do first of all!

Feb 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
19342
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes the server happy. I set up a copy of this form at my web site so that I could see exactly what a...
0
2921
by: Cenray | last post by:
How to generate a web request from a Winform Application using a WebService? In a C# Windows Application, when I try to genrate a web request using the following code, it is woking fine Winform code --------------- Browser.DocumentHTML = ""; string HTMLData="";
1
5870
by: Vasu | last post by:
Hi, I have a requirement to download a file from the web site using a client tool. Iam writing a C# program to download using WebRequest, HttpRequest, WebResponse and so on. The problem Iam having is to navigate thru multiple pages. I have to login
16
12636
by: thomas peter | last post by:
I am building a precache engine... one that request over 100 pages on an remote server to cache them remotely... can i use the HttpWebRequest and WebResponse classes for this? or must i use the MSHTML objects to really load the HTML and request all of the images on site? string lcUrl = http://www.cnn.com; // *** Establish the request
4
5037
by: Steven Pu | last post by:
Hi, Specifically, the website I am trying to access is, https://gmail.google.com/ I've read elsewhere that Google only uses SSL2, while .NET uses SSL3 and is not backward compatible. Is this true? In any case, I want to know how this problem can be solved. The code
0
1890
by: Subra Mallampalli | last post by:
Hi, I am trying to connect over HTTPS using a client certificate. I am able to connect fine when using IE. From my application, however, I get the following error: The underlying connection was closed: Could not establish secure channel for SSL/TLS. at System.Net.HttpWebRequest.CheckFinalStatus() at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult) at
7
4251
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant" value="Merchant Name"> <input type="hidden" name="OrderID" value="Unique OrderID value"> <input type="hidden" name="email" value="Customers email address (OPTIONAL)">
5
4443
by: | last post by:
Hi all, HttpWebRequest, and SoapHttpClientProtocol both expose a ClientCertificates property, which can hold multiple client certificates, but on the service side, it can only receive one client certificate, since it derives System.Web.Services.WebService class, and it's Context.Request.ClientCertificate is a single HttpClientCertificate object, is there a way to receive all the client certificates that is sent in the request? or does IIS...
2
14205
by: STEVE.KING | last post by:
Greetings: I need to download an executable and some other binary files (a C++ DLL) from a virtual directory in my WinForms application. No-Touch Deployment manages my .NET code fine but auxilliary files such as these must be downloaded "manually" in my code. My text-based files download fine but I've ran into a problem downloading an .EXE. When it downloads the file size is the same but it has been altered somehow because a) the...
5
2006
by: Dave | last post by:
What is the benefit of using "as" vs the other? HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://www.contoso.com/"); vs. HttpWebRequest myReq = WebRequest.Create("http://www.contoso.com/") as HttpWebRequest;
0
8896
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8810
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6211
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4387
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2798
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2035
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1790
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.