Skip to content

Commit

Permalink
Merge pull request #364 from mercadopago/release/7.6.3
Browse files Browse the repository at this point in the history
Release v7.6.3
  • Loading branch information
DouglasCorreiaMeli authored Jul 29, 2024
2 parents 60a7a26 + 602bd24 commit 3077f3b
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ coverage

woocommerce-mercadopago.zip

qit-env.json
qit-env.yml
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [7.6.3] - 2024-07-29
### Fix:
- Fix the size of the card logos at checkout.
- Fix the problem of not showing the disclaimer about card fees for some countries.

## [7.6.2] - 2024-07-16
### Added:
- Added validation on user permissions to download plugin logs.
- Increased plugin wordpress tested version to the latest available.
### Fix:
- Addressed an issue where discount and commission calculations were not being shown correctly on order details.

## [7.6.1] - 2024-06-26
### Fix:
- Addressed an funnel metrics issue
Expand Down
4 changes: 2 additions & 2 deletions assets/js/checkouts/custom/mp-custom-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const CheckoutPage = {
this.setBackground('fcCardNumberContainer', 'url(' + secureThumbnail + ') 98% 50% no-repeat #fff');
document
.querySelector(CheckoutElements.fcCardNumberContainer)
.style.setProperty('background-size', 'auto 32px', 'important');
.style.setProperty('background-size', 'auto', 'important');
},

