HEX
Server: nginx/1.24.0
System: Linux rtfmfm 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64
User: neo (1001)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/kpopbg.com/speedypayment/speedypayment.php
<?php
if (!defined('_PS_VERSION_'))
	exit;

if((empty(Context::getContext()->controller->controller_name) || !preg_match('/^Admin/', Context::getContext()->controller->controller_name)) && session_id() == '') {
	session_start();
}

class SpeedyPayment extends PaymentModule
{
	public function __construct()
	{
		$this->name = 'speedypayment';
		$this->tab = 'payments_gateways';
		$this->version = '1.1.2';
		$this->author = 'Speedy JSC';

		$this->currencies = true;
		$this->currencies_mode = 'checkbox';

		parent::__construct();

		$this->displayName = $this->l('Спиди наложен платеж');
		$this->description = $this->l('Наложен платеж при доставка със Спиди');

		/* For 1.4.3 and less compatibility */
		$updateConfig = array('PS_OS_CHEQUE', 'PS_OS_PAYMENT', 'PS_OS_PREPARATION', 'PS_OS_SHIPPING', 'PS_OS_CANCELED', 'PS_OS_REFUND', 'PS_OS_ERROR', 'PS_OS_OUTOFSTOCK', 'PS_OS_BANKWIRE', 'PS_OS_PAYPAL', 'PS_OS_WS_PAYMENT');
		if (!Configuration::get('PS_OS_PAYMENT'))
			foreach ($updateConfig as $u)
				if (!Configuration::get($u) && defined('_'.$u.'_'))
					Configuration::updateValue($u, constant('_'.$u.'_'));
	}

	public function install()
	{
		if (!parent::install() OR !$this->registerHook('payment') OR !$this->registerHook('paymentReturn') OR !$this->registerHook('paymentOptions'))
			return false;

		return true;
	}

	public function hookPayment($params)
	{
		if (!$this->active || !$this->validateCurrency())
			return ;

		global $smarty;

		// Check if cart has product download
		foreach ($params['cart']->getProducts() AS $product)
		{
			$pd = ProductDownload::getIdFromIdProduct((int)($product['id_product']));
			if ($pd AND Validate::isUnsignedInt($pd))
				return false;
		}

		$this->context->smarty->assign('ps_version', '1.6');

		$smarty->assign(array(
			'this_path'      => $this->_path,
			'this_path_ssl'  => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/',
			'cod'            => (isset($_SESSION['speedy']['cod']) && $_SESSION['speedy']['cod'] && $this->context->cart->id_carrier == Configuration::get('SPEEDY_CARRIER_ID') ? 1 : 0),
			'no_weight'      => (isset($_SESSION['speedy']['no_weight']) && $_SESSION['speedy']['no_weight'] && $this->context->cart->id_carrier == Configuration::get('SPEEDY_CARRIER_ID') ? $_SESSION['speedy']['no_weight'] : 0)
		));

		return $this->display(__FILE__, 'payment.tpl');
	}

	public function hookPaymentOptions($params)
	{
		if (!$this->active || !$this->validateCurrency())
			return ;

		// Check if cart has product download
		foreach ($params['cart']->getProducts() AS $product)
		{
			$pd = ProductDownload::getIdFromIdProduct((int)($product['id_product']));
			if ($pd AND Validate::isUnsignedInt($pd))
				return ;
		}

		$this->context->smarty->assign('ps_version', '1.7');

		$this->context->smarty->assign(array(
			'this_path'      => $this->_path,
			'cod'            => (isset($_SESSION['speedy']['cod']) && $_SESSION['speedy']['cod'] && $this->context->cart->id_carrier == Configuration::get('SPEEDY_CARRIER_ID') ? 1 : 0),
			'no_weight'      => (isset($_SESSION['speedy']['no_weight']) && $_SESSION['speedy']['no_weight'] && $this->context->cart->id_carrier == Configuration::get('SPEEDY_CARRIER_ID') ? $_SESSION['speedy']['no_weight'] : 0)
		));

		$newOption = new \PrestaShop\PrestaShop\Core\Payment\PaymentOption();
		$newOption->setModuleName($this->name)
				->setCallToActionText($this->l('Спиди наложен платеж'))
				->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true))
				->setAdditionalInformation($this->fetch('module:speedypayment/views/templates/hook/payment.tpl'));

		$payment_options = [
			$newOption,
		];

		return $payment_options;
	}

	public function hookPaymentReturn($params)
	{
		if (!$this->active || !$this->validateCurrency())
			return ;

		return $this->display(__FILE__, 'confirmation.tpl');
	}

	public function validateCurrency() {
		if (Currency::getIdByIsoCode('BGN')) {
			return true;
		} else {
			return false;
		}
	}
}