71 lines
1.5 KiB
PHP
71 lines
1.5 KiB
PHP
<?php
|
|
|
|
use Imoje\Payment\Payment;
|
|
use Imoje\Payment\Util;
|
|
|
|
/**
|
|
* Class IMojePaymentModuleFrontController
|
|
*
|
|
* @property bool display_column_left
|
|
* @property bool display_column_right
|
|
*/
|
|
class IMojePaymentModuleFrontController extends ModuleFrontController
|
|
{
|
|
|
|
/**
|
|
* Initialize controller
|
|
*
|
|
* @throws PrestaShopException
|
|
* @see FrontController::init()
|
|
*/
|
|
public function init()
|
|
{
|
|
$this->display_column_left = false;
|
|
$this->display_column_right = false;
|
|
parent::init();
|
|
}
|
|
|
|
/**
|
|
* @throws PrestaShopException
|
|
* @throws Exception
|
|
*/
|
|
public function initContent()
|
|
{
|
|
parent::initContent();
|
|
|
|
$payment = new Payment(
|
|
Configuration::get('IMOJE_SANDBOX')
|
|
? Util::ENVIRONMENT_SANDBOX
|
|
: Util::ENVIRONMENT_PRODUCTION,
|
|
Configuration::get('IMOJE_SERVICE_KEY'),
|
|
Configuration::get('IMOJE_SERVICE_ID'),
|
|
Configuration::get('IMOJE_MERCHANT_ID')
|
|
);
|
|
|
|
$cart = $this->context->cart;
|
|
|
|
if(!$cart->date_upd) {
|
|
Tools::redirect('/');
|
|
|
|
return;
|
|
}
|
|
|
|
$imoje = new iMoje();
|
|
|
|
$this->context->smarty->assign([
|
|
'form' => $payment->buildOrderForm(
|
|
$imoje->getDataForRequestToPaywall($cart)
|
|
),
|
|
'checkout_link' => $this->context->link->getPageLink(Configuration::get('PS_ORDER_PROCESS_TYPE')
|
|
? 'order-opc'
|
|
: 'order'),
|
|
'text_return_to_checkout' => $this->module->l('Please wait, you will be returned to checkout.', 'payment'),
|
|
'ga_key' => Configuration::get('IMOJE_GA_KEY'),
|
|
]);
|
|
|
|
$this->setTemplate(IMoje::buildTemplatePath('pay', 'front'));
|
|
|
|
return;
|
|
}
|
|
}
|