/**
  * Validate payment data
  *
  * This check is performed on payment information submission, as well as on placing order.
  * Workflow state is stored validation state model
  *
  * @param Varien_Object $data
  * @throws Mage_Core_Exception
  */
 public function validate($data)
 {
     $newChecksum = $this->_generateChecksum($data->getPaymentMethodCode(), $data->getCardType(), $data->getCardNumber(), $data->getCardExpMonth(), $data->getCardExpYear(), $data->getAmount(), $data->getCurrencyCode());
     $validationState = $this->_getValidationState($data->getCardType());
     if (!$validationState) {
         $this->_resetValidationState();
         return;
     }
     // check whether is authenticated before placing order
     if ($this->getIsPlaceOrder()) {
         if ($validationState->getChecksum() != $newChecksum) {
             Mage::throwException(Mage::helper('centinel')->__('Payment information error. Please start over.'));
         }
         if ($validationState->isAuthenticateSuccessful()) {
             return;
         }
         Mage::throwException(Mage::helper('centinel')->__('Please verify the card with the issuer bank before placing the order.'));
     } else {
         if ($validationState->getChecksum() != $newChecksum || !$validationState->isLookupSuccessful()) {
             $this->lookup($data);
             $validationState = $this->_getValidationState();
         }
         if ($validationState->isLookupSuccessful()) {
             return;
         }
         Mage::throwException(Mage::helper('centinel')->__('This card has failed validation and cannot be used.'));
     }
 }