get_data() instanceof \Square\Models\RetrieveCustomerResponse ? $this->get_data()->getCustomer()->getCards() : array(); $tokens = array(); if ( is_array( $cards ) ) { foreach ( $cards as $card ) { if ( 'SQUARE_GIFT_CARD' === $card->getCardBrand() ) { continue; } $token_id = $card->getId(); $card_type = 'AMERICAN_EXPRESS' === $card->getCardBrand() ? Payment_Gateway_Helper::CARD_TYPE_AMEX : $card->getCardBrand(); $tokens[ $token_id ] = new Payment_Gateway_Payment_Token( $token_id, array( 'type' => 'credit_card', 'card_type' => $card_type, 'last_four' => $card->getLast4(), 'exp_month' => $card->getExpMonth(), 'exp_year' => $card->getExpYear(), ) ); } } return $tokens; } }