/**
  * process Payment: authorize only or authorize & capture
  *
  * @param Eway_Rapid31_Model_Response $response
  * @return Eway_Rapid31_Model_Response
  * @throws Mage_Core_Exception
  */
 protected function _processPayment(Eway_Rapid31_Model_Response $response)
 {
     $this->_initCheckout();
     $cardData = $response->getCustomer();
     if ($cardData['CardNumber'] && $cardData['CardName']) {
         $response = $this->_checkout->doAuthorisation($response);
         if ($response->isSuccess() && Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
             $response = $this->_checkout->doCapturePayment($response);
         }
     } else {
         if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
             $response = $this->_checkout->doAuthorisation($response);
         } elseif (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
             $response = $this->_checkout->doTransaction($response);
         }
     }
     if (!$response->isSuccess()) {
         Mage::throwException(Mage::helper('ewayrapid')->__('Sorry, your payment could not be processed (Message: %s). Please check your details and try again, or try an alternative payment method.', $response->getMessage()));
     }
     return $response;
 }
Example #2
0
 /**
  * Update token when checkout with existing token
  *
  * @param Eway_Rapid31_Model_Response $response
  * @param null $ccNumber
  * @return $this
  */
 protected function _updateToken(Eway_Rapid31_Model_Response $response, $ccNumber = null)
 {
     try {
         $customer = $response->getCustomer();
         $tokenInfo = array('Token' => $response->getTokenCustomerID(), 'Card' => $customer['CardNumber'] ? substr_replace($customer['CardNumber'], '******', 6, 6) : 'Paypal', 'Owner' => $customer['CardName'], 'StartMonth' => $customer['CardStartMonth'], 'StartYear' => $customer['CardStartYear'], 'IssueNumber' => $customer['CardIssueNumber'], 'ExpMonth' => $customer['CardExpiryMonth'], 'ExpYear' => strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear'], 'Type' => $this->checkCardType($customer['CardNumber']), 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customer));
         Mage::helper('ewayrapid/customer')->updateToken($ccNumber, $tokenInfo);
         return true;
     } catch (Exception $e) {
         return false;
     }
 }