I'm using PayPal rest-api-sdk-php the latest version. Everything is working fine in terms of creating the payment and executing the payment and getting all the relevant data back but have decided I want the total amount paid via paypal. It returns a JSON object back, example below
"transactions": [
{
"amount": {
"total": "20.00",
"currency": "GBP",
"details": {
"subtotal": "17.50",
"tax": "1.30",
"shipping": "1.20"
}
},
"description": "Payment description",
"invoice_number": "55e30dbd55cea",
"item_list": {
"items": [
{
"name": "Ground Coffee 40 oz",
"price": "7.50",
"currency": "GBP",
"quantity": "1",
"description": "Ground Coffee 40 oz",
"tax": "0.30"
},
{
"name": "Granola bars",
"price": "2.00",
"currency": "USD",
"quantity": "5",
"description": "Granola Bars with Peanuts",
"tax": "0.20"
}
]
},
}
],
I have tried calling $payment->transactions->amount->total but get an error. Just wondered if someone can shed some light. Thanks
"transactions" is an array, so you need to iterate through it. If you want the first total amount, try $payment->transactions[0]->amount->total;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With