Skip to content
Advertisement

Retrieving PayPal email address after payment?

When you are setting up a PayPal Buy Now Button, you can take customers to the URL when they finish checkout.

Is there a way to retrieve their PayPal email immediately after PayPal checkout using $_GET?

Does PayPal append some kind of ?email=email@address.com at the end of your thankyou page?

Or is there any variable I could add at the end of my thankyou page when typing a success URL inside the PayPal?

Basically I want to store their PayPal email address that they used on deposit, so that when they would cash out, the same PayPal email address will be used.

Just wanted to let you know why I’m interested in storing their real PayPal email address in the first place.

Any help from someone who have knowledge in this would be appreciated.

Advertisement

Answer

With a legacy HTML Buy Now button that redirects away from your page, there is never any guarantee the payer will return to your site after a successful transaction. With such an old integration, the only reliable way to get the email address of the payer and record this information in your database is to implement the old IPN service.


Instead, you should do a server-side integration of the current Standard Checkout.

Follow the Set up standard payments guide and make 2 routes on your server, one for ‘Create Order’ and one for ‘Capture Order’, documented here. Both routes should return only JSON data (no HTML or text). Inside the 2nd route, when the capture API is successful you should store its resulting payment details in your database (particularly purchase_units[0].payments.captures[0].id, which is the PayPal transaction ID — as well as the payer object’s email address, in your case) and perform any necessary business logic (such as sending confirmation emails or reserving product) immediately before forwarding your return JSON to the frontend caller.

Pair those 2 routes with the frontend approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement