Skip to content

Commit

Permalink
[BOT] Migrate hotfix 1.13.7 to GitHub.
Browse files Browse the repository at this point in the history
  • Loading branch information
nabil509 committed Nov 24, 2020
1 parent dc98b43 commit 66b4892
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.13.7, 2020-11-24:
- [embedded] Bug fix: Embedded payment fields not correctly displayed since the last gateway JS library delivery on PrestaShop 1.6.
- [embedded] Bug fix: Update token on minicart change on PrestaShop 1.6.
- Minor fix.

1.13.6, 2020-10-27:
- [embedded] Bug fix: Display 3DS result for REST API payments.
- Display warning message when only offline refund is possible.
Expand Down
2 changes: 1 addition & 1 deletion payzen/classes/PayzenTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PayzenTools

private static $CMS_IDENTIFIER = 'PrestaShop_1.5-1.7';
private static $SUPPORT_EMAIL = '[email protected]';
private static $PLUGIN_VERSION = '1.13.6';
private static $PLUGIN_VERSION = '1.13.7';
private static $GATEWAY_VERSION = 'V2';

const ORDER_ID_REGEX = '#^[a-zA-Z0-9]{1,9}$#';
Expand Down
31 changes: 31 additions & 0 deletions payzen/controllers/front/rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,42 @@ public function __construct()
$this->logger = PayzenTools::getLogger();
}

public function getToken()
{
$cart = $this->context->cart;

$payment = new PayzenStandardPayment();
$token = $payment->getFormToken($cart);

if ($token) {
$json = array('token' => $token);

if (Tools::getValue('refreshIdentifierToken')) {
$identifierToken = $payment->getFormToken($cart, true);
$json['identifierToken'] = $identifierToken;
}
} else {
$json = array(
'status' => 'error',
'message' => $this->l('Error when creating token.')
);
}

die(Tools::jsonEncode($json));
}

