diff --git a/CHANGELOG.md b/CHANGELOG.md index c10520ed..d7bc25d0 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 52de1012..57038807 100755 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@
-# 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. diff --git a/composer.json b/composer.json index ec8381ca..cbeb4329 100755 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ } ], "type": "magento2-module", - "version": "3.16.0", + "version": "3.17.0", "license": [ "OSL-3.0", "AFL-3.0" @@ -28,6 +28,7 @@ ] }, "require": { - "ext-json": "*" + "ext-json": "*", + "ext-mbstring": "*" } } diff --git a/src/MercadoPago/Core/Block/Adminhtml/System/Config/InterestPayment/Button.php b/src/MercadoPago/Core/Block/Adminhtml/System/Config/InterestPayment/Button.php index 5c07498d..bf056019 100644 --- a/src/MercadoPago/Core/Block/Adminhtml/System/Config/InterestPayment/Button.php +++ b/src/MercadoPago/Core/Block/Adminhtml/System/Config/InterestPayment/Button.php @@ -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 ""; } @@ -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); diff --git a/src/MercadoPago/Core/Block/Adminhtml/System/Config/InterestPayment/Note.php b/src/MercadoPago/Core/Block/Adminhtml/System/Config/InterestPayment/Note.php index c7e973ae..19022a83 100644 --- a/src/MercadoPago/Core/Block/Adminhtml/System/Config/InterestPayment/Note.php +++ b/src/MercadoPago/Core/Block/Adminhtml/System/Config/InterestPayment/Note.php @@ -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 ""; } diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php index 0e4f6ca8..5ab6a4b5 100644 --- a/src/MercadoPago/Core/Helper/Data.php +++ b/src/MercadoPago/Core/Helper/Data.php @@ -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 @@ -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 */ @@ -50,6 +50,7 @@ class Data extends \Magento\Payment\Helper\Data * payment calculator */ const STATUS_ACTIVE = 'active'; + const PAYMENT_TYPE_CREDIT_CARD = 'credit_card'; /** @@ -83,6 +84,10 @@ class Data extends \Magento\Payment\Helper\Data * @var Switcher */ protected $_switcher; + + /** + * @var ComposerInformation + */ protected $_composerInformation; /** @@ -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 ); @@ -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); } @@ -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); @@ -192,9 +194,6 @@ 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; } @@ -202,7 +201,6 @@ public function getApiInstance($accessToken = null) /** * @param $accessToken * @return bool - * @throws LocalizedException */ public function isValidAccessToken($accessToken) { @@ -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; } @@ -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') { @@ -296,7 +297,6 @@ protected function _getMultiCardValue($data, $field) */ public function getMercadoPagoPaymentMethods($accessToken) { - $this->log('GET /v1/payment_methods', 'mercadopago'); try { @@ -304,13 +304,13 @@ public function getMercadoPagoPaymentMethods($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); } @@ -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']; } } diff --git a/src/MercadoPago/Core/Lib/RestClient.php b/src/MercadoPago/Core/Lib/RestClient.php index 5ff20516..6605ae59 100644 --- a/src/MercadoPago/Core/Lib/RestClient.php +++ b/src/MercadoPago/Core/Lib/RestClient.php @@ -7,12 +7,11 @@ /** * MercadoPago cURL RestClient - * + * * @codeCoverageIgnore */ class RestClient { - /** * API URL */ @@ -68,7 +67,6 @@ private static function get_connect($uri, $method, $content_type, $extra_params return $connect; } - /** * @param $connect * @param $data @@ -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 @@ -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() @@ -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; diff --git a/src/MercadoPago/Core/Model/BasicConfigProvider.php b/src/MercadoPago/Core/Model/BasicConfigProvider.php index 82956ad8..3a6582ed 100644 --- a/src/MercadoPago/Core/Model/BasicConfigProvider.php +++ b/src/MercadoPago/Core/Model/BasicConfigProvider.php @@ -141,7 +141,7 @@ public function makeBannerCheckout() ScopeInterface::SCOPE_STORE ); - $excludePaymentMethods = explode(",", $excludePaymentMethods); + $excludePaymentMethods = is_string($excludePaymentMethods) ? explode(",", $excludePaymentMethods) : []; try { $debit = 0; diff --git a/src/MercadoPago/Core/Model/Core.php b/src/MercadoPago/Core/Model/Core.php index 49aef2d6..871176b4 100644 --- a/src/MercadoPago/Core/Model/Core.php +++ b/src/MercadoPago/Core/Model/Core.php @@ -35,7 +35,7 @@ * Class Core * * @package MercadoPago\Core\Model - * + * * @codeCoverageIgnore */ class Core extends \Magento\Payment\Model\Method\AbstractMethod @@ -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(); } diff --git a/src/MercadoPago/Core/Model/CustomBankTransfer/Payment.php b/src/MercadoPago/Core/Model/CustomBankTransfer/Payment.php index 0543c3f3..275e4013 100644 --- a/src/MercadoPago/Core/Model/CustomBankTransfer/Payment.php +++ b/src/MercadoPago/Core/Model/CustomBankTransfer/Payment.php @@ -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 = []; diff --git a/src/MercadoPago/Core/Model/CustomTicket/Payment.php b/src/MercadoPago/Core/Model/CustomTicket/Payment.php index 36935975..8374b842 100644 --- a/src/MercadoPago/Core/Model/CustomTicket/Payment.php +++ b/src/MercadoPago/Core/Model/CustomTicket/Payment.php @@ -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 = []; diff --git a/src/MercadoPago/Core/Model/Preference/Basic.php b/src/MercadoPago/Core/Model/Preference/Basic.php index 555e38bc..eff3b972 100644 --- a/src/MercadoPago/Core/Model/Preference/Basic.php +++ b/src/MercadoPago/Core/Model/Preference/Basic.php @@ -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) { diff --git a/src/MercadoPago/Core/Model/Preference/Wallet.php b/src/MercadoPago/Core/Model/Preference/Wallet.php index b1b0dd9a..c0716dff 100644 --- a/src/MercadoPago/Core/Model/Preference/Wallet.php +++ b/src/MercadoPago/Core/Model/Preference/Wallet.php @@ -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]; } diff --git a/src/MercadoPago/Core/composer.json b/src/MercadoPago/Core/composer.json index cfe98c65..01f50232 100644 --- a/src/MercadoPago/Core/composer.json +++ b/src/MercadoPago/Core/composer.json @@ -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" diff --git a/src/MercadoPago/Core/etc/module.xml b/src/MercadoPago/Core/etc/module.xml index be9fb608..3924443c 100644 --- a/src/MercadoPago/Core/etc/module.xml +++ b/src/MercadoPago/Core/etc/module.xml @@ -1,6 +1,6 @@- - - - - - -
-- -
- - - -- -
-- -
-1. Acesse o seu banco ou aplicativo de pagamentos
+2. Escolha pagar via Pix com código QR
+3. Escaneie o seguinte código
+Acesse o seu banco ou aplicativo de pagamentos e escolha pagar via Pix. Em seguida, cole o seguinte código de pagamento:
+