/**
  * It sets card`s data into additional information of payment model
  *
  * @param Gorilla_ChasePaymentech_Model_Gateway_Result|Varien_Object $response
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return Varien_Object
  */
 protected function _registerCard(Varien_Object $response, Mage_Sales_Model_Order_Payment $payment)
 {
     $cardsStorage = $this->getCardsStorage($payment);
     $card = $cardsStorage->registerCard();
     $card->setRequestedAmount($payment->getAmount())->setBalanceOnCard($response->getBalanceOnCard())->setLastTransId($response->getTransactionId())->setUniqueOrderNumber($response->getInvoiceNumber())->setCustomerRefNum($response->getCustomerRefNum())->setAuthorizationCode($response->getAuthorizationCode())->setProcessedAmount($response->getAmount())->setCcType($response->getCardType())->setCcOwner($payment->getCcOwner())->setCcLast4($response->getCcLast4())->setCcExpMonth($payment->getCcExpMonth())->setCcExpYear($payment->getCcExpYear())->setCcSsIssue($payment->getCcSsIssue())->setCcSsStartMonth($payment->getCcSsStartMonth())->setCcSsStartYear($payment->getCcSsStartYear());
     $cardsStorage->updateCard($card);
     //$this->_clearAssignedData($payment);
     return $card;
 }
 /**
  * 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.'));
     }
 }
 /**
  * It sets card`s data into additional information of payment model
  *
  * @param $response Gorilla_AuthorizenetCim_Model_Gateway_Result
  * @param $payment Mage_Sales_Model_Order_Payment
  * @return Varien_Object
  */
 protected function _registerCard(Varien_Object $response, Mage_Sales_Model_Order_Payment $payment)
 {
     $cardsStorage = $this->getCardsStorage($payment);
     $card = $cardsStorage->registerCard();
     $card->setRequestedAmount($response->getRequestedAmount())->setBalanceOnCard($response->getBalanceOnCard())->setLastTransId($response->getTransactionId())->setProcessedAmount($response->getAmount())->setCcType($response->getCardType())->setCcOwner($payment->getCcOwner())->setCcLast4($response->getCcLast4())->setCcExpMonth($payment->getCcExpMonth())->setCcExpYear($payment->getCcExpYear())->setCcSsIssue($payment->getCcSsIssue())->setCcSsStartMonth($payment->getCcSsStartMonth())->setCcSsStartYear($payment->getCcSsStartYear());
     $cardsStorage->updateCard($card);
     return $card;
 }