Hi.
Im struggling to get the data out of the Returned data from Paypal Api..
When a payment is made all is ok and If i call ::
$payment = Payment::get($payment_id, $this->_api_context)->toArray();
return $payment; // for testing all data returned
return $payment['transactions']['related_resources']['transaction_fee']; // trying to get the data
I get
{
"id": "PAY-2VF66335NA......",
"intent": "sale",
"state": "approved",
"cart": "7JA26864N.../.",
"payer": {
"payment_method": "paypal",
"status": "VERIFIED",
"payer_info": {
"email": "test@my_app.co.uk",
"first_name": "Chris",
"last_name": "",
"payer_id": "T26U6W.....",
"shipping_address": {
"recipient_name": "Chris",
"line1": "Spitalfields Arts Market, 112 Brick Lane,",
"city": "London",
"state": "London",
"postal_code": "E1 6RL",
"country_code": "GB"
},
"country_code": "GB"
}
},
"transactions": [
{
"amount": {
"total": "10.00",
"currency": "GBP",
"details": {}
},
"payee": {
"merchant_id": "25NU22K....",
"email": "[email protected]"
},
"description": "Mailbox Topup",
"item_list": {
"items": [
{
"name": "Mailbox Topup",
"price": "10.00",
"currency": "GBP",
"quantity": 1
}
],
"shipping_address": {
"recipient_name": "Chris",
"line1": "Spitalfields Arts Market, 112 Brick Lane,",
"city": "London",
"state": "London",
"postal_code": "E1 6RL",
"country_code": "GB"
}
},
"related_resources": [
{
"sale": {
"id": "5SK92059H7....",
"state": "pending",
"amount": {
"total": "10.00",
"currency": "GBP",
"details": {
"subtotal": "10.00"
}
},
"payment_mode": "INSTANT_TRANSFER",
"reason_code": "PAYMENT_REVIEW",
"protection_eligibility": "INELIGIBLE",
"transaction_fee": {
"value": "0.54",
"currency": "GBP"
},
"parent_payment": "PAY-",
"create_time": "2018-11-26T13:24:26Z",
"update_time": "2018-11-26T13:24:26Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/sale/",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/sale//refund",
"rel": "refund",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/",
"rel": "parent_payment",
"method": "GET"
}
],
"soft_descriptor": "PAYPAL *TESTFACILIT"
}
}
]
}
],
"redirect_urls": {
"return_url": "https://my-app.test/payments/paypal/status?",
"cancel_url": "https://my-app.test/payments/paypal/status"
},
"create_time": "2018-11-26T13:24:26Z",
"update_time": "2018-11-26T13:24:25Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/",
"rel": "self",
"method": "GET"
}
]
}
But when I try accessing the Transaction Fee I get an error Undefined index: related_resources.
How do i get that data?
Many thansk