/**
  * Convert amount for payone service request
  * @param Payone_Api_Request_Interface $request
  * @return type
  */
 public function map(Payone_Api_Request_Interface $request)
 {
     /** @var $request Payone_Api_Request_Authorization */
     if ($request->getAmount()) {
         $this->mapAmount($request);
     }
     return $request->toArray();
 }
示例#2
0
 /**
  * @param Payone_Api_Request_Interface $request
  * @param Exception
  * @return boolean
  */
 public function saveException(Payone_Api_Request_Interface $request, Exception $ex)
 {
     $domainObject = $this->getFactory()->getModelApi();
     $domainObject->setData($request->toArray());
     $domainObject->setRawRequest($request->__toString());
     $domainObject->setStacktrace($ex->getTraceAsString());
     $domainObject->setResponse(Payone_Core_Model_System_Config_ResponseType::EXCEPTION);
     $domainObject->save();
 }
 /**
  * @param Exception $e
  * @param null|Payone_Api_Request_Interface $request
  */
 public function protocolException(Exception $e, Payone_Api_Request_Interface $request = null)
 {
     foreach ($this->loggers as $key => $logger) {
         /** @var $logger Payone_Protocol_Logger_Interface */
         $logger->log(get_class($e) . ' ' . $e->getMessage(), Payone_Protocol_Logger_Interface::LEVEL_ERROR);
         if ($request !== null) {
             $requestAsString = $request->__toString();
             $logger->log($requestAsString, Payone_Protocol_Logger_Interface::LEVEL_ERROR);
         }
     }
     foreach ($this->repositories as $key => $repository) {
         /** @var $repository Payone_Api_Persistence_Interface */
         $repository->saveException($request, $e);
     }
 }
示例#4
0
 /**
  * @param Payone_Api_Request_Interface $request
  * @return bool
  * @throws Payone_Api_Exception_Request_InvalidKey
  * @throws Payone_Api_Exception_Request_InvalidMid
  * @throws Payone_Api_Exception_Request_InvalidMode
  * @throws Payone_Api_Exception_Request_InvalidPortalid
  */
 public function validateRequest(Payone_Api_Request_Interface $request)
 {
     if ($request->getMid() == '') {
         throw new Payone_Api_Exception_Request_InvalidMid();
     }
     if ($request->getPortalid() == '') {
         throw new Payone_Api_Exception_Request_InvalidPortalid();
     }
     if ($request->getKey() == '') {
         throw new Payone_Api_Exception_Request_InvalidKey();
     }
     if ($request->getMode() == '') {
         throw new Payone_Api_Exception_Request_InvalidMode();
     }
     return true;
 }
示例#5
0
 /**
  * @param Payone_Api_Request_Interface $request
  */
 protected function mapDefaultParameters(Payone_Api_Request_Interface $request)
 {
     $helper = $this->helper();
     $solutionName = 'noovias';
     $solutionVersion = $helper->getPayoneVersion();
     $integratorName = 'magento';
     $integratorVersion = $helper->getMagentoVersion();
     $request->setEncoding('UTF-8');
     $request->setMid($this->getConfigPayment()->getMid());
     $request->setPortalid($this->getConfigPayment()->getPortalid());
     $request->setMode($this->getConfigPayment()->getMode());
     $request->setKey($this->getConfigPayment()->getKey());
     $request->setIntegratorName($integratorName);
     $request->setIntegratorVersion($integratorVersion);
     $request->setSolutionName($solutionName);
     $request->setSolutionVersion($solutionVersion);
 }
 /**
  * @param Mage_Sales_Model_Order $order
  * @param Payone_Api_Response_Interface $response
  * @param Payone_Api_Request_Interface $request
  * @throws Payone_Core_Exception_TransactionAlreadyExists
  * @return null|Payone_Core_Model_Domain_Transaction
  */
 public function createByApiResponse(Mage_Sales_Model_Order $order, Payone_Api_Response_Interface $response, Payone_Api_Request_Interface $request)
 {
     $transaction = $this->getFactory()->getModelTransaction();
     if ($request->isFrontendApiCall() === false) {
         $transaction->load($response->getTxid(), 'txid');
         // should not exist but to be sure load by txid
         if ($transaction->hasData()) {
             throw new Payone_Core_Exception_TransactionAlreadyExists($response->getTxid());
         }
         $transaction->setTxid($response->getTxid());
     } else {
         $transaction->setFrontendApiCall(1);
     }
     $transaction->setLastTxaction($response->getStatus());
     $transaction->setUserid($response->getUserid());
     $transaction->setStoreId($order->getStoreId());
     $transaction->setOrderId($order->getId());
     $transaction->setReference($order->getIncrementId());
     $transaction->setCurrency($order->getOrderCurrencyCode());
     $transaction->setCustomerId($order->getCustomerId());
     $transaction->setClearingtype($request->getClearingtype());
     $transaction->setMode($request->getMode());
     $transaction->setMid($request->getMid());
     $transaction->setAid($request->getAid());
     $transaction->setPortalid($request->getPortalid());
     $transaction->setLastSequencenumber(0);
     $data = $response->toArray();
     $transaction->addData($data);
     $transaction->save();
     return $transaction;
 }
示例#7
0
 /**
  * @todo we should introduce an Request_Payment_Interface
  *
  * @param Payone_Api_Request_Interface $request
  * @return bool
  */
 protected function mapInvoicingData(Payone_Api_Request_Interface $request)
 {
     /** @var $invoicing Payone_Api_Request_Parameter_Invoicing_Transaction */
     $invoicing = $request->getInvoicing();
     if ($invoicing == null) {
         return false;
     }
     if ($invoicing->hasItems()) {
         /** @var $request Payone_Api_Request_Authorization  */
         $currency = $request->getCurrency();
         $invoicingItems = $invoicing->getItems();
         foreach ($invoicingItems as $item) {
             /** @var $item Payone_Api_Request_Parameter_Invoicing_Item */
             $price = $item->getPr();
             $mappedPrice = $this->getMapperCurrency()->mapAmountToSub($price, $currency);
             $item->setPr($mappedPrice);
         }
     }
     return true;
 }
示例#8
0
 /**
  * @param Payone_Api_Request_Interface $request
  * @return bool
  */
 protected function mapInvoicingData(Payone_Api_Request_Interface $request)
 {
     /** @var $invoicing Payone_Api_Request_Parameter_Invoicing_Transaction */
     /** @var $request Payone_Api_Request_UpdateAccess */
     $invoicing = $request->getInvoicing();
     if ($invoicing == null) {
         return false;
     }
     if ($invoicing->hasItems()) {
         $currency = $request->getCurrency();
         $invoicingItems = $invoicing->getItems();
         foreach ($invoicingItems as $item) {
             /** @var $item Payone_Api_Request_Parameter_Invoicing_Access_Item */
             $priceTrail = $item->getPrTrail();
             $mappedPriceTrail = $this->getMapperCurrency()->mapAmountToSub($priceTrail, $currency);
             $item->setPrTrail($mappedPriceTrail);
             $priceRecurring = $item->getPrRecurring();
             $mappedPriceRecurring = $this->getMapperCurrency()->mapAmountToSub($priceRecurring, $currency);
             $item->setPrRecurring($mappedPriceRecurring);
         }
     }
     return true;
 }