* @copyright 2005-2019 PayLane sp. z.o.o. * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PayLane sp. z.o.o. */ /** * Only Prestashop 1.6 */ class PaylanePaymentModuleFrontController extends ModuleFrontController { public $ssl = true; public $display_column_left = false; public function __construct() { parent::__construct(); $this->display_column_left = false; } /** * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $cart = $this->context->cart; if (!$this->module->checkCurrency($cart)) { Tools::redirect('index.php?controller=order'); } //if is submit data create order // if(!empty(Tools::getValue('description')) && !Order::getOrderByCartId(Tools::getValue('description'))) { // $this->createOrder(); // } if (method_exists('Tools', 'getAllValues')) { $params = Tools::getAllValues(); } else { $params = $_POST + $_GET; } if (!isset($params) || !isset($params['payment_type'])) { Tools::redirect('index.php?controller=order'); } else { if ($params['payment_type'] == 'Blik') { $file_name = 'BLIK'; } else { $file_name = $params['payment_type']; } require_once(_PS_MODULE_DIR_ . 'paylane/class/' . $file_name . '.php'); $paylane = Module::getInstanceByName('paylane'); $handler = new $params['payment_type']($paylane); $templateVars = $handler->getTemplateVars(); $pathSsl = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/'; $this->context->smarty->assign(array_merge(array( 'nbProducts' => $cart->nbProducts(), 'this_path' => $this->module->getPathUri(), 'this_path_bw' => $this->module->getPathUri(), 'this_path_ssl' => $pathSsl ), $templateVars)); if ($params['payment_type'] === 'PayPal') { $params['payment_type'] = 'Paypal'; } $this->setTemplate('payment_form/' . $this->toSnakeCase($params['payment_type']) . '16.tpl'); //?paypal } } protected function toSnakeCase($input) { preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches); $ret = $matches[0]; foreach ($ret as &$match) { $match = $match == Tools::strtoupper($match) ? Tools::strtolower($match) : lcfirst($match); } return implode('_', $ret); } protected function createOrder(){ die( $this->module->validateOrder( (int)$this->context->cart->id, (int)Configuration::get('PAYLANE_PAYMENT_STATUS_PENDING'), sprintf('%01.2f', $this->context->cart->getOrderTotal(true, Cart::BOTH)), 'Paylane ', null, [], (int)$this->context->cart->id_currency, false, $this->context->customer->secure_key ) ); } }