This commit is contained in:
Roman Pyrih
2024-12-12 15:57:01 +01:00
parent 2e7c3943e4
commit e75fa515f5
62 changed files with 4916 additions and 42 deletions

View File

@@ -19,7 +19,7 @@
<div class="blockreassurance_product">
{foreach from=$blocks item=$block key=$key}
<div{if $block['type_link'] !== $LINK_TYPE_NONE && !empty($block['link'])} style="cursor:pointer;" onclick="window.open('{$block['link']}')"{/if}>
<div class="item-{$key}" {if $block['type_link'] !== $LINK_TYPE_NONE && !empty($block['link'])} style="cursor:pointer;" onclick="window.open('{$block['link']}')"{/if}>
<span class="item-product">
{if $block['icon'] != 'undefined'}
{if $block['custom_icon']}
@@ -33,7 +33,7 @@
<p class="block-title" style="color:{$textColor};">{$block['title']}</p>
{else}
<span class="block-title" style="color:{$textColor};">{$block['title']}</span>
<p style="color:{$textColor};">{$block['description'] nofilter}</p>
<p class="block-description" style="color:{$textColor};">{$block['description'] nofilter}</p>
{/if}
</div>
{/foreach}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
modules/raty/alior.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>raty</name>
<displayName><![CDATA[Raty]]></displayName>
<version><![CDATA[1.5.12]]></version>
<description><![CDATA[Moduł do obsługi rat Alior Banku.]]></description>
<author><![CDATA[Alior Bank]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Czy jesteś pewien aby odinstalować ten moduł?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../');
exit;

View File

@@ -0,0 +1,35 @@
<?php
class RatyPaymentModuleFrontController extends ModuleFrontController
{
public $ssl = true;
public $display_column_left = false;
/**
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$cart = $this->context->cart;
if (!$this->module->checkAmount($cart->getOrderTotal())) {
Tools::redirect('index.php?controller=order');
}
//print_r($cart);die;
$this->context->smarty->assign(array(
'nbProducts' => $cart->nbProducts(),
'cust_currency' => $cart->id_currency,
'currencies' => $this->module->getCurrency((int)$cart->id_currency),
'total' => $cart->getOrderTotal(true, Cart::BOTH),
'this_path' => $this->module->getPathUri(),
'this_path_bw' => $this->module->getPathUri(),
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->module->name.'/'
));
$this->setTemplate('payment_execution.tpl');
}
}

View File

@@ -0,0 +1,44 @@
<?php
class RatyValidationModuleFrontController extends ModuleFrontController
{
/**
* @see FrontController::postProcess()
*/
public function postProcess()
{
$cart = $this->context->cart;
$customer = new Customer($cart->id_customer);
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
if ($module['name'] == 'raty') {
$authorized = true;
break;
}
}
if (!$authorized) {
die($this->module->l('Metoda płatności jest niedostępna.', 'validation'));
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$currency = $this->context->currency;
$total = (float) $cart->getOrderTotal(true, Cart::BOTH);
$mailVars = array();
$this->module->validateOrder($cart->id, Configuration::get('PS_OS_RATY'), $total, $this->module->displayName, null, $mailVars, (int) $currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
}
}

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

11
modules/raty/index.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../');
exit;

BIN
modules/raty/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
modules/raty/logo.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

37
modules/raty/map.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
/**
* Mapping between Alior's categories and store's categories
* Alior Category => Store's categories IDs eg. 'TKC_AGDD' => [1, 19, 33],
*/
return [
'TKC_AGDD' => [],
'TKC_AGDM' => [],
'TKC_AKCAUTO' => [],
'TKC_BIZUT' => [],
'TKC_DZIECIE' => [],
'TKC_EDU' => [],
'TKC_FOTO' => [],
'TKC_INSTRMUZ' => [],
'TKC_KOMP' => [],
'TKC_MATBUD' => [],
'TKC_MEBLE' => [1,2,42,43,44,45,46,47,48,77,78,131,60,61,63,64,65,66,67,68,69,70,71,72,73,74,75,76,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,117,118,119,120,121,122,123,124,125,126,127,128,129,130,132,133,134,135,136,137,138,139,140,141,142,143,144,145,115,116],
'TKC_MOTO' => [],
'TKC_NARZ' => [],
'TKC_ODZIEZ' => [],
'TKC_OGRO' => [],
'TKC_OGRZEW' => [],
'TKC_OKDZW' => [],
'TKC_OPAL' => [],
'TKC_OPROGR' => [],
'TKC_PAKIE' => [],
'TKC_RTV' => [],
'TKC_SPORTREH' => [],
'TKC_SPRZKOM' => [],
'TKC_SYSTEKO' => [],
'TKC_SZTUK' => [],
'TKC_TELE' => [],
'TKC_UBEZ' => [],
'TKC_USLUGI' => [],
'default' => 'TKC_MEBLE'
];

13
modules/raty/payment.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
/* SSL Management */
$useSSL = true;
require('../../config/config.inc.php');
Tools::displayFileAsDeprecated();
// init front controller in order to use Tools::redirect
$controller = new FrontController();
$controller->init();
Tools::redirect(Context::getContext()->link->getModuleLink('Raty', 'payment'));

13
modules/raty/raty.css Normal file
View File

@@ -0,0 +1,13 @@
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
Created on : 2016-10-18, 11:12:27
Author : Kamil
*/
#module-raty-payment ul.step li a,#module-raty-payment ul.step li span,#module-raty-payment ul.step li.step_current span,#module-raty-payment ul.step li.step_current_end span{
font-size: 16px !important;
}

793
modules/raty/raty.php Normal file
View File

@@ -0,0 +1,793 @@
<?php
use PrestaShop\PrestaShop\Core\Payment\PaymentOption;
if (!defined('_PS_VERSION_')) {
exit;
}
class Raty extends PaymentModule
{
protected $_html = '';
protected $_postErrors = array();
public $details;
public $owner;
public $address;
public $extra_mail_vars;
public $paymentUrl;
public $kalkulatorUrl;
public function __construct()
{
$this->name = 'raty';
$this->tab = 'payments_gateways';
$this->version = '1.5.12';
$this->author = 'Alior Bank';
$this->bootstrap = true;
$this->is_eu_compatible = 1;
$this->controllers = array('payment', 'validation');
$this->is_eu_compatible = 1;
$this->ps_versions_compliancy = array('min' => '1.7');
parent::__construct();
$this->displayName = $this->l('Raty');
$this->description = $this->l('Moduł do obsługi rat Alior Banku.');
$this->confirmUninstall = $this->l('Czy jesteś pewien aby odinstalować ten moduł?');
$this->kalkulatorUrl = 'https://kalkulator.raty.aliorbank.pl/';
$this->paymentUrl = 'https://raty.aliorbank.pl/directcreditsystem-frontend-consumerfinance-internet-standard/paymentprovider/';
if (!Configuration::get('RATY_NAME')) {
$this->warning = $this->l('No name provided');
}
}
private function createOrderState()
{
// create new order status STATUSNAME
$values_to_insert = [
'invoice' => 0,
'send_email' => 0,
'module_name' => $this->name,
'color' => 'RoyalBlue',
'unremovable' => 0,
'hidden' => 0,
'logable' => 0,
'delivery' => 0,
'shipped' => 0,
'paid' => 0,
'deleted' => 0
];
if (!Db::getInstance()->insert('order_state', $values_to_insert)) {
return false;
}
$id_order_state = (int) Db::getInstance()->Insert_ID();
$languages = Language::getLanguages(false);
foreach ($languages as $language) {
Db::getInstance()->insert('order_state_lang', [
'id_order_state' => $id_order_state,
'id_lang' => $language['id_lang'],
'name' => 'Oczekiwanie na zatwierdzenie umowy ratalnej przez Alior Bank',
'template' => ''
]);
}
if (!@copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'alior.gif', _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'os' . DIRECTORY_SEPARATOR . $id_order_state . '.gif')) {
return false;
}
Configuration::updateValue('PS_OS_RATY', $id_order_state);
unset($id_order_state);
return true;
}
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
if (
!parent::install()
|| !$this->installSql()
|| !$this->registerHook('displayHeader')
|| !$this->registerHook('displayProductButtons')
|| !$this->registerHook('displayShoppingCartFooter')
|| !$this->registerHook('payment')
|| !$this->registerHook('paymentOptions')
|| !$this->registerHook('paymentReturn')
|| !$this->registerHook('displayAdminProductsMainStepLeftColumnBottom')
|| !$this->registerHook('displayBackOfficeCategory')
|| !$this->registerHook('actionObjectProductUpdateBefore')
|| !$this->registerHook('actionObjectCategoryAddBefore')
|| !$this->registerHook('actionObjectCategoryUpdateBefore')
|| !$this->createOrderState()
|| !Configuration::updateValue('RATY_NAME', 'Raty')
|| !Configuration::updateValue('RATY_PARTNERID', '1001')
|| !Configuration::updateValue('RATY_SUBPARTNERID', '')
|| !Configuration::updateValue('RATY_MCC', '')
|| !Configuration::updateValue('RATY_STANDARD_PROMOTION', '')
|| !Configuration::updateValue('RATY_CATEGORY_PROMOTION', '')
|| !Configuration::updateValue('RATY_CATEGORY_PROMOTION_START', '')
|| !Configuration::updateValue('RATY_CATEGORY_PROMOTION_END', '')
|| !Configuration::updateValue('RATY_PRODUCT_PROMOTION', '')
|| !Configuration::updateValue('RATY_PRODUCT_PROMOTION_START', '')
|| !Configuration::updateValue('RATY_PRODUCT_PROMOTION_END', '')
|| !Configuration::updateValue('RATY_MIN_VALUE', '0')
|| !Configuration::updateValue('RATY_MAX_VALUE', '26920')
|| !Configuration::updateValue('RATY_SALT', 'QWERSJR1234$$%')
|| !Configuration::updateValue('RATY_TITLE', 'Raty - Alior Bank')
|| !Configuration::updateValue('RATY_DESCRIPTION', '')
) {
return false;
}
return true;
}
public function uninstall()
{
if (
!parent::uninstall()
|| !Configuration::deleteByName('RATY_NAME')
|| !Configuration::deleteByName('RATY_PARTNERID')
|| !Configuration::deleteByName('RATY_SUBPARTNERID')
|| !Configuration::deleteByName('RATY_MCC')
|| !Configuration::deleteByName('RATY_STANDARD_PROMOTION')
|| !Configuration::deleteByName('RATY_CATEGORY_PROMOTION')
|| !Configuration::deleteByName('RATY_CATEGORY_PROMOTION_START')
|| !Configuration::deleteByName('RATY_CATEGORY_PROMOTION_END')
|| !Configuration::deleteByName('RATY_PRODUCT_PROMOTION')
|| !Configuration::deleteByName('RATY_PRODUCT_PROMOTION_START')
|| !Configuration::deleteByName('RATY_PRODUCT_PROMOTION_END')
|| !Configuration::deleteByName('RATY_MIN_VALUE')
|| !Configuration::deleteByName('RATY_MAX_VALUE')
|| !Configuration::deleteByName('RATY_SALT')
|| !Configuration::deleteByName('RATY_TITLE')
|| !Configuration::deleteByName('RATY_DESCRIPTION')
) {
return false;
}
return true;
}
protected function installSql() {
$data = [
'product' => 'alior_product_promotion',
'product_shop' => 'alior_product_promotion',
'category' => 'alior_category_promotion',
'category_shop' => 'alior_category_promotion',
];
foreach($data as $table => $column) {
if(!$this->isColumnExists($table, $column)) {
$sql = 'ALTER TABLE ' . _DB_PREFIX_ . $table . ' ADD ' . $column . ' INT NULL';
$result = Db::getInstance()->execute($sql);
if(!$result) {
return false;
}
}
}
return true;
}
private function isColumnExists($table, $column) {
$db = Db::getInstance();
$db->executeS("SELECT count(" . $column . ') FROM ' . _DB_PREFIX_ . $table);
return $db->numRows() > 0;
}
public function hookActionObjectProductUpdateBefore($params) {
$product = $params['object'];
if(!isset($_POST['alior_product_promotion'])) {
$product->alior_product_promotion = 0;
}
return;
}
public function hookActionObjectCategoryUpdateBefore($params) {
$category = $params['object'];
$category->alior_category_promotion = 1;
if(!isset($_POST['alior_category_promotion'])) {
$category->alior_category_promotion = 0;
}
return;
}
public function hookActionObjectCategoryAddBefore($params) {
$category = $params['object'];
$category->alior_category_promotion = 1;
if(!isset($_POST['alior_category_promotion'])) {
$category->alior_category_promotion = 0;
}
return;
}
public function hookDisplayAdminProductsMainStepLeftColumnBottom($params) {
$product = new Product($params['id_product']);
$this->context->smarty->assign(array('alior_product_promotion' => $product->alior_product_promotion));
return $this->display(__FILE__, 'views/templates/hook/updateproduct.tpl');
}
public function hookDisplayBackOfficeCategory($params) {
$id = (int)Tools::getValue('id_category');
if(isset($params['request'])) {
$id = $params['request']->get('categoryId');
}
$category = new Category($id);
$this->context->smarty->assign(array('alior_category_promotion' => $category->alior_category_promotion));
return $this->display(__FILE__, 'views/templates/hook/updatecategory.tpl');
}
public function hookPaymentOptions($params)
{
if (!$this->active) {
return;
}
if (!$this->checkCurrency($params['cart']) || !$this->checkAmount($params['cart']->getOrderTotal()) || !$this->getPromotion($params['cart']->getProducts())) {
return;
}
$this->context->smarty->assign(['raty_description' => Configuration::get('RATY_DESCRIPTION')]);
$offlineOption = new PaymentOption();
$offlineOption->setCallToActionText(Configuration::get('RATY_TITLE'))
->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true))
->setAdditionalInformation($this->fetch('module:raty/views/templates/front/payment_infos.tpl'))
->setLogo(Media::getMediaPath(_PS_MODULE_DIR_.$this->name.'/alior.gif'));
return [
$offlineOption,
];
}
public function getContent()
{
$output = '';
if (Tools::isSubmit('submitRaty')) {
$error = false;
if (!($raty_parentid = Tools::getValue('RATY_PARTNERID')) || empty($raty_parentid)) {
$output .= $this->displayError($this->l('Musisz wypełnić pole \'Parent ID\'.'));
$error = true;
} elseif (!$error) {
Configuration::updateValue('RATY_PARTNERID', $raty_parentid);
}
Configuration::updateValue('RATY_SUBPARTNERID', Tools::getValue('RATY_SUBPARTNERID'));
if (!($raty_salt = Tools::getValue('RATY_SALT')) || empty($raty_salt)) {
$output .= $this->displayError($this->l('Musisz wypełnić pole \'Salt\'.'));
$error = true;
} elseif (!$error) {
Configuration::updateValue('RATY_SALT', $raty_salt);
}
Configuration::updateValue('RATY_MCC', Tools::getValue('RATY_MCC'));
Configuration::updateValue('RATY_STANDARD_PROMOTION', Tools::getValue('RATY_STANDARD_PROMOTION'));
Configuration::updateValue('RATY_CATEGORY_PROMOTION', Tools::getValue('RATY_CATEGORY_PROMOTION'));
Configuration::updateValue('RATY_CATEGORY_PROMOTION_START', Tools::getValue('RATY_CATEGORY_PROMOTION_START'));
Configuration::updateValue('RATY_CATEGORY_PROMOTION_END', Tools::getValue('RATY_CATEGORY_PROMOTION_END'));
Configuration::updateValue('RATY_PRODUCT_PROMOTION', Tools::getValue('RATY_PRODUCT_PROMOTION'));
Configuration::updateValue('RATY_PRODUCT_PROMOTION_START', Tools::getValue('RATY_PRODUCT_PROMOTION_START'));
Configuration::updateValue('RATY_PRODUCT_PROMOTION_END', Tools::getValue('RATY_PRODUCT_PROMOTION_END'));
Configuration::updateValue('RATY_MIN_VALUE', $this->changeNumberFormat(Tools::getValue('RATY_MIN_VALUE')));
Configuration::updateValue('RATY_MAX_VALUE', $this->changeNumberFormat(Tools::getValue('RATY_MAX_VALUE')));
Configuration::updateValue('RATY_DESCRIPTION', Tools::getValue('RATY_DESCRIPTION'));
Configuration::updateValue('RATY_TITLE', Tools::getValue('RATY_TITLE'));
if (!$error) {
$output .= $this->displayConfirmation($this->l('Parametry uaktualnione.'));
}
}
return $output . $this->renderForm();
}
public function hookDisplayProductButtons($params)
{
$product = $params['product'];
if (empty($product->price_amount)){
return;
}
$price = $product->price_amount;
if (!$this->checkAmount($price)) {
return;
}
$promotion = $this->getPromotion([$product]);
if (!$promotion) {
return;
}
if (!$this->isCached('productraty.tpl', $this->getCacheId($product->id))) {
$promotion = str_replace('${sep}', '%2C', $promotion);
$this->smarty->assign(array(
'this_path_raty' => $this->_path,
'this_kalkulator' => $this->kalkulatorUrl .
'init?supervisor=' . Configuration::get('RATY_PARTNERID') .
'&promotionList='.$promotion.'&amount=',
'this_cena' => $this->changeNumberFormat(round($price, 2))
));
}
return $this->display(__FILE__, 'productraty.tpl', $this->getCacheId($product->id));
}
public function hookDisplayProductAdditionalInfo($params)
{
$product = $params['product'];
if (empty($product->price_amount)){
return;
}
$price = $product->price_amount;
if (!$this->checkAmount($price)) {
return;
}
$promotion = $this->getPromotion([$product]);
if (!$promotion) {
return;
}
if (!$this->isCached('productraty.tpl', $this->getCacheId($product->id))) {
$promotion = str_replace('${sep}', '%2C', $promotion);
$this->smarty->assign(array(
'this_path_raty' => $this->_path,
'this_kalkulator' => $this->kalkulatorUrl .
'init?supervisor=' . Configuration::get('RATY_PARTNERID') .
'&promotionList='.$promotion.'&amount=',
'this_cena' => $this->changeNumberFormat(round($price, 2))
));
}
return $this->display(__FILE__, 'productraty.tpl', $this->getCacheId($product->id));
}
public function hookDisplayShoppingCartFooter($params)
{
if (!$this->checkCurrency($params['cart']) || !$this->checkAmount($params['cart']->getOrderTotal())) {
return;
}
$promotion = $this->getPromotion($params['cart']->getProducts());
if(!$promotion){
return;
}
$promotion = str_replace('${sep}', '%2C', $promotion);
$this->smarty->assign(array(
'this_path_raty' => $this->_path,
'this_kalkulator' => $this->kalkulatorUrl .
'init?supervisor=' . Configuration::get('RATY_PARTNERID') .
'&promotionList='.$promotion.'&amount=',
'this_cena' => $this->changeNumberFormat($params['cart']->getOrderTotal()),
));
return $this->display(__FILE__, 'raty_cart.tpl');
}
public function hookDisplayHeader($params)
{
$this->context->controller->addCSS($this->_path . 'raty.css', 'all');
}
public function hookPaymentReturn($params)
{
if (!$this->active) {
return;
}
$order = $params['order'];
$state = $order->getCurrentState();
if (in_array($state, array(Configuration::get('PS_OS_RATY'), Configuration::get('PS_OS_OUTOFSTOCK'), Configuration::get('PS_OS_OUTOFSTOCK_UNPAID')))) {
$customer = new Customer($order->id_customer);
$firstName = $customer->firstname;
$lastName = $customer->lastname;
$partnerId = Configuration::get('RATY_PARTNERID');
$subpartnerId = Configuration::get('RATY_SUBPARTNERID');
$mcc = Configuration::get('RATY_MCC');
$promotion = $this->getPromotion($order->getProductsDetail());
$salt = Configuration::get('RATY_SALT');
$calculatedIncome = '';
$limit = '';
$transactionCode = $order->reference;
$total = $this->getRounded($order->total_paid);
$date = date('Y-m-d');
$time = date('H:i:s');
$dateAndTime = $date . 'T' . $time;
$verificationCode = hash('sha256', $salt . $this->changeNumberFormat($total) .
$transactionCode . $partnerId . $subpartnerId . $dateAndTime . $mcc . $firstName . $lastName . $limit . $calculatedIncome . $promotion);
$values = [
'url' => $this->paymentUrl,
'firstName' => $firstName,
'lastName' => $lastName,
'partnerId' => $partnerId,
'subpartnerId' => $subpartnerId,
'mcc' => $mcc,
'limit' => $limit,
'promotion' => $promotion,
'calculatedIncome' => $calculatedIncome,
'verificationCode' => $verificationCode,
'transactionCode' => $transactionCode,
'dateAndTime' => $dateAndTime,
'amount' => $this->changeNumberFormat($total),
'status' => 'ok',
'articlesList' => base64_encode(json_encode($this->getAliorsArticlesListJson($order)))
];
$this->context->smarty->assign($values);
} else {
$this->context->smarty->assign('status', 'failed');
}
return $this->context->smarty->fetch('module:raty/views/templates/hook/payment_return.tpl');
}
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Ustawienia'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('PartnerID'),
'name' => 'RATY_PARTNERID',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Kod partnera handlowego')
),
array(
'type' => 'text',
'label' => $this->l('SubpartnerID'),
'name' => 'RATY_SUBPARTNERID',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Dodatkowy kod partnera handlowego.')
),
array(
'type' => 'text',
'label' => $this->l('MCC'),
'name' => 'RATY_MCC',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Kod MCC.')
),
array(
'type' => 'text',
'label' => $this->l('Oferta standardowa'),
'name' => 'RATY_STANDARD_PROMOTION',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Kod oferty standardowej.')
),
array(
'type' => 'html',
'label' => $this->l('Oferta specjalna dla Kategorii'),
'name' => 'RATY_CATEGORY_PROMOTION',
'desc' => $this->l('Kod oferty specjalnej dla Kategorii.'),
'html_content' =>
'<div class="row">'
. '<div>'
. '<div class="col-lg-6 col-md-12 col-sm-12">'
. '<input type="text" name="RATY_CATEGORY_PROMOTION" id="RATY_CATEGORY_PROMOTION" class="" value="' . Configuration::get('RATY_CATEGORY_PROMOTION') . '" style="width: 250px;">'
. '</div>'
. '<div class="col-lg-6 col-md-12 col-sm-12" style="padding-top: 0; display: flex;">'
. '<span class="col-lg-3 control-label">Czas trwania:</span>'
. '<div class="col-lg-9">'
. '<input type="date" name="RATY_CATEGORY_PROMOTION_START" id="RATY_CATEGORY_PROMOTION_START" class="" value="' . Configuration::get('RATY_CATEGORY_PROMOTION_START') . '"> - '
. '<input type="date" name="RATY_CATEGORY_PROMOTION_END" id="RATY_CATEGORY_PROMOTION_END" class="" value="' . Configuration::get('RATY_CATEGORY_PROMOTION_END') . '">'
. '</div>'
. '</div>'
. '</div>'
),
array(
'type' => 'html',
'label' => $this->l('Oferta specjalna dla Produktu'),
'name' => 'RATY_PRODUCT_PROMOTION',
'desc' => $this->l('Kod oferty specjalnej dla Produktu.'),
'html_content' =>
'<div class="row">'
. '<div>'
. '<div class="col-lg-6 col-md-12 col-sm-12">'
. '<input type="text" name="RATY_PRODUCT_PROMOTION" id="RATY_PRODUCT_PROMOTION" class="" value="' . Configuration::get('RATY_PRODUCT_PROMOTION') . '" style="width: 250px;">'
. '</div>'
. '<div class="col-lg-6 col-md-12 col-sm-12" style="padding-top: 0; display: flex;">'
. '<span class="col-lg-3 control-label">Czas trwania:</span>'
. '<div class="col-lg-9">'
. '<input type="date" name="RATY_PRODUCT_PROMOTION_START" id="RATY_PRODUCT_PROMOTION_START" class="" value="' . Configuration::get('RATY_PRODUCT_PROMOTION_START') . '"> - '
. '<input type="date" name="RATY_PRODUCT_PROMOTION_END" id="RATY_PRODUCT_PROMOTION_END" class="" value="' . Configuration::get('RATY_PRODUCT_PROMOTION_END') . '">'
. '</div>'
. '</div>'
. '</div>'
),
array(
'type' => 'text',
'label' => $this->l('Minimalna wartość'),
'name' => 'RATY_MIN_VALUE',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Minimalna wartość od której dostępna jest sprzedaż ratalna.')
),
array(
'type' => 'text',
'label' => $this->l('Maksymalna wartość'),
'name' => 'RATY_MAX_VALUE',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Maksymalna wartość do której dostępna jest sprzedaż ratalna.')
),
array(
'type' => 'text',
'label' => $this->l('Salt'),
'name' => 'RATY_SALT',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Kod Salt odtrzymany od banku')
),
array(
'type' => 'text',
'label' => $this->l('Nazwa płatności'),
'name' => 'RATY_TITLE',
'class' => 'fixed-width-xxl',
),
array(
'type' => 'textarea',
'label' => $this->l('Dodatkowy opis'),
'name' => 'RATY_DESCRIPTION',
'class' => 'fixed-width-xxl',
),
),
'submit' => array(
'title' => $this->l('Save'),
)
),
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitRaty';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
return $helper->generateForm(array($fields_form));
}
public function checkCurrency($cart)
{
$currency_order = new Currency($cart->id_currency);
$currencies_module = $this->getCurrency($cart->id_currency);
if (is_array($currencies_module)) {
foreach ($currencies_module as $currency_module) {
if ($currency_order->id == $currency_module['id_currency']) {
return true;
}
}
}
return false;
}
public function getConfigFieldsValues()
{
return array(
'RATY_PARTNERID' => Tools::getValue('RATY_PARTNERID', Configuration::get('RATY_PARTNERID')),
'RATY_SUBPARTNERID' => Tools::getValue('RATY_SUBPARTNERID', Configuration::get('RATY_SUBPARTNERID')),
'RATY_MCC' => Tools::getValue('RATY_MCC', Configuration::get('RATY_MCC')),
'RATY_STANDARD_PROMOTION' => Tools::getValue('RATY_STANDARD_PROMOTION', Configuration::get('RATY_STANDARD_PROMOTION')),
'RATY_PRODUCT_PROMOTION' => Tools::getValue('RATY_PRODUCT_PROMOTION', Configuration::get('RATY_PRODUCT_PROMOTION')),
'RATY_PRODUCT_PROMOTION_START' => Tools::getValue('RATY_PRODUCT_PROMOTION_START', Configuration::get('RATY_PRODUCT_PROMOTION_START')),
'RATY_PRODUCT_PROMOTION_END' => Tools::getValue('RATY_PRODUCT_PROMOTION_END', Configuration::get('RATY_PRODUCT_PROMOTION_END')),
'RATY_CATEGORY_PROMOTION' => Tools::getValue('RATY_CATEGORY_PROMOTION', Configuration::get('RATY_CATEGORY_PROMOTION')),
'RATY_CATEGORY_PROMOTION_START' => Tools::getValue('RATY_CATEGORY_PROMOTION_START', Configuration::get('RATY_CATEGORY_PROMOTION_START')),
'RATY_CATEGORY_PROMOTION_END' => Tools::getValue('RATY_CATEGORY_PROMOTION_END', Configuration::get('RATY_CATEGORY_PROMOTION_END')),
'RATY_MIN_VALUE' => Tools::getValue('RATY_MIN_VALUE', $this->changeNumberFormat(Configuration::get('RATY_MIN_VALUE'))),
'RATY_MAX_VALUE' => Tools::getValue('RATY_MAX_VALUE', $this->changeNumberFormat(Configuration::get('RATY_MAX_VALUE'))),
'RATY_SALT' => Tools::getValue('RATY_SALT', Configuration::get('RATY_SALT')),
'RATY_TITLE' => Tools::getValue('RATY_TITLE', Configuration::get('RATY_TITLE')),
'RATY_DESCRIPTION' => Tools::getValue('RATY_DESCRIPTION', Configuration::get('RATY_DESCRIPTION')),
);
}
public function checkAmount($total)
{
$minValue = (float) $this->changeNumberFormat(Configuration::get('RATY_MIN_VALUE'));
$maxValue = (float) $this->changeNumberFormat(Configuration::get('RATY_MAX_VALUE'));
if($minValue > 0 && $maxValue > 0) {
return $total >= $minValue && $total <= $maxValue;
}
return false;
}
private function changeNumberFormat($value)
{
return number_format($value, 2, '.', '');
}
private function getAliorsArticlesListJson($order)
{
$products = $order->getProductsDetail();
$totalShippingCost = (float)$order->total_shipping;
$totalDiscounts = (float)$order->total_discounts;
$totalWrapping = (float)$order->total_wrapping;
// @see https://stackoverflow.com/questions/42981409/php7-1-json-encode-float-issue
// json_encode makes float values wrong. This is simple fix
if (version_compare(phpversion(), '7.1', '>=')) {
ini_set( 'serialize_precision', -1 );
}
$json = ['articlesList' => []];
foreach ($products as $prod) {
if (!empty($prod['unit_price_tax_incl'])){
$price = $prod['unit_price_tax_incl'];
} else {
$price = !empty($prod['product_price_wt']) ? $prod['product_price_wt'] : $prod['product_price'];
}
$json['articlesList'][] = [
"category" => $this->getAliorsCategory($prod['id_category_default']),
"name" => $this->clearName($prod['product_name']),
"number" => (int)$prod['product_quantity'],
"price" => $this->getRounded($price),
];
}
if ($totalShippingCost){
$json['articlesList'][] = [
"category" => 'TKC_USLUGI', // from Alior's docs
"name" => 'Shipping costs',
"number" => 1,
"price" => $this->getRounded($totalShippingCost),
];
}
if ($totalDiscounts){
$json['articlesList'][] = [
"category" => 'TKC_RABAT', // from Alior's docs
"name" => 'Discount',
"number" => 1,
"price" => $this->getRounded($totalDiscounts) * -1,
];
}
if ($totalWrapping){
$json['articlesList'][] = [
"category" => 'TKC_USLUGI', // from Alior's docs
"name" => 'Inne',
"number" => 1,
"price" => $this->getRounded($totalWrapping),
];
}
return $json;
}
/**
* Returns Alior's ID of category based on mapping (see map.php)
* @return string
*/
private function getAliorsCategory($shopCategoryId)
{
$map = require(dirname(__FILE__) . '/map.php');
if (empty($map)) {
return '';
}
foreach ($map as $aliorId => $shopCats) {
if (in_array($shopCategoryId, $shopCats)) {
return $aliorId;
}
}
return !empty($map['default']) ? $map['default'] : '';
}
/**
* @param $price
* @return |null
*/
private function getRounded($price) {
$precision = method_exists('Context', 'getComputingPrecision')
? Context::getContext()->getComputingPrecision()
: _PS_PRICE_DISPLAY_PRECISION_;
if (is_array($this->context->currency)) {
return Tools::ps_round($price, (int)$this->context->currency['decimals'] * $precision);
} elseif (is_object($this->context->currency)) {
return Tools::ps_round($price, (int)$this->context->currency->decimals * $precision);
}
return null;
}
/**
* @param $name
* @return string
*/
private function clearName($name) {
$name = str_replace('|', '', $name);
return preg_replace('/[\x00-\x1F]/', '', $name);
}
private function checkCategoryPromotion($product) {
$categories = Product::getProductCategories($product->id);
foreach($categories as $categoryId)
{
$category = new Category($categoryId);
if($category->alior_category_promotion) {
return true;
}
}
return false;
}
public function formatDate($date, $expectedFormat = 'j-M-Y', $currentFormat = 'Y-m-d'){
if(!$date){
return 0;
}
$date = DateTime::createFromFormat($currentFormat, $date);
return $date->format($expectedFormat);
}
private function getPromotion($products) {
$todayDate = date("Y/m/d");
$promotionsType = [];
$isProductPromotionValid = true;
$isCategoryPromotionValid = true;
if(
!Configuration::get('RATY_PRODUCT_PROMOTION_START') ||
$this->formatDate(Configuration::get('RATY_PRODUCT_PROMOTION_START'), "Y/m/d", "Y-m-d") > $todayDate ||
$this->formatDate(Configuration::get('RATY_PRODUCT_PROMOTION_END'), "Y/m/d", "Y-m-d") < $todayDate
) {
$isProductPromotionValid = false;
}
if(
!Configuration::get('RATY_CATEGORY_PROMOTION_START') ||
$this->formatDate(Configuration::get('RATY_CATEGORY_PROMOTION_START'), "Y/m/d", "Y-m-d") > $todayDate ||
$this->formatDate(Configuration::get('RATY_CATEGORY_PROMOTION_END'), "Y/m/d", "Y-m-d") < $todayDate
) {
$isCategoryPromotionValid = false;
}
foreach($products as $product) {
array_push($promotionsType, $this->getProductPromotion($product, $isProductPromotionValid, $isCategoryPromotionValid));
}
$promotion = explode('${sep}', Configuration::get('RATY_' . $promotionsType[0] .'_PROMOTION'));
if(count($promotionsType) > 1) {
for($i = 1; $i < count($promotionsType); $i++) {
$promotionType = explode('${sep}', Configuration::get('RATY_' . $promotionsType[$i] .'_PROMOTION'));
$promotion = array_intersect($promotion, $promotionType);
}
}
return implode('${sep}', $promotion);
}
private function getProductPromotion($product, $isProductPromotionValid, $isCategoryPromotionValid) {
if(is_array($product)){
$product = new Product($product['id_product']);
}
if($isProductPromotionValid && $product->alior_product_promotion) {
return 'PRODUCT';
}
if($isCategoryPromotionValid && $this->checkCategoryPromotion($product)) {
return 'CATEGORY';
}
return 'STANDARD';
}
}

