PAYMENT.CAPTURE.COMPLETED: How to get parent payment?

696 Views Asked by At

When getting an event PAYMENT.SALE.COMPLETED in a webhook, you can use this code to get more information about the payer:

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

Now I updated to SDK V2, and get PAYMENT.CAPTURE.COMPLETED-events. How does this work here? It seems there is no $resource->parent_payment. I tried something like:

$request = new PayPalCheckoutSdk\Orders\OrdersGetRequest($resource->id);

But this only returns RESOURCE_NOT_FOUND.

How can I get the Payerinfo here?

1

There are 1 best solutions below

3
On

The resource->id returned is a v2/payments id, not an Order ID.

v2/checkout/orders IDs are only used during payer approval, and have no accounting value.