Skip to content

Commit

Permalink
Merge branch 'hotfix/2.5.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabil Berhouche committed Mar 9, 2021
2 parents d4a5dfc + d7686be commit 067e653
Show file tree
Hide file tree
Showing 59 changed files with 73 additions and 62 deletions.
6 changes: 3 additions & 3 deletions Block/Payment/Form/Payzen.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private function checkAndGetLogoUrl($fileName)
return false;
}

return $this->getCcTypeImageSrc($fileName, false);
return $this->dataHelper->getLogoImageSrc($fileName);
}

public function getConfigData($name)
Expand Down Expand Up @@ -69,9 +69,9 @@ protected function _toHtml()
return parent::_toHtml();
}

public function getCcTypeImageSrc($card, $cc = true)
public function getCcTypeImageSrc($card)
{
return $this->dataHelper->getCcTypeImageSrc($card, $cc);
return $this->dataHelper->getCcTypeImageSrc($card);
}

public function getCurrentCustomer()
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.5, 2021-03-09:
- Use online payment means logos.
- [franfinance] Send cart details for FranFinance payments.

2.5.4, 2021-02-02:
- Fix installment details errors introduced in 2.5.3 version.

Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Payment/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private function back($msg)
{
// Clear all messages in session.
$this->messageManager->getMessages(true);
$this->messageManager->addError($msg);
$this->messageManager->addErrorMessage($msg);

$this->dataHelper->log($msg . ' Redirecting to backend create order page.');

Expand Down
12 changes: 6 additions & 6 deletions Controller/Adminhtml/Payment/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private function redirectError($order = null)
{
// Clear all messages in session.
$this->messageManager->getMessages(true);
$this->messageManager->addError(__('An error has occurred during the payment process.'));
$this->messageManager->addErrorMessage(__('An error has occurred during the payment process.'));

$this->dataHelper->log('Redirecting to order creation page.' . ($order ? " Order #{$order->getIncrementId()}." : ''));

Expand Down Expand Up @@ -103,7 +103,7 @@ private function redirectResponse($order, $case, $checkUrlWarn = false)
if ($features['prodfaq']) {
// Display going to production message.
$message = __('<u><p>GOING INTO PRODUCTION:</u></p> You want to know how to put your shop into production mode, please read chapters &laquo; Proceeding to test phase &raquo; and &laquo; Shifting the shop to production mode &raquo; in the documentation of the module.');
$this->messageManager->addNotice($message);
$this->messageManager->addNoticeMessage($message);
}

if ($checkUrlWarn) {
Expand All @@ -113,20 +113,20 @@ private function redirectResponse($order, $case, $checkUrlWarn = false)
$message = __('The shop is in maintenance mode.The automatic notification cannot work.');
} else {
$message = __('The automatic validation has not worked. Have you correctly set up the notification URL in your PayZen Back Office?');
$message .= '<br /><br />';
$message .= '&nbsp;<br /><br />';
$message .= __('For understanding the problem, please read the documentation of the module:<br />&nbsp;&nbsp;&nbsp;- Chapter &laquo; To read carefully before going further &raquo;<br />&nbsp;&nbsp;&nbsp;- Chapter &laquo; Notification URL settings &raquo;');
}

$this->messageManager->addError($message);
$this->messageManager->addErrorMessage($message);
}
}

if ($case === Payment::SUCCESS) {
$this->messageManager->addSuccess(
$this->messageManager->addSuccessMessage(
__('The payment was successful. Your order was registered successfully.')
);
} elseif ($case === Payment::FAILURE) {
$this->messageManager->addWarning(__('Your payment was not accepted. Please, try to re-order.'));
$this->messageManager->addWarningMessage(__('Your payment was not accepted. Please, try to re-order.'));
}

$this->dataHelper->log("Redirecting to order view or order index page for order #{$order->getIncrementId()}.");
Expand Down
6 changes: 3 additions & 3 deletions Controller/Adminhtml/Payment/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function execute()
$id = $this->getRequest()->getParam('order_id');
$order = $this->orderRepository->get($id);
if (! $order->getId()) {
$this->messageManager->addError(__('This order no longer exists.'));
$this->messageManager->addErrorMessage(__('This order no longer exists.'));
$resultRedirect->setPath('sales/*/');

return $resultRedirect;
Expand All @@ -87,9 +87,9 @@ public function execute()
$payment->getMethodInstance()->validatePayment($payment);

} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(__('An error has occurred during the validation process.'));
$this->messageManager->addErrorMessage(__('An error has occurred during the validation process.'));
}

