When using PayPal API is it possible to get payer info?

un1t
Contributor
Contributor

Currently we use IPN, and when we receive notification there is payer info, such as email, residence_country, first_name, last_name.

 

We want to switch to API (because it is possible to create refund thought API). But in API calls create payment and execute payment,  there is no information about payer.

 

How can we get this payer info?

 

Login to Me Too
4 REPLIES 4

Martho
Contributor
Contributor

Yes, you have to use webhooks in this case.

Login to Me Too

un1t
Contributor
Contributor

> Yes, you have to use webhooks in this case.

 

Which exactly webhook provides this info?

I've already checked webhook and I could not find such info in webhooks.

Login to Me Too

Martho
Contributor
Contributor

I'm using PHP with the Paypal-SDK. The general approach (without error-handling etc) is:

 

PAYMENT.SALE.COMPLETED

$resource = $webhookEvent->getResource();

$Payment = \Paypal\Api\Payment::get($resource->parent_payment, $api);
$Payer = $Payment->getPayer();
$Payerinfo = $Payer->getPayerInfo();

 

Login to Me Too

un1t
Contributor
Contributor

Thank you!

 

I checked this webhook in webhook simulator. And it really does not provide payer info.

But your code looks more like sequential API calls, than just parsing webhook response.

So I dig into it, and I found that execute payment API call returns payer info.

 

https://developer.paypal.com/docs/api/payments/v1/#payment_execute

 

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.