Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I capture user information when the PayPal button is clicked?

I have a form were a user enters information, and then I have a PayPal button that the user will click once the fields have been filled in. The problem I'm having is how to you capture the user information when the paypal button is clicked, if the form has action="http://paypl.com/something/something".

Do I have to make this a 2 page process - one for me to capture the user information and then one to have the user click the paypal button?

By the way - the PayPal button directs the user to paypal.com to actually make the payment.

like image 431
Catfish Avatar asked Dec 12 '22 19:12

Catfish


1 Answers

Guys, there's an easier solution here. Paypal allows you to pass those values through to it, then it will spit them back to you. There's actually two methods of getting the data back--a return URL that posts upon completion with return values (I've not been terribly lucky making that work) then a separate function that sends you a post upon completion of a transaction to a separate page on your site, where you can collect back all the variables you posted to the site. I suggest the latter because on a buy it now page there's a possibility of the user not being returned to the site because the return button UI is pretty weak on PayPal's end.

To set it up you'd log in to your PayPal account, click on myaccount > profile > website payment preferences. Enabling the "payment data transfer" will do the trick. Once you've got it setup correctly, upon completion of a transaction it'll send to the page of your choice a post of everything you sent it....remember, you can send in variables such as Name, Address, etc just by defining them properly in the form. All the variables available are found here

Sure, you could go through grabbing the elements from the form via Jquery or the like, then do an onclick save to DB, but why fight it? It's a heck of a lot more work and may have issues if Javascript is off.

Don't forget to build a sandbox site to test! Good Luck.

like image 134
bpeterson76 Avatar answered Feb 15 '23 11:02

bpeterson76