$resultRedirect->setPath('sales/order/view',['order_id' => $order->getId()]);
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/System/Config/Reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function execute()
// Clear cache.
$this->cache->clean();

$this->messageManager->addSuccess(
$this->messageManager->addSuccessMessage(
__('The configuration of the PayZen module has been successfully reset.')
);

Expand Down
8 changes: 4 additions & 4 deletions Controller/Payment/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected function redirectResponse($order, $case, $checkUrlWarn = false)
if ($features['prodfaq']) {
// Display going to production message.
$message = __('<u><p>GOING INTO PRODUCTION:</u></p> You want to know how to put your shop into production mode, please read chapters &laquo; Proceeding to test phase &raquo; and &laquo; Shifting the shop to production mode &raquo; in the documentation of the module.');
$this->messageManager->addNotice($message);
$this->messageManager->addNoticeMessage($message);
}

if ($checkUrlWarn) {
Expand All @@ -132,11 +132,11 @@ protected function redirectResponse($order, $case, $checkUrlWarn = false)
$message = __('The shop is in maintenance mode.The automatic notification cannot work.');
} else {
$message = __('The automatic validation has not worked. Have you correctly set up the notification URL in your PayZen Back Office?');
$message .= '<br /><br />';
$message .= '&nbsp;<br /><br />';
$message .= __('For understanding the problem, please read the documentation of the module:<br />&nbsp;&nbsp;&nbsp;- Chapter &laquo; To read carefully before going further &raquo;<br />&nbsp;&nbsp;&nbsp;- Chapter &laquo; Notification URL settings &raquo;');
}

$this->messageManager->addError($message);
$this->messageManager->addErrorMessage($message);
}
}

Expand All @@ -151,7 +151,7 @@ protected function redirectResponse($order, $case, $checkUrlWarn = false)
$resultRedirect = $this->createResult('checkout/onepage/success', ['_scope' => $storeId]);
} else {
if ($case === Payment::FAILURE) {
$this->messageManager->addWarning(__('Your payment was not accepted. Please, try to re-order.'));
$this->messageManager->addWarningMessage(__('Your payment was not accepted. Please, try to re-order.'));
}

$this->dataHelper->log("Restore cart for order #{$order->getIncrementId()} to allow re-order quicker.");
Expand Down
34 changes: 25 additions & 9 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Lyranetwork\Payzen\Block\Adminhtml\System\Config\Form\Field\Gift\AddedCards;
use Lyranetwork\Payzen\Model\Method\Gift;

class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
Expand Down Expand Up @@ -475,26 +477,40 @@ public function getCurrentCustomer($customerSession)
}

/**
* Return card logo source path if exists, else return false.
* Return card logo source path from upload directory or the online logo.
* @param string $card
* @param boolean $cc
*
* @return string|boolean
*/
public function getCcTypeImageSrc($card, $cc = true)
public function getCcTypeImageSrc($card)
{
if ($cc) {
$card = 'cc/' . strtolower($card) . '.png';
$name = strtolower($card) . '.png';

if ($this->isUploadFileImageExists('cc/' . $card)) {
return $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) .
'payzen/images/cc/' . $name;
} else {
return $this->getCommonConfigData('logo_url') . $name;
}
}

