Prestashop 1.6.1.16 - SEO Friendly URL останавливает платежный шлюз - PullRequest
0 голосов
/ 20 сентября 2018

:)

Модуль шлюза оплаты от https://bpoint -uat.premier.com.au / developers / v3 / index.htm #! # Plugins , и он работает хорошобез функции SEO Friendly URL в Prestashop 1.6.1.16.Когда эта функция включена, платежный шлюз переводит пользователя обратно на первый шаг процесса оплаты после нажатия «подтвердить» для завершения платежа.Я думал, что это как-то связано с переписыванием URL-адреса, дружественного к SEO, но я не могу понять это.Интересно, что в верхней части скрипта validate.php можно увидеть оператор if, который возвращает пользователя к шагу 1 процесса оплаты в случае сбоя любого из 4 операторов.Из того, что я вижу, это наиболее вероятная точка, в которой этот процесс завершается неудачей.

Будем благодарны за любые подсказки или предложения по тестированию или отладке, чтобы найти решение.Ниже приведен скрипт проверки, в котором, как мне кажется, происходит сбой, и основной класс Bpoint:

validate.php -

    <?php

include(dirname(__FILE__) . '/../../config/config.inc.php');
include(dirname(__FILE__) . '/../../init.php');
/* will include backward file */
include(dirname(__FILE__) . '/bpoint.php');

/* will include library bpoint */
include_once(dirname(__FILE__) . '/library/BPOINT_API.php');
include_once(dirname(__FILE__) . '/library/BPOINT_currencyAmount.php');

$bpoint = new BPOINT();

/* Does the cart exist and is valid? */
$cart = Context::getContext()->cart;

if ($cart->id_customer == 0 OR $cart->id_address_delivery == 0 OR $cart->id_address_invoice == 0 OR ! $bpoint->active)
    Tools::redirect('index.php?controller=order&step=1');

$customer = new Customer((int) $cart->id_customer);
$currency = new Currency((int) $cart->id_currency);
$invoiceAddress = new Address((int) $cart->id_address_invoice);
if (!Validate::isLoadedObject($customer) || !Validate::isLoadedObject($invoiceAddress) && !Validate::isLoadedObject($currency)) {
    Logger::addLog('Issue loading customer, address and/or currency data');
    die('An unrecoverable error occured while retrieving you data');
}

$order_total = (float) ($cart->getOrderTotal(true, Cart::BOTH));
$payment_currency_id = Configuration::get('BPOINT_PAYMENT_CURRENCY');

$payment_currency = new Currency($payment_currency_id);
$payment_total = floatval($order_total / $currency->conversion_rate * $payment_currency->conversion_rate);

$bpCurrencyAmount = new BPOINTCurrencyAmount();
$api_url = $bpoint->getApiUrl() . 'v2';

$bpoint->validateOrder($cart->id, Configuration::get('BPOINT_PENDING_STATUS_ID'), $payment_total, $bpoint->displayName, null, array(), (int) $payment_currency->id, true, $customer->secure_key);

$order = new Order($bpoint->currentOrder);

$txn = new BPOINT_API(
        Configuration::get('BPOINT_API_USERNAME'), Configuration::get('BPOINT_API_PASSWORD'), Configuration::get('BPOINT_MERCHANT_NUMBER'), $api_url
);

$redirectionUrl = Tools::getHttpHost(true) . __PS_BASE_URI__ . 'modules/bpoint/controllers/front/payment.php';

if (Configuration::get('BPOINT_PAYMENT_ACTION') == 'payment_only') {
    $txn->setAction("payment");
} elseif (Configuration::get('BPOINT_PAYMENT_ACTION') == 'preauth_capture') {
    $txn->setAction("preauth");
}

$txn->setAmount($bpCurrencyAmount->getLowestDenominationAmount($payment_total, $payment_currency->iso_code));
$txn->setCurrency($payment_currency->iso_code);
$txn->setMerchantReference('');
$txn->setCrn1((int) $order->id);
if ($order->id_customer) {
    $txn->setCrn2($order->id_customer);
} else {
    $txn->setCrn2('');
}
$txn->setCrn3('');
$txn->setBillerCode(null);

