title: Getting Last4 Digits of Card using Customer Object - Stripe API with PHP
body: <p>I want to get the last 4 digits of a customers card using Stripe. 
  I have already stored the Customer using: </p>
  
  <pre><code>      // Get the credit card details submitted by the form
        $token = $_POST['stripeToken'];
  
        // Create a Customer
        $StripeCustomer = \Stripe\Customer::create(array(
                "description" =&gt; "$username",
                "card" =&gt; $token
        ));
  </code></pre>
  
  <p>Now I'd like to access and then store the card's last 4 digits. (For context, I want to show users which card they have stored using Stripe for future payments - this is not a subscription service). </p>
  
  <p>I have searched for a solution but a lot of the posts are saving the last4 digits AFTER a charge, and pull the information from the charge like:     </p>
  
  <pre><code>$last4 = null;
  try {
      $charge = Stripe_Charge::create(array(
      "amount" =&gt; $grandTotal, // amount in cents, again
      "currency" =&gt; "usd",
      "card" =&gt; $token,
      "description" =&gt; "Candy Kingdom Order")
  );
  $last4 = $charge-&gt;card-&gt;last4;
  </code></pre>
  
  <p>I would like to do the same BEFORE the charge , so I want to pull the last 4 from the Customer Object. The Stripe API documentation shows the attribute path for last4 from Customers,<br>
   <code>customer-&gt;sources-&gt;data-&gt;last4</code></p>
  
  <p>However, this does not seem to give me the correct last 4 digits.<br>
  <code>$last4 = $StripeCustomer-&gt;sources-&gt;data-&gt;last4;</code>     </p>
  
  <p>I think I am misunderstanding how to use attributes in the Stripe API. Could someone point me in the right direction?   </p>