if ($this->isUploadFileImageExists($card)) {
/**
* Return submodule logo source path if exists, return false elsewhere.
* @param string $card
*
* @return string|boolean
*/
public function getLogoImageSrc($name)
{
if ($this->isUploadFileImageExists($name)) {
return $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) .
'payzen/images/' . $card;
'payzen/images/' . $name;
} else {
$asset = $this->assetRepo->createAsset('Lyranetwork_Payzen::images/' . $card);
// Default logo from the installed plugin.
$asset = $this->assetRepo->createAsset('Lyranetwork_Payzen::images/' . $name);

if ($this->isPublishFileImageExists($asset->getRelativeSourceFilePath())) {
return $this->getViewFileUrl('Lyranetwork_Payzen::images/' . $card);
return $this->getViewFileUrl('Lyranetwork_Payzen::images/' . $name);
}
}

Expand Down
1 change: 1 addition & 0 deletions Model/Method/Franfinance.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Franfinance extends Payzen

protected $_canUseInternal = false;

protected $needsCartData = true;
protected $currencies = ['EUR'];
protected $countries = ['FR', 'GP', 'MQ', 'GF', 'RE', 'YT'];

Expand Down
18 changes: 9 additions & 9 deletions Model/Method/Payzen.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public function acceptPayment(\Magento\Payment\Model\InfoInterface $payment)
$this->paymentHelper->createInvoice($order);

$order->save();
$this->messageManager->addSuccess(__('The payment has been accepted.'));
$this->messageManager->addSuccessMessage(__('The payment has been accepted.'));

$redirectUrl = $this->urlBuilder->getUrl(
'sales/order/view',
Expand Down Expand Up @@ -583,7 +583,7 @@ public function acceptPayment(\Magento\Payment\Model\InfoInterface $payment)
$message .= $e->getMessage();
}

$this->messageManager->addError($message);
$this->messageManager->addErrorMessage($message);
throw $e;
}
}
Expand All @@ -609,7 +609,7 @@ public function denyPayment(\Magento\Payment\Model\InfoInterface $payment)
if (! $this->restHelper->getPrivateKey($storeId)) {
$this->dataHelper->log("Cannot cancel payment online for order #{$order->getIncrementId()}: private key is not configured, let Magento cancel the payment.");

$this->messageManager->addWarning(__('Payment is cancelled only in Magento. Please, consider cancelling the payment in PayZen Back Office.'));
$this->messageManager->addWarningMessage(__('Payment is cancelled only in Magento. Please, consider cancelling the payment in PayZen Back Office.'));
return true;
}

Expand Down Expand Up @@ -680,7 +680,7 @@ public function denyPayment(\Magento\Payment\Model\InfoInterface $payment)
// Merchant does not subscribe to REST WS option, deny payment offline.
$this->dataHelper->log("Cannot cancel payment online for order #{$order->getIncrementId()}: REST API not available for merchant, let Magento cancel the payment.");

$this->messageManager->addWarning(__('Payment is cancelled only in Magento. Please, consider cancelling the payment in PayZen Back Office.'));
$this->messageManager->addWarningMessage(__('Payment is cancelled only in Magento. Please, consider cancelling the payment in PayZen Back Office.'));
return true;
} else {
$message = __('Cancellation error') . ': ';
Expand All @@ -692,7 +692,7 @@ public function denyPayment(\Magento\Payment\Model\InfoInterface $payment)
$message .= $e->getMessage();
}

$this->messageManager->addError($message);
$this->messageManager->addErrorMessage($message);
throw $e;
}
}
Expand Down Expand Up @@ -807,7 +807,7 @@ public function validatePayment(\Magento\Payment\Model\InfoInterface $payment)
$order->save();

$this->dataHelper->log("Payment information updated for validated order #{$order->getIncrementId()}.");
$this->messageManager->addSuccess(__('Payment validated successfully.'));
$this->messageManager->addSuccessMessage(__('Payment validated successfully.'));
} catch(\UnexpectedValueException $e) {
$this->dataHelper->log(
"Validate payment error: {$e->getMessage()}.",
Expand Down Expand Up @@ -837,14 +837,14 @@ public function validatePayment(\Magento\Payment\Model\InfoInterface $payment)
$message .= $e->getMessage();
}

$this->messageManager->addError($message);
$this->messageManager->addErrorMessage($message);
}
}
}

