Esempio n. 1
0
    public function backendInterface($intOrderId)
    {
        $objOrderInfo = $this->Database->prepare("SELECT * FROM tl_iso_orders WHERE id=?")->limit(1)->execute($intOrderId);
        $arrOrderInfo = $objOrderInfo->fetchAssoc();
        $this->Input->setGet('uid', $arrOrderInfo['uniqid']);
        $objModule = new ModuleIsotopeOrderDetails($this->Database->execute("SELECT * FROM tl_module WHERE type='iso_orderdetails'"));
        $strOrderDetails = $objModule->generate(true);
        $arrPaymentInfo = deserialize($arrOrderInfo['payment_data'], true);
        $this->fltOrderTotal = $arrOrderInfo['grandTotal'];
        //Get the authorize.net configuration data
        $objAIMConfig = $this->Database->prepare("SELECT * FROM tl_iso_payment_modules WHERE type=?")->execute('authorizedotnet');
        if ($objAIMConfig->numRows < 1) {
            return '<i>' . $GLOBALS['TL_LANG']['MSC']['noPaymentModules'] . '</i>';
        }
        //Code specific to Authorize.net!
        $objTemplate = new BackendTemplate('be_pos_terminal');
        if ($objAIMConfig->numRows > 0) {
            $delimResponse = "TRUE";
            $delimChar = $objAIMConfig->authorize_delimiter;
            $loginID = $objAIMConfig->authorize_login;
            $transKey = $objAIMConfig->authorize_trans_key;
            $transType = 'PRIOR_AUTH_CAPTURE';
            $status = $objAIMConfig->debug ? "TRUE" : "FALSE";
            $strMode = $objAIMConfig->debug ? "test" : "secure";
        }
        if ($this->Input->post('FORM_SUBMIT') == 'be_pos_terminal' && $arrPaymentInfo['x_trans_id'] !== "0") {
            $cybersource_values = array("x_version" => '3.1', "x_login" => $loginID, "x_tran_key" => $transKey, "x_type" => $transType, "x_trans_id" => $arrPaymentInfo['x_trans_id'], "x_amount" => number_format($this->fltOrderTotal, 2), "x_delim_data" => 'TRUE', "x_delim_char" => ',', "x_encap_char" => '"', "x_relay_response" => 'FALSE');
            foreach ($cybersource_values as $key => $value) {
                $fields .= "{$key}=" . urlencode($value) . "&";
            }
            $fieldsFinal = rtrim($fields, '&');
            $objRequest = new Request();
            $objRequest->send('https://secure.authorize.net/gateway/transact.dll', $fieldsFinal, 'post');
            $arrResponses = $this->handleResponse($objRequest->response);
            foreach (array_keys($arrResponses) as $key) {
                $arrReponseLabels[standardize($key)] = $key;
            }
            $objTemplate->fields = $this->generateResponseString($arrResponses, $arrReponseLabels);
            //$objTemplate->headline = $arrResponses['transaction-status'] . ' - ' . $this->strReason;
            $strResponse = '<p class="tl_info">' . $arrPaymentInfo['authorize_response'] . ' - ' . $arrResponses['transaction-status'] . '</p>';
            switch ($arrResponses['transaction-status']) {
                case 'Approved':
                    $arrPaymentInfo['authorization_code'] = $arrResponses['authorization-code'];
                    $strPaymentInfo = serialize($arrPaymentInfo);
                    $this->Database->prepare("UPDATE tl_iso_orders SET status='processing', payment_data=? WHERE id=?")->execute($strPaymentInfo, $intOrderId);
                    break;
                default:
                    $arrPaymentInfo['authorize_reason'] = $arrResponses['reason'];
                    $strPaymentInfo = serialize($arrPaymentInfo);
                    $this->Database->prepare("UPDATE tl_iso_orders SET status='on_hold', cybersource_reason=? WHERE id=?")->execute($strPaymentInfo, $intOrderId);
                    break;
            }
            $objTemplate->isConfirmation = true;
            //$objTemplate->showPrintLink = true;
        }
        $action = ampersand($this->Environment->request, ENCODE_AMPERSANDS);
        //$objTemplate->x_cust_id;
        $objTemplate->formId = 'be_pos_terminal';
        $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['confirmOrder']);
        $return = '<div id="tl_buttons">
<input type="hidden" name="FORM_SUBMIT" value="' . $objTemplate->formId . '" />
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">
<a href="' . ampersand(str_replace('&key=payment', '', $this->Environment->request)) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBT']) . '">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>
<h2 class="sub_headline">' . $GLOBALS['ISO_LANG']['PAY']['authorizedotnet'][0] . (!$arrPaymentInfo['x_trans_id'] || $arrPaymentInfo['x_trans_id'] == "0" ? ' - ' . 'Test Transaction' : '') . '</h2>
<div class="tl_formbody_edit">
<div class="tl_tbox block">';
        $return .= $strResponse ? $strResponse : '';
        $return .= $strOrderDetails;
        $return .= '</div></div>';
        if ($arrOrderInfo['status'] == 'pending') {
            $return .= '<div class="tl_formbody_submit"><div class="tl_submit_container">';
            $return .= '<input type="submit" class="submit" value="' . $objTemplate->slabel . '" /></div></div>';
        }
        $objTemplate->orderReview = $return;
        $objTemplate->action = $action;
        $objTemplate->rowLast = 'row_' . (count($this->editable) + 1) . ($i % 2 == 0 ? ' odd' : ' even');
        return $objTemplate->parse();
    }
