I\'m accessing customer data from the Stripe API, which I\'d like to convert to JSON. Usually I\'d convert an object to an array and use json_encode()
but I don
The attributes of Stripe_Object
s can be accessed like this:
$customer->attribute;
So to get the customer's card's last4
, you can do this:
$customer->default_card->last4;
However, you'll need to make sure you have the default_card
attribute populated. You can retrieve the default_card
object at the same time as the rest of the customer by passing the expand
argument:
$customer = Stripe_Customer::retrieve(array(
"id" => "cus_2dVcTSc6ZtHQcv",
"expand" => array("default_card")
));