Skip to content

Commit

Permalink
New payment method: OnlineÜberweisen.
Browse files Browse the repository at this point in the history
ClientLib update
  • Loading branch information
RichardCardGate committed Oct 24, 2019
1 parent 331f2c9 commit 1ec5809
Show file tree
Hide file tree
Showing 11 changed files with 266 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modules/cardgate/cardgate-clientlib-php/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 CardGate B.V.
Copyright (c) 2018 CardGate B.V.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions modules/cardgate/cardgate-clientlib-php/README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ to your `composer.json` file:
```json
{
"require": {
"cardgate/cardgate-clientlib-php": "~1.0.0"
"cardgate/cardgate-clientlib-php": "~1.1.4"
}
}
```
Expand All @@ -32,7 +32,7 @@ You may also git clone or [download the files manually](https://github.com/cardg

```php
cardgate\api\Autoloader::register();
$oCardGate = new cardgate\api\Client( 1, '<merchant key>', TRUE );
$oCardGate = new cardgate\api\Client( <merchant id>, '<merchant key>', TRUE );
```

## Support ##
Expand Down
2 changes: 1 addition & 1 deletion modules/cardgate/cardgate-clientlib-php/src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class Client {
/**
* Client version.
*/
const CLIENT_VERSION = "1.1.10";
const CLIENT_VERSION = "1.1.12";

/**
* Url to use for production.
Expand Down
4 changes: 2 additions & 2 deletions modules/cardgate/cardgate-clientlib-php/src/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ final class Method {
const PAYSAFECASH = 'paysafecash';

/**
* SofortPay
* OnlineUberweisen
*/
const SOFORTPAY = 'sofortpay';
const ONLINEUEBERWEISEN = 'onlineueberweisen';

/**
* Gift Card
Expand Down
2 changes: 1 addition & 1 deletion modules/cardgate/cardgate.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Cardgate extends PaymentModule {
var $shop_version = _PS_VERSION_;

public function __construct() {
Configuration::updateValue ( 'CARDGATE_MODULE_VERSION', '1.7.7' );
Configuration::updateValue ( 'CARDGATE_MODULE_VERSION', '1.7.8' );
$this->name = 'cardgate';
$this->paymentcode = 'cardgate';
$this->paymentname = 'CardGate';
Expand Down
2 changes: 1 addition & 1 deletion 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.7';
var $version = '1.7.8';
var $tab = 'payments_gateways';
var $author = 'CardGate';
var $shop_version = _PS_VERSION_;
Expand Down
214 changes: 214 additions & 0 deletions modules/cardgateonlineueberweisen/cardgateonlineueberweisen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
<?php

use PrestaShop\PrestaShop\Core\Payment\PaymentOption;

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

/**
* CardGate - Prestashop
*
* 2010-11-09 (LL) Version 1.00
* Initial release
*
* 2011-04-18 (BZ) Version 1.01
* Added PayPal, updated countries for payment options
*
* Data for langiange translations
*
* $this->l('Pay with')
*/
class Cardgateonlineueberweisen 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 = '';

private $_postErrors = array();
protected $_childClassFile = __FILE__;

/**
* Available payment methods setup
*/
public function __construct() {
global $cookie, $order;

$this->name = 'cardgateonlineueberweisen';
$this->paymentcode = 'onlineueberweisen';
$this->ps_versions_compliancy = array('min' => '1.7.1.0', 'max' => _PS_VERSION_ );
$this->paymentname = 'OnlineÜberweisen';
$this->logoname = 'onlineueberweisen';
$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;
$this->currencies = true;
$this->currencies_mode = 'checkbox';
$this->bootstrap = true;

parent::__construct();
$this->page = basename( __FILE__, '.php');
$this->displayName = $this->l('CardGate OnlineÜberweisen');
$this->description = $this->l('Accepts payments with CardGate OnlineÜberweisen.');
$this->confirmUninstall = $this->l('Are you sure you want to delete your details?');

if ( !count( Currency::checkPaymentCurrencies( $this->id ) ) ) {
$this->warning = $this->l('No currency has been set for this module.');
}

$total = 0;
$rate = 'EUR';

if ( isset( $GLOBALS['cart'] ) && $GLOBALS['cart']->id_currency > 0 ) {
$currency = new Currency( $GLOBALS['cart']->id_currency );
$total = round( Tools::convertPrice( $GLOBALS['cart']->getOrderTotal( true, 3 ), $currency ), 2 );
$rate = $currency->iso_code;
}
$id_lang = (!isset( $cookie ) OR ! is_object( $cookie )) ? intval( Configuration::get('PS_LANG_DEFAULT') ) : intval( $cookie->id_lang );

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 = floatval(Configuration::get( 'CARDGATE_'.strtoupper( $this->paymentcode).'_EXTRACOST' ));

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') );
}

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 );
}
}
}

?>
13 changes: 13 additions & 0 deletions modules/cardgateonlineueberweisen/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>cardgateonlineueberweisen</name>
<displayName><![CDATA[CardGate OnlineÜberweisen]]></displayName>
<version><![CDATA[1.7.0]]></version>
<description><![CDATA[Accepts payments with CardGate OnlineÜberweisen.]]></description>
<author><![CDATA[Richard Schoots]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Are you sure you want to delete your details?]]></confirmUninstall>
<is_configurable>0</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>
13 changes: 13 additions & 0 deletions modules/cardgateonlineueberweisen/config_nl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>cardgateonlineueberweisen</name>
<displayName><![CDATA[CardGate OnlineÜberweisen]]></displayName>
<version><![CDATA[1.7.0]]></version>
<description><![CDATA[Accepteert betalingen met CardGate OnlineÜberweisen]]></description>
<author><![CDATA[CardGate]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Weet u zeker dat u uw details wilt verwijderen?]]></confirmUninstall>
<is_configurable>0</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>
Binary file added modules/cardgateonlineueberweisen/logo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions modules/cardgateonlineueberweisen/redirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

include(dirname( __FILE__ ) . '/../../config/config.inc.php');

define( 'LOGER_TRANSACTIONS', false ); // true ou false, write log of response or not
define( 'FICHIER_LOG', 'dialxs.log' ); // File for testing response answer
define( 'EMAIL_DE_NOTIFICATION', '' ); // Email
// add Link Object to Context if is does not exist yet
//fixes bug when member function getPageLink() is called

if ( !is_object( Context::getContext()->link ) ) {
Context::getContext()->link = new Link();
}

if ( isset( $_GET['extra'] ) && isset( $_GET['status'] ) ) {
header( 'Location: ' . Tools::getHttpHost( true, true ) . __PS_BASE_URI__ . 'order-confirmation.php' );
}
?>

0 comments on commit 1ec5809

Please sign in to comment.