protected function validatePaymentOffline($order)
{
$this->messageManager->addWarning(__('Payment is validated only in Magento. Please, consider validating the payment in PayZen Back Office.'));
$this->messageManager->addWarningMessage(__('Payment is validated only in Magento. Please, consider validating the payment in PayZen Back Office.'));

// Wrap payment result to use traditional order creation tunnel.
$data = ['vads_trans_status' => 'AUTHORISED'];
Expand Down Expand Up @@ -1145,7 +1145,7 @@ public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount)
} elseif ($e->getCode() === 'PSP_100') {
// Merchant does not subscribe to REST WS option, refund payment offline.
$notice = __('You are not authorized to do this action online. Please, do not forget to update payment in PayZen Back Office.');
$this->messageManager->addWarning($notice);
$this->messageManager->addWarningMessage($notice);
// Magento will do an offline refund.
} else {
$message = __('Refund error') . ': ';
Expand Down
6 changes: 3 additions & 3 deletions Model/PayzenConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function getModuleLogoUrl()
{
$fileName = $this->method->getConfigData('module_logo');

return $this->getCcTypeImageSrc($fileName, false);
return $this->dataHelper->getLogoImageSrc($fileName);
}

protected function getAvailableCcTypes()
Expand Down Expand Up @@ -118,9 +118,9 @@ protected function getEntryMode()
return $this->method->getEntryMode();
}

protected function getCcTypeImageSrc($card, $cc = true)
protected function getCcTypeImageSrc($card)
{
return $this->dataHelper->getCcTypeImageSrc($card, $cc);
return $this->dataHelper->getCcTypeImageSrc($card);
}

