/** * Set split_tender_id to quote payment if neeeded * * @param Varien_Object $response * @param Mage_Sales_Model_Order_Payment $payment * @return bool */ protected function _processPartialAuthorizationResponse($response, $orderPayment) { if (!$response->getSplitTenderId()) { return false; } $quotePayment = $orderPayment->getOrder()->getQuote()->getPayment(); $this->setPartialAuthorizationLastActionState(self::PARTIAL_AUTH_LAST_DECLINED); $exceptionMessage = null; try { switch ($response->getResponseCode()) { case self::RESPONSE_CODE_APPROVED: $this->_registerCard($response, $orderPayment); $this->_clearAssignedData($quotePayment); $this->setPartialAuthorizationLastActionState(self::PARTIAL_AUTH_LAST_SUCCESS); return true; case self::RESPONSE_CODE_HELD: if ($response->getResponseReasonCode() != self::RESPONSE_REASON_CODE_PARTIAL_APPROVE) { return false; } if ($this->getCardsStorage($orderPayment)->getCardsCount() + 1 >= self::PARTIAL_AUTH_CARDS_LIMIT) { $this->cancelPartialAuthorization($orderPayment); $this->_clearAssignedData($quotePayment); $this->setPartialAuthorizationLastActionState(self::PARTIAL_AUTH_CARDS_LIMIT_EXCEEDED); $quotePayment->setAdditionalInformation($orderPayment->getAdditionalInformation()); $exceptionMessage = Mage::helper('paygate')->__('You have reached the maximum number of credit card allowed to be used for the payment.'); break; } $orderPayment->setAdditionalInformation($this->_splitTenderIdKey, $response->getSplitTenderId()); $this->_registerCard($response, $orderPayment); $this->_clearAssignedData($quotePayment); $this->setPartialAuthorizationLastActionState(self::PARTIAL_AUTH_LAST_SUCCESS); $quotePayment->setAdditionalInformation($orderPayment->getAdditionalInformation()); $exceptionMessage = null; break; case self::RESPONSE_CODE_DECLINED: case self::RESPONSE_CODE_ERROR: $this->setPartialAuthorizationLastActionState(self::PARTIAL_AUTH_LAST_DECLINED); $quotePayment->setAdditionalInformation($orderPayment->getAdditionalInformation()); $exceptionMessage = $this->_wrapGatewayError($response->getResponseReasonText()); break; default: $this->setPartialAuthorizationLastActionState(self::PARTIAL_AUTH_LAST_DECLINED); $quotePayment->setAdditionalInformation($orderPayment->getAdditionalInformation()); $exceptionMessage = $this->_wrapGatewayError(Mage::helper('paygate')->__('Payment partial authorization error.')); } } catch (Exception $e) { $exceptionMessage = $e->getMessage(); } throw new Mage_Payment_Model_Info_Exception($exceptionMessage); }