public function getContent()
 {
     if (Tools::isSubmit('btnSubmit')) {
         $this->postProcess();
     }
     $currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
     $id_lang = Configuration::get('PS_LANG_DEFAULT');
     $carriers = Carrier::getCarriers($id_lang, false, false, false, null, 0);
     $config = Configuration::getMultiple(array('COD_ENABLED', 'COD_SHOW_ZERO', 'COD_TITLE', 'COD_ORDER_STATUS', 'COD_SPECIFIC_COUNTRY', 'COD_COUNTRY', 'COD_MINIMUM_ORDER', 'COD_MAXIMUM_ORDER', 'COD_COST_CALCULATION', 'COD_COST_INLAND', 'COD_COST_FOREIGN', 'COD_FREE_FROM', 'COD_CUSTOM_TEXT', 'COD_DISALLOW_METHODS', 'COD_DISALLOWED_METHODS', 'COD_ORDER_TIME'));
     $this->context->smarty->assign(array('module_name' => $this->name, 'displayName' => $this->displayName, 'order_time' => $config['COD_ORDER_TIME'], 'request_uri' => $_SERVER['REQUEST_URI'], 'enabled' => $config['COD_ENABLED'], 'show_zero' => $config['COD_SHOW_ZERO'], 'title' => $config['COD_TITLE'], 'orders_status' => OrderStateCore::getOrderStates((int) $this->context->language->id), 'order_status' => $config['COD_ORDER_STATUS'], 'specific_country' => $config['COD_SPECIFIC_COUNTRY'], 'country' => ($a = unserialize($config['COD_COUNTRY'])) ? $a : array(), 'all_countrys' => Country::getCountries((int) $this->context->language->id, true), 'minimum_order' => $config['COD_MINIMUM_ORDER'], 'maximum_order' => $config['COD_MAXIMUM_ORDER'], 'cost_calculation' => $config['COD_COST_CALCULATION'], 'cost_inland' => $config['COD_COST_INLAND'], 'cost_foreign' => $config['COD_COST_FOREIGN'], 'free_from' => $config['COD_FREE_FROM'], 'custom_text' => $config['COD_CUSTOM_TEXT'], 'disallow_methods' => $config['COD_DISALLOW_METHODS'], 'carriers' => $carriers, 'disallowed_methods' => ($a = unserialize($config['COD_DISALLOWED_METHODS'])) ? $a : array(), 'currency_sign' => $currency->sign));
     $this->context->controller->addJS($this->local_path . '/views/js/script.js', 'all');
     $output = $this->context->smarty->fetch($this->local_path . '/views/templates/admin/configure.tpl');
     return $output;
 }
 public function uninstall()
 {
     $status = true;
     $veritrans_payment_waiting_order_state_id = Configuration::get('VT_ORDER_STATE_ID');
     if ($veritrans_payment_waiting_order_state_id) {
         $order_state = new OrderStateCore($veritrans_payment_waiting_order_state_id);
         $order_state->delete();
     }
     if (!parent::uninstall()) {
         $status = false;
     }
     return $status;
 }
Example #3
0
 private function getOrdersStatuses()
 {
     $statuses = OrderStateCore::getOrderStates($this->def_lang);
     $statuses = array_map(array($this, 'statusProcess'), $statuses);
     return $statuses;
 }
