Populating Customers credit card info

So just by the way, all the functions are documented in the PHP SDK documentation, so for example here’s the Customer object details. For the last 4, you can see it lives in the cards field (which according to the documentation is an array of Card objects). So you should be able to get it like so:

$customer = $api_response->getResult()->getCustomer();
$last_four = $customer->getCards()[0]->getLast4();

Again, since this is an array, there may be more than one card and the above only shows the first card (array index 0), so you may want to loop through to provide a dropdown list for the customer to choose from, or something similar. As for if the row is needed, technically speaking you can do the above in one line of code, it depends on how you want to break it out. For example this would also work:

$last_four =$api_response->getResult()->getCustomer()->getCards()[0]->getLast4();
1 Like