9
modules/raty/raty.tpl Normal file
View File

@@ -0,0 +1,9 @@
<div id="raty">
<form id="wniosek" method="post">
<input type="text" name="imie" placeholder="Imię"/><br/>
<input type="text" name="nazwisko" placeholder="nazwisko"/><br/>
<input type="text" name="amount" placeholder="kwota"/>
<button type="submit">Złóż</button>
</form>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
modules/raty/raty/alior.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>raty</name>
<displayName><![CDATA[Raty]]></displayName>
<version><![CDATA[1.0.0]]></version>
<description><![CDATA[Moduł do obsługi rat Alior Banku.]]></description>
<author><![CDATA[LogsHub.com]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Czy jesteś pewien aby odinstalować ten moduł?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../');
exit;

View File

@@ -0,0 +1,35 @@
<?php
class RatyPaymentModuleFrontController extends ModuleFrontController
{
public $ssl = true;
public $display_column_left = false;
/**
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$cart = $this->context->cart;
if (!$this->module->checkAmount($cart->getOrderTotal())) {
Tools::redirect('index.php?controller=order');
}
//print_r($cart);die;
$this->context->smarty->assign(array(
'nbProducts' => $cart->nbProducts(),
'cust_currency' => $cart->id_currency,
'currencies' => $this->module->getCurrency((int)$cart->id_currency),
'total' => $cart->getOrderTotal(true, Cart::BOTH),
'this_path' => $this->module->getPathUri(),
'this_path_bw' => $this->module->getPathUri(),
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->module->name.'/'
));
$this->setTemplate('payment_execution.tpl');
}
}

View File

@@ -0,0 +1,44 @@
<?php
class RatyValidationModuleFrontController extends ModuleFrontController
{
/**
* @see FrontController::postProcess()
*/
public function postProcess()
{
$cart = $this->context->cart;
$customer = new Customer($cart->id_customer);
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
if ($module['name'] == 'raty') {
$authorized = true;
break;
}
}
if (!$authorized) {
die($this->module->l('Metoda płatności jest niedostępna.', 'validation'));
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$currency = $this->context->currency;
$total = (float) $cart->getOrderTotal(true, Cart::BOTH);
$mailVars = array();
$this->module->validateOrder($cart->id, Configuration::get('PS_OS_RATY'), $total, $this->module->displayName, null, $mailVars, (int) $currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
}
}

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../');
exit;

BIN
modules/raty/raty/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

37
modules/raty/raty/map.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
/**
* Mapping between Alior's categories and store's categories
* Alior Category => Store's categories IDs eg. 'TKC_AGDD' => [1, 19, 33],
*/
return [
'TKC_AGDD' => [],
'TKC_AGDM' => [],
'TKC_AKCAUTO' => [],
'TKC_BIZUT' => [],
'TKC_DZIECIE' => [],
'TKC_EDU' => [],
'TKC_FOTO' => [],
'TKC_INSTRMUZ' => [],
'TKC_KOMP' => [],
'TKC_MATBUD' => [],
'TKC_MEBLE' => [],
'TKC_MOTO' => [],
'TKC_NARZ' => [],
'TKC_ODZIEZ' => [],
'TKC_OGRO' => [],
'TKC_OGRZEW' => [],
'TKC_OKDZW' => [],
'TKC_OPAL' => [],
'TKC_OPROGR' => [],
'TKC_PAKIE' => [],
'TKC_RTV' => [],
'TKC_SPORTREH' => [],
'TKC_SPRZKOM' => [],
'TKC_SYSTEKO' => [],
'TKC_SZTUK' => [],
'TKC_TELE' => [],
'TKC_UBEZ' => [],
'TKC_USLUGI' => [],
'default' => 'TKC_AGDM'
];

View File

@@ -0,0 +1,13 @@
<?php
/* SSL Management */
$useSSL = true;
require('../../config/config.inc.php');
Tools::displayFileAsDeprecated();
// init front controller in order to use Tools::redirect
$controller = new FrontController();
$controller->init();
Tools::redirect(Context::getContext()->link->getModuleLink('raty', 'payment'));

View File

@@ -0,0 +1,13 @@
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
Created on : 2016-10-18, 11:12:27
Author : Kamil
*/
#module-raty-payment ul.step li a,#module-raty-payment ul.step li span,#module-raty-payment ul.step li.step_current span,#module-raty-payment ul.step li.step_current_end span{
font-size: 16px !important;
}

521
modules/raty/raty/raty.php Normal file
View File

@@ -0,0 +1,521 @@
<?php
use PrestaShop\PrestaShop\Core\Payment\PaymentOption;
if (!defined('_PS_VERSION_')) {
exit;
}
class Raty extends PaymentModule
{
protected $_html = '';
protected $_postErrors = array();
public $details;
public $owner;
public $address;
public $extra_mail_vars;
public function __construct()
{
$this->name = 'raty';
$this->tab = 'payments_gateways';
$this->version = '1.4.4';
$this->author = 'LogsHub.com';
$this->bootstrap = true;
$this->is_eu_compatible = 1;
$this->controllers = array('payment', 'validation');
$this->is_eu_compatible = 1;
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => '1.7.6.99');
parent::__construct();
$this->displayName = $this->l('Raty');
$this->description = $this->l('Moduł do obsługi rat Alior Banku.');
$this->confirmUninstall = $this->l('Czy jesteś pewien aby odinstalować ten moduł?');
if (!Configuration::get('RATY_NAME')) {
$this->warning = $this->l('No name provided');
}
}
private function createOrderState()
{
// create new order status STATUSNAME
$values_to_insert = [
'invoice' => 0,
'send_email' => 0,
'module_name' => $this->name,
'color' => 'RoyalBlue',
'unremovable' => 0,
'hidden' => 0,
'logable' => 0,
'delivery' => 0,
'shipped' => 0,
'paid' => 0,
'deleted' => 0
];
if (!Db::getInstance()->insert('order_state', $values_to_insert)) {
return false;
}
$id_order_state = (int) Db::getInstance()->Insert_ID();
$languages = Language::getLanguages(false);
foreach ($languages as $language) {
Db::getInstance()->insert('order_state_lang', [
'id_order_state' => $id_order_state,
'id_lang' => $language['id_lang'],
'name' => 'Oczekiwanie na zatwierdzenie umowy ratalnej przez Alior Bank',
'template' => ''
]);
}
if (!@copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'alior.gif', _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'os' . DIRECTORY_SEPARATOR . $id_order_state . '.gif')) {
return false;
}
Configuration::updateValue('PS_OS_RATY', $id_order_state);
unset($id_order_state);
return true;
}
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
if (!parent::install()
||
!$this->registerHook('displayHeader') ||
!$this->registerHook('displayProductButtons') ||
!$this->registerHook('displayShoppingCartFooter') ||
!$this->registerHook('payment') ||
!$this->registerHook('paymentOptions') ||
!$this->registerHook('paymentReturn') ||
!$this->createOrderState() ||
!Configuration::updateValue('RATY_NAME', 'Raty') ||
!Configuration::updateValue('RATY_URL', 'https://aliorbank.pl') ||
!Configuration::updateValue('RATY_PARTNERID', '1001') ||
!Configuration::updateValue('RATY_SUBPARTNERID', '') ||
!Configuration::updateValue('RATY_MCC', '') ||
!Configuration::updateValue('RATY_PROMOTION', '') ||
!Configuration::updateValue('RATY_WARTOSC', '') ||
!Configuration::updateValue('RATY_KALKULATOR', '') ||
!Configuration::updateValue('RATY_SALT', 'QWERSJR1234$$%')
) {
return false;
}
return true;
}
public function uninstall()
{
if (!parent::uninstall()||
!Configuration::deleteByName('RATY_NAME') ||
!Configuration::deleteByName('RATY_URL') ||
!Configuration::deleteByName('RATY_PARTNERID') ||
!Configuration::deleteByName('RATY_SUBPARTNERID') ||
!Configuration::updateValue('RATY_MCC', '') ||
!Configuration::updateValue('RATY_PROMOTION', '') ||
!Configuration::updateValue('RATY_WARTOSC', '') ||
!Configuration::updateValue('RATY_KALKULATOR', '') ||
!Configuration::deleteByName('RATY_SALT')
) {
return false;
}
return true;
}
public function hookPaymentOptions($params)
{
if (!$this->active) {
return;
}
if (!$this->checkCurrency($params['cart']) || !$this->checkAmount($params['cart']->getOrderTotal())) {
return;
}
$offlineOption = new PaymentOption();
$offlineOption->setCallToActionText($this->l('Raty - Alior Bank'))
->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true))
// ->setAdditionalInformation($this->context->smarty->fetch('module:paymentexample/views/templates/front/payment_infos.tpl'))
->setLogo(Media::getMediaPath(_PS_MODULE_DIR_.$this->name.'/alior.gif'));
return [
$offlineOption,
];
}
public function getContent()
{
$output = '';
if (Tools::isSubmit('submitRaty')) {
$error = false;
if (!($raty_url = Tools::getValue('RATY_URL')) || empty($raty_url)) {
$output .= $this->displayError($this->l('Musisz wypełnić pole \'Adres URL\'.'));
$error = true;
} else {
Configuration::updateValue('RATY_URL', $raty_url);
}
if (!($raty_parentid = Tools::getValue('RATY_PARTNERID')) || empty($raty_parentid)) {
$output .= $this->displayError($this->l('Musisz wypełnić pole \'Parent ID\'.'));
$error = true;
} elseif (!$error) {
Configuration::updateValue('RATY_PARTNERID', $raty_parentid);
}
Configuration::updateValue('RATY_SUBPARTNERID', Tools::getValue('RATY_SUBPARTNERID'));
if (!($raty_salt = Tools::getValue('RATY_SALT')) || empty($raty_salt)) {
$output .= $this->displayError($this->l('Musisz wypełnić pole \'Salt\'.'));
$error = true;
} elseif (!$error) {
Configuration::updateValue('RATY_SALT', $raty_salt);
}
Configuration::updateValue('RATY_MCC', Tools::getValue('RATY_MCC'));
Configuration::updateValue('RATY_PROMOTION', Tools::getValue('RATY_PROMOTION'));
Configuration::updateValue('RATY_WARTOSC', $this->changeNumberFormat(Tools::getValue('RATY_WARTOSC')));
Configuration::updateValue('RATY_KALKULATOR', Tools::getValue('RATY_KALKULATOR'));
if (!$error) {
$output .= $this->displayConfirmation($this->l('Parametry uaktualnione.'));
}
}
return $output . $this->renderForm();
}
public function hookDisplayProductButtons($params)
{
if (empty($params['product']->price_amount)){
return;
}
$price = $params['product']->price_amount;
if (!$this->checkAmount($price)) {
return;
}
if (!$this->isCached('productraty.tpl', $this->getCacheId($params['product']->id))) {
$promotion = Tools::getValue('RATY_PROMOTION', Configuration::get('RATY_PROMOTION'));
$this->smarty->assign(array(
'this_path' => $this->_path,
'this_path_raty' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/',
'this_kalkulator' => Tools::getValue('RATY_KALKULATOR', Configuration::get('RATY_KALKULATOR')) .
'?installmentNumber=21&offerCode='.$promotion.'&cartValue=',
'this_cena' => $this->changeNumberFormat(round($price, 2))
));
}
return $this->display(__FILE__, 'productraty.tpl', $this->getCacheId($params['product']->id));
}
public function hookDisplayShoppingCartFooter($params)
{
if (!$this->checkCurrency($params['cart']) || !$this->checkAmount($params['cart']->getOrderTotal())) {
return;
}
$promotion = Tools::getValue('RATY_PROMOTION', Configuration::get('RATY_PROMOTION'));
$this->smarty->assign(array(
'this_path' => $this->_path,
'this_path_raty' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/',
'this_kalkulator' => Tools::getValue('RATY_KALKULATOR', Configuration::get('RATY_KALKULATOR')) .
'?installmentNumber=21&offerCode='.$promotion.'&cartValue=',
'this_cena' => $this->changeNumberFormat($params['cart']->getOrderTotal()),
));
return $this->display(__FILE__, 'raty_cart.tpl', $this->getCacheId());
}
public function hookDisplayHeader($params)
{
$this->context->controller->addCSS($this->_path . 'raty.css', 'all');
}
public function hookPayment($params)
{
if (!$this->active) {
return;
}
if (!$this->changeNumberFormat($this->checkAmount($params['cart']->getOrderTotal()))) {
return;
}
$promotion = Tools::getValue('RATY_PROMOTION', Configuration::get('RATY_PROMOTION'));
$this->smarty->assign(array(
'this_path' => $this->_path,
'this_path_raty' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/',
'this_kalkulator' => Tools::getValue('RATY_KALKULATOR', Configuration::get('RATY_KALKULATOR')) .
'?installmentNumber=21&offerCode='.$promotion.'&cartValue=',
'this_cena' => $this->changeNumberFormat($params['cart']->getOrderTotal()),
));
return $this->display(__FILE__, 'payment.tpl');
}
public function hookPaymentReturn($params)
{
if (!$this->active) {
return;
}
$state = $params['order']->getCurrentState();
if (in_array($state, array(Configuration::get('PS_OS_RATY'), Configuration::get('PS_OS_OUTOFSTOCK'), Configuration::get('PS_OS_OUTOFSTOCK_UNPAID')))) {
$customer = new Customer($params['order']->id_customer);
$firstName = $customer->firstname;
$lastName = $customer->lastname;
$url = Tools::getValue('RATY_URL', Configuration::get('RATY_URL'));
$partnerId = Tools::getValue('RATY_PARTNERID', Configuration::get('RATY_PARTNERID'));
$subpartnerId = Tools::getValue('RATY_SUBPARTNERID', Configuration::get('RATY_SUBPARTNERID'));
$mcc = Tools::getValue('RATY_MCC', Configuration::get('RATY_MCC'));
$promotion = Tools::getValue('RATY_PROMOTION', Configuration::get('RATY_PROMOTION'));
$salt = Tools::getValue('RATY_SALT', Configuration::get('RATY_SALT'));
$calculatedIncome = '';
$limit = '';
$transactionCode = $params['order']->reference;
$total = $params['order']->total_paid;
$date = date('Y-m-d');
$time = date('H:i:s');
$dateAndTime = $date . 'T' . $time;
$verificationCode = hash('sha256', $salt . $this->changeNumberFormat($total) .
$transactionCode . $partnerId . $subpartnerId . $dateAndTime . $mcc . $firstName . $lastName . $limit . $calculatedIncome . $promotion);
$values = [
'url' => $url,
'firstName' => $firstName,
'lastName' => $lastName,
'amount' => $total,
'partnerId' => $partnerId,
'subpartnerId' => $subpartnerId,
'mcc' => $mcc,
'limit' => $limit,
'promotion' => $promotion,
'calculatedIncome' => $calculatedIncome,
'verificationCode' => $verificationCode,
'transactionCode' => $transactionCode,
'dateAndTime' => $dateAndTime,
'amount' => $this->changeNumberFormat($total),
'status' => 'ok',
'articlesList' => base64_encode(json_encode($this->getAliorsArticlesListJson(
$params['order']->getProducts(),
(float)$params['order']->total_shipping,
(float)$params['order']->total_discounts
))),
];
$this->context->smarty->assign($values);
} else {
$this->context->smarty->assign('status', 'failed');
}
return $this->context->smarty->fetch('module:raty/views/templates/hook/payment_return.tpl');
}
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Ustawienia'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Adres URL'),
'name' => 'RATY_URL',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Adres URL banku.')
),
array(
'type' => 'text',
'label' => $this->l('PartnerID'),
'name' => 'RATY_PARTNERID',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Kod partnera handlowego')
),
array(
'type' => 'text',
'label' => $this->l('SubpartnerID'),
'name' => 'RATY_SUBPARTNERID',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Dodatkowy kod partnera handlowego.')
),
array(
'type' => 'text',
'label' => $this->l('MCC'),
'name' => 'RATY_MCC',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Kod MCC.')
),
array(
'type' => 'text',
'label' => $this->l('Promocja'),
'name' => 'RATY_PROMOTION',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Kod promocji.')
),
array(
'type' => 'text',
'label' => $this->l('Wartość'),
'name' => 'RATY_WARTOSC',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Minimalna wartość od której dostępna jest sprzedaż ratalna.')
),
array(
'type' => 'text',
'label' => $this->l('URL kalkulatora'),
'name' => 'RATY_KALKULATOR',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Link do obliczenia wysokości rat')
),
array(
'type' => 'text',
'label' => $this->l('Salt'),
'name' => 'RATY_SALT',
'class' => 'fixed-width-xxl',
'desc' => $this->l('Kod Salt odtrzymany od banku')
),
),
'submit' => array(
'title' => $this->l('Save'),
)
),
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitRaty';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
return $helper->generateForm(array($fields_form));
}
public function checkCurrency($cart)
{
$currency_order = new Currency($cart->id_currency);
$currencies_module = $this->getCurrency($cart->id_currency);
if (is_array($currencies_module)) {
foreach ($currencies_module as $currency_module) {
if ($currency_order->id == $currency_module['id_currency']) {
return true;
}
}
}
return false;
}
public function getConfigFieldsValues()
{
return array(
'RATY_URL' => Tools::getValue('RATY_URL', Configuration::get('RATY_URL')),
'RATY_PARTNERID' => Tools::getValue('RATY_PARTNERID', Configuration::get('RATY_PARTNERID')),
'RATY_SUBPARTNERID' => Tools::getValue('RATY_SUBPARTNERID', Configuration::get('RATY_SUBPARTNERID')),
'RATY_MCC' => Tools::getValue('RATY_MCC', Configuration::get('RATY_MCC')),
'RATY_PROMOTION' => Tools::getValue('RATY_PROMOTION', Configuration::get('RATY_PROMOTION')),
'RATY_WARTOSC' => Tools::getValue('RATY_WARTOSC', $this->changeNumberFormat(Configuration::get('RATY_WARTOSC'))),
'RATY_KALKULATOR' => Tools::getValue('RATY_KALKULATOR', Configuration::get('RATY_KALKULATOR')),
'RATY_SALT' => Tools::getValue('RATY_SALT', Configuration::get('RATY_SALT')),
);
}
public function checkAmount($total)
{
$wartosc = (float) Tools::getValue('RATY_WARTOSC', $this->changeNumberFormat(Configuration::get('RATY_WARTOSC')));
if ($wartosc > 0) {
return $wartosc <= $total;
}
return false;
}
private function changeNumberFormat($value)
{
return number_format($value, 2, '.', '');
}
private function getAliorsArticlesListJson(array $products, $totalShippingCost, $totalDiscounts)
{
$totalShippingCost = (float)$totalShippingCost;
$totalDiscounts = (float)$totalDiscounts;
// @see https://stackoverflow.com/questions/42981409/php7-1-json-encode-float-issue
// json_encode makes float values wrong. This is simple fix
if (version_compare(phpversion(), '7.1', '>=')) {
ini_set( 'serialize_precision', -1 );
}
$json = ['articlesList' => []];
foreach ($products as $prod) {
if (!empty($prod['unit_price_tax_incl'])){
$price = $prod['unit_price_tax_incl'];
} else {
$price = !empty($prod['product_price_wt']) ? $prod['product_price_wt'] : $prod['product_price'];
}
$json['articlesList'][] = [
"category" => $this->getAliorsCategory($prod['id_category_default']),
"name" => $prod['product_name'],
"number" => (int)$prod['product_quantity'],
"price" => (float)$price,
];
}
if ($totalShippingCost){
$json['articlesList'][] = [
"category" => 'TKC_USLUGI', // from Alior's docs
"name" => 'Shipping costs',
"number" => 1,
"price" => $totalShippingCost,
];
}
if ($totalDiscounts){
$json['articlesList'][] = [
"category" => 'TKC_RABAT', // from Alior's docs
"name" => 'Discount',
"number" => 1,
"price" => $totalDiscounts * -1,
];
}
return $json;
}
/**
* Returns Alior's ID of category based on mapping (see map.php)
* @return string
*/
private function getAliorsCategory($shopCategoryId)
{
$map = require(dirname(__FILE__) . '/map.php');
if (empty($map)) {
return '';
}
foreach ($map as $aliorId => $shopCats) {
if (in_array($shopCategoryId, $shopCats)) {
return $aliorId;
}
}
return !empty($map['default']) ? $map['default'] : '';
}
}

