Skip to content

Commit

Permalink
Merge pull request #19 from paynl/feature/PLUG-416
Browse files Browse the repository at this point in the history
Add ideal banks option
  • Loading branch information
woutse authored Jul 17, 2021
2 parents 6e6a56f + 7c99276 commit 30ae6bf
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 18 deletions.
5 changes: 4 additions & 1 deletion paynl_paymentmethods/controllers/front/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function initContent()
$invoiceAddress = new Address((int)$cart->id_address_invoice);

$paymentOptionId = Tools::getValue('pid');

$bank_id = Tools::getValue('bankid');

$token = Configuration::get('PAYNL_TOKEN');
$serviceId = Configuration::get('PAYNL_SERVICE_ID');
Expand Down Expand Up @@ -211,6 +211,9 @@ public function initContent()
$apiStart->setExtra1('CartId: ' . $cart->id);
$apiStart->setObject('prestashop16 ' . $module->getVersion());
$apiStart->setOrderNumber($cart->id);
if ($bank_id) {
$apiStart->setPaymentOptionSubId($bank_id);
}

$apiStart->setPaymentOptionId($paymentOptionId);

Expand Down
27 changes: 22 additions & 5 deletions paynl_paymentmethods/payment.tpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
<link rel="stylesheet" href="/modules/paynl_paymentmethods/paynl.css" />

<script type="text/javascript" src="/modules/paynl_paymentmethods/paynl.js"></script>

{foreach from=$profiles key=k item=v}
<div class="row">
<div class="col-xs-12">
<p class="payment_module" >
<a data-ajax="false" class="paynl_paymentmethod " href="{$link->getModuleLink('paynl_paymentmethods', 'payment', [pid => {$v.id}], true)|escape:'html'}" title="{l s=$v.name mod='paynl_paymentmethods'}">
<img src="https://static.pay.nl/payment_profiles/75x75/{$v.id}.png" alt="{$v.name}" />
{$v.name}{if isset($v.extraCosts)} <span class="">{$v.extraCosts}</span> {/if}
</a>
{if $v.id == 10 && $showbanks}
<a data-ajax="false" class="paynl_paymentmethod showbanks" >
<img src="https://static.pay.nl/payment_profiles/75x75/{$v.id}.png" alt="{$v.name}" />
{$v.name}{if isset($v.extraCosts)} <span class="">{$v.extraCosts}</span> {/if}
</a>
<span id="showbanks_submenu_container">
<span id="showbanks_submenu">
{foreach from=$banks key=bk item=b}
<a data-ajax="false" class="paynl_paymentmethod bank" href="{$link->getModuleLink('paynl_paymentmethods', 'payment', [pid => {$v.id}, bankid => {$b.id}], true)|escape:'html'}" title="{l s=$b.name mod='paynl_paymentmethods'}">
<img src="https://static.pay.nl/ideal/banks/25x25/{$b.id}.png" alt="{$b.name}" />
{$b.name}
</a>
{/foreach}
</span>
</span>
{else}
<a data-ajax="false" class="paynl_paymentmethod " href="{$link->getModuleLink('paynl_paymentmethods', 'payment', [pid => {$v.id}], true)|escape:'html'}" title="{l s=$v.name mod='paynl_paymentmethods'}">
<img src="https://static.pay.nl/payment_profiles/75x75/{$v.id}.png" alt="{$v.name}" />
{$v.name}{if isset($v.extraCosts)} <span class="">{$v.extraCosts}</span> {/if}
</a>
{/if}
</p>
</div>
</div>
Expand Down
60 changes: 53 additions & 7 deletions paynl_paymentmethods/paynl.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
p.payment_module a.paynl_paymentmethod:after {
p.payment_module a.paynl_paymentmethod:after,
#showbanks_submenu a:after {
color: #777777;
content: "";
display: block;
Expand All @@ -13,14 +14,59 @@ p.payment_module a.paynl_paymentmethod:after {
}

p.payment_module a.paynl_paymentmethod *,
p.payment_module a.paynl_paymentmethod{
p.payment_module a.paynl_paymentmethod {
padding: 3px;
padding-left: 10px;
padding-left: 10px;
vertical-align: middle;
cursor: pointer;
}
p.payment_module a.paynl_paymentmethod label{
margin-right:10px;

p.payment_module a.paynl_paymentmethod label {
margin-right: 10px;
}
a.paynl_paymentmethod{

a.paynl_paymentmethod {
height: 85px;
}
}

#showbanks_submenu a:after {
font-size: 15px;
}

#showbanks_submenu {
display: block;
border: 1px solid #d6d4d4;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
font-size: 17px;
line-height: 23px;
color: #333;
font-weight: bold;
padding: 5px;
letter-spacing: -1px;
position: relative;
background: #0000000d;
}

#showbanks_submenu_container {
max-height: 0;
-webkit-transition: max-height 1s;
-o-transition: max-height .5s;
transition: max-height 1s;
overflow: hidden;
display: block;
}

