Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
Release/magento 3.17.0 (#194)
Browse files Browse the repository at this point in the history
* Added new mask to avoid special characters in Document field

* fix: removed sponsor id from header (#233)

* feat: initial structure

* New Pix Screen Mobile Experience

* feat(PPWP-1090): added event to call initCardForm

* fix: 🐛 Fix bug when buyer applies a discount

* fix: 🐛 Fix placeOrder context exec

* fix: 🐛 PPWP-1188 support php 8.1

* fix: 🐛 PPWP-1188 add require ext-mbstring

* build(v3.17.0): 📦 New version v3.17.0 of Mercado Pago for Magento 2

Co-authored-by: Cleiton Aguiar Andrade <[email protected]>
Co-authored-by: hugodamm <[email protected]>
Co-authored-by: Giovanni Cavallari <[email protected]>
Co-authored-by: sleaof <[email protected]>
Co-authored-by: Hugo Damm <[email protected]>
Co-authored-by: DouglasCorreiaMeli <[email protected]>
Co-authored-by: Fernando Lira <[email protected]>
  • Loading branch information
8 people authored Jul 20, 2022
1 parent a099a7d commit b04f03a
Show file tree
Hide file tree
Showing 24 changed files with 975 additions and 578 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ 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).

## [3.17.0] - 2022-07-04

### Added
- Support to Magento 2.4.4 with PHP 8.1
- Default success page of Magento support a Pix payment information

### Fixed
- Reload credit/debit card base amount on updated cart with coupon
- Document input accept correct characters
- Not sent sponsor id in header request

## [3.16.0] - 2022-05-05

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</a>
</p>

# Magento 2 - Mercado Pago Module (v3.16.0)
# Magento 2 - Mercado Pago Module (v3.17.0)

The Mercado Pago plugin for Magento 2 allows you to expand the functionalities of your online store and offer a unique payment experience for your customers.

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
],
"type": "magento2-module",
"version": "3.16.0",
"version": "3.17.0",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand All @@ -28,6 +28,7 @@
]
},
"require": {
"ext-json": "*"
"ext-json": "*",
"ext-mbstring": "*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ public function render(AbstractElement $element)
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();

$siteId = strtoupper(
$this->scopeConfig->getValue(
ConfigData::PATH_SITE_ID,
ScopeInterface::SCOPE_STORE
)
$getSiteId = $this->scopeConfig->getValue(
ConfigData::PATH_SITE_ID,
ScopeInterface::SCOPE_STORE
);

$siteId = is_string($getSiteId) ? mb_strtoupper($getSiteId) : '';

if ($this->hideInterestPayment($siteId, $element->getOriginalData())) {
return "";
}
Expand Down Expand Up @@ -136,9 +136,11 @@ public static function changeUrlByCountry()
{
$objectManager = ObjectManager::getInstance();

$siteId = strtoupper(
$objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue(ConfigData::PATH_SITE_ID)
);
$getSiteId = $objectManager
->get('Magento\Framework\App\Config\ScopeConfigInterface')
->getValue(ConfigData::PATH_SITE_ID);

$siteId = is_string($getSiteId) ? mb_strtoupper($getSiteId) : '';

$country = Country::getCountryToMp($siteId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public function __construct(
*/
public function render(AbstractElement $element)
{
$siteId = strtoupper(
$this->scopeConfig->getValue(
ConfigData::PATH_SITE_ID,
ScopeInterface::SCOPE_STORE
)
$getSiteId = $this->scopeConfig->getValue(
ConfigData::PATH_SITE_ID,
ScopeInterface::SCOPE_STORE
);

$siteId = is_string($getSiteId) ? mb_strtoupper($getSiteId) : '';

if ($this->hideInterestPayment($siteId, $element->getOriginalData())) {
return "";
}
Expand Down
32 changes: 17 additions & 15 deletions src/MercadoPago/Core/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
use MercadoPago\Core\Lib\Api;
use MercadoPago\Core\Lib\RestClient;
use MercadoPago\Core\Logger\Logger;
use MercadoPago\Core\Model\Custom\Payment;
use MercadoPago\Core\Helper\PaymentPlaces;

/**
* Class Data
Expand All @@ -37,10 +35,12 @@ class Data extends \Magento\Payment\Helper\Data
*api platform openplatform
*/
const PLATFORM_OPENPLATFORM = 'openplatform';

/**
*api platform stdplatform
*/
const PLATFORM_STD = 'std';

/**
*type
*/
Expand All @@ -50,6 +50,7 @@ class Data extends \Magento\Payment\Helper\Data
* payment calculator
*/
const STATUS_ACTIVE = 'active';

const PAYMENT_TYPE_CREDIT_CARD = 'credit_card';

/**
Expand Down Expand Up @@ -83,6 +84,10 @@ class Data extends \Magento\Payment\Helper\Data
* @var Switcher
*/
protected $_switcher;

/**
* @var ComposerInformation
*/
protected $_composerInformation;

/**
Expand Down Expand Up @@ -151,9 +156,8 @@ public function __construct(
*/
public function log($message, $name = "mercadopago", $array = null)
{
//load admin configuration value, default is true
$actionLog = $this->scopeConfig->getValue(
\MercadoPago\Core\Helper\ConfigData::PATH_ADVANCED_LOG,
ConfigData::PATH_ADVANCED_LOG,
ScopeInterface::SCOPE_STORE
);

Expand All @@ -166,7 +170,6 @@ public function log($message, $name = "mercadopago", $array = null)
$message .= " - " . json_encode($array);
}

//set log
$this->_mpLogger->setName($name);
$this->_mpLogger->debug($message);
}
Expand All @@ -182,7 +185,6 @@ public function getApiInstance($accessToken = null)
throw new LocalizedException(__('The ACCESS_TOKEN has not been configured, without this credential the module will not work correctly.'));
}

//$api = new Api($accessToken);
$api = $this->_api;
$api->set_access_token($accessToken);
$api->set_platform(self::PLATFORM_OPENPLATFORM);
Expand All @@ -192,17 +194,13 @@ public function getApiInstance($accessToken = null)
RestClient::setUrlStore($this->getUrlStore());
RestClient::setEmailAdmin($this->scopeConfig->getValue('trans_email/ident_sales/email', ScopeInterface::SCOPE_STORE));
RestClient::setCountryInitial($this->getCountryInitial());
RestClient::setSponsorID($this->scopeConfig->getValue('payment/mercadopago/sponsor_id', ScopeInterface::SCOPE_STORE));

//$api->set_so((string)$this->_moduleContext->getVersion()); //TODO tracking

return $api;
}

/**
* @param $accessToken
* @return bool
* @throws LocalizedException
*/
public function isValidAccessToken($accessToken)
{
Expand All @@ -228,7 +226,7 @@ public function isValidAccessToken($accessToken)
*/
public function getAccessToken($scopeCode = ScopeInterface::SCOPE_STORE)
{
$accessToken = $this->scopeConfig->getValue(\MercadoPago\Core\Helper\ConfigData::PATH_ACCESS_TOKEN, $scopeCode);
$accessToken = $this->scopeConfig->getValue(ConfigData::PATH_ACCESS_TOKEN, $scopeCode);
if (empty($accessToken)) {
return false;
}
Expand Down Expand Up @@ -272,11 +270,14 @@ public function setOrderSubtotals($data, $order)
protected function _getMultiCardValue($data, $field)
{
$finalValue = 0;

if (!isset($data[$field])) {
return $finalValue;
}

$amountValues = explode('|', $data[$field]);
$statusValues = explode('|', $data['status']);

foreach ($amountValues as $key => $value) {
$value = (float)str_replace(' ', '', $value);
if (str_replace(' ', '', $statusValues[$key]) === 'approved') {
Expand All @@ -296,21 +297,20 @@ protected function _getMultiCardValue($data, $field)
*/
public function getMercadoPagoPaymentMethods($accessToken)
{

$this->log('GET /v1/payment_methods', 'mercadopago');

try {
$mp = $this->getApiInstance($accessToken);

$payment_methods = $mp->get("/v1/payment_methods");

$treated_payments_methods = [];
$treated_payments_methods = [];

foreach ($payment_methods['response'] as $payment_method) {
if (!isset($payment_method['payment_places'])) {
if (is_array($payment_method) && isset($payment_method['id']) && !isset($payment_method['payment_places'])) {
$payment_method['payment_places'] = PaymentPlaces::getPaymentPlaces($payment_method['id']);
}

array_push($treated_payments_methods, $payment_method);
}

Expand Down Expand Up @@ -413,9 +413,11 @@ public function getFingerPrintLink($localization)
'MPE' => 'https://www.mercadopago.com.pe/ayuda/terminos-y-politicas_194',
'MCO' => 'https://www.mercadopago.com.co/ayuda/terminos-y-politicas_194',
];

if (array_key_exists($localization, $site_id)) {
return $site_id[$localization];
}

return $site_id['MLA'];
}
}
11 changes: 1 addition & 10 deletions src/MercadoPago/Core/Lib/RestClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@

/**
* MercadoPago cURL RestClient
*
*
* @codeCoverageIgnore
*/
class RestClient
{

/**
* API URL
*/
Expand Down Expand Up @@ -68,7 +67,6 @@ private static function get_connect($uri, $method, $content_type, $extra_params
return $connect;
}


/**
* @param $connect
* @param $data
Expand Down Expand Up @@ -187,7 +185,6 @@ public static function delete($uri, $content_type = "application/json", $extra_p
return self::exec("DELETE", $uri, null, $content_type, $extra_params);
}


/**************
*
* Error implementation tracking
Expand All @@ -198,7 +195,6 @@ public static function delete($uri, $content_type = "application/json", $extra_p
static $url_store = "";
static $email_admin = "";
static $country_initial = "";
static $sponsor_id = "";
static $check_loop = 0;

public static function getIntegratorID()
Expand All @@ -207,11 +203,6 @@ public static function getIntegratorID()
return $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue(ConfigData::PATH_ADVANCED_INTEGRATOR);
}

public static function setSponsorID($sponsor_id)
{
self::$sponsor_id = $sponsor_id;
}

public static function setModuleVersion($module_version)
{
self::$module_version = $module_version;
Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Core/Model/BasicConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function makeBannerCheckout()
ScopeInterface::SCOPE_STORE
);

$excludePaymentMethods = explode(",", $excludePaymentMethods);
$excludePaymentMethods = is_string($excludePaymentMethods) ? explode(",", $excludePaymentMethods) : [];

try {
$debit = 0;
Expand Down
11 changes: 7 additions & 4 deletions src/MercadoPago/Core/Model/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* Class Core
*
* @package MercadoPago\Core\Model
*
*
* @codeCoverageIgnore
*/
class Core extends \Magento\Payment\Model\Method\AbstractMethod
Expand Down Expand Up @@ -397,17 +397,20 @@ public function getMessageByStatus($status, $status_detail)
*/
protected function getCustomerInfo($customer, $order)
{
$email = htmlentities($customer->getEmail());
$email = $customer->getEmail();
$email = is_string($email) ? htmlentities($email) : '';
if ($email == "") {
$email = $order['customer_email'];
}

$first_name = htmlentities($customer->getFirstname());
$first_name = $customer->getFirstname();
$first_name = is_string($first_name) ? htmlentities($first_name) : '';
if ($first_name == "") {
$first_name = $order->getBillingAddress()->getFirstname();
}

$last_name = htmlentities($customer->getLastname());
$last_name = $customer->getLastname();
$last_name = is_string($last_name) ? htmlentities($last_name) : '';
if ($last_name == "") {
$last_name = $order->getBillingAddress()->getLastname();
}
Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Core/Model/CustomBankTransfer/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function preparePostPayment($usingSecondCardInfo = null)
public function getPaymentOptions()
{
$excludePaymentMethods = $this->_scopeConfig->getValue(\MercadoPago\Core\Helper\ConfigData::PATH_CUSTOM_EXCLUDE_PAYMENT_METHODS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
$listExclude = explode(',', $excludePaymentMethods);
$listExclude = is_string($excludePaymentMethods) ? explode(',', $excludePaymentMethods) : [];
$payment_methods = $this->_coreModel->getPaymentMethods();
$paymentOptions = [];

Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Core/Model/CustomTicket/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function preparePostPayment($usingSecondCardInfo = null)
public function getTicketsOptions()
{
$excludePaymentMethods = $this->_scopeConfig->getValue(\MercadoPago\Core\Helper\ConfigData::PATH_CUSTOM_EXCLUDE_PAYMENT_METHODS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
$listExclude = explode(",", $excludePaymentMethods);
$listExclude = is_string($excludePaymentMethods) ? explode(",", $excludePaymentMethods) : [];

$payment_methods = $this->_coreModel->getPaymentMethods();
$tickets = [];
Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Core/Model/Preference/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected function getExcludedPaymentsMethods($config)
{
$excludedMethods = [];
$excluded_payment_methods = $config['exclude_payment_methods'];
$arr_epm = explode(",", $excluded_payment_methods);
$arr_epm = is_string($excluded_payment_methods) ? explode(",", $excluded_payment_methods) : [];

if (count($arr_epm) > 0) {
foreach ($arr_epm as $m) {
Expand Down
9 changes: 4 additions & 5 deletions src/MercadoPago/Core/Model/Preference/Wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,11 @@ protected function getPreference()
protected function getExcludedPaymentMethods()
{
$excluded = [];
$configExcludedPaymentMethods = explode(
',',
$this->getConfig(ConfigData::PATH_CUSTOM_EXCLUDE_PAYMENT_METHODS)
);
$configExcludedPaymentMethods = $this->getConfig(ConfigData::PATH_CUSTOM_EXCLUDE_PAYMENT_METHODS);
$excludedPaymentMethods = is_string($configExcludedPaymentMethods) ?
explode(',', $configExcludedPaymentMethods) : [];

foreach ($configExcludedPaymentMethods as $paymentMethod) {
foreach ($excludedPaymentMethods as $paymentMethod) {
$excluded[] = ['id' => $paymentMethod];
}

Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mercadopago/core",
"description": "Mercado Pago Magento 2 Plugin",
"type": "magento2-module",
"version": "3.16.0",
"version": "3.17.0",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Core/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="MercadoPago_Core" setup_version="3.16.0">
<module name="MercadoPago_Core" setup_version="3.17.0">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Payment"/>
Expand Down
Loading

0 comments on commit b04f03a

Please sign in to comment.