findContainerField(field) {
Expand Down Expand Up @@ -337,7 +337,7 @@ const CheckoutPage = {
},

getBankInterestDisclaimerCountries(siteId) {
return siteId === 'mlc' || siteId === 'mco' || siteId === 'mpe';
return siteId.toUpperCase() === 'MLC' || siteId.toUpperCase() === 'MCO' || siteId.toUpperCase() === 'MPE';
},

getInstallments(response, bankInterestDisclaimer) {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/checkouts/custom/mp-custom-page.min.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions changelog.log
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
CHANGELOG:
== Changelog ==

= v7.6.3 (29/07/2024) =
* Fixed:
- Fix the size of the card logos at checkout.
- Fix the problem of not showing the disclaimer about card fees for some countries.

= v7.6.2 (16/07/2024) =
* Added:
- Added validation on user permissions to download plugin logs.
- Increased plugin wordpress tested version to the latest available.
* Fixed:
- Addressed an issue where discount and commission calculations were not being shown correctly on order details.

= v7.6.1 (26/06/2024) =
* Fix:
- Addressed an funnel metrics issue
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"qit:comp": "./vendor/bin/qit run:phpcompatibility woocommerce-mercadopago --zip woocommerce-mercadopago.zip",
"qit:sec": "./vendor/bin/qit run:security woocommerce-mercadopago --zip woocommerce-mercadopago.zip",
"qit:api": "./vendor/bin/qit run:woo-api woocommerce-mercadopago --zip woocommerce-mercadopago.zip",
"qit:env-up": "./vendor/bin/qit env:up --config ./qit-env.json",
"qit:env-up": "./vendor/bin/qit --woo=8.9.0 env:up",
"qit:env-down": "./vendor/bin/qit env:down"
},
"require": {
Expand All @@ -46,7 +46,7 @@
"require-dev": {
"squizlabs/php_codesniffer": "^3.7",
"phpmetrics/phpmetrics": "^2.8",
"woocommerce/qit-cli": "^0.5.0",
"woocommerce/qit-cli": "^0.5.3",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"wp-coding-standards/wpcs": "^2.2.1"
},
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "woocommerce-mercadopago",
"description": "Woocommerce MercadoPago Payment Gateway",
"version": "7.6.1",
"version": "7.6.3",
"main": "main.js",
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions qit-env.sample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
wp: 6.5.5
php_version: 8.3
themes:
- storefront
# plugins:
# - really-simple-ssl
7 changes: 4 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Contributors:
Tags: ecommerce, mercadopago, woocommerce
Requires at least: 6.3
Tested up to: 6.5
Tested up to: 6.6
Requires PHP: 7.4
Stable tag: 7.6.1
Stable tag: 7.6.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -137,6 +137,7 @@ Check out our <a href="https://www.mercadopago.com.br/developers/pt/plugins_sdks
== Changelog ==

* Fix:
- Addressed an funnel metrics issue
- Fix the size of the card logos at checkout.
- Fix the problem of not showing the disclaimer about card fees for some countries.

[See changelog for all versions](https://github.com/mercadopago/cart-woocommerce/blob/main/CHANGELOG.md).
4 changes: 2 additions & 2 deletions src/Dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ public function __construct()
$this->requesterHelper = $this->setRequester();
$this->storeConfig = $this->setStore();
$this->logs = $this->setLogs();
$this->downloader = $this->setDownloader();
$this->sellerConfig = $this->setSeller();
$this->countryHelper = $this->setCountry();
$this->urlHelper = $this->setUrl();
Expand All @@ -347,6 +346,7 @@ public function __construct()
$this->noticesHelper = $this->setNotices();
$this->metadataConfig = $this->setMetadataConfig();
$this->currencyHelper = $this->setCurrency();
$this->downloader = $this->setDownloader();
$this->settings = $this->setSettings();
$this->creditsEnabledHelper = $this->setCreditsEnabled();
$this->checkoutCustomEndpoints = $this->setCustomCheckoutEndpoints();
Expand Down Expand Up @@ -704,6 +704,6 @@ private function setHelpers(): Helpers

private function setDownloader(): Downloader
{
return new Downloader($this->logs);
return new Downloader($this->logs, $this->currentUserHelper);
}
}
6 changes: 4 additions & 2 deletions src/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,17 @@ public function process_payment($order_id): array
$this->mercadopago->orderMetadata->setUsedGatewayData($order, get_class($this)::ID);

if ($this->discount != 0) {
$percentage = Numbers::getPercentageFromParcialValue((float) $discount, (float) $order->get_total());
$translation = $this->mercadopago->storeTranslations->commonCheckout['discount_title'];
$feeText = $this->getFeeText($translation, 'discount', $discount);
$feeText = $this->getFeeText($translation, $percentage, $discount);

$this->mercadopago->orderMetadata->setDiscountData($order, $feeText);
}

if ($this->commission != 0) {
$percentage = Numbers::getPercentageFromParcialValue((float) $comission, (float) $order->get_total());
$translation = $this->mercadopago->storeTranslations->commonCheckout['fee_title'];
$feeText = $this->getFeeText($translation, 'commission', $commission);
$feeText = $this->getFeeText($translation, $percentage, $commission);

$this->mercadopago->orderMetadata->setCommissionData($order, $feeText);
}
Expand Down
16 changes: 16 additions & 0 deletions src/Helpers/Numbers.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,20 @@ public static function calculateByCurrency(string $currency, float $value, float

return self::format($value * $ratio * 100) / 100;
}

/**
* Returns the percentage of parcialValue on the sum with the paid value
*
* @param float $parcialValue
* @param float $paidValue
*
* @return float
*/
public static function getPercentageFromParcialValue(float $parcialValue, $paidValue)
{
$total = $paidValue + $parcialValue;
$percentage = ($parcialValue / $total) * 100;

return self::format($percentage);
}
}
20 changes: 14 additions & 6 deletions src/IO/Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use MercadoPago\Woocommerce\Entities\Files\Log as LogFile;
use MercadoPago\Woocommerce\Libraries\Logs\Logs;
use MercadoPago\Woocommerce\Helpers\Form;
use MercadoPago\Woocommerce\Helpers\CurrentUser;

if (!defined('ABSPATH')) {
exit;
Expand All @@ -23,9 +24,14 @@ class Downloader

public $pluginLogs;

/**
* @var CurrentUser
*/
private $currentUser;

public function __construct(Logs $logs)
public function __construct(Logs $logs, CurrentUser $currentUser)
{
$this->currentUser = $currentUser;
$this->logs = $logs;
$this->pluginLogs = $this->getNameOfFileLogs();
}
Expand Down Expand Up @@ -99,7 +105,7 @@ private function singleFileDownload(array $selectedFile): void
{
$filename = reset($selectedFile);

if (!$this->validateFilename($filename)) {
if (!$this->validatesDownloadSecurity($filename)) {
throw new \Exception('attempt to download the file ' . $filename . 'on ' . __METHOD__);
}

Expand Down Expand Up @@ -128,7 +134,7 @@ private function multipleFileDownload(array $selectedFiles): void

if ($zip->open($temp_file, \ZipArchive::CREATE) === true) {
foreach ($selectedFiles as $filename) {
if (!$this->validateFilename($filename)) {
if (!$this->validatesDownloadSecurity($filename)) {
continue;
}

Expand All @@ -152,14 +158,16 @@ private function multipleFileDownload(array $selectedFiles): void
}

/**
* Validates a filename to prevent path traversal attempts and ensure expected format.
* Validates a filename and user permissions to prevent path traversal attempts and ensure expected format.
*
* @param string $filename The filename to be validated
*
* @return bool True if the filename is valid, false otherwise
*/
private function validateFilename(string $filename): bool
private function validatesDownloadSecurity(string $filename): bool
{
$this->currentUser->validateUserNeededPermissions();

return $this->hasAllowedExtension($filename) &&
$this->hasNoDisallowedCharacters($filename) &&
$this->containsExpectedTerms($filename);
Expand All @@ -168,7 +176,7 @@ private function validateFilename(string $filename): bool
private function hasAllowedExtension(string $filename): bool
{
$allowed_pattern = '/\.log$/';
return (bool)preg_match($allowed_pattern, $filename);
return (bool)preg_match($allowed_pattern, $filename);
}

private function hasNoDisallowedCharacters(string $filename): bool
Expand Down
2 changes: 1 addition & 1 deletion src/WoocommerceMercadoPago.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class WoocommerceMercadoPago
/**
* @const
*/
private const PLUGIN_VERSION = '7.6.1';
private const PLUGIN_VERSION = '7.6.3';

/**
* @const
Expand Down
4 changes: 2 additions & 2 deletions woocommerce-mercadopago.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* Plugin Name: Mercado Pago
* Plugin URI: https://github.com/mercadopago/cart-woocommerce
* Description: Configure the payment options and accept payments with cards, ticket and money of Mercado Pago account.
* Version: 7.6.1
* Version: 7.6.3
* Author: Mercado Pago
* Author URI: https://developers.mercadopago.com/
* Text Domain: woocommerce-mercadopago
* Domain Path: /i18n/languages/
* WC requires at least: 5.5.2
* WC tested up to: 8.1.0
* WC tested up to: 9.0.2
* Requires PHP: 7.4
*
* @package MercadoPago
Expand Down

0 comments on commit 3077f3b

Please sign in to comment.