View File

@@ -0,0 +1,9 @@
<div id="raty">
<form id="wniosek" method="post">
<input type="text" name="imie" placeholder="Imię"/><br/>
<input type="text" name="nazwisko" placeholder="nazwisko"/><br/>
<input type="text" name="amount" placeholder="kwota"/>
<button type="submit">Złóż</button>
</form>
</div>

View File

@@ -0,0 +1,40 @@
<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
Tools::displayFileAsDeprecated();
include(dirname(__FILE__).'/../../header.php');
include(dirname(__FILE__).'/raty.php');
$context = Context::getContext();
$cart = $context->cart;
$raty = new Raty();
if ($cart->id_customer == 0 or $cart->id_address_delivery == 0 or $cart->id_address_invoice == 0 or !$raty->active) {
Tools::redirect('index.php?controller=order&step=1');
}
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
if ($module['name'] == 'raty') {
$authorized = true;
break;
}
}
if (!$authorized) {
die($raty->l('This payment method is not available.', 'validation'));
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$currency = $context->currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
$raty->validateOrder((int)$cart->id, $total, $raty->displayName, null, array(), (int)$currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)($cart->id).'&id_module='.(int)($raty->id).'&id_order='.$raty->currentOrder.'&key='.$customer->secure_key);

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../');
exit;

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,39 @@
{capture name=path}
<a href="{$link->getPageLink('order', true, NULL, "step=3")|escape:'html':'UTF-8'}" title="{l s='Go back to the Checkout' mod='raty'}">{l s='Checkout' mod='raty'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='Raty Alior Bank' mod='raty'}
{/capture}
{include file="$tpl_dir./breadcrumb.tpl"}
<h2>{l s='Podsumowanie zamówienia' mod='raty'}</h2>
{assign var='current_step' value='payment'}
{include file="$tpl_dir./order-steps.tpl"}
{if $nbProducts <= 0}
<p class="warning">{l s='Twój koszyk jest pusty.' mod='raty'}</p>
{else}
<h3>{l s='Raty Alior Bank' mod='raty'}</h3>
<form action="{$link->getModuleLink('raty', 'validation', [], true)|escape:'html'}" method="post">
<p>
<img src="{$this_path_bw}logo.png" alt="{l s='Raty Alior Bank' mod='raty'}" width="86" height="49" style="float:left; margin: 0px 10px 5px 0px;" />
{l s='Wybrałeś płatność poprzez raty Alior Banku.' mod='raty'}
<br/><br />
{l s='To jest Twoje skrócona informacja o zamówieniu:' mod='raty'}
</p>
<p style="margin-top:20px;">
- {l s='Całkowita kwota do zapłaty' mod='raty'}
<span id="amount" class="price">{displayPrice price=$total}</span>
{if $use_taxes == 1}
{l s='(zawiera VAT.)' mod='raty'}
{/if}
</p>
<p>
<b>{l s='Proszę potwierdź zamówienie klikając na "Potwierdzam zamówienie".' mod='raty'}</b>
</p>
<p class="cart_navigation" id="cart_navigation">
<input type="submit" value="{l s='Potwierdzam zamówienie' mod='raty'}" class="exclusive_large" />
<a href="{$link->getPageLink('order', true, NULL, "step=3")|escape:'html'}" class="button_large">{l s='Inne metody płatności' mod='raty'}</a>
</p>
</form>
{/if}

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../../');
exit;

