这里由Stripe发送的json获取发票状态:
Stripe\Collection JSON: {
...
"data" => [
[0] => Stripe\Invoice JSON: {
...
"lines": {
"data": [
{
...
"subscription": null,
"quantity": 1,
"plan": {
"interval": "month",
"name": "X-Large - 12 mois",
"created": 1435711579,
"amount": 52800,
"currency": "cad",
"id": "X-LARGE_12M",
"object": "plan",
"livemode": false,
"interval_count": 12,
"trial_period_days": null,
"metadata": {
},
"statement_descriptor": null
},
...
}
],
...
},
...
}
]
}
json响应可以在这里找到: https://stripe.com/docs/api#list_customer_invoices
我想访问plan id
(即:X-LARGE_12M
)。
所以我试过了:
$invoice->lines->data->plan->id
但它不起作用。
适用于其他领域。
有什么理由?
感谢。
答案 0 :(得分:1)
"data": [
{
data
元素是对象的数组。所以你需要像
foreach($invoice->lines->data as $data) {
echo $data->plan->id, "\r\n";
}