Log in

View Full Version : integrate PayPal buttons into a form



sniperman
06-01-2010, 05:36 AM
Hoping someone can shed some light on this topic.

1) I have a website with a form.
2) I have a form whose function is to send those details to an email
3) I would like to integrate PayPal (hard-code) into a form dropdown box.

The problem with PayPal code and its button is that it will take people directly to the PayPal website... and my form is not completed.

Is there a method to delay the PayPal function only until after a form has been submitted and completed?

The idea I have is to have the form data be collected and emailed in the initial process of the PHP file. And then place an IF statement in a PHP file redirects to the PayPal website only after the form action has been completed. I'm not sure however whether you can call a second submission action via PHP.

djr33
06-01-2010, 11:11 AM
1. It's problematic if you give the impression that they are submitting to paypal when you are using the data for something else. This applies especially if you are using credit card info. If this is just a redirect so that they can later use paypal to enter all the secure information, this is less of a problem.

2. You cannot submit a form twice. You can redirect the user to paypal after they submit to your website, or they can submit to paypal. It is possible to submit a GET query (like page.php?variable=value&other=value) just using a URL if paypal accepts that, but not POST (as with most forms).

3. You could use the curl() functions to send a behind-the-scenes 'form' (set of post data) to paypal, but this would be your server talking to paypal's server, nothing available to the user. It wouldn't work unless you are only forwarding info and the user doesn't need to log on to their account, etc.


I hope that helps get you started.

Basically the situation is complex and there aren't any great workarounds. You will probably find information on paypal's site about integration because you're certainly not the only person with this problem. See what they suggest.


There's one way around this: actually submit the form twice.
They submit the form to your site. On the receiving page you process the data and then output the data into a copy of the form. The user then submits this again and it goes to paypal.
Unfortunately you cannot force this form to submit or do it behind the scenes (for security reasons, mostly).
You can, however, use hidden fields (but with the same data and names) and then just have a submit button "Continue to PayPal" and that will send all of it and not be too intrusive.
You can even use Javascript to automatically submit this form. The problem there, though, is that it's not always going to work (if the user doesn't have Javascript enabled), and the user can avoid it if they choose.
Assuming your users are agreeable (they aren't trying to get around your system) then this is a good solution. It takes a bit of extra work from you in the programming, but it'll work smoothly in the end, I think.

sniperman
06-05-2010, 03:58 AM
thanks for that. you sold me on problematic. i've decided to break the form process up into two parts for registration and payments to maintain the site's integrity.

Having said that, there are a couple of people who sell PayPal integration into forms, similar to what I've mentioned. But I've worked for an ecommerce company who had several shop fronts, and these websites all seem to have similar content with different looks, so I assume not too many developers have bothered to explore the concepts I have mentioned.

Thanks mate

djr33
06-05-2010, 06:48 AM
It's not necessarily impossible to make this work, but it's very complex at least. And the best way around it (only way?) is some creativity. If you can just split up the form, then that's great.