Skip to content

Commit

Permalink
v1.1.1 Adapted structure to fit Prestashop guidelines, setting module…
Browse files Browse the repository at this point in the history
… name in payment options selection
  • Loading branch information
PayXpert Integration committed Apr 24, 2018
1 parent 4a98fdd commit eb7fb07
Show file tree
Hide file tree
Showing 77 changed files with 1,979 additions and 1,648 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.1.1
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The author of this plugin can NEVER be held responsible for this software.
There is no warranty what so ever. You accept this by using this software.

## Changelog
* 1.1.1 - Setting module name in payment options selection
* 1.1.0 - Added iframe option
* 1.0.7 - Supports Prestashop 1.7
* 1.0.1 - Improve Prestashop versions support
Expand Down
4 changes: 2 additions & 2 deletions modules/payxpert/config.xml → config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<module>
<name>payxpert</name>
<displayName><![CDATA[PayXpert Payment Solutions]]></displayName>
<version><![CDATA[1.1.0]]></version>
<version><![CDATA[1.1.1]]></version>
<description><![CDATA[Accept payments today with PayXpert]]></description>
<author><![CDATA[PayXpert]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Are you sure about removing these details?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>
</module>
72 changes: 72 additions & 0 deletions controllers/front/iframe.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* Copyright 2013-2018 PayXpert
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author Regis Vidal
* @copyright 2013-2018 PayXpert
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 (the "License")
*/

require_once dirname(__FILE__) . '/../../lib/Connect2PayClient.php';

/**
*
* @since 1.5.0
*/
class PayxpertIframeModuleFrontController extends ModuleFrontController
{
public $ssl = true;
public $display_column_left = false;

/**
*
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$this->context->controller->addCSS(($this->module->getPath()) . 'views/css/iframe.css', 'all');
$cart = $this->context->cart;

$params = array();

// These should be filled only with Prestashop >= 1.7
$paymentType = Tools::getValue('payment_type', null);
$paymentProvider = Tools::getValue('payment_provider', null);

if (version_compare(_PS_VERSION_, '1.7', '>=')) {
if ($paymentType !== null && PayXpert\Connect2Pay\C2PValidate::isPayment($paymentType)) {
$payment = $this->module->getPaymentClient($cart, $paymentType, $paymentProvider);

if ($payment->preparePayment() == false) {
$message = "PayXpert : can't prepare transaction - " . $payment->getClientErrorMessage();
$this->module->addLog($message, 3);
Tools::redirect($this->module->getPageLinkCompat('order', true, null, "step=3"));
}

$src = $payment->getCustomerRedirectURL();
}
}

$this->context->smarty->assign(
array(/* */
'src' => $src, /* */
'this_link_back' => $this->module->getPageLinkCompat('order', true, null, "step=3")
) /* */
);

$this->setTemplate('module:payxpert/views/templates/hook/iframe.tpl');
}
}
File renamed without changes.
103 changes: 103 additions & 0 deletions controllers/front/payment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
/**
* Copyright 2013-2018 PayXpert
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author Regis Vidal
* @copyright 2013-2018 PayXpert
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 (the "License")
*/

require_once dirname(__FILE__) . '/../../lib/Connect2PayClient.php';

