Skip to content

Commit

Permalink
Merge pull request #21 from RichardCardGate/master
Browse files Browse the repository at this point in the history
Fix: Removed redundant  code.
  • Loading branch information
cardgate authored Sep 6, 2021
2 parents cdf2d92 + 0cf430d commit 28809fd
Show file tree
Hide file tree
Showing 46 changed files with 78 additions and 2,614 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Please visit [My CardGate](https://my.cardgate.com/) and retrieve your credentia

1. Download and unzip the most recent [cardgate.zip](https://github.com/cardgate/prestashop17/releases) file on your desktop.

2. Using FTP, upload the **modules** folder to the **root** folder of your website.
2. Using FTP, upload the **complete modules** folder to the **root** folder of your website.

3. In your PrestaShop **admin**, go to **Modules**, **Modules Catalog** and **Install** all the CardGate Modules.

Expand Down
2 changes: 1 addition & 1 deletion README_NL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ of neem contact op met je accountmanager.

1. Download en unzip de meest recente [cardgate.zip](https://github.com/cardgate/prestashop17/releases/) op je bureaublad.

2. Upload de **modules** map via FTP in de **root** map van je website.
2. Upload de **complete modules** map via FTP in de **root** map van je website.

3. In je PrestaShop **admin**, ga naar **Modules**, **Module Catalog** en **Installeer** alle CardGate modules.

Expand Down
5 changes: 0 additions & 5 deletions modules/cardgate/cardgate-clientlib-php/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,3 @@
/doc
/doc.generate.sh
INTERNAL
*.log
git.php
cardgate-clientlib.sublime-project
cardgate-clientlib.sublime-workspace
sftp-config.json
16 changes: 11 additions & 5 deletions modules/cardgate/cardgate.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
<?php
use Symfony\Component\Validator\Constraints\IsNull;

if ( file_exists( dirname( __FILE__ ) . '/../cardgate/cardgate.php') ) {
require_once dirname( __FILE__ ) . '/../cardgate/cardgate.php';
} else {
$GLOBALS['CARDGATENOTFOUND']=1;
if (!class_exists('CardgatePayment')) { class CardgatePayment extends PaymentModule { function get_url(){} } }
}

if (! defined ( '_PS_VERSION_' ))
exit ();

require_once "cardgatepayment.php";
class Cardgate extends PaymentModule {

class Cardgate extends CardgatePayment {

var $shop_version = _PS_VERSION_;

public function __construct() {
Configuration::updateValue ( 'CARDGATE_MODULE_VERSION', '1.7.13' );
Configuration::updateValue ( 'CARDGATE_MODULE_VERSION', '1.7.14' );
$this->name = 'cardgate';
$this->paymentcode = 'cardgate';
$this->paymentname = 'CardGate';
Expand All @@ -20,9 +28,7 @@ public function __construct() {
$this->bootstrap = true;
$this->currencies = true;
$this->currencies_mode = 'radio';

$this->imageurl = 'https://gateway.cardgateplus.com/images/logo' . $this->paymentcode . '.gif';


parent::__construct ();

$this->page = basename ( __FILE__, '.php' );
Expand Down
19 changes: 5 additions & 14 deletions modules/cardgate/cardgatepayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class CardgatePayment extends PaymentModule {

var $version = '1.7.13';
var $version = '1.7.14';
var $tab = 'payments_gateways';
var $author = 'CardGate';
var $shop_version = _PS_VERSION_;
Expand Down Expand Up @@ -58,10 +58,10 @@ public function hookPaymentOptions( $params ) {
}

$paymentOption = new PaymentOption();

$extraCosts = Configuration::get( 'CARDGATE_'.strtoupper( $this->paymentcode).'_EXTRACOST' );

$costText = '';
$extraCosts = $this->extraCosts($this->extra_cost);

if ($extraCosts > 0 ){
$oCurrency = new Currency( $params['cart']->id_currency );
$costText .= ' + '.$oCurrency->sign.' '.number_format($extraCosts, 2);
Expand Down Expand Up @@ -118,23 +118,15 @@ public function displayConf() {
$this->_html = $this->displayConfirmation( $this->l('Settings updated') );
}

function get_url() {
if ( Configuration::get('CARDGATE_MODE') == 1 ) {
return "https://secure-staging.curopayments.net/gateway/cardgate/";
} else {
return "https://secure.curopayments.net/gateway/cardgate/";
}
}

public function paymentData() {
public function paymentData() {
$data = [
'option' => [
'name' => 'option',
'type' => 'hidden',
'value' => $this->paymentcode,
]
];

return $data;
}

Expand All @@ -160,5 +152,4 @@ public function extraCosts( $extra_cost ) {
return round( $extra_cost, 2 );
}
}

}
2 changes: 1 addition & 1 deletion modules/cardgate/config_nl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>cardgate</name>
<displayName><![CDATA[CardGate Bank common]]></displayName>
<version><![CDATA[1.7.10]]></version>
<version><![CDATA[1.7.14]]></version>
<description><![CDATA[CardGate Bank base module.]]></description>
<author><![CDATA[CardGate]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
1 change: 0 additions & 1 deletion modules/cardgate/controllers/front/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class CardgateValidationModuleFrontController extends ModuleFrontController
*/
public function postProcess()
{

require_once(str_replace('controllers/front','',dirname(__FILE__)).'cardgate-clientlib-php/init.php');

$option = $_REQUEST['option'];
Expand Down
151 changes: 1 addition & 150 deletions modules/cardgateafterpay/cardgateafterpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@
*
* $this->l('Pay with')
*/
class Cardgateafterpay extends PaymentModule {

var $tab = 'payments_gateways';
var $author = 'CardGate';
var $shop_version = _PS_VERSION_;
var $currencies = true;
var $currencies_mode = 'radio';
var $_html = '';
var $extra_cost = '';
protected $_paymentHookTpl = '';
class Cardgateafterpay extends CardgatePayment {

private $_postErrors = array();
protected $_childClassFile = __FILE__;
Expand All @@ -48,7 +39,6 @@ public function __construct() {
$this->paymentname = 'Afterpay';
$this->logoname = 'afterpay';
$this->version = Configuration::get('CARDGATE_MODULE_VERSION');
$this->imageurl = 'https://gateway.cardgateplus.com/images/logo' . $this->paymentcode . '.gif';
$this->extra_cost = Configuration::get('CARDGATE_' . strtoupper( $this->paymentcode ) . '_EXTRACOST');
$this->controllers = array('validation');
$this->is_eu_compatible = 1;
Expand Down Expand Up @@ -80,145 +70,6 @@ public function __construct() {
if ( isset( $GLOBALS['CARDGATENOTFOUND'] ) )
$this->warning = $this->l('The CardGate module is not found.');
}

public function install() {

if ( !parent::install() || !$this->registerHook('paymentOptions') || !$this->registerHook('paymentReturn') ) {
return false;
}
return true;

$payment = strtoupper( $this->paymentcode );

if ( !parent::install() OR ! $this->registerHook('payment') )
return false;
return true;
}

public function uninstall() {

$paymentcode = $this->paymentcode;

if ( $paymentcode == '')
return false;

$paymentcode = strtoupper( $paymentcode );

if ( !parent::uninstall() )
return false;
return true;
}

public function hookPaymentOptions( $params ) {

if ( !$this->active ) {
return;
}
if ( !$this->checkCurrency( $params['cart'] ) ) {
return;
}

if (isset($_COOKIE['issuer'])){
$issuer = $_COOKIE['issuer'];
} else {
$issuer = 0;
}

$paymentOption = new PaymentOption();

$costText = '';
$extraCosts = $this->extraCosts($this->extra_cost);

if ($extraCosts > 0 ){
$oCurrency = new Currency( $params['cart']->id_currency );
$costText .= ' + '.$oCurrency->sign.' '.number_format($extraCosts, 2);
}

if ($this->paymentcode == 'ideal'){
$this->smarty->assign(['issuers'=>$this->getBanks(),'selected'=>$issuer]);
$additionalInformation = $this->fetch('module:cardgateideal/views/templates/front/payment_infos.tpl');
} else {
$additionalInformation = null;
}

$display = Configuration::get('CARDGATE_PAYMENT_DISPLAY');
if ($display == 'textandlogo' || $display == 'textonly'){
$actionText = $this->l('Pay with').' '.$this->paymentname . $costText;
} else {
$actionText = null;
}

if ($display == 'textandlogo' || $display == 'logoonly' ){
$logo = Media::getMediaPath(_PS_MODULE_DIR_.$this->name.'/logo.gif');
} else {
$logo = null;
}

$paymentOption->setCallToActionText($actionText)
->setAction($this->context->link->getModuleLink('cardgate', 'validation', array(), true))
->setInputs( $this->paymentData() )
->setAdditionalInformation($additionalInformation)
->setLogo($logo);

$payment_options = [
$paymentOption
];
return $payment_options;
}

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 displayConf() {

$this->_html = $this->displayConfirmation( $this->l('Settings updated') );
}

function get_url() {
if ( Configuration::get('CARDGATE_MODE') == 1 ) {
return "https://secure-staging.curopayments.net/gateway/cardgate/";
} else {
return "https://secure.curopayments.net/gateway/cardgate/";
}
}

public function paymentData() {
$data = [
'option' => [
'name' => 'option',
'type' => 'hidden',
'value' => $this->paymentcode,
]
];

return $data;
}

public function extraCosts( $extra_cost ) {
$cart = $this->context->cart;
$total = number_format( ($cart->getOrderTotal( true, Cart::BOTH ) ), 2, '.', '');
if ( $extra_cost == 0 || $extra_cost == '') {
return 0;
}
if ( strstr( $extra_cost, '%') ) {
$percentage = str_replace('%', '', $extra_cost );
return round( ($total * $percentage / 100 ), 2 );
}
if ( is_numeric( $extra_cost ) ) {
return round( $extra_cost, 2 );
}
}

}

?>
2 changes: 1 addition & 1 deletion modules/cardgateafterpay/config_nl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>cardgateafterpay</name>
<displayName><![CDATA[CardGate Afterpay]]></displayName>
<version><![CDATA[1.7.0]]></version>
<version><![CDATA[1.7.14]]></version>
<description><![CDATA[Accepteert betalingen met CardGate Afterpay]]></description>
<author><![CDATA[CardGate]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
Loading

0 comments on commit 28809fd

Please sign in to comment.