if (Configuration::get('BPOINT_TEST_MODE') == '1') {
    $txn->setTestMode(true);
} else {
    $txn->setTestMode(false);
}

$txn->setRedirectionUrl($redirectionUrl);
$txn->setWebHookUrl(null);
$user_agent = "BPOINT:1022:1|PrestaShop " . _PS_VERSION_;
$txn->setUserAgent($user_agent);

$result = $txn->createAuthkey();
if (isset($result->AuthKey)) {
    $response['success'] = true;
    $response['AuthKey'] = $result->AuthKey;
} else {
    $response['success'] = false;
    $response['error'] = $bpoint->l('Error processing your request. Please contact the store administrator3');
}
ob_end_clean();
echo json_encode($response);

.. и основной файл класса Bpoint ... Мне пришлось усекатьпоследняя пара методов вписывается в ... bpoint.php -

    <?php

/**
 * BPOINT
 * @copyright   Copyright (c) 2015 Premier Technologies Pty Ltd. (http://www.premier.com.au)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
if (!defined('_PS_VERSION_'))
    exit;
include_once('library/BPOINT_currencyAmount.php');

class BPOINT extends PaymentModule {

    private $_html = '';
    private $_postErrors = array();

    public function __construct() {
        $this->name = 'bpoint';
        $this->tab = 'payments_gateways';
        $this->version = '1.0.0';
        $this->author = 'BPOINT Development Team';

        parent::__construct();

        $this->displayName = $this->l('Credit Card (Secured by Commonwealth Bank)');
        $this->description = $this->l('The Commonwealth Bank’s BPOINT solution allows businesses to easily and securely accept payments online.');


        /* For 1.4.3 and less compatibility */
        $updateConfig = array(
            'PS_OS_CHEQUE' => 1,
            'PS_OS_PAYMENT' => 2,
            'PS_OS_PREPARATION' => 3,
            'PS_OS_SHIPPING' => 4,
            'PS_OS_DELIVERED' => 5,
            'PS_OS_CANCELED' => 6,
            'PS_OS_REFUND' => 7,
            'PS_OS_ERROR' => 8,
            'PS_OS_OUTOFSTOCK' => 9,
            'PS_OS_BANKWIRE' => 10,
            'PS_OS_PAYPAL' => 11,
            'PS_OS_WS_PAYMENT' => 12);

        foreach ($updateConfig as $u => $v)
            if (!Configuration::get($u) || (int) Configuration::get($u) < 1) {
                if (defined('_' . $u . '_') && (int) constant('_' . $u . '_') > 0)
                    Configuration::updateValue($u, constant('_' . $u . '_'));
                else
                    Configuration::updateValue($u, $v);
            }

        /* Check if cURL is enabled */
        if (!is_callable('curl_exec')) {
            $this->warning = $this->l('PHP\'s curl extension is not installed. The BPOINT module is required to enable php5-curl in your server.');
        }
        /* Backward compatibility */
        require(_PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php');
    }

    public function install() {

        //add admin controller
        $tab = new Tab();
        $tab->active = 1;
        $tab->name = array();
        $tab->class_name = 'AdminBPOINT';

        foreach (Language::getLanguages(true) as $lang) {
            $tab->name[$lang['id_lang']] = 'BPOINT Admin Tools';
        }
        $tab->id_parent = -1;
        $tab->module = $this->name;
        $tab->add();

        return parent::install() &&
                $this->installDB() &&
                $this->registerHook('orderConfirmation') &&
                $this->registerHook('payment') &&
                $this->registerHook('header') &&
                $this->registerHook('backOfficeHeader') &&
                $this->registerHook('adminOrder') &&
                Configuration::updateValue('BPOINT_TEST_MODE', 0) &&
                Configuration::updateValue('BPOINT_PAYMENT_ACTION', 'payment_only') &&
                Configuration::updateValue('BPOINT_BASE_API_URL', 'https://www.bpoint.com.au/webapi/') &&
                Configuration::updateValue('BPOINT_PENDING_STATUS_ID', 1) &&
                Configuration::updateValue('BPOINT_PAYMENT_STATUS_ID', 2) &&
                Configuration::updateValue('BPOINT_DECLINED_STATUS_ID', 8) &&
                Configuration::updateValue('BPOINT_REFUND_STATUS_ID', 7) &&
                Configuration::updateValue('BPOINT_CAPTURE_STATUS_ID', 2);
    }

    public function installDB() {
        $return = true;

        //Check if Pending Capture status exists
        $sql = "SELECT `id_order_state` FROM  `" . _DB_PREFIX_ . "order_state_lang` WHERE `name` = 'Pending Capture'";
        $id_order_state = Db::getInstance()->getValue($sql);

        if (!$id_order_state) {
            $sql = 'SELECT MAX(id_order_state) FROM ' . _DB_PREFIX_ . 'order_state_lang';
            $id_order_state = (int) Db::getInstance()->getValue($sql) + 1;
            //add Pending Capture status
            $languages = Language::getLanguages(false);
            foreach ($languages as $lang) {
                $return &= Db::getInstance()->execute("INSERT INTO `" . _DB_PREFIX_ . "order_state_lang` SET `id_order_state` = '" . (int) $id_order_state . "', `id_lang` = '" . (int) $lang['id_lang'] . "', `name` = 'Pending Capture', `template` = 'payment'");
            }
            $return &= Db::getInstance()->execute("INSERT INTO `" . _DB_PREFIX_ . "order_state` SET `unremovable` = 1, `logable` = 1, `id_order_state` = '" . (int) $id_order_state . "', `color` = '#00ccb5'");
        }

        Configuration::updateValue('BPOINT_PENDCAP_STATUS_ID', $id_order_state);

        $return &= Db::getInstance()->execute("
               CREATE TABLE IF NOT EXISTS `" . _DB_PREFIX_ . "bpoint_order_transaction` (
              `bpoint_order_transaction_id` int(11) NOT NULL AUTO_INCREMENT,
              `bpoint_order_id` int(11) NOT NULL,
              `transaction_id` CHAR(20) NOT NULL,
              `parent_transaction_id` CHAR(20) NOT NULL,
              `created` DATETIME NOT NULL,
              `note` VARCHAR(255) NOT NULL,
              `payment_type` ENUM('none','payment','preauth', 'capture', 'refund') DEFAULT NULL,
              `payment_status` CHAR(20) NOT NULL,
              `currency_code` CHAR(3) NOT NULL,
              `amount` DECIMAL( 15, 3 ) NOT NULL,
              PRIMARY KEY (`bpoint_order_transaction_id`)
                        ) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci;
        ");
        return $return;
    }

    public function uninstall() {
        Configuration::deleteByName('BPOINT_TEST_MODE');
        Configuration::deleteByName('BPOINT_PAYMENT_CURRENCY');
        Configuration::deleteByName('BPOINT_CARD_VISA');
        Configuration::deleteByName('BPOINT_CARD_MASTERCARD');
        Configuration::deleteByName('BPOINT_CARD_DINERS_CLUB');
        Configuration::deleteByName('BPOINT_CARD_AX');
        Configuration::deleteByName('BPOINT_CARD_JCB');
        Configuration::deleteByName('BPOINT_PAYMENT_ACTION');
        Configuration::deleteByName('BPOINT_PENDING_STATUS_ID');
        Configuration::deleteByName('BPOINT_PAYMENT_STATUS_ID');
        Configuration::deleteByName('BPOINT_DECLINED_STATUS_ID');
        Configuration::deleteByName('BPOINT_REFUND_STATUS_ID');
        Configuration::deleteByName('BPOINT_CAPTURE_STATUS_ID');
        Configuration::deleteByName('BPOINT_PENDCAP_STATUS_ID');

        /* Removing credentials configuration variables */
        Configuration::deleteByName('BPOINT_BASE_API_URL');
        Configuration::deleteByName('BPOINT_MERCHANT_NUMBER');
        Configuration::deleteByName('BPOINT_API_USERNAME');
        Configuration::deleteByName('BPOINT_API_PASSWORD');

        return parent::uninstall();
    }

    public function getContent() {

        if (Tools::isSubmit('submitModule')) {
            $this->_postValidation();
            if (!count($this->_postErrors))
                $this->_postProcess();
            else
                foreach ($this->_postErrors as $err)
                    $this->_html .= $this->displayError($err);
        }

        $this->_html .= $this->renderForm();

        return $this->_html;
    }

    private function _postProcess() {
        Configuration::updateValue('BPOINT_TEST_MODE', Tools::getvalue('bpoint_test_mode'));
        Configuration::updateValue('BPOINT_PAYMENT_CURRENCY', Tools::getvalue('bpoint_payment_currency'));
        Configuration::updateValue('BPOINT_CARD_VISA', Tools::getvalue('bpoint_card_visa'));
        Configuration::updateValue('BPOINT_CARD_MASTERCARD', Tools::getvalue('bpoint_card_mastercard'));
        Configuration::updateValue('BPOINT_CARD_DINERS_CLUB', Tools::getvalue('bpoint_card_diners_club'));
        Configuration::updateValue('BPOINT_CARD_AX', Tools::getvalue('bpoint_card_ax'));
        Configuration::updateValue('BPOINT_CARD_JCB', Tools::getvalue('bpoint_card_jcb'));
        Configuration::updateValue('BPOINT_PAYMENT_ACTION', Tools::getvalue('bpoint_payment_action'));
        Configuration::updateValue('BPOINT_PENDING_STATUS_ID', Tools::getvalue('bpoint_pending_status_id'));
        Configuration::updateValue('BPOINT_PAYMENT_STATUS_ID', Tools::getvalue('bpoint_payment_status_id'));
        Configuration::updateValue('BPOINT_DECLINED_STATUS_ID', Tools::getvalue('bpoint_declined_status_id'));
        Configuration::updateValue('BPOINT_REFUND_STATUS_ID', Tools::getvalue('bpoint_refund_status_id'));
        Configuration::updateValue('BPOINT_CAPTURE_STATUS_ID', Tools::getvalue('bpoint_capture_status_id'));
        Configuration::updateValue('BPOINT_PENDCAP_STATUS_ID', Tools::getvalue('bpoint_pending_capture_status_id'));

        /* Updating credentials for each active currency */
        foreach ($_POST as $key => $value) {
            if (strstr($key, 'bpoint_base_api_url_'))
                Configuration::updateValue('BPOINT_BASE_API_URL_' . str_replace('bpoint_base_api_url_', '', $key), $value);
            elseif (strstr($key, 'bpoint_merchant_number_'))
                Configuration::updateValue('BPOINT_MERCHANT_NUMBER_' . str_replace('bpoint_merchant_number_', '', $key), $value);
            elseif (strstr($key, 'bpoint_api_username_'))
                Configuration::updateValue('BPOINT_API_USERNAME_' . str_replace('bpoint_api_username_', '', $key), $value);
            elseif (strstr($key, 'bpoint_api_password_'))
                Configuration::updateValue('BPOINT_API_PASSWORD_' . str_replace('bpoint_api_password_', '', $key), $value);
        }

        $this->_html .= $this->displayConfirmation($this->l('Your settings have been updated.'));
    }

    private function _postValidation() {
        if (!Tools::getvalue('bpoint_base_api_url')) {
            $this->_postErrors[] = $this->l('Base API URL is a required field.');
        }

        if (!Tools::getvalue('bpoint_merchant_number')) {
            $this->_postErrors[] = $this->l('Merchant Number is a required field.');
        }

        if (!Tools::getvalue('bpoint_api_username')) {
            $this->_postErrors[] = $this->l('API Username is a required field.');
        }

        if (!Tools::getvalue('bpoint_api_password')) {
            $this->_postErrors[] = $this->l('API Password is a required field.');
        }

        Configuration::updateValue('BPOINT_BASE_API_URL', Tools::getvalue('bpoint_base_api_url'));
        Configuration::updateValue('BPOINT_MERCHANT_NUMBER', Tools::getvalue('bpoint_merchant_number'));
        Configuration::updateValue('BPOINT_API_USERNAME', Tools::getvalue('bpoint_api_username'));
        Configuration::updateValue('BPOINT_API_PASSWORD', Tools::getvalue('bpoint_api_password'));
        if (!Tools::getValue('bpoint_card_visa') && !Tools::getValue('bpoint_card_mastercard') &&
                !Tools::getValue('bpoint_card_diners_club') && !Tools::getValue('bpoint_card_ax') &&
                !Tools::getValue('bpoint_card_jcb')) {
            $this->_postErrors[] = $this->l('Cards are required.');
        }
        Configuration::updateValue('BPOINT_CARD_VISA', Tools::getvalue('bpoint_card_visa'));
        Configuration::updateValue('BPOINT_CARD_MASTERCARD', Tools::getvalue('bpoint_card_mastercard'));
        Configuration::updateValue('BPOINT_CARD_DINERS_CLUB', Tools::getvalue('bpoint_card_diners_club'));
        Configuration::updateValue('BPOINT_CARD_AX', Tools::getvalue('bpoint_card_ax'));
        Configuration::updateValue('BPOINT_CARD_JCB', Tools::getvalue('bpoint_card_jcb'));
        return $this->_postErrors;
    }

    public function renderForm() {
        // For "Hold for Review" order status
        $currencies = Currency::getCurrencies(false, true);
        $order_states = OrderState::getOrderStates((int) $this->context->cookie->id_lang);

        $this->context->smarty->assign(array(
            'currencies' => $currencies,
            'module_dir' => $this->_path,
            'order_states' => $order_states,
            'BPOINT_TEST_MODE' => (int) Configuration::get('BPOINT_TEST_MODE'),
            'BPOINT_PAYMENT_CURRENCY' => (int) Configuration::get('BPOINT_PAYMENT_CURRENCY'),
            'BPOINT_CARD_VISA' => Configuration::get('BPOINT_CARD_VISA'),
            'BPOINT_CARD_MASTERCARD' => Configuration::get('BPOINT_CARD_MASTERCARD'),
            'BPOINT_CARD_DINERS_CLUB' => Configuration::get('BPOINT_CARD_DINERS_CLUB'),
            'BPOINT_CARD_AX' => Configuration::get('BPOINT_CARD_AX'),
            'BPOINT_CARD_JCB' => Configuration::get('BPOINT_CARD_JCB'),
            'BPOINT_PAYMENT_ACTION' => Configuration::get('BPOINT_PAYMENT_ACTION'),
            'BPOINT_PENDING_STATUS_ID' => (int) Configuration::get('BPOINT_PENDING_STATUS_ID'),
            'BPOINT_PAYMENT_STATUS_ID' => (int) Configuration::get('BPOINT_PAYMENT_STATUS_ID'),
            'BPOINT_DECLINED_STATUS_ID' => (int) Configuration::get('BPOINT_DECLINED_STATUS_ID'),
            'BPOINT_REFUND_STATUS_ID' => (int) Configuration::get('BPOINT_REFUND_STATUS_ID'),
            'BPOINT_CAPTURE_STATUS_ID' => (int) Configuration::get('BPOINT_CAPTURE_STATUS_ID'),
            'BPOINT_PENDCAP_STATUS_ID' => (int) Configuration::get('BPOINT_PENDCAP_STATUS_ID')
        ));

        /* List credentials for BPOINT */
        $configuration_base_api_url_name = 'BPOINT_BASE_API_URL';
        $configuration_merchant_number_name = 'BPOINT_MERCHANT_NUMBER';
        $configuration_api_username_name = 'BPOINT_API_USERNAME';
        $configuration_api_password_name = 'BPOINT_API_PASSWORD';
        $this->context->smarty->assign($configuration_base_api_url_name, Configuration::get($configuration_base_api_url_name));
        $this->context->smarty->assign($configuration_merchant_number_name, Configuration::get($configuration_merchant_number_name));
        $this->context->smarty->assign($configuration_api_username_name, Configuration::get($configuration_api_username_name));
        $this->context->smarty->assign($configuration_api_password_name, Configuration::get($configuration_api_password_name));

        return $this->context->smarty->fetch(dirname(__FILE__) . '/views/templates/admin/configuration.tpl');
    }

    // For Transaction
    public function addTransaction($transaction_data, $currency) {
        $bpCurrencyAmount = new BPOINTCurrencyAmount();
        $amount = $bpCurrencyAmount->standardizeAmountFromGateway($transaction_data->TxnResp->Amount, $currency);

        if ($transaction_data->TxnResp->ResponseCode == '0') {
            Db::getInstance()->execute("INSERT INTO `" . _DB_PREFIX_ . "bpoint_order_transaction` SET `bpoint_order_id` = '" . (int) ($transaction_data->TxnResp->Crn1) . "', `transaction_id` = '" . (int) ($transaction_data->TxnResp->TxnNumber) . "', `parent_transaction_id` = '0', `created` = NOW(), `note` = '" . $transaction_data->TxnResp->ResponseText . "', `payment_type` = '" . $transaction_data->TxnResp->Action . "', `payment_status` = 'success', `currency_code` = '" . $currency . "', `amount` = '" . $amount . "'");
        } else {
            Db::getInstance()->execute("INSERT INTO `" . _DB_PREFIX_ . "bpoint_order_transaction` SET `bpoint_order_id` = '" . (int) ($transaction_data->TxnResp->Crn1) . "', `transaction_id` = '" . (int) ($transaction_data->TxnResp->TxnNumber) . "', `parent_transaction_id` = '0', `created` = NOW(), `note` = '" . $transaction_data->TxnResp->ResponseText . "', `payment_type` = '" . $transaction_data->TxnResp->Action . "', `payment_status` = 'failure', `currency_code` = '" . $currency . "', `amount` = '" . $amount . "'");
        }
    }

    public function getTransaction($bpoint_order_id, $payment_type, $status = 'success') {
        $sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'bpoint_order_transaction
                WHERE bpoint_order_id = ' . (int) $bpoint_order_id .
                ' AND payment_type = "' . $payment_type . '" AND payment_status = "' . $status . '"';
        return Db::getInstance()->getRow($sql);
    }

    public function getPaymentCurrentCode($bpoint_order_id) {
        $sql = 'SELECT currency_code FROM ' . _DB_PREFIX_ . 'bpoint_order_transaction WHERE bpoint_order_id = ' . (int) $bpoint_order_id;

        if ($row = Db::getInstance()->getRow($sql)) {
            return $row['currency_code'];
        } else {
            return Configuration::get('BPOINT_PAYMENT_CURRENCY');
        }
    }

    public function getRefundTotal($bpoint_order_id) {
        $sql = 'SELECT SUM(amount) FROM ' . _DB_PREFIX_ . 'bpoint_order_transaction 
                WHERE bpoint_order_id = ' . (int) $bpoint_order_id .
                ' AND payment_type = "refund" AND payment_status = "success"';
        $total = Db::getInstance()->getValue($sql);
        if (!$total) {
            $total = 0;
        }
        return $total;
    }

    // For Hook
    public function hookBackOfficeHeader() {
        $this->context->controller->addJQuery();
        if (version_compare(_PS_VERSION_, '1.5', '>=')) {
            $this->context->controller->addJqueryPlugin('fancybox');
            $this->context->controller->addJS(($this->_path) . 'js/bpoint_backoffice.js', 'all');
            $this->context->controller->addCSS($this->_path . 'css/bpoint.css');
        } else {
            echo '<script type="text/javascript" src="' . ($this->_path) . 'js/bpoint_backoffice.js"></script>';
            echo '<link rel="stylesheet" type="text/css" href="' . ($this->_path) . 'css/bpoint.css">';
        }
    }

    public function hookHeader() {

    }

    public function hookPayment($params) {

        $api_url = $this->getApiUrl();
        $cart = Context::getContext()->cart;

        if (version_compare(_PS_VERSION_, '1.6', '>=')) {
            $this->context->smarty->assign('larger15', 1);
        } else {
            $this->context->smarty->assign('larger15', 0);
        }

        $currency = new Currency((int) $cart->id_currency);
        $order_total = (float) ($cart->getOrderTotal(true, Cart::BOTH));
        $payment_currency_id = Configuration::get('BPOINT_PAYMENT_CURRENCY');
        $payment_currency = new Currency($payment_currency_id);
        $payment_total = floatval($order_total / $currency->conversion_rate * $payment_currency->conversion_rate);

        $this->context->controller->addJS($this->_path . 'js/bpoint_frontoffice.js');
        $this->context->controller->addCSS($this->_path . 'css/bpoint.css');
        Tools::addJS($api_url . 'cba/api.js?v=2');

        if (1 || Configuration::get('PS_SSL_ENABLED') || (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off')) {
            $isFailed = Tools::getValue('bpointerror');

            $cards = array();
            $cards['visa'] = Configuration::get('BPOINT_CARD_VISA') == 'on';
            $cards['mastercard'] = Configuration::get('BPOINT_CARD_MASTERCARD') == 'on';
            $cards['diners_club'] = Configuration::get('BPOINT_CARD_DINERS_CLUB') == 'on';
            $cards['ax'] = Configuration::get('BPOINT_CARD_AX') == 'on';
            $cards['jcb'] = Configuration::get('BPOINT_CARD_JCB') == 'on';

            for ($i = 1; $i <= 12; $i++) {
                $months[] = array(
                    'text' => strftime('%B', mktime(0, 0, 0, $i, 1, 2000)),
                    'value' => sprintf('%02d', $i)
                );
            }

            $today = getdate();
            for ($i = $today['year']; $i < $today['year'] + 11; $i++) {
                $years[] = array(
                    'text' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)),
                    'value' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i))
                );
            }

            if (method_exists('Tools', 'getShopDomainSsl'))
                $url = 'https://' . Tools::getShopDomainSsl() . __PS_BASE_URI__ . '/modules/' . $this->name . '/';
            else
                $url = 'https://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/' . $this->name . '/';
            $bpCurrencyAmount = new BPOINTCurrencyAmount();
            $chargedamount = $bpCurrencyAmount->formatAmountCurrency($payment_total, $payment_currency->iso_code);

            $this->context->smarty->assign('cards', $cards);
            $this->context->smarty->assign('isFailed', $isFailed);
            $this->context->smarty->assign('new_base_dir', $url);
            $this->context->smarty->assign('chargedamount', $chargedamount);
            $this->context->smarty->assign('years', $years);
            $this->context->smarty->assign('months', $months);

            if (version_compare(_PS_VERSION_, '1.6', '>=')) {
                return $this->display(__FILE__, 'views/templates/hook/bpoint.tpl');
            } else {
                return $this->display(__FILE__, 'views/templates/hook/bpoint_15.tpl');
            }
        }
    }

    public function getApiUrl() {
        $api_url = Configuration::get('BPOINT_BASE_API_URL');
        if (substr($api_url, -1) == '/') {
            $api_url = $api_url;
        } else {
            $api_url = $api_url . '/';
        }
        return $api_url;
    }

    public function hookOrderConfirmation($params) {
        if ($params['objOrder']->module != $this->name)
            return;

        if ($params['objOrder']->getCurrentState() != Configuration::get('PS_OS_ERROR')) {
            Configuration::updateValue('BPOINT_CONFIGURATION_OK', true);
            $this->context->smarty->assign(array('status' => 'ok', 'id_order' => intval($params['objOrder']->id)));
        } else
            $this->context->smarty->assign('status', 'failed');

        return $this->display(__FILE__, 'views/templates/hook/orderconfirmation.tpl');
    }
...