Esempio n. 1
0
    /**
     * @see FrontController::initContent()
     */
    public function initContent()
    {
        $link = $this->context->link;
        $realex = new RealexRedirect();
        $this->display_column_left = false;
        parent::initContent();
        if (!$this->context->customer->isLogged() && !$this->context->customer->is_guest) {
            Tools::redirect('index.php?controller=order');
        }
        $infos = $this->getInfosForm();
        $currency = $this->context->currency;
        extract($infos, EXTR_OVERWRITE);
        if (!$this->module->checkCurrency($cart)) {
            Tools::redirect('index.php?controller=order');
        }
        // ---------------- REALVAULT
        $inputs_payer = "<input type='hidden' name='PAYER_EXIST' value='" . $payer_exists . "' />";
        $inputs_payer .= "<input type='hidden' name='PAYER_REF' value='" . $ref_payer . "' />";
        $inputs_pmt_registered = '';
        if ($payer_exists) {
            $sql = 'SELECT `refpayment_realex`,
			`paymentname_realex`,
			`type_card_realex`,
			rs.`name_realex_subaccount`,
			`threeds_realex_subaccount`,
			`dcc_realex_subaccount`,
			`dcc_choice_realex_subaccount`
			FROM `' . _DB_PREFIX_ . 'realex_paymentref`
			JOIN `' . _DB_PREFIX_ . 'realex_rel_card` rc ON `type_card_realex`=`realex_card_name`
			JOIN `' . _DB_PREFIX_ . 'realex_subaccount` rs ON rs.`id_realex_subaccount`=rc.`id_realex_subaccount`
			WHERE `id_realex_payerref` = "' . pSQL($id_realex_payerref) . '"';
            $pmt_refs = Db::getInstance()->ExecuteS($sql);
            if (count($pmt_refs) > 0) {
                foreach ($pmt_refs as $pmt_ref) {
                    $inputs_pmt_registered .= "<form method='post' action='" . $link->getModuleLink('realexredirect', 'validation', array(), true) . "'>";
                    $inputs_pmt_registered .= "<input type='hidden' name='PMT_REF' value='{$pmt_ref['refpayment_realex']}' />";
                    //SHA1
                    $tmp = $timestamp . '.' . $realex->merchant_id . '.' . $order_id;
                    $tmp .= '.' . $realex->getAmountFormat($cart->getOrderTotal(true, Cart::BOTH)) . '.' . $iso_currency . '.' . $ref_payer;
                    $sha1_temp = sha1($tmp);
                    $sha1 = sha1($sha1_temp . '.' . $realex->shared_secret);
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='SHA1HASH' value='{$sha1}'/>";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='CURRENCY' value='" . $iso_currency . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='MERCHANT_ID' value='" . $realex->merchant_id . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='ACCOUNT' value='" . $pmt_ref['name_realex_subaccount'] . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='ORDER_ID' value='" . $order_id . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='AMOUNT' value='" . $realex->getAmountFormat($cart->getOrderTotal(true, Cart::BOTH)) . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='TIMESTAMP' value='" . $timestamp . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='AUTO_SETTLE_FLAG' value='" . $settlement . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='BILLING_ZIP' value='" . $billing_postcode . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='BILLING_STREETNUMBER' value='" . $billing_streetumber . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='BILLING_CO' value='" . $billing_co . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='SHIPPING_ZIP' value='" . $shipping_postcode . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='SHIPPING_STREETNUMBER' value='" . $shipping_streetumber . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='SHIPPING_CO' value='" . $shipping_co . "' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='RETURN_TSS' value='1' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='DCC' value='{$pmt_ref['dcc_realex_subaccount']}' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='DCC_CHOICE' value='{$pmt_ref['dcc_choice_realex_subaccount']}' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='THREEDS' value='{$pmt_ref['threeds_realex_subaccount']}' />";
                    $inputs_pmt_registered .= "<input type='HIDDEN' name='TYPE_CARD' value='{$pmt_ref['type_card_realex']}' />";
                    $inputs_pmt_registered .= $inputs_payer;
                    if ($pmt_ref['type_card_realex'] == 'MC') {
                        $type_card = 'MasterCard';
                    } elseif ($pmt_ref['type_card_realex'] == 'AMEX') {
                        $type_card = 'American Express';
                    } else {
                        $type_card = Tools::ucfirst(Tools::strtolower($pmt_ref['type_card_realex']));
                    }
                    $inputs_pmt_registered .= "<div class='fleft'>{$pmt_ref['paymentname_realex']} / {$type_card}<br/>";
                    if ($realex->cvn) {
                        $inputs_pmt_registered .= $realex->l('Security Code', 'payment') . " : <input type='text' style='width:40px' name='cvn'  />";
                    }
                    $secure_link = $link->getModuleLink('realexredirect', "payment?reg={$pmt_ref['refpayment_realex']}&token=" . $this->context->cart->secure_key, array(), true);
                    $inputs_pmt_registered .= "<br/><a href='" . $secure_link . "' class='delete' onclick='return(confirm(\"" . $realex->bout_suppr . "\"))'>";
                    $inputs_pmt_registered .= 'x ' . $realex->l('Delete') . '</a></div>';
                    $inputs_pmt_registered .= "<p class='cart_navigation'>";
                    $inputs_pmt_registered .= "<input type='submit' name='submit_registered' value='" . $realex->bout_valide . "' class='exclusive_large' />";
                    $inputs_pmt_registered .= "</p><div class='clear'><br/></div>";
                    $inputs_pmt_registered .= '</form>';
                }
            }
        }
        $inputs_pmt_new = "<p class='cart_navigation'><input type='submit' name='submit' value='" . $realex->bout_valide . "' class='exclusive_large' /></p>";
        // ---------------- VARIABLES TPL
        $this->context->smarty->assign(array('nbProducts' => $cart->nbProducts(), 'cust_currency' => $cart->id_currency, 'order_id' => $order_id, 'currencies' => $this->module->getCurrency((int) $cart->id_currency), 'curr' => $currency->iso_code, 'total' => $cart->getOrderTotal(true, Cart::BOTH), 'amount' => $realex->getAmountFormat($cart->getOrderTotal(true, Cart::BOTH)), 'this_path' => $this->module->getPathUri(), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/', 'selectAccount' => $realex->getSelectAccount(), 'payer_exists' => $payer_exists, 'realvault' => $realex->realvault, 'input_registered' => $inputs_pmt_registered, 'input_new' => $inputs_pmt_new, 'submit_new' => $this->context->link->getModuleLink('realexredirect', 'payment', array('token' => $this->context->cart->secure_key), true)));
        $this->setTemplate('payment_execution.tpl');
    }