Skip to content

Commit

Permalink
Added iDEAL v2 options for issuers to admin and payment page.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph committed Dec 17, 2024
1 parent 32459e2 commit b5cd1f4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
32 changes: 29 additions & 3 deletions modules/cardgate/cardgate.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Cardgate extends CardgatePayment {
var $shop_version = _PS_VERSION_;

public function __construct() {
Configuration::updateValue ( 'CARDGATE_MODULE_VERSION', '1.7.16' );
Configuration::updateValue ( 'CARDGATE_MODULE_VERSION', '1.7.17' );
$this->name = 'cardgate';
$this->paymentcode = 'cardgate';
$this->paymentname = 'CardGate';
Expand Down Expand Up @@ -110,6 +110,7 @@ public function getContent() {
$merchantid = ( string ) Tools::getValue ( 'CARDGATE_MERCHANT_ID' );
$merchantapikey = ( string ) Tools::getValue ( 'CARDGATE_MERCHANT_API_KEY' );
$paymentdisplay = ( string ) Tools::getValue ( 'CARDGATE_PAYMENT_DISPLAY' );
$showissuers = ( string ) Tools::getValue ( 'CARDGATE_SHOW_ISSUERS' );
$my_module_field_names = $this->myModelFieldNames ();
foreach ( $my_module_field_names as $key => $my_module_field_name ) {
Configuration::updateValue ( $my_module_field_name, ( string ) Tools::getValue ( $my_module_field_name ) );
Expand All @@ -122,7 +123,8 @@ public function getContent() {
Configuration::updateValue ( 'CARDGATE_MERCHANT_ID', $merchantid );
Configuration::updateValue ( 'CARDGATE_MERCHANT_API_KEY', $merchantapikey );
Configuration::updateValue ( 'CARDGATE_PAYMENT_DISPLAY', $paymentdisplay );

Configuration::updateValue ( 'CARDGATE_SHOW_ISSUERS', $showissuers );

// reset iDEAL issuer cache
Configuration::updateValue('cardgate_issuer_refresh', 0);

Expand Down Expand Up @@ -231,7 +233,28 @@ public function displayForm() {
'name' => 'name'
),
'hint' => $this->l('Choose which display will be used at the checkout' )
)
),
array (
'type' => 'select',
'label' => $this->l('Show issuers' ),
'name' => 'CARDGATE_SHOW_ISSUERS',
'required' => false,
'default_value' => 0,
'options' => array (
'query' => array (
array (
'id' => 0,
'name' => 'Without issuers'
),
array (
'id' => 1,
'name' => 'With issuers'
)
),
'id' => 'id',
'name' => 'name'
)
),
),
'submit' => array (
'title' => $this->l('Save' ),
Expand Down Expand Up @@ -272,13 +295,15 @@ public function displayForm() {
$merchantid = ( string ) Tools::getValue ( 'CARDGATE_MERCHANT_ID' );
$merchantapikey = ( string ) TOOLS::getValue ( 'CARDGATE_MERCHANT_API_KEY' );
$paymentdisplay = ( string ) TOOLS::getValue ( 'CARDGATE_PAYMENT_DISPLAY' );
$showissuers = ( string ) TOOLS::getValue ( 'CARDGATE_SHOW_ISSUERS' );
} else {
$mode = Configuration::get ( 'CARDGATE_TEST_MODE' );
$siteid = Configuration::get ( 'CARDGATE_SITE_ID' );
$hashkey = Configuration::get ( 'CARDGATE_HASH_KEY' );
$merchantid = Configuration::get ( 'CARDGATE_MERCHANT_ID' );
$merchantapikey = Configuration::get ( 'CARDGATE_MERCHANT_API_KEY' );
$paymentdisplay = Configuration::get ( 'CARDGATE_PAYMENT_DISPLAY' );
$showissuers = Configuration::get ( 'CARDGATE_SHOW_ISSUERS' );
}

// Load current value
Expand All @@ -288,6 +313,7 @@ public function displayForm() {
$helper->fields_value ['CARDGATE_MERCHANT_ID'] = $merchantid;
$helper->fields_value ['CARDGATE_MERCHANT_API_KEY'] = $merchantapikey;
$helper->fields_value ['CARDGATE_PAYMENT_DISPLAY'] = $paymentdisplay;
$helper->fields_value ['CARDGATE_SHOW_ISSUERS'] = $showissuers;

return $helper->generateForm ( $fields_form );
}
Expand Down
17 changes: 11 additions & 6 deletions modules/cardgate/cardgatepayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function hookPaymentOptions( $params ) {

$costText = '';

if ($this->paymentcode == 'ideal'){
if ( $this->paymentcode == 'ideal' && Configuration::get( 'CARDGATE_SHOW_ISSUERS' ) ){
$this->smarty->assign(['issuers'=>$this->getBanks(),'selected'=>$issuer]);
$additionalInformation = $this->fetch('module:cardgateideal/views/templates/front/payment_infos.tpl');
} else {
Expand Down Expand Up @@ -129,10 +129,15 @@ public function paymentData() {
}

protected function generateForm() {
$this->context->smarty->assign([
'action' => $this->context->link->getModuleLink($this->name, 'validation', array(), true),
'issuers' => $this->getBanks(),
]);
return $this->context->smarty->fetch('module:cardgateideal/views/templates/front/payment_form.tpl');
if ( Configuration::get( 'CARDGATE_SHOW_ISSUERS' ) ) {
$this->context->smarty->assign([
'action' => $this->context->link->getModuleLink($this->name, 'validation', array(), true),
'issuers' => $this->getBanks(),
]);
return $this->context->smarty->fetch('module:cardgateideal/views/templates/front/payment_form.tpl');
} else {
return false;
}

}
}

0 comments on commit b5cd1f4

Please sign in to comment.