So, I have a Python PayPal REST API app that accepts payments. I create a Payment object and redirect the user to PayPal. When they get back I do:
payment = Payment.find(trans_id)
payment.execute({ "payer_id": payer_id })
If that's successful I get the email address of the payer like:
payer_info = payment.payer.payer_info.to_dict()
email = payer_info['email']
That works great, except sometimes it doesn't! Sometimes (actually just once so far) I get a payer back that doesn't have an email address. How is that possible? Is that something my code should expect? The system I'm working in needs an email as a primary key for our user database, so this is pretty hard to accommodate.
Thanks for any and all help!
Even if this question is 1 year old, this still seems to be a problem with the current Paypal REST API: sometimes the email field just doesn't show up.
Unfortunately I cannot provide a solution, as I am facing the same issue, but I have at least a little suggestion: the frequency of this phenomenon has slightly increased since I tried to get the email BEFORE executing the payment; when I moved the request AFTER the payment, this event became much less frequent; finally, in the few cases where this still occurs, a quick look at the payment log showed the proper email addresses, as expected, so these does not seem "special" paypal payments.
It seems to me that the email field is just "slow" to appear, even if the system properly waits each response from the paypal server... I am going to try to solve this problem by adding a timed retry in case of failure, in order to give few additional seconds to the paypal server to respond... but if someone more experienced than me could give a more solid opinion on this matter that would be greatly appreciated!
ps: actually my platform uses an up-to-date version of the official paypal PHP SDK