View File

@@ -0,0 +1,9 @@
<p class="payment_module" style="position:relative;">
<a class="cheque" href="{$link->getModuleLink('raty', 'payment')|escape:'html'}" title="{l s='Zapłać poprzez Raty Alior Bank' mod='raty'}">
<img src="{$this_path_raty}logo.png" alt="{l s='Zapłać poprzez raty Alior Bank' mod='raty'}" width="86" height="49"/>
{l s='Zapłać poprzez raty Alior Bank' mod='raty'}&nbsp;<span>{l s='' mod='raty'}</span>
</a>
{if !empty($this_kalkulator)}
<a href="{$this_kalkulator}{$this_cena}" target="_blank" style="border:none;background:none;right:20px;top:0px;z-index: 100;"><img src="{$this_path_raty}alior-kalkulator-guzik.gif" alt="{l s='Oblicz ratę' mod='raty'}" width="86" height="49"/></a>
{/if}
</p>

View File

@@ -0,0 +1,26 @@
{if $status == 'ok'}
<form name='fr' action='{$url}' method='POST'>
<input type='hidden' name='firstName' value='{$firstName}'/>
<input type='hidden' name='lastName' value='{$lastName}'/>
<input type='hidden' name='partnerId' value='{$partnerId}'/>
<input type='hidden' name='subPartnerId' value='{$subpartnerId}'/>
<input type='hidden' name='mcc' value='{$mcc}'>
<input type='hidden' name='limit' value='{$limit}'/>
<input type='hidden' name='promotion' value='{$promotion}'/>
<input type='hidden' name='calculatedIncome' value='{$calculatedIncome}'/>
<input type='hidden' name='verificationCode' value='{$verificationCode}'/>
<input type='hidden' name='transactionCode' value='{$transactionCode}'/>
<input type='hidden' name='dateAndTime' value='{$dateAndTime}'/>
<input type='hidden' name='amount' value='{$amount}'/>
<input type='hidden' name='articlesList' value='{$articlesList}'/>
</form>
<script type='text/javascript'>
document.fr.submit();
</script>
{else}
<p class="warning">
{l s='We noticed a problem with your order. If you think this is an error, feel free to contact our' mod='bankwire'}
<a href="{$link->getPageLink('contact', true)|escape:'html'}">{l s='expert customer support team' mod='bankwire'}</a>.
</p>
{/if}

