Skip to content

Commit

Permalink
Merge branch 'hotfix/2.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabil Berhouche committed Dec 15, 2020
2 parents 89ef612 + f2b6e0c commit 0eec510
Show file tree
Hide file tree
Showing 15 changed files with 277 additions and 224 deletions.
59 changes: 59 additions & 0 deletions Block/Adminhtml/System/Config/Form/Field/Standard/CardInfoMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* Copyright © Lyra Network.
* This file is part of PayZen plugin for Magento 2. See COPYING.md for license details.
*
* @author Lyra Network (https://www.lyra.com/)
* @copyright Lyra Network
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace Lyranetwork\Payzen\Block\Adminhtml\System\Config\Form\Field\Standard;

/**
* Custom renderer for the card info mode field.
*/

class CardInfoMode extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* Retrieve element HTML markup.
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
return parent::_getElementHtml($element) . "\n" . $this->renderScript($element);
}

/**
* Render element JavaScript code.
*
* @return string
*/
protected function renderScript(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$warningMessage = __('Warning, some payment means are not compatible with an integration by iframe. Please consult the documentation for more details.');

$script = '
<script>
require([
"prototype"
], function () {
var element = $("' . $element->getId() . '");
Event.observe(element, "change", function() {
var cardDataMode = element.options[element.selectedIndex].value;
if (cardDataMode == 3) {
if (! confirm("' . $warningMessage . '")) {
element.value = "' . $element->getValue(). '";
}
}
});
});
</script>';

return $script;
}
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.5.1, 2020-12-15:
- Display warning message on payment in iframe mode enabling.
- Bug fix: Manage PSP_100 errors when calling REST web services.
- Bug fix: Error 500 due to obsolete function (get_magic_quotes_gpc) in PHP 7.4.

2.5.0, 2020-11-25:
- [embedded] Bug fix: Empty cart to avoid double payments with REST API.
- [franfinance] Added new FranFinance submodule.
Expand Down
20 changes: 0 additions & 20 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,26 +402,6 @@ public function getOtherPaymentModelConfig()
return $connection->fetchAll($select);
}

/**
* Check if server has requirements to do WS operations.
*
* @throws \Lyranetwork\Payzen\Model\WsException
*/
public function checkWsRequirements()
{
if (! extension_loaded('soap')) {
throw new \Lyranetwork\Payzen\Model\WsException(
'SOAP extension for PHP must be enabled on the server in order to use PayZen web services.'
);
}

if (! extension_loaded('openssl')) {
throw new \Lyranetwork\Payzen\Model\WsException(
'OPENSSL extension for PHP must be enabled on the server in order to use PayZen web services.'
);
}
}

/**
* Unserialize data using JSON or PHP unserialize function if error.
*
Expand Down
5 changes: 3 additions & 2 deletions Helper/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ public function checkResult($response, $expectedStatuses = array())
if ($response['status'] !== 'SUCCESS') {
$msg = $answer['errorMessage'] . ' (' . $answer['errorCode'] . ').';
if (isset($answer['detailedErrorMessage']) && ! empty($answer['detailedErrorMessage'])) {
$msg .= ' Detailed message: ' . $answer['detailedErrorMessage'] .' (' . $answer['detailedErrorCode'] . ').';
$msg .= ' Detailed message: ' . $answer['detailedErrorMessage'] . ($answer['detailedErrorCode'] ?
' (' . $answer['detailedErrorCode'] . ').' : '');
}

throw new \Exception($msg);
throw new \Lyranetwork\Payzen\Model\RestException($msg, $answer['errorCode']);
} elseif (! empty($expectedStatuses) && ! in_array($answer['detailedStatus'], $expectedStatuses)) {
throw new \UnexpectedValueException(
"Unexpected transaction status returned ({$answer['detailedStatus']})."
Expand Down
23 changes: 0 additions & 23 deletions Model/Api/PayzenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,28 +326,5 @@ public static function sign($parameters, $key, $algo, $hashed = true)
throw new \InvalidArgumentException("Unsupported algorithm passed : {$algo}.");
}
}

/**
* PHP is not yet a sufficiently advanced technology to be indistinguishable from magic...
* so don't use magic_quotes, they mess up with the gateway response analysis.
*
* @param array $potentially_quoted_data
* @return mixed
*/
public static function uncharm($potentially_quoted_data)
{
if (get_magic_quotes_gpc()) {
$sane = array();
foreach ($potentially_quoted_data as $k => $v) {
$sane_key = stripslashes($k);
$sane_value = is_array($v) ? self::uncharm($v) : stripslashes($v);
$sane[$sane_key] = $sane_value;
}
} else {
$sane = $potentially_quoted_data;
}

return $sane;
}
}
}
2 changes: 1 addition & 1 deletion Model/Api/PayzenResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class PayzenResponse
*/
public function __construct($params, $ctx_mode, $key_test, $key_prod, $algo = PayzenApi::ALGO_SHA1)
{
$this->rawResponse = PayzenApi::uncharm($params);
$this->rawResponse = $params;
$this->certificate = trim(($ctx_mode == 'PRODUCTION') ? $key_prod : $key_test);

if (in_array($algo, PayzenApi::$SUPPORTED_ALGOS)) {
Expand Down
Loading

0 comments on commit 0eec510

Please sign in to comment.