使用Stripe中返回的对象/列表

时间:2015-02-26 11:35:30

标签: php stripe-payments

我有Stripe_List请求返回的\Stripe_InvoiceItem::all()

$invoice_items = \Stripe_InvoiceItem::all();
return $invoice_items;

这给了我以下内容:

Stripe_List JSON: {
    "object": "list",
    "has_more": false,
    "url": "\/v1\/invoiceitems",
    "data": [
        {
            "id": "ii_123456789abcdefg",
            "object": "invoiceitem",
            "date": 1424714643,
            "amount": 0,
            "livemode": false,
            "proration": false,
            "currency": "gbp",
            "customer": "cus_xyz12345",
            "description": "Invoice Item",
            "metadata": [],
            "invoice": "in_abcdefghijklmnop",
            "subscription": null,
            "quantity": null,
            "plan": null
        }
    ]
}

但是,我不确定如何循环结果。

return $invoice_items->data; // returns [{}]
return $invoice_items->data(); // Call to undefined method Stripe_List::data()
return $invoice_items->get('data'); // returns Call to undefined method Stripe_List::get()
return json_decode($invoice_items); // returns empty string

我认为这只是我基本的PHP知识的一个主要差距,但经过大量的谷歌搜索后,我很难找到任何答案。

1 个答案:

答案 0 :(得分:0)

$invoice_items->data应该是你想要的。它可能无法正确呈现字符串预览。如果你打印$invoice_items->data[0],你会得到正确的对象吗?