/**
*
* @since 1.5.0
*/
class PayxpertPaymentModuleFrontController extends ModuleFrontController
{
public $ssl = true;
public $display_column_left = false;

/**
*
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();

$cart = $this->context->cart;

// Default value for Prestashop < 1.7
$template = 'payment_execution.tpl';

$params = array();

// These should be filled only with Prestashop >= 1.7
$paymentType = Tools::getValue('payment_type', null);
$paymentProvider = Tools::getValue('payment_provider', null);

if (version_compare(_PS_VERSION_, '1.7', '>=')) {
if ($paymentType !== null && PayXpert\Connect2Pay\C2PValidate::isPayment($paymentType)) {
$params['payment_type'] = $paymentType;

if ($paymentProvider !== null && PayXpert\Connect2Pay\C2PValidate::isProvider($paymentProvider)) {
$params['payment_provider'] = $paymentProvider;
}

switch ($paymentType) {
case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER:
$template = 'module:' . $this->module->name . '/views/templates/front/payment_execution_bank_transfer.tpl';

if (isset($params['payment_provider'])) {
switch ($params['payment_provider']) {
case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_SOFORT:
$paymentLogo = 'sofort';
break;
case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_PRZELEWY24:
$paymentLogo = 'przelewy24';
break;
case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_IDEALKP:
$paymentLogo = 'ideal';
break;
}
}
break;
default:
// Default is Credit Card
$template = 'module:' . $this->module->name . '/views/templates/front/payment_execution_credit_card.tpl';
$paymentLogo = 'creditcard';
break;
}

$this->context->smarty->assign("payment_logo", $paymentLogo);
}
}

$this->context->smarty->assign(
array(/* */
'nbProducts' => $cart->nbProducts(), /* */
'cust_currency' => (int)($cart->id_currency), /* */
'total' => $cart->getOrderTotal(true, Cart::BOTH), /* */
'isoCode' => $this->context->language->iso_code, /* */
'this_path' => $this->module->getPathUri(), /* */
'this_link' => $this->module->getModuleLinkCompat('payxpert', 'redirect', $params), /* */
'this_link_back' => $this->module->getPageLinkCompat('order', true, null, "step=3") /* */
) /* */
);

$this->setTemplate($template);
}
}
67 changes: 67 additions & 0 deletions controllers/front/redirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* Copyright 2013-2018 PayXpert
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author Regis Vidal
* @copyright 2013-2018 PayXpert
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 (the "License")
*/

/**
*
* @since 1.5.0
*
*/
class PayxpertRedirectModuleFrontController extends ModuleFrontController
{
public $ssl = true;

/**
*
* @see FrontController::initContent()
*/
public function initContent()
{
if (!isset($this->context->cart)) {
$this->context->cart = new Cart();
}

$cart = $this->context->cart;

// These should be filled only with Prestashop >= 1.7
$paymentType = Tools::getValue('payment_type', null);
$paymentProvider = Tools::getValue('payment_provider', null);

$errorMessage = $this->module->redirect($cart, $paymentType, $paymentProvider);

$this->display_column_left = false;
parent::initContent();

$this->context->smarty->assign(
array(/* */
'errorMessage' => $errorMessage, /* */
'this_path' => $this->module->getPathUri(), /* */
'this_path_ssl' => Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/payxpert/', /* */
'this_link_back' => $this->module->getPageLinkCompat('order', true, null, "step=3") /* */
) /* */
);

if (version_compare(_PS_VERSION_, '1.7', '>=')) {
$this->setTemplate('module:' . $this->module->name . '/views/templates/front/payment_error17.tpl');
} else {
$this->setTemplate('payment_error.tpl');
}
}
}
57 changes: 57 additions & 0 deletions controllers/front/return.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Copyright 2013-2018 PayXpert
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author Regis Vidal
* @copyright 2013-2018 PayXpert
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 (the "License")
*/

/**
*
* @since 1.5.0
*
*/
class PayxpertReturnModuleFrontController extends ModuleFrontController
{
public $ssl = true;

/**
*
* @see FrontController::initContent()
*/
public function initContent()
{
if (!isset($this->context->cart)) {
$this->context->cart = new Cart();
}

$url = $this->module->getPageLinkCompat('order-confirmation');

$cart = $this->context->cart;
$customer = new Customer((int) ($cart->id_customer));
$ctrlURLPrefix = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://';

$url .= '?id_cart=' . (int)($cart->id) . '&id_module=' . (int)($this->module->id) . '&key=' . $customer->secure_key;

$this->context->smarty->assign(
array(/* */
'url' => $url
) /* */
);

$this->setTemplate('module:' . $this->module->name . '/views/templates/hook/return.tpl');
}
}
Loading

0 comments on commit eb7fb07

Please sign in to comment.