Skip to content

Commit

Permalink
Merge branch 'hotfix/2.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabil Berhouche committed Feb 1, 2021
2 parents 1b9740b + 18fe56e commit e2f954b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 23 deletions.
12 changes: 7 additions & 5 deletions Block/Adminhtml/System/Config/Form/Field/NotifyUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
->getUrl($element->getValue(), $params);
$element->setValue($notifyUrl);

$warnImg = $this->getViewFileUrl('Lyranetwork_Payzen::images/warn.png');
$comment = '<img src="' . $warnImg . '" style="vertical-align: middle; padding-right: 5px; height: 30px;"/>';
$comment .= '<span style="color: red; font-weight: bold; display: inline-block; width: 88%; vertical-align: middle;">'
. $element->getComment() . '</span>';
$element->setComment($comment);
if (strpos($element->getComment(), '<img') === false) {
$warnImg = $this->getViewFileUrl('Lyranetwork_Payzen::images/warn.png');
$comment = '<img src="' . $warnImg . '" style="vertical-align: middle; padding-right: 5px; height: 30px;"/>';
$comment .= '<span style="color: red; font-weight: bold; display: inline-block; width: 88%; vertical-align: middle;">'
. $element->getComment() . '</span>';
$element->setComment($comment);
}

return parent::render($element);
}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2.5.3, 2021-02-01:
- Fix installment information when saving the payment details in the Magento Back Office.
- Workarround to avoid conflict with "Payment & Shipping restrictions" plugin.

2.5.2, 2021-01-05:
- [embedded] Bug fix: Use the last version of PrototypeJS library when embedded payment fields option is enabled.
- Minor code fixes.
Expand Down
11 changes: 2 additions & 9 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
*/
protected $filesystem;

/**
* @var \Magento\Config\Model\Config\Structure
*/
protected $configStructure;

