Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PayPal REST API not returning payment_info

Tags:

paypal

I am using the REST API to authorize a PayPal transaction, and when it returns to confirm & execute the payment, I'd like to retrieve & display payer information such as name, address, phone, etc from their PayPal account for a checkout order confirmation page. (To avoid them having to type in all their billing/shipping address info, since this should be available from PayPal.)

Currently the return is only showing this for payer:

PayPal\Api\Payment Object
(
    [_propMap:PayPal\Common\PPModel:private] => Array
        (
            [id] => PAY-2EC51985XH550123JKHG3C4Y
            [create_time] => 2013-06-28T15:53:23Z
            [update_time] => 2013-06-28T15:53:23Z
            [state] => created
            [intent] => sale
            [payer] => PayPal\Api\Payer Object
                (
                    [_propMap:PayPal\Common\PPModel:private] => Array
                        (
                            [payment_method] => paypal
                        )

                )

            [transactions] => Array
            ...

The documentation states:

payer_info object

  • This object is pre-filled by PayPal when the payment_method is paypal.

(see https://developer.paypal.com/webapps/developer/docs/api/#payerinfo-object)

Even after the payment is executed, I still receive no payer_info object from PayPal. I am wondering if PayPal is only returning the info I prepopulate before sending the user off to PayPal? e.g.:

$payer = new Payer();
$payer->setPayment_method('paypal');

Is there a way to retrieve the user's name/address/phone/etc (what I expected to be available from Payment::get($pay_id)->getPayer()->getPayerInfo()->getShipping_address()) using the REST API?

Or do I have to have the user duplicate their efforts and enter address information on my checkout page? I sure hope not, as this is one of the big advantages of using PayPal as a payment method.

like image 872
Nate Beaty Avatar asked Jun 28 '13 16:06

Nate Beaty


1 Answers

I thought I would post an answer in case anyone else has this issue.

It does appear that the REST API fails to return the shipping information the majority of the time. Especially when using the GET /payments/payment endpoint. However I have seen it return shipping information from the POST /payments/payment/<PAYMENT_ID>/execute endpoint before.

Anyway, following the comments above it looks as if the OP ditched the REST API and went back to Express Checkout. Which is fair enough if you want to get the shipping data up front.

However, if you use the PayPal IPN in conjunction with the REST API it will provide the shipping and billing info on the callback. So you could collect the information at that point.

The only problem I see with doing this is that you can't confirm the address is correct with the user. PayPal however does show this information to the user as they make their way through payment and allows them to change it if necessary. So I believe it's safe to assume the data is accurate.

like image 116
diggersworld Avatar answered Dec 31 '22 18:12

diggersworld