Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gambio 3.12 compat #20

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Wirecard Checkout Seamless plugin for Gambio GX3

[![License](https://img.shields.io/badge/license-GPLv2-blue.svg)](https://raw.githubusercontent.com/wirecard/gambio-wcs/master/LICENSE)
[![Gambio GX3](https://img.shields.io/badge/Gambio_GX3-v3.10.0.1-green.svg)](https://www.gambio.de/)
[![Gambio GX3](https://img.shields.io/badge/Gambio_GX3-v3.12.0.3-green.svg)](https://www.gambio.de/)
[![PHP v5.6](https://img.shields.io/badge/php-v5.6-yellow.svg)](http://www.php.net)
[![PHP v7.0](https://img.shields.io/badge/php-v7.0-yellow.svg)](http://www.php.net)
[![PHP v7.1](https://img.shields.io/badge/php-v7.1-yellow.svg)](http://www.php.net)
[![PHP v7.2](https://img.shields.io/badge/php-v7.2-yellow.svg)](http://www.php.net)


Wirecard Checkout Seamless plugin for Gambio GX3.
Expand Down
4 changes: 4 additions & 0 deletions callback/wirecard/checkout_seamless_confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
*/

chdir('../../');

require_once('includes/modules/payment/wcs_top.php');
wcs_preserve_postparams();
require_once('includes/application_top.php');
wcs_preserve_postparams(true);
require_once DIR_FS_DOCUMENT_ROOT . 'includes/classes/WirecardCheckoutSeamless.php';

$seamless = new GMWirecardCheckoutSeamless_ORIGIN();
Expand Down
2 changes: 1 addition & 1 deletion checkout_wirecard_checkout_seamless.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
}
else
{
$iFrame = '<iframe name="' . MODULE_PAYMENT_WCP_WINDOW_NAME . '" src="' . $initResponse->getRedirectUrl()
$iFrame = '<iframe name="' . MODULE_PAYMENT_WCS_WINDOW_NAME . '" src="' . $initResponse->getRedirectUrl()
. '" width="100%" height="660" border="0" frameborder="0"></iframe>';
$smarty->assign('FORM_ACTION', $iFrame);
$smarty->assign('CHECKOUT_TITLE', $seamless->getText('confirm_title'));
Expand Down
27 changes: 24 additions & 3 deletions includes/classes/WirecardCheckoutSeamless.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

require_once DIR_FS_DOCUMENT_ROOT . '/gm/classes/GMWirecardCheckoutSeamless.php';

defined('GM_HTTP_SERVER') or define('GM_HTTP_SERVER', HTTP_SERVER);
define('MODULE_PAYMENT_WCS_WINDOW_NAME', 'wirecardCheckoutSeamlessIFrame');

class WirecardCheckoutSeamless_ORIGIN
{
public $code;
Expand Down Expand Up @@ -64,6 +67,13 @@ class WirecardCheckoutSeamless_ORIGIN
*/
static protected $dataStore = null;

/**
* caches contents returned from selection() method
* the selection methode may be called twice, for some reasons
* @var
*/
static protected $_selectionCache;

/**
* whether datastorage init failed
* @var bool
Expand Down Expand Up @@ -103,10 +113,12 @@ public function __construct()
$this->info = $this->constant("MODULE_PAYMENT_{$c}_TEXT_INFO"); // displayed in checkout
$this->description = $this->constant("MODULE_PAYMENT_{$c}_TEXT_DESC"); // displayed in admin area
$this->sort_order = $this->constant("MODULE_PAYMENT_{$c}_SORT_ORDER");
$this->description .= '<br /><br /><a href="' . GM_HTTP_SERVER . DIR_WS_ADMIN
if ($this->constant('DIR_WS_ADMIN') !== null)
{
$this->description .= '<br /><br /><a href="' . GM_HTTP_SERVER . DIR_WS_ADMIN
. 'wirecard_checkout_seamless_config.php" class="button" style="margin: auto auto 10px auto; ">'
. $this->_seamless->getText('configure') . '</a>';

}
$this->enabled = self::constant("MODULE_PAYMENT_{$c}_STATUS") == 'True';
define("MODULE_PAYMENT_{$c}_STATUS_TITLE", $this->_seamless->getText('active'));
define("MODULE_PAYMENT_{$c}_STATUS_DESC", '');
Expand Down Expand Up @@ -286,6 +298,12 @@ public function selection()
}

$paymentType = $this->_paymenttype;

// avoid duplicate invocation
if (isset(self::$_selectionCache[$paymentType])) {
return self::$_selectionCache[$paymentType];
}

if($paymentType == WirecardCEE_Stdlib_PaymentTypeAbstract::MAESTRO
|| $paymentType == WirecardCEE_Stdlib_PaymentTypeAbstract::CCARD_MOTO
)
Expand Down Expand Up @@ -319,7 +337,10 @@ public function selection()
}
}

return array('id' => $this->code, 'module' => $this->title, 'description' => $this->info, 'fields' => $fields);
$content = array('id' => $this->code, 'module' => $this->title, 'description' => $this->info, 'fields' => $fields);
self::$_selectionCache[$this->_paymenttype] = $content;

return $content;
}


Expand Down
80 changes: 80 additions & 0 deletions includes/modules/payment/wcs_top.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/**
* Shop System Plugins - Terms of Use
*
* The plugins offered are provided free of charge by Wirecard Central Eastern
* Europe GmbH
* (abbreviated to Wirecard CEE) and are explicitly not part of the Wirecard
* CEE range of products and services.
*
* They have been tested and approved for full functionality in the standard
* configuration
* (status on delivery) of the corresponding shop system. They are under
* General Public License Version 2 (GPLv2) and can be used, developed and
* passed on to third parties under the same terms.
*
* However, Wirecard CEE does not provide any guarantee or accept any liability
* for any errors occurring when used in an enhanced, customized shop system
* configuration.
*
* Operation in an enhanced, customized configuration is at your own risk and
* requires a comprehensive test phase by the user of the plugin.
*
* Customers use the plugins at their own risk. Wirecard CEE does not guarantee
* their full functionality neither does Wirecard CEE assume liability for any
* disadvantages related to the use of the plugins. Additionally, Wirecard CEE
* does not guarantee the full functionality for customized shop systems or
* installed plugins of other vendors of plugins within the same shop system.
*
* Customers are responsible for testing the plugin's functionality before
* starting productive operation.
*
* By installing the plugin into the shop system the customer agrees to these
* terms of use. Please do not use the plugin if you do not agree to these
* terms of use!
*
* @author WirecardCEE
* @copyright WirecardCEE
* @license GPLv2
*/

/**
* This file must be include before loading application_top
* You dont have any gambio features available
*/

/**
* Hide some POST params from gambio (ugly hack)
* If language and/or curreny are found by gambio (when including application_top), a 301 is generated.
* This behaviour breaks the server2server confirm and the return POST requests.
*
* @param bool $restore
*/
function wcs_preserve_postparams($restore = false)
{
static $preserved = [];

$params = [
'language',
'currency'
];

if (!isset($_POST)) {
return;
}

if ($restore) {
foreach ($preserved as $p => $v) {
$_POST[$p] = $v;
}

return;
}

foreach ($params as $p) {
if (isset($_POST[$p])) {
$preserved[$p] = $_POST[$p];
unset($_POST[$p]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ $(document).ready(function () {
checkoutPaymentArea.find('.continue_button').on('click', function (e) {

var code = checkoutPaymentArea.find("input[name='payment']:radio:checked").val();
if (typeof code == "undefined") {
code = checkoutPaymentArea.find("input[name='payment']").val();
}

// not a wirecard payment
if (!code.match(/^wcs_/))
return true;
Expand Down