Esempio n. 2
0
    /**
     * Generate the backend POS terminal
     *
     * @param int
     * @access public
     * @return string
     */
    public function backendInterface($intOrderId)
    {
        $arrOrderInfo = $this->Database->prepare("SELECT * FROM tl_iso_orders WHERE id=?")->limit(1)->execute($intOrderId)->fetchAssoc();
        $this->Input->setGet('uid', $arrOrderInfo['uniqid']);
        $objModule = new ModuleIsotopeOrderDetails($this->Database->execute("SELECT * FROM tl_module WHERE type='iso_orderdetails'"));
        $strOrderDetails = $objModule->generate(true);
        $arrPaymentData = deserialize($arrOrderInfo['payment_data'], true);
        //Get the authorize.net configuration data
        $objAIMConfig = $this->Database->prepare("SELECT * FROM tl_iso_payment_modules WHERE type=?")->execute('authorizedotnet');
        if ($objAIMConfig->numRows < 1) {
            return '<i>' . $GLOBALS['TL_LANG']['MSC']['noPaymentModules'] . '</i>';
        }
        //Code specific to Authorize.net!
        $objTemplate = new BackendTemplate('be_pos_terminal');
        if ($objAIMConfig->numRows > 0) {
            $this->authorize_delimiter = $objAIMConfig->authorize_delimiter;
            $this->authorize_login = $objAIMConfig->authorize_login;
            $this->authorize_trans_key = $objAIMConfig->authorize_trans_key;
            $this->debug = $objAIMConfig->debug;
            $this->new_order_status = $objAIMConfig->new_order_status;
            $this->authorize_trans_type = $objAIMConfig->authorize_trans_type;
        }
        if ($this->Input->post('FORM_SUBMIT') == 'be_pos_terminal' && $arrPaymentData['transaction-id'] !== "0") {
            $blnAuthCapture = $this->authCapturePayment($arrOrderInfo['id'], $arrOrderInfo['grandTotal'], true);
            $strResponse = '<p class="tl_info">' . sprintf("Transaction Status: %s, Reason: %s", $this->strStatus, $this->strReason) . '</p>';
        }
        if ($blnAuthCapture) {
            $objOrder = new IsotopeOrder();
            if (!$objOrder->findBy('id', $intOrderId)) {
                $objOrder->uniqid = uniqid($this->Isotope->Config->orderPrefix, true);
                $objOrder->findBy('id', $objOrder->save());
            }
            $objOrder->status = 'processing';
            $objOrder->save();
        }
        $return = '<div id="tl_buttons">
<input type="hidden" name="FORM_SUBMIT" value="be_pos_terminal">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">
<a href="' . ampersand(str_replace('&key=payment', '', $this->Environment->request)) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBT']) . '">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>
<h2 class="sub_headline">' . $GLOBALS['ISO_LANG']['PAY']['authorizedotnet'][0] . (!$arrPaymentData['transaction-id'] || $arrPaymentData['transaction-id'] == "0" ? ' - ' . 'Test Transaction' : '') . '</h2>
<div class="tl_formbody_edit">
<div class="tl_tbox block">';
        $return .= $strResponse ? $strResponse : '';
        $return .= $strOrderDetails;
        $return .= '</div></div>';
        if ($arrOrderInfo['status'] == $this->new_order_status) {
            $return .= '<div class="tl_formbody_submit"><div class="tl_submit_container">';
            $return .= '<input type="submit" class="submit" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['confirmOrder']) . '"></div></div>';
        }
        $objTemplate->orderReview = $return;
        $objTemplate->action = ampersand($this->Environment->request, ENCODE_AMPERSANDS);
        return $objTemplate->parse();
    }
Esempio n. 3
0
 /**
  * Generate the order details view when editing an order
  * @param object
  * @param string
  * @return string
  */
 public function generateOrderDetails($dc, $xlabel)
 {
     $objOrder = $this->Database->execute("SELECT * FROM tl_iso_orders WHERE id=" . $dc->id);
     if (!$objOrder->numRows) {
         $this->redirect($this->Environment->script . '?act=error');
     }
     $GLOBALS['TL_CSS'][] = 'system/modules/isotope/html/print.css|print';
     // Generate a regular order details module
     $this->Input->setGet('uid', $objOrder->uniqid);
     $objModule = new ModuleIsotopeOrderDetails($this->Database->execute("SELECT * FROM tl_module WHERE type='iso_orderdetails'"));
     return $objModule->generate(true);
 }