473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Post Data to PayPal from Code Behind

Hi, I'm trying to post data to PayPal for a shopping cart, basically I want
to replicate a form like the following, but create the variables dynamically
from code behind:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business"
value="se****@designerfotos.com">
<input type="hidden" name="item_name"
value="Aggregated items">
<input type="hidden" name="amount" value="3.00">
<input type="submit" value="PayPal">
</form>

How can I create the hidden input variables in a code behind file and have
the data posted to https://www.paypal.com/cgi-bin/webscr and the user
redirected to that site?

I'm using the .NET 2 framework, but I still can't figure this out.

The only way I've been able to get somewhere is to have a PayPalForm.aspx
file which is displayed in an iframe (inside a checkout user control), and
has the following code:

<form name="paypalform" id="paypalform"
action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<asp:PlaceHolder ID="pchMain" runat="server"></asp:PlaceHolder>
</form>

Then, in the PayPalForm.aspx.cs file, I can add the hidden input variables
to the placeholder.

The problem with this approach though, is I need to access other controls (a
radio button list) that are on the checkout.ascx file which the iframe sits
on.

So I have:

Checkout.ascx
Radio Button List
Iframe
PayPalForm.aspx

and I need to access the radio button list from within PayPalForm.aspx.cs

Does that make sense??!!

Oct 20 '06 #1
3 8003
Yourself,

You're on the right track. Rather than making a post to the paypal
script, you should put all your stuff in a querystring, redirect to
that URL. There are a few ways to integrate into paypal, you can either
use the my website to their website and back to mine (standard), or
call their web services from your website (pro/premium).

My guess is that you just need to package all of that stuff into the
query string and redirect the browser to the url.

ex:

https://www.paypal.com/cgi-bin/we***...ignerfotos.com...

Don't forget to check out the paypal sandbox for testing.

http://www.sandbox.paypal.com

Good luck!

~Brenton MCSD.NET

Yourself wrote:
Hi, I'm trying to post data to PayPal for a shopping cart, basically I want
to replicate a form like the following, but create the variables dynamically
from code behind:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business"
value="se****@designerfotos.com">
<input type="hidden" name="item_name"
value="Aggregated items">
<input type="hidden" name="amount" value="3.00">
<input type="submit" value="PayPal">
</form>

How can I create the hidden input variables in a code behind file and have
the data posted to https://www.paypal.com/cgi-bin/webscr and the user
redirected to that site?

I'm using the .NET 2 framework, but I still can't figure this out.

The only way I've been able to get somewhere is to have a PayPalForm.aspx
file which is displayed in an iframe (inside a checkout user control), and
has the following code:

<form name="paypalform" id="paypalform"
action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<asp:PlaceHolder ID="pchMain" runat="server"></asp:PlaceHolder>
</form>

Then, in the PayPalForm.aspx.cs file, I can add the hidden input variables
to the placeholder.

The problem with this approach though, is I need to access other controls (a
radio button list) that are on the checkout.ascx file which the iframe sits
on.

So I have:

Checkout.ascx
Radio Button List
Iframe
PayPalForm.aspx

and I need to access the radio button list from within PayPalForm.aspx.cs

Does that make sense??!!
Oct 20 '06 #2
Thanks for the tip, I had thought about using the querystring to pass the
data, but I was hoping to avoid it, as it makes it even easier to change the
prices etc.

Am I correct in thinking that there is no possible way of posting data to an
external URL from code behind AND redirecting the user?

If so, I think I will stick to my iframe technique, and work out a way of
getting data between the PayPalForm.aspx and the Checkout.ascx - possibly
using ViewState?
"Superman" <br*****@ungernet.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Yourself,

You're on the right track. Rather than making a post to the paypal
script, you should put all your stuff in a querystring, redirect to
that URL. There are a few ways to integrate into paypal, you can either
use the my website to their website and back to mine (standard), or
call their web services from your website (pro/premium).

My guess is that you just need to package all of that stuff into the
query string and redirect the browser to the url.

ex:

https://www.paypal.com/cgi-bin/we***...ignerfotos.com...

Don't forget to check out the paypal sandbox for testing.

http://www.sandbox.paypal.com

Good luck!

~Brenton MCSD.NET

Yourself wrote:
>Hi, I'm trying to post data to PayPal for a shopping cart, basically I
want
to replicate a form like the following, but create the variables
dynamically
from code behind:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business"
value="se****@designerfotos.com">
<input type="hidden" name="item_name"
value="Aggregated items">
<input type="hidden" name="amount" value="3.00">
<input type="submit" value="PayPal">
</form>

How can I create the hidden input variables in a code behind file and
have
the data posted to https://www.paypal.com/cgi-bin/webscr and the user
redirected to that site?

I'm using the .NET 2 framework, but I still can't figure this out.