/**
* @var \Lyranetwork\Payzen\Model\Logger\Payzen
*/
Expand Down Expand Up @@ -120,7 +115,6 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
* @param \Magento\Framework\App\MaintenanceMode $maintenanceMode
* @param \Magento\Config\Model\ResourceModel\Config $resourceConfig
* @param \Magento\Framework\Filesystem $filesystem
* @param \Magento\Config\Model\Config\Structure $configStructure
* @param \Lyranetwork\Payzen\Model\Logger\Payzen
* @param \Magento\Framework\App\State $appState
* @param \Zend\Http\PhpEnvironment\RemoteAddress $remoteAddress
Expand All @@ -135,7 +129,6 @@ public function __construct(
\Magento\Framework\App\MaintenanceMode $maintenanceMode,
\Magento\Config\Model\ResourceModel\Config $resourceConfig,
\Magento\Framework\Filesystem $filesystem,
\Magento\Config\Model\Config\Structure $configStructure,
\Lyranetwork\Payzen\Model\Logger\Payzen $logger,
\Magento\Framework\App\State $appState,
\Zend\Http\PhpEnvironment\RemoteAddress $remoteAddress,
Expand All @@ -150,7 +143,6 @@ public function __construct(
$this->maintenanceMode = $maintenanceMode;
$this->resourceConfig = $resourceConfig;
$this->filesystem = $filesystem;
$this->configStructure = $configStructure;
$this->logger = $logger;
$this->appState = $appState;
$this->remoteAddress = $remoteAddress;
Expand Down Expand Up @@ -331,7 +323,8 @@ public function getGroupTitle($path)
$parts = explode('/', $path);
$parentPath = 'payment/' . $parts[1] . '/' . $parts[2]; // We need the second level group.

return __($this->configStructure->getElement($parentPath)->getLabel())->render();
$configStructure = $this->objectManager->create('Magento\Config\Model\Config\Structure');
return __($configStructure->getElement($parentPath)->getLabel())->render();
}

/**
Expand Down
18 changes: 12 additions & 6 deletions Helper/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,11 @@ public function updatePaymentInfo(\Magento\Sales\Model\Order $order, \Lyranetwor
// Get choosen payment option if any.
$option = @unserialize($order->getPayment()->getAdditionalInformation(\Lyranetwork\Payzen\Helper\Payment::MULTI_OPTION));

if ($response->get('sequence_number') == 1 && (stripos($order->getPayment()->getMethod(), 'payzen_multi') === 0)
// Check if it's the first installment.
$isFirstInstallment = ($response->get('sequence_number') == 1)
|| (strpos($response->get('payment_config'), 'MULTI') !== false);

if ($isFirstInstallment && (stripos($order->getPayment()->getMethod(), 'payzen_multi') === 0)
&& is_array($option) && ! empty($option)) {
$count = (int) $option['count'];

Expand All @@ -398,18 +402,20 @@ public function updatePaymentInfo(\Magento\Sales\Model\Order $order, \Lyranetwor
// Installment amount, double cast to avoid rounding.
$installmentAmount = (int) (string) (($totalAmount - $firstAmount) / ($count - 1));

for ($i = 1; $i <= $count; $i++) {
$firstSeqNum = $response->get('sequence_number') ? (int) $response->get('sequence_number') : 1;

for ($i = $firstSeqNum; $i < $firstSeqNum + $count; $i++) {
$transactionId = $response->get('trans_id') . '-' . $i;

$delay = (int) $option['period'] * ($i - 1);
$date->setTimestamp(strtotime("+$delay days", $timestamp));

switch (true) {
case ($i == 1): // First transaction.
case ($i == $firstSeqNum): // First transaction.
$amount = $firstAmount;
break;

case ($i == $count): // Last transaction.
case ($i == $firstSeqNum + $count - 1): // Last transaction.
$amount = $totalAmount - $firstAmount - $installmentAmount * ($i - 2);
break;

Expand Down Expand Up @@ -443,8 +449,8 @@ public function updatePaymentInfo(\Magento\Sales\Model\Order $order, \Lyranetwor
\IntlDateFormatter::NONE
),
'Transaction ID' => $transactionId,
'Transaction UUID' => ($i == 1) ? $response->get('trans_uuid') : '',
'Transaction Status' => ($i == 1) ? $response->getTransStatus() : $this->getNextTransStatus($response->getTransStatus()),
'Transaction UUID' => ($i == $firstSeqNum) ? $response->get('trans_uuid') : '',
'Transaction Status' => ($i == $firstSeqNum) ? $response->getTransStatus() : $this->getNextTransStatus($response->getTransStatus()),
'Means of payment' => $response->get('card_brand'),
'Card Number' => $response->get('card_number'),
'Expiration Date' => $expiry,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"php" : "~5.5.0|~5.6.0|~7"
},
"type" : "magento2-module",
"version" : "2.5.2",
"version" : "2.5.3",
"license" : "OSL-3.0",
"autoload" : {
"files" : [
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<payzen>
<general>
<support_email>[email protected]</support_email>
<plugin_version>2.5.2</plugin_version>
<plugin_version>2.5.3</plugin_version>
<gateway_version>V2</gateway_version>
<cms_identifier>Magento_2.x</cms_identifier>
<enable_logs>1</enable_logs>
Expand Down
2 changes: 1 addition & 1 deletion i18n/fr_FR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@

"The configuration of the PayZen module has been successfully reset.","La configuration du module PayZen a été réinitialisée avec succès."
"The field &laquo; %1 &raquo; is invalid: please check column &laquo; %2 &raquo; of the option %3 in section &laquo; %4 &raquo;.","Le champ &laquo; %1 &raquo; est invalide: veuillez vérifier la colonne &laquo; %2 &raquo; de l'option %3 dans la section &laquo; %4 &raquo;."
"Invalid value for field &laquo; %s &raquo; in section &laquo; %s &raquo;.","Valeur invalide pour le champ &laquo; %s &raquo; dans la section &laquo; %s &raquo;."
"Invalid value for field &laquo; %1 &raquo; in section &laquo; %2 &raquo;.","Valeur invalide pour le champ &laquo; %1 &raquo; dans la section &laquo; %2 &raquo;."
"The field &laquo; %1 &raquo; is required for section &laquo; %2 &raquo;.","Le champ &laquo; %1 &raquo; est obligatoire pour la section &laquo; %2 &raquo;."
"You cannot enable several options with the same means of payment.","Vous ne pouvez pas activer plusieurs options avec le même moyen de paiement."
"Too many card types are selected.","Trop de types de carte sont sélectionnés."
Expand Down

0 comments on commit e2f954b

Please sign in to comment.