setData($orderData, $cartData); } protected function _getConfig() { if (null === $this->_config) { $config = Qs_Application::getConfig('ECommerce_Checkout'); $this->_config = $config->get('shipping'); } return $this->_config; } /** * Prepare and set data for payment * * @param array $orderData * @param array $cartData * @return App_ECommerce_Checkout_Adapter_Payment_Abstract */ public function setData(array $orderData, array $cartData) { $this->_data = $this->_prepareData($orderData, $cartData); return $this; } /** * @param $orderData * @param $cartData * @return array * @throws Qs_Exception */ protected function _prepareData($orderData, $cartData) { throw new Qs_Exception('Method ' . __METHOD__ . ' is not implemented'); } /** * Return payment data * * @return array */ public function getData() { return $this->_data; } /** * Process payment * * @param array $data * @param null $type * @return App_ECommerce_Checkout_Adapter_Payment_Abstract */ public function process($data = [], $type = null) { $options = ['data' => (!empty($data) ? $data : $this->getData())]; if (!empty($type)) { $options['type'] = $type; } $this->_payment = App_Service_Payment::factory($this->_paymentService, $options); return $this; } /** * Return payment object * * @return App_Service_Payment_Abstract */ public function getPayment() { return $this->_payment; } /** * Return payment response object * * @return App_Service_Payment_ResponseAbstract|bool */ public function getProcessResponse() { if ($this->_payment) { return $this->_payment->getResponse(); } return false; } /** * Return payment response errors */ public function getErrors() { return false; } /** * Verify and complete order * * @return boolean */ public function verifyOrder() { return true; } /** * @return null|string */ public function getResponseTransactionId() { if (!$this->getProcessResponse()) { return null; } return $this->getProcessResponse()->getData('transaction_id'); } }