Skip to content

Commit

Permalink
v1.1.0 Added iframe option
Browse files Browse the repository at this point in the history
  • Loading branch information
PayXpert Integration committed Feb 21, 2018
1 parent 7519a06 commit 4a98fdd
Show file tree
Hide file tree
Showing 9 changed files with 287 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.7
1.1.0
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.0 - Added iframe option
* 1.0.7 - Supports Prestashop 1.7
* 1.0.1 - Improve Prestashop versions support
* 1.0.0 - Initial Release
Expand Down
20 changes: 10 additions & 10 deletions modules/payxpert/config.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>payxpert</name>
<displayName><![CDATA[PayXpert Payment Solutions]]></displayName>
<version><![CDATA[1.0.7]]></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>
<name>payxpert</name>
<displayName><![CDATA[PayXpert Payment Solutions]]></displayName>
<version><![CDATA[1.1.0]]></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>
71 changes: 71 additions & 0 deletions modules/payxpert/controllers/front/iframe.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/**
* Copyright 2013-2017 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-2017 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()) . '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);
header('Location: ' . $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');
}
}
56 changes: 56 additions & 0 deletions modules/payxpert/controllers/front/return.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* Copyright 2013-2017 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-2017 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');
}
}
20 changes: 20 additions & 0 deletions modules/payxpert/css/iframe.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.js-payment-your-module-name.disabled iframe {
display: none;
}

.fluidIframe {
position: relative;
padding-bottom: 56.25%; /* proportion value to aspect ratio 16:9 (9 / 16 = 0.5625 or 56.25%) */
padding-top: 30px;
height: 0;
overflow: hidden;
}

.fluidIframe iframe {
border: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
Loading

0 comments on commit 4a98fdd

Please sign in to comment.