@smacy use json_decode
$result = json_decode($data);
$amount = $result->purchase_units->payments->captures->amount;
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
this is response received from paypal
how can it get $amount= purchase_units->payments>captures>amount in controller
{
"id":"6E664330RY678345V",
"status":"COMPLETED",
"purchase_units":[
{
"reference_id":"default",
"shipping":{
"name":{
"full_name":"John Doe"
},
"address":{
"address_line_1":"1 Cheeseman Ave Brighton East",
"admin_area_2":"Melbourne",
"admin_area_1":"Victoria",
"postal_code":"3001",
"country_code":"AU"
}
},
"payments":{
"captures":[
{
"id":"4GE11174NV766131P",
"status":"PENDING",
"status_details":{
"reason":"PENDING_REVIEW"
},
"amount":{
"currency_code":"USD",
"value":"2.00"
},
"final_capture":true,
"seller_protection":{
"status":"NOT_ELIGIBLE"
},
"links":[
{
"href":"https://api.sandbox.paypal.com/v2/payments/captures/4GE11174NV766131P",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.sandbox.paypal.com/v2/payments/captures/4GE11174NV766131P/refund",
"rel":"refund",
"method":"POST"
},
{
"href":"https://api.sandbox.paypal.com/v2/checkout/orders/6E664330RY678345V",
"rel":"up",
"method":"GET"
}
],
"create_time":"2022-05-19T08:36:15Z",
"update_time":"2022-05-19T08:36:15Z"
}
]
}
}
],
"payer":{
"name":{
"given_name":"John",
"surname":"Doe"
},
"email_address":"[email protected]",
"payer_id":"AD9L9U9LLGV7S",
"address":{
"address_line_1":"1 Cheeseman Ave Brighton East",
"admin_area_2":"Melbourne",
"admin_area_1":"Victoria",
"postal_code":"3001",
"country_code":"AU"
}
},
"links":[
{
"href":"https://api.sandbox.paypal.com/v2/checkout/orders/6E664330RY678345V",
"rel":"self",
"method":"GET"
}
]
}
Please or to participate in this conversation.