Skip to content

Commit

Permalink
Merge branch 'release/1.17.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alima Grine committed Mar 6, 2024
2 parents 15d70a3 + 2815778 commit 9021ced
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 56 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.17.0, 2024-02-27:
- [smartform] Display Smartform payment means as smart buttons.
- Bug fix: Fix messages generated at the end of the payment when customer service option is disabled.
- Bug fix: Skip the use of the class Media to add JS for PrestaShop 1.5.x.

1.16.6, 2024-02-14:
- Bug fix: Fix module custom order statuses creation during installation.

Expand Down
2 changes: 1 addition & 1 deletion payzen/classes/PayzenTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PayzenTools

private static $CMS_IDENTIFIER = 'PrestaShop_1.5-8.x';
private static $SUPPORT_EMAIL = '[email protected]';
private static $PLUGIN_VERSION = '1.16.6';
private static $PLUGIN_VERSION = '1.17.0';
private static $GATEWAY_VERSION = 'V2';

const ORDER_ID_REGEX = '#^[a-zA-Z0-9]{1,9}$#';
Expand Down
26 changes: 14 additions & 12 deletions payzen/payzen.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct()
{
$this->name = 'payzen';
$this->tab = 'payments_gateways';
$this->version = '1.16.6';
$this->version = '1.17.0';
$this->author = 'Lyra Network';
$this->controllers = array('redirect', 'submit', 'rest', 'iframe');
$this->module_key = 'f3e5d07f72a9d27a5a09196d54b9648e';
Expand Down Expand Up @@ -1143,9 +1143,11 @@ public function hookHeader($params)

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

$page = Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order';
if (version_compare(_PS_VERSION_, '1.6', '>=')) {
$page = Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order';
Media::addJsDef(array('payzen' => array('restUrl' => $return_url, 'pageType' => $page)));
}

Media::addJsDef(array('payzen' => array('restUrl' => $return_url, 'pageType' => $page)));
$this->addJS('rest.js');
}

Expand Down Expand Up @@ -2279,17 +2281,17 @@ public function createMessage($order, $response)
$msg->private = 1;
$msg->read = 1;
$msg->save();
}

// Create order message anyway to prevent changes on PrestaShop coming versions.
$msg = new Message();
$msg->message = $message;
$msg->id_order = (int) $order->id;
$msg->private = 1;
$msg->add();
// Create order message anyway to prevent changes on PrestaShop coming versions.
$msg = new Message();
$msg->message = $message;
$msg->id_order = (int) $order->id;
$msg->private = 1;
$msg->add();

// Mark message as read to archive it.
Message::markAsReaded($msg->id, 0);
// Mark message as read to archive it.
Message::markAsReaded($msg->id, 0);
}
}

private function jsonDecode($parameter)
Expand Down
2 changes: 1 addition & 1 deletion payzen/translations/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
$_MODULE['<{payzen}prestashop>back_office_943a7be3376d9d06d7fad4ba77229384'] = 'Nombre de tentatives de paiement par cartes';
$_MODULE['<{payzen}prestashop>back_office_6c73b22a547b4a052798d7d3ecdd044e'] = 'Nombre maximum de tentatives de paiement par cartes après un paiement en échec (entre 0 et 2). Si vide, la valeur par défaut de la plateforme est 2.';
$_MODULE['<{payzen}prestashop>back_office_987e8645a41e4ead21765654a6a21a5a'] = 'Paiement par alias';
$_MODULE['<{payzen}prestashop>back_office_3c766a16347c040785e2fa8f2c9ae292'] = 'Cette option permet de régler une commande sans resaisir les données bancaires à chaque paiement. L\'option \"Paiement par alias\" doit être activée sur votre boutique %s pour utiliser cette fonctionnalité.';
$_MODULE['<{payzen}prestashop>back_office_3c766a16347c040785e2fa8f2c9ae292'] = 'Cette option permet de régler une commande sans ressaisir les données bancaires à chaque paiement. L\'option \"Paiement par alias\" doit être activée sur votre boutique %s pour utiliser cette fonctionnalité.';
$_MODULE['<{payzen}prestashop>back_office_36bba20df9199b8c6c63e453327561ef'] = 'PAIEMENT EN PLUSIEURS FOIS';
$_MODULE['<{payzen}prestashop>back_office_1a6ef700f6d3393bc04df6848fff8ac5'] = 'ATTENTION: L\'activation de la fonctionnalité de paiement en nfois est soumise à accord préalable de Société Générale.';
$_MODULE['<{payzen}prestashop>back_office_b2dfd930fcfa8ae0afdf512070c87a27'] = 'Si vous activez cette fonctionnalité alors que vous ne disposez pas de cette option, une erreur 10000 – INSTALLMENTS_NOT_ALLOWED ou 07 - PAYMENT_CONFIG sera générée et l\'acheteur sera dans l\'incapacité de payer.';
Expand Down
8 changes: 4 additions & 4 deletions payzen/views/css/payzen.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ button.kr-popin-button {
cursor: pointer !important;
}