View File

@@ -0,0 +1,6 @@
{if !empty($this_kalkulator)}
<div id="oblicz-rate" class="single_raty">
<a href="{$this_kalkulator}{$this_cena}" target="_blank"><img src="/img/alior-button.webp"/></a>
</div>
<br/>
{/if}

View File

@@ -0,0 +1,5 @@
{if !empty($this_kalkulator)}
<div id="oblicz-rate" style="text-align:center;bottom:-4px;right: 400px">
<a href="{$this_kalkulator}{$this_cena}" target="_blank"><img src="{$this_path_raty}/alior-kalkulator-guzik.gif"/></a>
</div>
{/if}

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

View File

@@ -0,0 +1,40 @@
<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
Tools::displayFileAsDeprecated();
include(dirname(__FILE__).'/../../header.php');
include(dirname(__FILE__).'/raty.php');
$context = Context::getContext();
$cart = $context->cart;
$raty = new Raty();
if ($cart->id_customer == 0 or $cart->id_address_delivery == 0 or $cart->id_address_invoice == 0 or !$raty->active) {
Tools::redirect('index.php?controller=order&step=1');
}
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
if ($module['name'] == 'raty') {
$authorized = true;
break;
}
}
if (!$authorized) {
die($raty->l('This payment method is not available.', 'validation'));
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$currency = $context->currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
$raty->validateOrder((int)$cart->id, $total, $raty->displayName, null, array(), (int)$currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)($cart->id).'&id_module='.(int)($raty->id).'&id_order='.$raty->currentOrder.'&key='.$customer->secure_key);

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../');
exit;

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,39 @@
{capture name=path}
<a href="{$link->getPageLink('order', true, NULL, "step=3")|escape:'html':'UTF-8'}" title="{l s='Go back to the Checkout' mod='raty'}">{l s='Checkout' mod='raty'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='Raty Alior Bank' mod='raty'}
{/capture}
{include file="$tpl_dir./breadcrumb.tpl"}
<h2>{l s='Podsumowanie zamówienia' mod='raty'}</h2>
{assign var='current_step' value='payment'}
{include file="$tpl_dir./order-steps.tpl"}
{if $nbProducts <= 0}
<p class="warning">{l s='Twój koszyk jest pusty.' mod='raty'}</p>
{else}
<h3>{l s='Raty Alior Bank' mod='raty'}</h3>
<form action="{$link->getModuleLink('raty', 'validation', [], true)|escape:'html'}" method="post">
<p>
<img src="{$this_path_bw}logo.png" alt="{l s='Raty Alior Bank' mod='raty'}" width="86" height="49" style="float:left; margin: 0px 10px 5px 0px;" />
{l s='Wybrałeś płatność poprzez raty Alior Banku.' mod='raty'}
<br/><br />
{l s='To jest Twoje skrócona informacja o zamówieniu:' mod='raty'}
</p>
<p style="margin-top:20px;">
- {l s='Całkowita kwota do zapłaty' mod='raty'}
<span id="amount" class="price">{displayPrice price=$total}</span>
{if $use_taxes == 1}
{l s='(zawiera VAT.)' mod='raty'}
{/if}
</p>
<p>
<b>{l s='Proszę potwierdź zamówienie klikając na "Potwierdzam zamówienie".' mod='raty'}</b>
</p>
<p class="cart_navigation" id="cart_navigation">
<input type="submit" value="{l s='Potwierdzam zamówienie' mod='raty'}" class="exclusive_large" />
<a href="{$link->getPageLink('order', true, NULL, "step=3")|escape:'html'}" class="button_large">{l s='Inne metody płatności' mod='raty'}</a>
</p>
</form>
{/if}

