我得到下面的对象,该对象从获取Stripe会话ID的过程中返回(该对象称为$order
)。
我可以使用第一个对象级别打印值print_r($order->id);
如何打印第二级的值,例如金额或货币?
我尝试了print_r($order->display_items->amount);
和print_r($order->display_items['amount']);
PHP:
Stripe\Checkout\Session JSON: {
"id": "some_id","object": "checkout.session","billing_address_collection": null,"cancel_url": "some_url","client_reference_id": null,"customer": "some_id","customer_email": null,"display_items": [{
"amount": 2990,// this is what I need
"currency": "eur",// this is what I need
"custom": {
"description": null,"images": null,"name": "some_product"
},"quantity": 1,"type": "custom"
}],"livemode": false,"locale": "en","mode": "payment","payment_intent": "some_id","payment_method_types": [ "card" ],"setup_intent": null,"submit_type": null,"subscription": null,"success_url": "some_url"
}
更新:
如果我使用print_r($order->display_items);
,则会得到以下信息。我可以将其分配给数组,然后从那里打印(如果没有其他解决方案)?
Array ( [0] => Stripe\StripeObject Object ( [amount] => 2990 [currency] => eur [custom] => Stripe\StripeObject Object ( [description] => [images] => [name] => some_product ) [quantity] => 1 [type] => custom ) )
非常感谢。