.kr-smart-form[kr-single-payment-button] {
max-width: 100%;
}

.payzen-show-options {
display: block !important;
}

.payzen-hide-confirmation {
display: none !important;
}
4 changes: 0 additions & 4 deletions payzen/views/css/payzen_bc.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,3 @@ label.payzen_label {
display: inline-block;
vertical-align: middle;
}

.kr-smart-form[kr-single-payment-button] {
max-width: 100%;
}
39 changes: 34 additions & 5 deletions payzen/views/js/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

$(function() {
$('#total_price').on('DOMSubtreeModified', function() {
if (typeof (payzen) === 'undefined') {
return;
}

// If it's one-page checkout, do nothing.
if (payzen.pageType === 'order-opc') {
return;
Expand Down Expand Up @@ -90,8 +94,8 @@ var payzenInitRestEvents = function() {
}

// Reset PrestaShop confirmation button style on error.
var conditions = $('#conditions_to_approve\\[terms-and-conditions\\]');
if (conditions.is(":checked")) {
var approvedConditions = $('input[name*="conditions_to_approve\"]:checked').length == $('input[name*="conditions_to_approve\"]').length;
if (approvedConditions) {
$("#payment-confirmation button.btn").removeClass('disabled');
}

Expand All @@ -117,22 +121,41 @@ var payzenInitRestEvents = function() {
$('.payzen .kr-form-error').html('');
});

KR.button.onClick(function() {
KR.smartForm.onClick(function({paymentMethod, action, formId}) {
// Hide oneclick description if it is present and is not popin mode.
if ($('#payzen_oneclick_payment_description').length && ! $('.payzen .kr-popin-button').length && ! $('.payzen .kr-type-popin').length) {
$('#payzen_oneclick_payment_description').hide();
}

return payzenCheckTermsAndConditions(paymentMethod);
});

KR.onPopinClosed(function() {
// Reset PrestaShop confirmation button style on popin close.
var conditions = $('#conditions_to_approve\\[terms-and-conditions\\]');
if (conditions.is(":checked")) {
if (payzenCanProceed()) {
$("#payment-confirmation button.btn").removeClass('disabled');
}
});
};

var payzenCheckTermsAndConditions = function(paymentMethod) {
if (! payzenCanProceed()) {
KR.throwCustomError(payzenTranslate("CLIENT_312"), paymentMethod);
return false;
}

return true;
};

var payzenCanProceed = function() {
var approvedConditions = ($('input[name*="conditions_to_approve\"]:checked').length == $('input[name*="conditions_to_approve\"]').length);
if (! approvedConditions || $("#payment-confirmation button.btn").prop('disabled')) {
return false;
}

return true;
};

// Translate error message.
var payzenTranslate = function(code) {
var lang = PAYZEN_LANGUAGE; // Global variable that contains current language.
Expand All @@ -154,6 +177,7 @@ var PAYZEN_ERROR_MESSAGES = {
CLIENT_301: 'Le numéro de carte est invalide. Vérifiez le numéro et essayez à nouveau.',
CLIENT_302: 'La date d\'expiration est invalide. Vérifiez la date et essayez à nouveau.',
CLIENT_303: 'Le code de sécurité CVV est invalide. Vérifiez le code et essayez à nouveau.',
CLIENT_312: 'Veuillez vous assurer que vous avez accepté les conditions générales de vente.',
CLIENT_999: 'Une erreur technique est survenue. Merci de réessayer plus tard.',

INT_999: 'Une erreur technique est survenue. Merci de réessayer plus tard.',
Expand All @@ -174,6 +198,7 @@ var PAYZEN_ERROR_MESSAGES = {
CLIENT_301: 'The card number is invalid. Please check the number and try again.',
CLIENT_302: 'The expiration date is invalid. Please check the date and try again.',
CLIENT_303: 'The card security code (CVV) is invalid. Please check the code and try again.',
CLIENT_312: 'Please make sure you have accepted the terms and conditions.',
CLIENT_999: 'A technical error has occurred. Please try again later.',

INT_999: 'A technical error has occurred. Please try again later.',
Expand All @@ -194,6 +219,7 @@ var PAYZEN_ERROR_MESSAGES = {
CLIENT_301: 'Die Kartennummer ist ungültig. Bitte überprüfen Sie die Nummer und versuchen Sie es erneut.',
CLIENT_302: 'Das Verfallsdatum ist ungültig. Bitte überprüfen Sie das Datum und versuchen Sie es erneut.',
CLIENT_303: 'Der Kartenprüfnummer (CVC) ist ungültig. Bitte überprüfen Sie den Nummer und versuchen Sie es erneut.',
CLIENT_312: 'Bitte akzeptieren Sie unsere Allgemeinen Geschäftsbedingungen.',
CLIENT_999: 'Ein technischer Fehler ist aufgetreten. Bitte Versuchen Sie es später erneut.',

INT_999: 'Ein technischer Fehler ist aufgetreten. Bitte Versuchen Sie es später erneut.',
Expand All @@ -214,6 +240,7 @@ var PAYZEN_ERROR_MESSAGES = {
CLIENT_301: 'El número de tarjeta no es válido. Por favor, compruebe el número y vuelva a intentarlo.',
CLIENT_302: 'La fecha de caducidad no es válida. Por favor, compruebe la fecha y vuelva a intentarlo.',
CLIENT_303: 'El código de seguridad de la tarjeta (CVV) no es válido. Por favor revise el código y vuelva a intentarlo.',
CLIENT_312: 'Es necesario aceptar los términos y condiciones al final de la página para poder proceder con el pago.',
CLIENT_999: 'Ha ocurrido un error técnico. Por favor, inténtelo de nuevo más tarde.',

INT_999: 'Ha ocurrido un error técnico. Por favor, inténtelo de nuevo más tarde.',
Expand All @@ -234,6 +261,7 @@ var PAYZEN_ERROR_MESSAGES = {
CLIENT_301: 'O número do cartão é inválido. Por favor, cheque o número e tente novamente.',
CLIENT_302: 'A data de expiração é inválida. Verifique a data e tente novamente.',
CLIENT_303: 'O código de segurança do cartão (CVV) é inválido. Verifique o código e tente novamente.',
CLIENT_312: 'Certifique-se que aceitou os termos e as condições.',
CLIENT_999: 'Ocorreu um erro técnico. Por favor, tente novamente mais tarde.',

INT_999: 'Ocorreu um erro técnico. Por favor, tente novamente mais tarde.',
Expand All @@ -254,6 +282,7 @@ var PAYZEN_ERROR_MESSAGES = {
CLIENT_301: 'O número do cartão é inválido. Por favor, cheque o número e tente novamente.',
CLIENT_302: 'A data de expiração é inválida. Verifique a data e tente novamente.',
CLIENT_303: 'O código de segurança do cartão (CVV) é inválido. Verifique o código e tente novamente.',
CLIENT_312: 'Certifique-se que aceitou os termos e as condições.',
CLIENT_999: 'Ocorreu um erro técnico. Por favor, tente novamente mais tarde.',

INT_999: 'Ocorreu um erro técnico. Por favor, tente novamente mais tarde.',
Expand Down
4 changes: 2 additions & 2 deletions payzen/views/templates/hook/bc/payment_std_rest.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

{if $payzen_std_card_data_mode == '5'}
<div id="payzen_standard_rest_wrapper" style="padding-top: 10px; padding-left: 40px;">
<div class="kr-embedded"{if $payzen_std_rest_popin_mode == 'True'} kr-popin{/if}
<div class="kr-embedded"{if $payzen_std_rest_popin_mode == 'True'} kr-popin {/if}
kr-form-token="{$payzen_rest_identifier_token|escape:'html':'UTF-8'}"
kr-language="{$payzen_set_std_rest_language|escape:'html':'UTF-8'}"
{if isset($payzen_set_std_rest_kr_public_key)}kr-public-key="{$payzen_set_std_rest_kr_public_key|escape:'html':'UTF-8'}"{/if}
Expand All @@ -46,7 +46,7 @@
</div>
</div>
{elseif $payzen_std_card_data_mode == '7' || $payzen_std_card_data_mode === '8' || $payzen_std_card_data_mode === '9'}
<div class="kr-smart-form"{if $payzen_std_rest_popin_mode == 'True'} kr-popin {else} kr-single-payment-button {/if} {if $payzen_std_card_data_mode === '8' || $payzen_std_card_data_mode === '9'} kr-card-form-expanded {/if} {if $payzen_std_card_data_mode === '9'} kr-no-card-logo-header {/if} kr-form-token="{$payzen_rest_identifier_token|escape:'html':'UTF-8'}"
<div class="kr-smart-form"{if $payzen_std_rest_popin_mode == 'True'} kr-popin {/if} {if $payzen_std_card_data_mode === '8' || $payzen_std_card_data_mode === '9'} kr-card-form-expanded {/if} {if $payzen_std_card_data_mode === '9'} kr-no-card-logo-header {/if} kr-form-token="{$payzen_rest_identifier_token|escape:'html':'UTF-8'}"
{if isset($payzen_set_std_rest_kr_public_key)}kr-public-key="{$payzen_set_std_rest_kr_public_key|escape:'html':'UTF-8'}"{/if}
{if isset($payzen_set_std_rest_return_url)}kr-post-url-success="{$payzen_set_std_rest_return_url|escape:'html':'UTF-8'}"{/if}
{if isset($payzen_set_std_rest_return_url)}kr-post-url-refused="{$payzen_set_std_rest_return_url|escape:'html':'UTF-8'}"{/if}></div>
Expand Down
63 changes: 36 additions & 27 deletions payzen/views/templates/hook/payment_std_rest.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@
<div class="kr-form-error"></div>
</div>
{elseif $payzen_std_card_data_mode === '7' || $payzen_std_card_data_mode === '8' || $payzen_std_card_data_mode === '9'}
<div class="kr-smart-form" {if $payzen_std_rest_popin_mode == 'True'} kr-popin {else} kr-single-payment-button {/if} {if $payzen_std_card_data_mode === '8' || $payzen_std_card_data_mode === '9'} kr-card-form-expanded {/if} {if $payzen_std_card_data_mode === '9'} kr-no-card-logo-header {/if} kr-form-token="{$payzen_rest_identifier_token|escape:'html':'UTF-8'}"></div>
<div class="kr-smart-form" {if $payzen_std_rest_popin_mode == 'True'} kr-popin {/if} {if $payzen_std_card_data_mode === '8' || $payzen_std_card_data_mode === '9'} kr-card-form-expanded {/if} {if $payzen_std_card_data_mode === '9'} kr-no-card-logo-header {/if} kr-form-token="{$payzen_rest_identifier_token|escape:'html':'UTF-8'}"></div>
{/if}
</section>

<script type="text/javascript">
$(document).ready(function() {
$paymentOptions = $('.payment-option');
if ($paymentOptions && $paymentOptions.length == 1) {
$('input[type="radio"][name="payment-option"]').on('click', function(e) {
payzenManageButtonDisplay();
});
var paymentOptions = $('.payment-option');
if (paymentOptions && paymentOptions.length == 1) {
$("#payment-option-1").prop("checked", true);
$('#payment-option-1-additional-information').addClass('payzen-show-options');
{if $payzen_std_display_title != 'True'}
$('#payment-option-1-container').hide();
Expand All @@ -51,10 +56,6 @@
$('#payment-option-1-additional-information').removeClass('payzen-show-options');
}
{if $payzen_std_rest_popin_mode != 'True'}
KR.setFormConfig({ form: { smartform: { singlePaymentButton: { visibility: false } } } });
{/if}
{if $payzen_std_smartform_compact_mode == 'True'}
KR.setFormConfig({ cardForm: { layout: 'compact' }, smartForm: { layout: 'compact'} });
{/if}
Expand All @@ -63,14 +64,9 @@
KR.setFormConfig({ smartForm: { groupingThreshold: "{$payzen_std_smartform_payment_means_grouping_threshold|escape:'html':'UTF-8'}" } });
{/if}
KR.onPaymentMethodSelected(data => {
var element = $('#conditions_to_approve\\[terms-and-conditions\\]');
if (element.is(":checked")) {
$("#payment-confirmation button.btn").removeClass('disabled');
}
});
KR.onFormReady(() => {
payzenManageButtonDisplay();
{if $payzen_std_rest_popin_mode == 'True'}
var element = $(".kr-smart-button");
if (element.length > 0) {
Expand All @@ -82,9 +78,32 @@
}
}
{/if}
});
})
});
var payzenManageButtonDisplay = async function() {
{if ($payzen_std_rest_popin_mode === 'True') || ($payzen_std_card_data_mode === '5')}
return;
{/if}
var methods = await KR.getPaymentMethods().then(function(result) {
return result;
});
// If only the card form is available, hide our payment button and use Prestashop button.
if ((methods.paymentMethods.length == 1) && (methods.paymentMethods[0] == 'CARDS')) {
$(".kr-payment-button").hide();
return;
}
var currentOptionId = $("input[type='radio'][name='payment-option']:checked").attr('id');
if ($("#" + currentOptionId + "-additional-information").find("#payzen_standard_rest_wrapper").length > 0) {
$("#payment-confirmation").addClass('payzen-hide-confirmation');
} else {
$("#payment-confirmation").removeClass('payzen-hide-confirmation');
}
};
var payzenSubmit = function(e) {
e.preventDefault();
Expand All @@ -97,25 +116,15 @@
{/if}
{if $payzen_std_rest_popin_mode == 'True'}
if (smartformModalButton.length === 0 && isSmartform.length > 0) {
var element = jQuery('.kr-smart-button');
var paymentMethod = element.attr('kr-payment-method');
KR.openPaymentMethod(paymentMethod);
} else {
KR.openPopin();
}
KR.openPopin();
$('#payment-confirmation button').removeAttr('disabled');
{else}
$('#payzen_standard').data('submitted', true);
$('.payzen .processing').css('display', 'block');
$('#payment-confirmation button').attr('disabled', 'disabled');
if (isSmartform.length > 0 || smartformModalButton.length > 0) {
KR.openSelectedPaymentMethod();
} else {
KR.submit();
}
KR.submit();
{/if}
}
Expand Down

0 comments on commit 9021ced

Please sign in to comment.