View File

@@ -0,0 +1 @@
<p>{$raty_description}</p>

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../../');
exit;

View File

@@ -0,0 +1,7 @@
<p class="payment_module" style="position:relative;">
<a class="cheque" href="{$link->getModuleLink('raty', 'payment')|escape:'html'}" title="{l s='Zapłać poprzez Raty Alior Bank' mod='raty'}">
<img src="{$this_path_raty}logo.png" alt="{l s='Zapłać poprzez raty Alior Bank' mod='raty'}" width="86" height="49"/>
{l s='Zapłać poprzez raty Alior Bank' mod='raty'}&nbsp;<span>{l s='' mod='raty'}</span>
</a>
<a href="{$this_kalkulator}{$this_cena}" target="_blank" style="border:none;background:none;right:20px;top:0px;z-index: 100;"><img src="{$this_path_raty}alior-kalkulator-guzik.gif" alt="{l s='Oblicz ratę' mod='raty'}" width="86" height="49"/></a>
</p>

View File

@@ -0,0 +1,26 @@
{if $status == 'ok'}
<form name='fr' action='{$url}' method='POST'>
<input type='hidden' name='firstName' value='{$firstName}'/>
<input type='hidden' name='lastName' value='{$lastName}'/>
<input type='hidden' name='partnerId' value='{$partnerId}'/>
<input type='hidden' name='subPartnerId' value='{$subpartnerId}'/>
<input type='hidden' name='mcc' value='{$mcc}'>
<input type='hidden' name='limit' value='{$limit}'/>
<input type='hidden' name='promotion' value='{$promotion}'/>
<input type='hidden' name='calculatedIncome' value='{$calculatedIncome}'/>
<input type='hidden' name='verificationCode' value='{$verificationCode}'/>
<input type='hidden' name='transactionCode' value='{$transactionCode}'/>
<input type='hidden' name='dateAndTime' value='{$dateAndTime}'/>
<input type='hidden' name='amount' value='{$amount}'/>
<input type='hidden' name='articlesList' value='{$articlesList}'/>
</form>
<script type='text/javascript'>
document.fr.submit();
</script>
{else}
<p class="warning">
{l s='We noticed a problem with your order. If you think this is an error, feel free to contact our' mod='bankwire'}
<a href="{$link->getPageLink('contact', true)|escape:'html'}">{l s='expert customer support team' mod='bankwire'}</a>.
</p>
{/if}

