示例#1
0
 /**
  * @param array $params
  *
  * @return Payone_Api_Response_Authorization_Approved|Payone_Api_Response_Authorization_Redirect|Payone_Api_Response_Error
  * @throws Payone_Api_Exception_UnknownStatus
  */
 public function map(array $params)
 {
     $this->setParams($params);
     if ($this->isApproved()) {
         $response = new Payone_Api_Response_Genericpayment_Approved($params);
     } elseif ($this->isOk()) {
         $response = new Payone_Api_Response_Genericpayment_Ok($params);
     } elseif ($this->isRedirect()) {
         $response = new Payone_Api_Response_Genericpayment_Redirect($params);
     } elseif ($this->isError()) {
         $response = new Payone_Api_Response_Error($params);
     } else {
         throw new Payone_Api_Exception_UnknownStatus();
     }
     $response->setRawResponse($params);
     return $response;
 }
 /**
  * Endpoint for handling all kinds of errors and exceptions,
  * Notifies Magento admin of error (by email), allows displaying of ALL payment methods
  *
  * Takes Exception and/or Error response as parameter, to provide information for error email
  *
  * @param null|Exception $ex
  * @param null|Payone_Api_Response_Error $response
  * @throws Mage_Payment_Exception
  * @return bool
  */
 protected function handleError(Exception $ex = null, Payone_Api_Response_Error $response = null)
 {
     $config = $this->getConfig();
     if ($config->isIntegrationEventAfterPayment()) {
         if ($config->onErrorStopCheckout()) {
             // Mage_Payment_Exception is caught in checkout and message gets displayed to customer.
             throw new Mage_Payment_Exception($config->getStopCheckoutMessage());
         }
         return true;
     }
     $additionalInfo = array();
     if (!empty($response)) {
         $errorName = 'Creditrating check ERROR. Code: ' . $response->getErrorcode();
         $errorMessage = $response->getErrormessage();
         $stackTrace = '';
         $additionalInfo['customermessage'] = $response->getCustomermessage();
     } elseif (!empty($ex)) {
         $errorName = 'Creditrating check Exception. ' . get_class($ex);
         $errorMessage = $ex->getMessage();
         $stackTrace = $ex->getTraceAsString();
     } else {
         $errorName = 'Creditrating check unexpected error. ';
         $errorMessage = 'An unexpected error occured during creditrating check.';
         $stackTrace = '';
     }
     $helperEmail = $this->helperEmail();
     $helperEmail->setStoreId($this->getConfigStore()->getStoreId());
     $helperEmail->sendEmailError($errorName, $errorMessage, $stackTrace, $additionalInfo);
     return true;
 }