How is it possible to get the parent payment of a refund, which was notified to me by PayPal?
I got this notification (webhook) from PayPal:
{
"create_time": "2015-02-20T10:56:36Z",
"event_type": "PAYMENT.SALE.REFUNDED",
"id": "WH-XXX-XXX",
"links": [
{
"href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-XXX-XXX",
"method": "GET",
"rel": "self"
},
{
"href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-XXX-XXX/resend",
"method": "POST",
"rel": "resend"
}
],
"resource": {
"amount": {
"currency": "EUR",
"details": {
"subtotal": "-XX.XX",
"tax": "XX.XX"
},
"total": "-XX.XX"
},
"create_time": "2015-02-20T10:55:10Z",
"id": "XXX",
"links": [
{
"href": "https://10.73.133.169:17881/v1/payments/refund/XXX",
"method": "GET",
"rel": "self"
}
],
"state": "completed"
},
"resource_type": "sale",
"summary": "A EUR XX.XX EUR sale payment was refunded"
}
If i take the resource -> id and do the following request with the PayPal PHP-SDK, i get a refund object but without the "parent_payment" field (documented here: https://developer.paypal.com/docs/api/#look-up-a-refund)
PayPal\Api\Refund::get($id, $api);
Every other call like..
PayPal\Api\Sale::get($id, $api);
or
PayPal\Api\Transaction::get($id, $api);
or
PayPal\Api\Payment::get($id, $api);
fails!
What is wrong with my notifications or the methods i am using?
UPDATE: Here is my response from the Refund::get() lookup:
{
"id": "XXX",
"create_time": "2015-02-20T10:55:10Z",
"state": "completed",
"amount": {
"total": "-XX.XX",
"currency": "EUR",
"details": {
"subtotal": "-XX.XX",
"tax": "XX.XX"
}
},
"links": [
{
"href": "https://api.paypal.com/v1/payments/refund/XXX",
"rel": "self",
"method": "GET"
}
]
}
Generally, when you do a lookup on Refund, you will get a response, that includes
parent_payment
that should have the PaymentID that could be used to retrieve the payment object.This is how the response would look like:
Refund:get()
}
Payment:get();