View File

@@ -0,0 +1,17 @@
<script>
function getPrice() {
let price = '{$this_cena}';
let priceObj = document.querySelectorAll('.product-prices .current-price');
if (priceObj.length > 0) {
price = priceObj[priceObj.length - 1].textContent;
}
return parseFloat(price.replace(',', '.').replace(/[^\d.]/g, ""));
}
</script>
<br/>
<div id="oblicz-rate">
<a onclick="window.open('{$this_kalkulator}' + getPrice())" target="_blank">
<img src="{$this_path_raty}/alior-kalkulator-guzik.gif"/>
</a>
</div>
<br/>

View File

@@ -0,0 +1,16 @@
<script>
function getPrice() {
let price = '{$this_cena}';
let priceObj = document.querySelectorAll('.cart-total .value');
if (priceObj.length > 0) {
price = priceObj[priceObj.length - 1].textContent;
}
return parseFloat(price.replace(',', '.').replace(/[^\d.]/g, ""));
}
</script>
<div id="oblicz-rate" style="text-align:center;bottom:-4px;right: 400px">
<a onclick="window.open('{$this_kalkulator}' + getPrice())" target="_blank">
<img src="{$this_path_raty}/alior-kalkulator-guzik.gif"/>
</a>
</div>

View File

@@ -0,0 +1,26 @@
<script>
function check(event) {
let checkbox = document.getElementById('alior_category_promotion');
value = event.target.checked ? 1 : 0;
checkbox.value = value;
}
</script>
<div class="form-group row">
<label class="form-control-label">
Raty Alior
</label>
<div class="col-sm pt-2">
<label>
<input type="checkbox" id="alior_category_promotion" name="alior_category_promotion" onclick="check(event)"/>
Włącz ofertę specjalną dla tej kategorii
</label>
</div>
</div>
<script>
let checkbox = document.getElementById('alior_category_promotion');
checkbox.value = {$alior_category_promotion}
checkbox.checked = false;
if(checkbox.value === '1') {
checkbox.checked = true;
}
</script>

View File

@@ -0,0 +1,27 @@
<script>
function check(event) {
let checkbox = document.getElementById('alior_product_promotion');
value = event.target.checked ? 1 : 0;
checkbox.value = value;
}
</script>
<div id="caraty-product-promotion">
<h2>Raty Alior</h2>
<div class="row">
<div class="col-md-12">
<label>
<input type="checkbox" id="alior_product_promotion" name="alior_product_promotion" onclick="check(event)"/>
Włącz ofertę specjalną dla tego produktu
</label>
</div>
</div>
</div>
<script>
let checkbox = document.getElementById('alior_product_promotion');
checkbox.value = {$alior_product_promotion}
checkbox.checked = false;
if(checkbox.value === '1') {
checkbox.checked = true;
}
</script>

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;