The only way I've been able to get somewhere is to have a PayPalForm.aspx
file which is displayed in an iframe (inside a checkout user control),
and
has the following code:

<form name="paypalform" id="paypalform"
action="https://www.paypal.com/cgi-bin/webscr" method="post"
target="_top">
<asp:PlaceHolder ID="pchMain" runat="server"></asp:PlaceHolder>
</form>

Then, in the PayPalForm.aspx.cs file, I can add the hidden input
variables
to the placeholder.

The problem with this approach though, is I need to access other controls
(a
radio button list) that are on the checkout.ascx file which the iframe
sits
on.

So I have:

Checkout.ascx
Radio Button List
Iframe
PayPalForm.aspx

and I need to access the radio button list from within PayPalForm.aspx.cs

Does that make sense??!!

Oct 20 '06 #3

"Yourself" <in*****@email.addresswrote in message
news:J4******************@text.news.blueyonder.co. uk...
Hi, I'm trying to post data to PayPal for a shopping cart, basically I
want
to replicate a form like the following, but create the variables
dynamically
from code behind:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business"
value="se****@designerfotos.com">
<input type="hidden" name="item_name"
value="Aggregated items">
<input type="hidden" name="amount" value="3.00">
<input type="submit" value="PayPal">
</form>

How can I create the hidden input variables in a code behind file and have
the data posted to https://www.paypal.com/cgi-bin/webscr and the user
redirected to that site?

I'm using the .NET 2 framework, but I still can't figure this out.

The only way I've been able to get somewhere is to have a PayPalForm.aspx
file which is displayed in an iframe (inside a checkout user control), and
has the following code:

<form name="paypalform" id="paypalform"
action="https://www.paypal.com/cgi-bin/webscr" method="post"
target="_top">
<asp:PlaceHolder ID="pchMain" runat="server"></asp:PlaceHolder>
</form>

Then, in the PayPalForm.aspx.cs file, I can add the hidden input variables
to the placeholder.

The problem with this approach though, is I need to access other controls
(a
radio button list) that are on the checkout.ascx file which the iframe
sits
on.

So I have:

Checkout.ascx
Radio Button List
Iframe
PayPalForm.aspx

and I need to access the radio button list from within PayPalForm.aspx.cs

Does that make sense??!!
Here is how I do this.

I have a form which has the static data. I have a placeholder in the form. I
build the non-static form data using stringbuilder and add is using

Dim ctrl as control = Page.ParseControl(PayPalFormDataString)
plc1.controls.add(ctrl).

I have the form automatically submit when it is called using javascript. (I
also have a button appear for those that have it disabled).

Couple of caveats... you want to make sure the page is only called by a
valid checkout button click and not from someone just going to that page.
You also need to handle the broken back button issue .. I use a redirect,
and finally you don't want the page to cache locally. I use <%@ OutputCache
Location="None" VaryByParam="None" %>

I also have a javascript waiting progress bar to provide some motion while
the post is processing.

An alternative to all of this is paypal has some code to handle a lot of
this but I choose not to use.
Mike
Oct 20 '06 #4

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

Similar topics

0
by: rgparkins | last post by:
HI I have 2 problems, 1 of which is tied to PHP and 1 loosely tied, so I'll put this out there. Got a problem that I have been working on for a while now which involves implementing the...
3
by: Tom | last post by:
Hi. After I got some information from the user I need to POST it in XML format to the server NOT MY SERVER - a server at https://xxxx.xxx and to reveive the response. Please let me know...
10
by: Mark | last post by:
Hi All, I could do with some assistance... I am working on an ecommerce site in vb.net (aspx) I have built all my pages that perform the checkout process and gets to a summary screen where you...
2
by: Vishal | last post by:
Hello, I am posting some credit card info to the payment server via a similar code. My code is written in VB.NET but uses the same approach. At the end however I do a...
8
by: Laith Zraikat | last post by:
I am trying to invoke a post request from code behind of an asp.net page using "WebClient" object, and I want the user to be redirected to the action url as well. So far Ive been able to send...
3
by: David Veeneman | last post by:
I am creating a form on the server that I want to POST to a URL that's being called with Server.Transfer(). What's the simplest way to do that? A little background: I'm programming buttons that...
4
by: David Veeneman | last post by:
I want to programmatically create some POST data on a web server, then pass that data to another web page that the server calls, using Server.Transfer(). What's the best way to do that? I'm...
2
by: hagenaer | last post by:
Hello, I'm building a simple shopping cart to work with PayPal. I'd like to have the user post his basket to my page, validate the input, then redirect him _with his validated form data_ to...
10
ak1dnar
by: ak1dnar | last post by:
Hi, I need to submit this page to paypal server for processing the postdata string or you can suggest any other way to do this. Can I do this in the code behind somehow(vb)? I've looked at the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...

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.