C
Code Monkey
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=" + "(e-mail address removed)");
postData += ("&item_name=" + "Test");
postData += ("¤cy_code=" + "GBP");
postData += ("&amount=" + "0.00");
postData += ("&return=" +
"http://www.myserver.com/paymentReceived.aspx");
postData += ("&rm=" + "2");
byte[] data = encoding.GetBytes(postData);
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("https://www.paypal.com/cgi-bin/webscr");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
// 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.
What I want to do is attach the following code to a button
<code>
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "cmd=" + "business";
postData += ("&business=" + "(e-mail address removed)");
postData += ("&item_name=" + "Test");
postData += ("¤cy_code=" + "GBP");
postData += ("&amount=" + "0.00");
postData += ("&return=" +
"http://www.myserver.com/paymentReceived.aspx");
postData += ("&rm=" + "2");
byte[] data = encoding.GetBytes(postData);
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("https://www.paypal.com/cgi-bin/webscr");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
// 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.