Example #4
0
    /**
     * 后台配置模块
     * @return string
     */
    public function getContent()
    {
        global $currentIndex, $cookie;
        if (Tools::isSubmit('Submit_Gofpay_CheckOut')) {
            $errors = array();
            if ($paymentTitle = Tools::getValue('GOFPAY_PAYMENT_TITLE')) {
                Configuration::updateValue('GOFPAY_PAYMENT_TITLE', $_POST['GOFPAY_PAYMENT_TITLE']);
            } else {
                $errors['GOFPAY_PAYMENT_TITLE'] = '<div class="warning warn"><h3>' . $this->l('Payment Title seems to be wrong') . '</h3></div>';
            }
            if ($websiteId = Tools::getValue('GOFPAY_WEBSITE_ID') and preg_match('/[0-9]/', $_POST['GOFPAY_WEBSITE_ID'])) {
                Configuration::updateValue('GOFPAY_WEBSITE_ID', $_POST['GOFPAY_WEBSITE_ID']);
            } else {
                $errors['GOFPAY_WEBSITE_ID'] = '<div class="warning warn"><h3>' . $this->l('Merchant No. seems to be wrong') . '</h3></div>';
            }
            if ($secretKey = Tools::getValue('GOFPAY_SECRET_KEY')) {
                Configuration::updateValue('GOFPAY_SECRET_KEY', $_POST['GOFPAY_SECRET_KEY']);
            } else {
                $errors['GOFPAY_SECRET_KEY'] = '<div class="warning warn"><h3>' . $this->l('Gateway No. seems to be wrong') . '</h3></div>';
            }
            //if ($mode = Tools::getValue('GOFPAY_MODE'))
            //    Configuration::updateValue('GOFPAY_MODE', $_POST['GOFPAY_MODE']);
            //else
            //    $errors['GOFPAY_MODE'] = '<div class="warning warn"><h3>'.$this->l('Sign key seems to be wrong').'</h3></div>';
            if ($gatewayUrl = Tools::getValue('GOFPAY_GATEWAY_URL')) {
                Configuration::updateValue('GOFPAY_GATEWAY_URL', $_POST['GOFPAY_GATEWAY_URL']);
            } else {
                $errors['GOFPAY_GATEWAY_URL'] = '<div class="warning warn"><h3>' . $this->l('Gateway Url seems to be wrong') . '</h3></div>';
            }
            if ($gatewayVersion = Tools::getValue('GOFPAY_GATEWAY_VERSION')) {
                Configuration::updateValue('GOFPAY_GATEWAY_VERSION', $_POST['GOFPAY_GATEWAY_VERSION']);
            } else {
                $errors['GOFPAY_GATEWAY_VERSION'] = '<div class="warning warn"><h3>' . $this->l('Gateway Url seems to be wrong') . '</h3></div>';
            }
            if ($successStatus = Tools::getValue('GOFPAY_GATEWAY_STATUS')) {
                Configuration::updateValue('GOFPAY_GATEWAY_STATUS', $_POST['GOFPAY_GATEWAY_STATUS']);
            } else {
                $errors['GOFPAY_GATEWAY_STATUS'] = '<div class="warning warn"><h3>' . $this->l('Payment Success Order Status seems to be wrong') . '</h3></div>';
            }
            if (!sizeof($errors)) {
                Tools::redirectAdmin($currentIndex . '&configure=gofpay&token=' . Tools::getValue('token') . '&conf=4');
            }
        }
        $order_states = OrderStateCore::getOrderStates($cookie->id_lang);
        $options = '';
        foreach ($order_states as $statu) {
            if ($statu["id_order_state"] == Tools::getValue('GOFPAY_GATEWAY_STATUS', Configuration::get('GOFPAY_GATEWAY_STATUS'))) {
                $options .= '<option value="' . $statu["id_order_state"] . '" selected="selected">' . $statu["name"] . '</option>';
            } else {
                $options .= '<option value="' . $statu["id_order_state"] . '">' . $statu["name"] . '</option>';
            }
        }
        $html = '<h2>' . $this->displayName . '</h2>
        <form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
            <fieldset>
                <legend><img src="' . __PS_BASE_URI__ . 'modules/gofpay/logo.png" />' . $this->l('Settings') . '</legend>
                <p>' . $this->l('First use the sandbox to test out the module then you can use the real mode if everything\'s fine. Don\'t forget to change your merchant key and id according to the mode!') . '</p>
                <label>' . $this->l('Payment Title') . '</label>
                <div class="margin-form">
                    <input type="text" name="GOFPAY_PAYMENT_TITLE" value="' . Tools::getValue('GOFPAY_PAYMENT_TITLE', Configuration::get('GOFPAY_PAYMENT_TITLE')) . '" size="100" />' . $errors['GOFPAY_PAYMENT_TITLE'] . '
                </div>
                <label>' . $this->l('Website Id') . '</label>
                <div class="margin-form">
                    <input type="text" name="GOFPAY_WEBSITE_ID" value="' . Tools::getValue('GOFPAY_WEBSITE_ID', Configuration::get('GOFPAY_WEBSITE_ID')) . '" size="8" />' . $errors['GOFPAY_WEBSITE_ID'] . '
                </div>
				  <label>' . $this->l('Secret Key') . '</label>
                <div class="margin-form">
                    <input type="text" name="GOFPAY_SECRET_KEY" value="' . Tools::getValue('GOFPAY_SECRET_KEY', Configuration::get('GOFPAY_SECRET_KEY')) . '" size="16"/>' . $errors['GOFPAY_SECRET_KEY'] . '
                </div>
                <label>' . $this->l('Gateway Url') . '</label>
                <div class="margin-form">
                    <input type="text" name="GOFPAY_GATEWAY_URL" value="' . Tools::getValue('GOFPAY_GATEWAY_URL', Configuration::get('GOFPAY_GATEWAY_URL')) . '" size="100"/>' . $errors['GOFPAY_GATEWAY_URL'] . '
                </div>
                <label>' . $this->l('Gateway Version') . '</label>
                <div class="margin-form">
                    <input type="text" name="GOFPAY_GATEWAY_VERSION" value="' . Tools::getValue('GOFPAY_GATEWAY_VERSION', Configuration::get('GOFPAY_GATEWAY_VERSION')) . '" size="2"/>' . $errors['GOFPAY_GATEWAY_VERSION'] . '
                </div>
                <label>' . $this->l('Payment Success Order Status') . '</label>
                <div class="margin-form">
                    <select name="GOFPAY_GATEWAY_STATUS">' . $options . '</select>' . $errors['GOFPAY_GATEWAY_STATUS'] . '
                </div>
                <div class="clear center"><input type="submit" name="Submit_Gofpay_CheckOut" class="button" value="' . $this->l('Save And Update') . '" /></div>
            </fieldset>
        </form>';
        return $html;
    }
