/**
  * @param CardInterface $card
  * @param CardInterface[] $cardsToSave
  * @return bool
  */
 protected function cardShouldBeDeleted(CardInterface $card, array $cardsToSave)
 {
     foreach ($cardsToSave as $cardToSave) {
         if (!isset($cardToSave['card_id'])) {
             $cardToSave['card_id'] = null;
         }
         if ($card->getCardId() == $cardToSave['card_id']) {
             return false;
         }
     }
     return true;
 }
 /**
  * @param CardInterface $cardInterface
  * @return bool
  * @throws LocalizedException
  */
 public function delete(CardInterface $cardInterface)
 {
     $cardId = $cardInterface->getCardId();
     $customerId = $cardInterface->getCustomerId();
     try {
         $deleted = $this->cardAdapter->delete($customerId, $cardId);
     } catch (OpenpayException $e) {
         throw new LocalizedException(__($e->getDescription()), $e);
     }
     $cacheIdentifier = $this->getCacheIdentifier($customerId);
     $this->cache->remove($cacheIdentifier);
     return $deleted;
 }