Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/1.7.0 #14

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions Block/Adminhtml/System/Config/Tracking/Tracking.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/**
* Copyright © MercadoPago. All rights reserved.
*
* @author Mercado Pago
* @license See LICENSE for license details.
*/

namespace MercadoPago\AdbPayment\Block\Adminhtml\System\Config\Tracking;

use Magento\Backend\Model\Auth\Session;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use MercadoPago\AdbPayment\Gateway\Config\Config;

class Tracking extends Template
{

/**
* @var Session
*/
protected $session;

/**
* @var Config
*/
protected $config;

/**
* @var string
*/
protected $_template = 'MercadoPago_AdbPayment::melidata/tracking.phtml';

/**
* @param Context $context
* @param Session $session
* @param Config $config
* @param array $data
*/
public function __construct(
Context $context,
Session $session,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->session = $session;
$this->config = $config;
}

/**
* @return String
*/
public function getConfigData()
{

return [
'moduleVersion' => $this->config->getModuleVersion(),
'platformVersion' => $this->config->getMagentoVersion(),
'siteId' => $this->config->getMpSiteId() ? $this->config->getMpSiteId() : "Credencial não cadastrada",
];
}
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ 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).

## [1.7.0] - 2024-03-27
### Added
- Added trackings in selected paths for melidata

### Fixed
- Validation for expired credentials
- Correction for area code error in old platform versions

## [1.6.3] - 2024-03-07
### Changed
- Adjusting Iframe creation with 3Ds.
Expand Down
13 changes: 8 additions & 5 deletions Model/Adminhtml/Source/MerchantPaymentMethods.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright © MercadoPago. All rights reserved.
*
Expand Down Expand Up @@ -76,12 +77,14 @@ public function toOptionArray(): array

$payments = $this->getAllPaymentMethods();

if ($payments['success'] === true) {
if ($payments['success'] === true && isset($payments['methods'])) {
foreach ($payments['methods'] as $payment) {
$options[] = [
'value' => $payment['id'],
'label' => __($payment['name']),
];
if (isset($payment['id']) && isset($payment['name'])) {
$options[] = [
'value' => $payment['id'],
'label' => __($payment['name']),
];
}
}
}

Expand Down
14 changes: 8 additions & 6 deletions Model/Adminhtml/Source/PaymentMethodsOff.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,23 @@ public function toOptionArray(): array

$payments = $this->mercadopagoConfig->getMpPaymentMethods($storeId);

if ($payments['success'] === true) {
if ($payments['success'] === true && isset($payments['response'])) {
$options = array_merge($options, $this->mountPaymentMethodsOff($payments['response']));
}

return $options;
}

public function mountPaymentMethodsOff(array $paymentMethods): ?array {
public function mountPaymentMethodsOff(array $paymentMethods): ?array
{

$options = [];
foreach ($paymentMethods as $payment) {
if (in_array($payment['payment_type_id'], self::PAYMENT_TYPE_ID_ALLOWED) &&
$payment['status'] === self::PAYMENT_STATUS_ACTIVE) {
if (
isset($payment['payment_type_id']) && isset($payment['status']) &&
in_array($payment['payment_type_id'], self::PAYMENT_TYPE_ID_ALLOWED) &&
$payment['status'] === self::PAYMENT_STATUS_ACTIVE
) {

if (empty($payment['payment_places'])) {
$options[] = [
Expand All @@ -93,10 +97,8 @@ public function mountPaymentMethodsOff(array $paymentMethods): ?array {
$labels = array();
foreach ($options as $key => $row) {
$labels[$key] = $row['label'];

}
array_multisort($labels, SORT_ASC, $options);
return $options;
}

}
5 changes: 5 additions & 0 deletions Model/Console/Command/Adminstrative/FetchMerchant.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ public function __construct(
$this->storeManager = $storeManager;
$this->json = $json;
$this->messageManager = $messageManager;
try {
$this->state->getAreaCode();
} catch (Exception $e) {
$this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
}
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Model/Ui/ConfigProviderCheckoutCredits.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ public function isActive()
$storeId = $this->cart->getStoreId();
$payments = $this->mercadopagoConfig->getMpPaymentMethods($storeId);

if ($payments['success'] === true) {
if ($payments['success'] === true && isset($payments['response'])) {
foreach ($payments['response'] as $payment) {
if ($payment['id'] === self::PAYMENT_METHOD_ID) {
if (isset($payment['id']) && $payment['id'] === self::PAYMENT_METHOD_ID) {
return true;
}
}
Expand All @@ -179,7 +179,7 @@ public function isActive()

/**
* Get images for payment method banner.
*
*
* @return array
*/
public function getImages()
Expand All @@ -197,7 +197,7 @@ public function getImages()

/**
* Get images for payment method banner.
*
*
* @return array
*/
public function getImagesByName($name)
Expand Down
16 changes: 9 additions & 7 deletions Model/Ui/ConfigProviderPaymentMethodsOff.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ConfigProviderPaymentMethodsOff implements ConfigProviderInterface
*/
protected $cart;

/**
/**
* @var MercadoPagoConfig
*/
protected $mercadopagoConfig;
Expand All @@ -55,7 +55,7 @@ class ConfigProviderPaymentMethodsOff implements ConfigProviderInterface
*/
protected $escaper;

/**
/**
* @var Repository
*/
protected $assetRepo;
Expand Down Expand Up @@ -140,7 +140,7 @@ public function getPaymentMethodsOffActive($storeId)
$options = [];
$payments = $this->mercadopagoConfig->getMpPaymentMethods($storeId);

if ($payments['success'] === true) {
if ($payments['success'] === true && isset($payments['response'])) {
$options = $this->mountPaymentMethodsOff($payments['response']);
}

Expand All @@ -163,7 +163,7 @@ public function filterPaymentMethodsOffConfigActive(array $paymentMethods, ?stri
$actives = explode(",", $methodsOffActive);

foreach ($paymentMethods as $payment) {
if(isset($payment['value']) && !in_array($payment['value'], $actives)){
if (isset($payment['value']) && !in_array($payment['value'], $actives)) {
$options[] = $payment;
}
}
Expand All @@ -180,8 +180,11 @@ public function mountPaymentMethodsOff(array $paymentMethods = []): array
{
$options = [];
foreach ($paymentMethods as $payment) {
if (in_array($payment['payment_type_id'], self::PAYMENT_TYPE_ID_ALLOWED) &&
$payment['status'] === self::PAYMENT_STATUS_ACTIVE) {
if (
isset($payment['payment_type_id']) && isset($payment['status']) &&
in_array($payment['payment_type_id'], self::PAYMENT_TYPE_ID_ALLOWED) &&
$payment['status'] === self::PAYMENT_STATUS_ACTIVE
) {

if (empty($payment['payment_places'])) {
$options[] = [
Expand Down Expand Up @@ -216,5 +219,4 @@ public function mountPaymentMethodsOff(array $paymentMethods = []): array
array_multisort($labels, SORT_ASC, $options);
return $options;
}

}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mercadopago/adb-payment",
"description": "MercadoPago - Payment for Adobe Commerce",
"version": "1.6.3",
"version": "1.7.0",
"require": {
"php": "~7.3.0||~7.4.0||~8.1.0||~8.2.0",
"ext-json": "*",
Expand Down
Loading
Loading