protected function renderMaskedPan($maskedPan)
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.4",
"version" : "2.5.5",
"license" : "OSL-3.0",
"autoload" : {
"files" : [
Expand Down
3 changes: 2 additions & 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.4</plugin_version>
<plugin_version>2.5.5</plugin_version>
<gateway_version>V2</gateway_version>
<cms_identifier>Magento_2.x</cms_identifier>
<enable_logs>1</enable_logs>
Expand All @@ -35,6 +35,7 @@
<rest_notify_url>payzen/payment_rest/check</rest_notify_url>
<rest_url>https://api.payzen.eu/api-payment/</rest_url>
<static_url>https://static.payzen.eu/static/</static_url>
<logo_url>https://secure.payzen.eu/static/latest/images/type-carte/</logo_url>

<language>fr</language>
<validation_mode></validation_mode>
Expand Down
Binary file removed view/base/web/images/cc/alinea_cdx.png
Binary file not shown.
Binary file removed view/base/web/images/cc/alinea_cdx_sb.png
Binary file not shown.
Binary file removed view/base/web/images/cc/amex.png
Binary file not shown.
Binary file removed view/base/web/images/cc/cb.png
Binary file not shown.
Binary file removed view/base/web/images/cc/codensa.png
Binary file not shown.
Binary file removed view/base/web/images/cc/diners.png
Binary file not shown.
Binary file removed view/base/web/images/cc/e-cartebleue.png
Binary file not shown.
Binary file removed view/base/web/images/cc/e_cv.png
Binary file not shown.
Binary file removed view/base/web/images/cc/efecty.png
Binary file not shown.
Binary file removed view/base/web/images/cc/epnf_3x.png
Binary file not shown.
Binary file removed view/base/web/images/cc/epnf_4x.png
Binary file not shown.
Binary file removed view/base/web/images/cc/fullcb3x.png
Binary file not shown.
Binary file removed view/base/web/images/cc/fullcb4x.png
Binary file not shown.
Binary file removed view/base/web/images/cc/giropay.png
Binary file not shown.
Binary file removed view/base/web/images/cc/illicado.png
Binary file not shown.
Binary file removed view/base/web/images/cc/illicado_sb.png
Binary file not shown.
Binary file removed view/base/web/images/cc/jcb.png
Binary file not shown.
Binary file removed view/base/web/images/cc/klarna.png
Binary file not shown.
Binary file removed view/base/web/images/cc/maestro.png
Binary file not shown.
Binary file removed view/base/web/images/cc/mastercard.png
Binary file not shown.
Binary file removed view/base/web/images/cc/mastercard_debit.png
Binary file not shown.
Binary file removed view/base/web/images/cc/paypal.png
Binary file not shown.
Binary file removed view/base/web/images/cc/paypal_sb.png
Binary file not shown.
Binary file removed view/base/web/images/cc/postfinance.png
Binary file not shown.
Binary file removed view/base/web/images/cc/postfinance_efin.png
Binary file not shown.
Binary file removed view/base/web/images/cc/pse.png
Diff not rendered.
Binary file removed view/base/web/images/cc/sdd.png
Diff not rendered.
Binary file removed view/base/web/images/cc/sofort_banking.png
Diff not rendered.
Binary file removed view/base/web/images/cc/truffaut_cdx.png
Diff not rendered.
Binary file removed view/base/web/images/cc/truffaut_cdx_sb.png
Diff not rendered.
Binary file removed view/base/web/images/cc/visa.png
Diff not rendered.
Binary file removed view/base/web/images/cc/visa_debit.png
Diff not rendered.
Binary file removed view/base/web/images/cc/visa_electron.png
Diff not rendered.
Binary file removed view/base/web/images/cc/vpay.png
Diff not rendered.
2 changes: 1 addition & 1 deletion view/frontend/web/template/payment/cc-type.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<label data-bind="attr: {for: $parent.getCode() + '_cc_type_' + card.value}">
<!--ko if: card.icon -->
<img data-bind="attr: {src: card.icon, title: card.label}" style="max-height: 35px; max-width: 90px; vertical-align: middle;">
<img data-bind="attr: {src: card.icon, title: card.label, alt: option.key}" style="max-height: 35px; max-width: 90px; vertical-align: middle;">
<!--/ko-->

<!--ko ifnot: card.icon -->
Expand Down
3 changes: 1 addition & 2 deletions view/frontend/web/template/payment/payzen-choozeo.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<!-- ko if: getModuleLogoUrl() -->
<img data-bind="attr: {src: getModuleLogoUrl()}"
class="payment-icon"
alt="PayZen"
style="width: 76px;"
/>
<!--/ko-->
Expand Down Expand Up @@ -65,7 +64,7 @@

<label data-bind="attr: {for: $parent.getCode() + '_option' + option.key}">
<!--ko if: option.icon -->
<img data-bind="attr: {src: option.icon, title: option.label}" style="height: 32px; vertical-align: middle;">
<img data-bind="attr: {src: option.icon, alt: option.key}" style="height: 32px; vertical-align: middle;">
<!--/ko-->

<!--ko ifnot: option.icon -->
Expand Down
1 change: 0 additions & 1 deletion view/frontend/web/template/payment/payzen-franfinance.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<!-- ko if: getModuleLogoUrl() -->
<img data-bind="attr: {src: getModuleLogoUrl()}"
class="payment-icon"
alt="PayZen"
style="width: 76px;"
/>
<!--/ko-->
Expand Down
1 change: 0 additions & 1 deletion view/frontend/web/template/payment/payzen-fullcb.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<!-- ko if: getModuleLogoUrl() -->
<img data-bind="attr: {src: getModuleLogoUrl()}"
class="payment-icon"
alt="PayZen"
style="width: 76px;"
/>
<!--/ko-->
Expand Down
1 change: 0 additions & 1 deletion view/frontend/web/template/payment/payzen-gift.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<!-- ko if: getModuleLogoUrl() -->
<img data-bind="attr: {src: getModuleLogoUrl()}"
class="payment-icon"
alt="PayZen"
style="width: 76px;"
/>
<!--/ko-->
Expand Down
1 change: 0 additions & 1 deletion view/frontend/web/template/payment/payzen-multi.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<!-- ko if: getModuleLogoUrl() -->
<img data-bind="attr: {src: getModuleLogoUrl()}"
class="payment-icon"
alt="PayZen"
style="width: 76px;"
/>
<!--/ko-->
Expand Down
Loading

0 comments on commit 067e653

Please sign in to comment.