How to get user information when you click PayPal?

I have a form when a user enters information, and then I have a PayPal button that the user clicks after filling in the fields. The problem I am facing is how you capture 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 user information, and then one for the user to click the Paypal button?

By the way, the PayPal button directs the user to paypal.com to make a payment.

+4
source share
4 answers

Guys, there is an easier solution here. Paypal allows you to pass these values ​​before then it will spit them back to you. There are actually two methods for returning data: a return URL, which ends after returning with the returned values ​​(I’m not very lucky that this works), and then a separate function that sends you a message after the transaction is completed, to a separate one on your site, where You can return all the variables that you sent to the site. I suggest the latter, because on the Buy Now page there is a possibility that the user will not be returned to the site, because the user interface of the return button is rather weak at the end of PayPal.

To set it up, you need to log in to your PayPal account, click on myaccount> profile> website payment settings. Enabling "billing" will do the trick. After you have configured it correctly, upon completion of the transaction, it will send a message to the page of your choice about everything that you sent it .... remember, you can send variables such as Name, Address, etc. defining them correctly in the form. All available variables are found here.

Of course, you can go through capturing elements from the form through Jquery or the like, and then do onclick save for DB, but why fight it? This is a hell of a lot more work and can have problems if Javascript is disabled.

Do not forget to create a test site for the sandbox! Good luck.

+6
source

You have several options. You can make two forms: one, which is sent to your server, where you record user information, and then display the second form with the "Pay Now" button. As a second option, you can extract the information from the form using JavaScript and submit it to your server using AJAX, and then submit the form to PayPal when the AJAX request is complete. This may or may not be more complex, but it will not change the existing user interface, which may be desirable.

+3
source

I would make the action the current page, catch the button and save the user information, and then use header: Location("http://paypl.com/something/something"); . It does not matter. Hope this helps.

Edit: Also see Josh's other answer. They are equally good. Note that the Ajax parameter requires JavaScript to be enabled - thus, guarantees must be put in place if it is disabled.

+3
source

My recommendation would be to add all your user / order data to your own local database so that you can generate an order identifier. You can then pass this order ID to the PayPal button code in a field called invoice.

This value will be returned to PDT / IPN as $ _POST ['invoice'] so that you can easily pull out all this data and process it in your application accordingly.

Another alternative would be to use Express Checkout instead of Standard Payments. This is a bit more active, but it has fewer restrictions.

However, even with EC, I still recommend sending an order identifier of some kind along with a payment request so that you can easily and easily take it back and forth.

+1
source

All Articles