Getting Last4 Digits of Card using Customer Object - Stripe API with PHP

$last4 = $StripeCustomer->sources->data[0]->last4;

sources->data is an array so you'd have to select the first card.

Side note: You're using the token twice, once to create the customer, and the second to create the charge, this will result in an error as the token can only be used once. You'd have to charge the customer instead of the token.


For any one else who lands here from search engines, here's a link to the Stripe docs on how to get the last 4 digits of a card saved to the customer https://stripe.com/docs/api/customers/object#customer_object-sources-data-last4