Exemple #1
0
 /**
  * @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();
     $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());
     $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;
 }
 /**
  * @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;
 }