/** * Set split_tender_id to quote payment if needed * * @param \Magento\Framework\Object $response * @param float $orderPayment * @throws \Magento\Payment\Model\Info\Exception * @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 = __('You have reached the maximum number of credit cards ' . '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(__('Something went wrong while authorizing the partial payment.')); } } catch (\Exception $e) { $exceptionMessage = $e->getMessage(); } throw new \Magento\Payment\Model\Info\Exception($exceptionMessage); }