/**
* @see FrontController::postProcess()
*/
public function postProcess()
{
if (Tools::getValue('refreshToken')) {
$this->logger->logInfo('Cart has been updated, let\'s refresh form token.');
$this->getToken();

return;
}

$this->logger->logInfo("User return to shop process starts.");

if (! $this->checkRestReturnValidity()) {
Expand Down
5 changes: 4 additions & 1 deletion payzen/payzen.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct()
{
$this->name = 'payzen';
$this->tab = 'payments_gateways';
$this->version = '1.13.6';
$this->version = '1.13.7';
$this->author = 'Lyra Network';
$this->controllers = array('redirect', 'submit', 'rest', 'iframe');
$this->module_key = 'f3e5d07f72a9d27a5a09196d54b9648e';
Expand Down Expand Up @@ -893,6 +893,9 @@ public function hookHeader($params)

$this->context->smarty->assign('payzen_rest_theme', $rest_theme);

$page = Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order';

Media::addJsDef(array('payzen' => array('restUrl' => $return_url, 'pageType' => $page)));
$this->addJS('rest.js');
}
}
Expand Down
38 changes: 38 additions & 0 deletions payzen/views/js/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,44 @@
*/

$(function() {
$('#total_price').on('DOMSubtreeModified', function() {
// If it's one-page checkout, do nothing.
if (payzen.pageType === 'order-opc') {
return;
}

var refreshData = 'refreshToken=1';
if (typeof $('#payzen_payment_by_identifier') !== 'undefined') {
refreshData += '&refreshIdentifierToken=1';
}

$.ajax({
type: 'POST',
url: decodeURIComponent(payzen.restUrl),
async: false,
cache: false,
data: refreshData,
success: function(json) {
var response = JSON.parse(json);

if (response.token) {
var token = response.token;
sessionStorage.setItem('payzenToken', response.token);

if (response.identifierToken) {
sessionStorage.setItem('payzenIdentifierToken', response.identifierToken);

if ($('#payzen_payment_by_identifier').val() == '1') {
token = response.identifierToken;
}
}

KR.setFormConfig({ formToken: token, language: PAYZEN_LANGUAGE });
}
}
});
});

setTimeout(function() {
if ($('#cgv').length) {
if ($('#cgv').is(':checked')) {
Expand Down
6 changes: 1 addition & 5 deletions payzen/views/templates/hook/bc/payment_choozeo.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,17 @@
</div>

<script type="text/javascript">
// <![CDATA[
$('div.payment_module.payzen_choozeo a img').on('click', function(e) {
$(this).parent().find('input').prop("checked", true);
$(this).parent().find('input').prop('checked', true);
$('#payzen_choozeo').submit();
});
// ]]>
</script>

{if {$payzen_choozeo_options|@count} == 1}
<script type="text/javascript">
// <![CDATA[
$('div.payment_module.payzen_choozeo a').on('hover', function(e) {
$('div.payment_module.payzen_choozeo a form .payzen_card_click img').toggleClass('hover');
});
// ]]>
</script>
{/if}

Expand Down
12 changes: 9 additions & 3 deletions payzen/views/templates/hook/bc/payment_std_oneclick.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
</ul>

<script type="text/javascript">
$(document).ready(function() {
sessionStorage.setItem('payzenIdentifierToken', "{$payzen_rest_identifier_token|escape:'html':'UTF-8'}");
sessionStorage.setItem('payzenToken', "{$payzen_rest_form_token|escape:'html':'UTF-8'}");
});
function payzenOneclickPaymentSelect(paymentByIdentifier) {
if (paymentByIdentifier) {
$('#payzen_oneclick_payment_description_1').show();
Expand All @@ -64,13 +69,14 @@
{if ($payzen_std_card_data_mode == '5')}
$('.payzen .kr-form-error').html('');
var token;
if ($('#payzen_payment_by_identifier').val() == '1') {
var token = "{$payzen_rest_identifier_token|escape:'html':'UTF-8'}";
token = sessionStorage.getItem('payzenIdentifierToken');
} else {
var token = "{$payzen_rest_form_token|escape:'html':'UTF-8'}";
token = sessionStorage.getItem('payzenToken');
}
KR.setFormConfig({ formToken: token });
KR.setFormConfig({ formToken: token, language: PAYZEN_LANGUAGE });
{/if}
}
</script>
Expand Down
9 changes: 8 additions & 1 deletion payzen/views/templates/hook/bc/payment_std_rest.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<img class="logo" src="{$payzen_logo|escape:'html':'UTF-8'}" alt="PayZen" />{$payzen_title|escape:'html':'UTF-8'}

<div id="payzen_standard_rest_wrapper" style="padding-top: 10px; padding-left: 40px;">
<div class="kr-embedded"{if $payzen_rest_popin} kr-popin{/if} kr-form-token="{$payzen_rest_identifier_token|escape:'html':'UTF-8'}">
<div class="kr-embedded"{if $payzen_rest_popin} kr-popin{/if}>
<div class="kr-pan"></div>
<div class="kr-expiry"></div>
<div class="kr-security-code"></div>
Expand All @@ -36,6 +36,13 @@
</div>
</div>

<script type="text/javascript">
$('#payzen_standard_rest_wrapper').ready(function() {
KR.removeForms();
KR.setFormConfig({ formToken: "{$payzen_rest_identifier_token|escape:'html':'UTF-8'}", language: PAYZEN_LANGUAGE });
});
</script>

{if $payzen_saved_identifier}
{include file="./payment_std_oneclick.tpl"}
<input id="payzen_payment_by_identifier" type="hidden" name="payzen_payment_by_identifier" value="1" />
Expand Down
2 changes: 0 additions & 2 deletions payzen/views/templates/hook/payment_choozeo.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@

<!--[if IE]>
<script type="text/javascript">
// <![CDATA[
$('#payzen_choozeo label.payzen_card_click img').on('click', function(e) {
$(this).parent().click();
});
// ]]>
</script>
<![endif]-->
2 changes: 1 addition & 1 deletion payzen/views/templates/hook/payment_std_oneclick.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
var token = "{$payzen_rest_form_token|escape:'html':'UTF-8'}";
}
KR.setFormConfig({ formToken: token });
KR.setFormConfig({ formToken: token, language: PAYZEN_LANGUAGE });
{/if}
}
</script>
Expand Down
6 changes: 3 additions & 3 deletions payzen/views/templates/hook/payment_std_rest.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<div class="kr-pan"></div>
<div class="kr-expiry"></div>
<div class="kr-security-code"></div>
<button type="button" class="kr-payment-button" {if !$payzen_rest_popin}style="display:none;"{/if}></button>
<button type="button" class="kr-payment-button" {if !$payzen_rest_popin}style="display: none;"{/if}></button>
<div class="kr-field processing" style="display: none; border: none !important;">
<div style="background-image: url('{$smarty.const._MODULE_DIR_|escape:'html':'UTF-8'}payzen/views/img/loading_big.gif');
margin: 0 auto; display: block; height: 35px; background-color: #ffffff; background-position: center;
background-repeat: no-repeat; background-size: 35px;">
margin: 0 auto; display: block; height: 35px; background-color: #ffffff; background-position: center;
background-repeat: no-repeat; background-size: 35px;">
</div>
</div>

Expand Down

0 comments on commit 66b4892

Please sign in to comment.