Example #5
0
    /**
     * @param bool $b_updated
     */
    private function _displayForm($b_updated = false)
    {
        global $cookie;
        require_once '../classes/order/OrderState.php';
        $this->_html .= '<h2><a target="_blank" href="http://przelewy24.pl"><img src="../modules/przelewy24/img/logo.png" title="Przelewy24" alt="Przelewy24" /></a>&nbsp;' . $this->l('Configuration') . '</h2>';
        $this->_html .= '<p style="font-size: 16px;">' . $this->l('Here you can change integration settings of Przelewy24 Payment Module') . '</p>';
        $this->_html .= '<script type="text/javascript">
								function refreshSprzedawcaIDStatusIcon(){
                                    if($("#sprzedawcaID").val() != ""){
                                        $("#sprzedawcaIDStatusIcon").attr("src", "../img/admin/icon-valid.png");
                                    } else {
                                        $("#sprzedawcaIDStatusIcon").attr("src", "../img/admin/icon-cancel.png");
                                    }
                                }

                                $(function(){
                                        $("#test_mode").change(
                                                function()
                                                {
                                                        var o_Test_Transaction=$("#test-transaction");

                                                        if($(this).val()==1)
                                                        {
                                                                o_Test_Transaction.css("visibility","visible");
                                                        }
                                                        else
                                                        {
                                                                o_Test_Transaction.css("visibility","hidden");
                                                        }
                                                }
                                        );
                                        $("#sprzedawcaID").keyup(
                                            function(){
                                                refreshSprzedawcaIDStatusIcon();
                                            }
                                        );

                                        refreshSprzedawcaIDStatusIcon();
                                });
                           </script>';
        if ($b_updated) {
            $this->_html .= '<div class="conf confirm"><img alt="Potwierdź" src="../img/admin/ok.gif"/>' . $this->l('Updated') . '</div>';
        }
        $this->_html .= '
		<fieldset>
			<legend><img src="../img/admin/error.png" />' . $this->l('Important Information') . '</legend>
			<p>' . $this->l("You have to be registered to use module Przelewy24. If you have just done it, you can configure module in Payment Settings. However if you still have not registered, go to") . ' <a target="_blank" href="http://www.przelewy24.pl/cms,20,rejestracja.htm">' . $this->l("this link") . '</a>.</p>

        </fieldset>';
        $this->_html .= '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
                            <fieldset>
                                    <legend><img src="../img/admin/cog.gif" />' . $this->l('Payment Settings') . '</legend>

									<table>
										<tr>
											<td><label><img src="../img/admin/tab-customers.gif" />' . $this->l('Partner ID') . '<br /><small style="color:red">' . $this->l('mandatory') . '</small></label></td>
											<td><input id="sprzedawcaID" type="text" name="sprzedawcaID" value="' . Configuration::get('P24_ID_SPRZEDAWCY') . '" /><img id="sprzedawcaIDStatusIcon" src="../img/admin/icon-cancel.png" style="width: 23px; height: 23px" /></td>
										</tr>
										<tr>
											<td><label>' . $this->l('Status before completing payment') . '</label></td>
											<td>
												<select name="order_state_1">';
        foreach (OrderStateCore::getOrderStates($cookie->id_lang) as $orderState) {
            $selected = Configuration::get('P24_ORDER_STATE_1') == $orderState['id_order_state'] ? ' selected="selected"' : '';
            $this->_html .= '<option value="' . $orderState['id_order_state'] . '"' . $selected . '>' . $orderState['name'] . '</option>';
        }
        $this->_html .= '						</select>
											</td>
										</tr>
										<tr>
											<td><label>' . $this->l('Status after completing payment') . '</label></td>
											<td>
												<select name="order_state_2">';
        foreach (OrderStateCore::getOrderStates($cookie->id_lang) as $orderState) {
            $selected = Configuration::get('P24_ORDER_STATE_2') == $orderState['id_order_state'] ? ' selected="selected"' : '';
            $this->_html .= '<option value="' . $orderState['id_order_state'] . '"' . $selected . '>' . $orderState['name'] . '</option>';
        }
        $this->_html .= '						</select>
											</td>
										</tr>
										<tr>
											<td rowspan="2"><label>' . $this->l('Module mode') . '</label></td>
											<td>
												<h5 style="display:inline">' . $this->l('Mode:') . '</h5>
                                                <select name="test_mode" id="test_mode" style="margin-left:16px">
                                                        <option value="1"' . (Configuration::get('P24_TEST_MODE') == 1 ? ' selected="selected"' : '') . '>' . $this->l('test') . '</option>
                                                        <option value="0"' . (Configuration::get('P24_TEST_MODE') == 0 ? ' selected="selected"' : '') . '>' . $this->l('normal') . '</option>
                                                </select>
                                            </td>
										</tr>
										<tr>
											<td id="test-transaction" style="visibility:' . (Configuration::get('P24_TEST_MODE') == 1 ? 'visible' : 'hidden') . '">
												<h5 style="display:inline">' . $this->l('Test transaction type:') . '</h5>
                                                <select name="test_transaction_select" id="test_transaction_select" style="margin-left:9px">
                                                        <option value="1"' . (Configuration::get('P24_TEST_MODE_TRANSACTION') == 1 ? ' selected="selected"' : '') . '>' . $this->l('correct') . '</option>
                                                        <option value="0"' . (Configuration::get('P24_TEST_MODE_TRANSACTION') == 0 ? ' selected="selected"' : '') . '>' . $this->l('faulty') . '</option>
                                                </select>
                                            </td>
										</tr>
									</table>
                            </fieldset>
                            <fieldset>
                                <legend><img src="../img/admin/cog.gif" />' . $this->l('Installment Settings') . '</legend>
                                <table>
                                    <tr>
                                        <td><label><h5 style="display:inline">' . $this->l('Show') . '</h5></label></td>
                                        <td>
                                            <select name="installment_show">
                                                <option value="2"' . (Configuration::get('P24_INSTALLMENT_SHOW') == 2 ? ' selected="selected"' : '') . '>' . $this->l('button (payment page) and information (product page)') . '</option>
                                                <option value="1"' . (Configuration::get('P24_INSTALLMENT_SHOW') == 1 ? ' selected="selected"' : '') . '>' . $this->l('button (payment page) only') . '</option>
                                                <option value="0"' . (Configuration::get('P24_INSTALLMENT_SHOW') == 0 ? ' selected="selected"' : '') . '>' . $this->l('hide all') . '</option>
                                            </select>
                                        </td>
                                    </tr>
                                </table>
                            </fieldset>
                            <input type="submit" name="submit" value="' . $this->l('Save settings') . '" class="button" />
                        </form>';
    }