Example #1
0
    function onAfterOrderConfirm(&$order, &$methods, $method_id)
    {
        parent::onAfterOrderConfirm($order, $methods, $method_id);
        if (parent::onBeforeOrderCreate($order, $do) === true) {
            return true;
        }
        if (!function_exists('curl_init')) {
            $this->app->enqueueMessage('The Authorize.net payment plugin in AIM mode needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error');
            $do = false;
            return false;
        }
        if (empty($this->payment_params->merchant_id)) {
            $this->app->enqueueMessage('You have to configure a customer merchant for the westpac plugin payment first : check your plugin\'s parameters, on your website backend', 'error');
            return false;
        }
        if (empty($this->payment_params->username)) {
            $this->app->enqueueMessage('You have to configure your username for the westpac plugin payment first : check your plugin\'s parameters,
			on your website backend', 'error');
            return false;
        }
        if (empty($this->payment_params->password)) {
            $this->app->enqueueMessage('You have to configure your password for the westpac plugin payment first : check your plugin\'s parameters,
			on your website backend', 'error');
            return false;
        }
        if (empty($this->payment_params->certFile) || $this->payment_params->certFile == '.pem expected') {
            $this->app->enqueueMessage('You have to define the certificat file path for the westpac Api plugin payment first : check your plugin\'s parameters,
			on your website backend', 'error');
            return false;
        }
        include dirname(__FILE__) . DS . 'westpacapi_qvalent.php';
        $capath = JPath::clean(HIKASHOP_ROOT . 'plugins' . DS . 'hikashoppayment' . DS . 'westpacApi' . DS . 'cacerts.crt');
        $initParams = "certificateFile=" . $this->payment_params->certFile . "&" . "caFile=" . $capath . "&" . 'logDirectory=' . HIKASHOP_ROOT . 'media' . DS . 'com_hikashop' . DS . 'upload' . DS . 'safe' . DS . 'logs' . DS;
        $paywayAPI = new Qvalent_PayWayAPI();
        $paywayAPI->initialise($initParams);
        $amount = round($order->cart->full_total->prices[0]->price_value_with_tax, 2) * 100;
        $this->ccLoad();
        $vars = array('order.type' => "capture", 'customer.merchant' => trim($this->payment_params->merchant_id), 'customer.username' => trim($this->payment_params->username), 'customer.password' => trim($this->payment_params->password), 'customer.orderNumber' => $order->order_id, 'customer.originalOrderNumber' => $order->order_id, 'card.PAN' => $this->cc_number, 'card.CVN' => $this->cc_CCV, 'card.expiryYear' => $this->cc_year, 'card.expiryMonth' => $this->cc_month, 'card.currency' => 'AUD', 'order.amount' => $amount, 'order.ECI' => 'SSL');
        if ($this->payment_params->testingmode) {
            $vars['customer.merchant'] = 'TEST';
        }
        if ($this->payment_params->debug) {
            $this->writeToLog("\n Data (vars) send to westpac in Api Mode: \n\n\n");
            $this->writeToLog(print_r($vars, true));
        }
        $requestText = $paywayAPI->formatRequestParameters($vars);
        $responseText = $paywayAPI->processCreditCard($requestText);
        $post_response = $paywayAPI->parseResponseParameters($responseText);
        if ($this->payment_params->debug) {
            $this->writeToLog("\n Data (post response) receive from westpac in Api Mode: \n\n\n");
            $this->writeToLog(print_r($post_response, true));
        }
        $this->ccClear();
        if ($post_response['response.summaryCode'] == '0') {
            $order_status = $this->payment_params->verified_status;
            $this->modifyOrder($order->order_id, $order_status, true, true);
            return $this->showPage('thankyou');
        } else {
            $order_status = $this->payment_params->invalid_status;
            $this->modifyOrder($order->order_id, $order_status, true, true);
            $cancel_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=order&task=cancel_order&order_id=' . $order->order_id . $this->url_itemid;
            $error = "Report by Westpac </br>Error : " . $post_response['response.text'];
            $this->app->redirect($cancel_url, $error);
            return true;
        }
    }
Example #2
0
 protected function _refundcall(Varien_Object $payment)
 {
     if ($this->getDebug()) {
         $writer = new Zend_Log_Writer_Stream($this->getLogPath());
         $logger = new Zend_Log($writer);
         $logger->info("entering _refundcall()");
     }
     $paywayAPI = new Qvalent_PayWayAPI();
     if ($this->getDebug()) {
         $logger->info("Qvalent_PayWayAPI created");
     }
     $init = "certificateFile=" . $this->getCertificate() . "&" . "caFile=" . $this->getCaFile() . "&" . "logDirectory=" . $this->getLogDir();
     if ($this->getDebug()) {
         $logger->info($init);
     }
     $paywayAPI->initialise($init);
     if ($this->getDebug()) {
         $logger->info("Qvalent_PayWayAPI initialised");
     }
     $orderNumber = $payment->getOrder()->getStoreId() . str_pad($payment->getOrder()->getQuoteId(), 9, '0', STR_PAD_LEFT);
     if ($this->getDebug()) {
         $logger->info(print_r($payment->getOrder()->getData(), true));
     }
     $params = array();
     $params["order.type"] = "refund";
     $params["customer.username"] = $this->getUsername();
     $params["customer.password"] = $this->getPassword();
     $params["customer.merchant"] = $this->getMerchantID();
     $params["card.expiryYear"] = substr($payment->getCcExpYear(), 2, 2);
     $params["card.expiryMonth"] = str_pad($payment->getCcExpMonth(), 2, '0', STR_PAD_LEFT);
     $params["card.currency"] = $payment->getOrder()->getBaseCurrencyCode();
     $params["order.amount"] = $this->getAmount() * 100;
     $params["order.ECI"] = "SSL";
     $params["customer.orderNumber"] = $payment->getCcTransId() . "R";
     $params["customer.originalOrderNumber"] = $payment->getCcTransId();
     if ($this->getDebug()) {
         $logger->info("Params: " . print_r($params, true));
     }
     $requestText = $paywayAPI->formatRequestParameters($params);
     $responseText = $paywayAPI->processCreditCard($requestText);
     $result = $paywayAPI->parseResponseParameters($responseText);
     if ($this->getDebug()) {
         $logger->info("Result: " . print_r($result, true));
     }
     return $result;
 }