#showbanks_submenu_container.active {
max-height: 1000px;
}

p.payment_module a.paynl_paymentmethod.bank {
height: auto;
padding: 7px;
}

p.payment_module a.paynl_paymentmethod.bank img {
padding-right: 10px;
}
6 changes: 6 additions & 0 deletions paynl_paymentmethods/paynl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

$(document).ready(function () {
$("a.showbanks").click(function () {
$("#showbanks_submenu_container").toggleClass("active");
});
});
34 changes: 29 additions & 5 deletions paynl_paymentmethods/paynl_paymentmethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function __construct()
{
$this->name = 'paynl_paymentmethods';
$this->tab = 'payments_gateways';
$this->version = '3.5.8';
$this->version = '3.6.0';
$this->_postErrors = array();
$this->module_key = '6c2f48f238008e8f68271f5e4763d308';

Expand Down Expand Up @@ -282,7 +282,8 @@ public function hookPayment($params)
asort($methodOrder);

$activeProfilesTemp = $activeProfiles;
$activeProfiles = array();
$ideal_banks = array();
$activeProfiles = array();

foreach (array_keys($methodOrder) as $iProfileId) {
foreach ($activeProfilesTemp as $iKey => $arrActiveProfile) {
Expand All @@ -305,18 +306,27 @@ public function hookPayment($params)
$arrActiveProfile['extraCosts'] = Tools::displayPrice($feeCurrency, $objCurrency,false);
}

if ($arrActiveProfile['id'] == 10) {
$ideal_banks = $arrActiveProfile['paymentOptionSubList'];
}

array_push($activeProfiles, $arrActiveProfile);
unset($activeProfilesTemp[$iKey]);
}
}
}

$showbanks = Configuration::get('PAYNL_SHOWBANKS');
$smarty->assign(array(
'this_path' => $this->_path,
'profiles' => $activeProfiles,
//'banks' => $paynl->getIdealBanks(),
'this_path_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'],
ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/' . $this->name . '/'
'banks' => $ideal_banks,
'showbanks' => $showbanks,
'this_path_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars(
$_SERVER['HTTP_HOST'],
ENT_COMPAT,
'UTF-8'
) . __PS_BASE_URI__ . 'modules/' . $this->name . '/'
));

return $this->display(_PS_MODULE_DIR_ . '/' . $this->name . '/' . $this->name . '.php', 'payment.tpl');
Expand Down Expand Up @@ -408,6 +418,7 @@ public function getContent()
Configuration::updateValue('PAYNL_SUCCESS', $_POST['success']);
Configuration::updateValue('PAYNL_CANCEL', $_POST['cancel']);
Configuration::updateValue('PAYNL_LOGGING', $_POST['logging']);
Configuration::updateValue('PAYNL_SHOWBANKS', $_POST['showbanks']);
if (isset($_POST['enaC'])) {
Configuration::updateValue('PAYNL_COUNTRY_EXCEPTIONS', serialize($_POST['enaC']));
}
Expand Down Expand Up @@ -507,6 +518,7 @@ public function displayFormSettings()
$arrConfig[] = 'PAYNL_PAYMENT_MIN';
$arrConfig[] = 'PAYNL_PAYMENT_MAX';
$arrConfig[] = 'PAYNL_LOGGING';
$arrConfig[] = 'PAYNL_SHOWBANKS';

$conf = Configuration::getMultiple($arrConfig);

Expand Down Expand Up @@ -584,6 +596,16 @@ public function displayFormSettings()
}
$osLogging .= '</select>';

$osBanks = '<select name="showbanks">';

$bankStates = array(0 => $this->l('Disabled'), 1 => $this->l('Enabled'));

foreach ($bankStates as $stateVal => $stateText) {
$selected = $conf['PAYNL_SHOWBANKS'] == $stateVal ? ' selected' : '';
$osBanks .= '<option value="' . $stateVal . '"' . $selected . '>' . $stateText . '</option>';
}
$osBanks .= '</select>';


$countries = DB::getInstance()->ExecuteS('SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country WHERE id_module = ' . (int)($this->id));
foreach ($countries as $country) {
Expand Down Expand Up @@ -780,6 +802,8 @@ public function displayFormSettings()
<div class="margin-form">' . $osCancel . '</div>
<label>' . $this->l('Log process information') . '</label>
<div class="margin-form">' . $osLogging . '</div>
<label>' . $this->l('Show Ideal banks') . '</label>
<div class="margin-form">' . $osBanks . '</div>
<br />'
. $exceptions .
Expand Down

0 comments on commit 30ae6bf

Please sign in to comment.