Reputation: 120
$receipt array give the below output. How to get orderId ?
pr($data); die;
to get orderId, $data['receipt']['orderId']; But its gives me error..
App\Model\Entity\PaymentDetail Object
(
[id] => 4
[user_id] => 4
[company_id] => 5
[receipt] => {"orderId":"GPA.3312-5688-8401-53436","packageName":"com.kenbar.mynus2","productId":"com.mynus2.subscription99","purchaseTime":1534914306517,"purchaseState":0,"purchaseToken":"gefffblagdakjleamfngklli.AO-J1Ow9Q5PncOoRk-oshlRBQ8kVqt3A4uIZuQi6InX7sr4bx2lNzjS-VjOXyMIwkl2G-afrI0fzoVLEADNZP2RWekoxwe4ko1M884JALYhaZsxo44U9DshbKJxbDNQHcCx9_z0yQpxc","autoRenewing":true}
)
Upvotes: 0
Views: 81
Reputation: 1476
You can use
$order_id = json_decode($data->reciept, true)["orderId"];
Upvotes: 0
Reputation: 8338
$orderId=json_decode($your_array->receipt);
echo $orderId->orderId;
You have a json
as a string in your stdClass
object field so you need to decode it first before you access it.
The above code will work for you.
Upvotes: 0
Reputation: 10645
$orderJson = json_decode(data['receipt'],true);
print_r($orderJson['orderId']);
As data['receipt']
contains a JSON string you need to parse it externally before consuming it as an object.
Upvotes: 2