Skip to content

Commit

Permalink
Merge pull request #22 from mercadopago/release/1.9.0
Browse files Browse the repository at this point in the history
Release v1.9.0
  • Loading branch information
katelucena-meli authored Dec 18, 2024
2 parents 29e50ba + 7c57a2a commit c413da9
Show file tree
Hide file tree
Showing 86 changed files with 4,508 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [pull_request]

jobs:
validate-code-standards:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

services:
mysql:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ vendor
.phpunit.result.cache
testdoc.txt
.idea
coverage/
coverage/
test-results
83 changes: 83 additions & 0 deletions Block/Sales/Form/Yape.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* Copyright © MercadoPago. All rights reserved.
*
* @author Mercado Pago
* @license See LICENSE for license details.
*/

namespace MercadoPago\AdbPayment\Block\Sales\Form;

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

/**
* Payment form block by YAPE.
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/
class Yape extends \Magento\Payment\Block\Form
{
/**
* YAPE template.
*
* @var string
*/
protected $_template = 'MercadoPago_AdbPayment::form/yape.phtml';

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

/**
* @var ConfigYape
*/
protected $configYape;

/**
* @var Quote
*/
protected $sessionQuote;

/**
* @param Context $context
* @param Config $config
* @param ConfigYape $configYape
* @param Quote $sessionQuote
*/
public function __construct(
Context $context,
Config $config,
ConfigYape $configYape,
Quote $sessionQuote
) {
parent::__construct($context);
$this->config = $config;
$this->configYape = $configYape;
$this->sessionQuote = $sessionQuote;
}

/**
* Get Backend Session Quote.
*/
public function getBackendSessionQuote()
{
return $this->sessionQuote->getQuote();
}

/**
* Title.
*
* @return string
*/
public function getTitle()
{
$storeId = $this->getBackendSessionQuote()->getStoreId();

return $this->configYape->getTitle($storeId);
}

}
28 changes: 28 additions & 0 deletions Block/Sales/Info/Yape.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

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

namespace MercadoPago\AdbPayment\Block\Sales\Info;

use MercadoPago\AdbPayment\Block\Sales\Info\Info;


/**
* Payment details form block by Yape.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
*/
class Yape extends Info
{
/**
* Yape Info template.
*
* @var string
*/
protected $_template = 'MercadoPago_AdbPayment::info/yape/instructions.phtml';
}
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ 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.9.0] - 2024-12-18
### Changed
- Changed magento order cancellation flow in MP rejected status
- Updated support admin link

### Fixed
- Off payment methods disabled in MLC
- Adjustment on installments info in vault
- Translate customer invalid email message
- Adjustment on cancel orders cron

## Added
- Added new Yape payment method for Peru

## [1.8.5] - 2024-10-30
### Changed
- Adjustments on maximum order amount when payment has financial cost
Expand Down
2 changes: 1 addition & 1 deletion Controller/MpIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ protected function analyzeMpStatusAndAdobeStatus(

$this->logger->debug([
'action' => 'notification',
'isInvalid' => $response->getIsValid(),
'isInvalid' => !$response->getIsValid(),
'payload' => $response->getMessage(),
]);

Expand Down
14 changes: 14 additions & 0 deletions Controller/Notification/CheckoutCustom.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ public function initProcess(
foreach ($transactions as $transaction) {
$order = $this->getOrderData($transaction->getOrderId());

if ($mpStatus == 'rejected') {
try {
$order->cancel()->save();
} catch (Exception $e) {
return $this->createResult(
500,
[
'error' => 500,
'message' => "Error cancelling order with payment rejected: " . $e->getMessage(),
]
);
}
}

if ($mpStatus === 'refunded') {
$refund = new CheckoutCustomRefund(
$this->config,
Expand Down
21 changes: 17 additions & 4 deletions Cron/CancelCheckoutCredits.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,23 @@ public function execute()
)
->where(
new \Zend_Db_Expr(
"sop.method = ? AND TIME_TO_SEC(TIMEDIFF(CURRENT_TIMESTAMP, CAST(JSON_EXTRACT(sop.additional_information, '$.date_of_expiration') AS DATETIME))) >= 0 "
),
ConfigCheckoutCredits::METHOD
);
"sop.method = ?
AND TIME_TO_SEC(
TIMEDIFF(CURRENT_TIMESTAMP(),
STR_TO_DATE(
REPLACE(
SUBSTRING_INDEX(
JSON_UNQUOTE(JSON_EXTRACT(sop.additional_information, '$.date_of_expiration')),
'.',
1
),
'T', ' '
),
'%Y-%m-%d %H:%i:%s'
)
)
) >= 0"
), ConfigCheckoutCredits::METHOD);

foreach ($orders as $order) {
$orderId = $order->getEntityId();
Expand Down
19 changes: 17 additions & 2 deletions Cron/CancelCheckoutPro.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,22 @@ public function execute()
['method', 'additional_information']
)
->where(new \Zend_Db_Expr(
"sop.method = ? AND TIME_TO_SEC(TIMEDIFF(CURRENT_TIMESTAMP, CAST(JSON_EXTRACT(sop.additional_information, '$.date_of_expiration') AS DATETIME))) >= 0 "
"sop.method = ?
AND TIME_TO_SEC(
TIMEDIFF(CURRENT_TIMESTAMP(),
STR_TO_DATE(
REPLACE(
SUBSTRING_INDEX(
JSON_UNQUOTE(JSON_EXTRACT(sop.additional_information, '$.date_of_expiration')),
'.',
1
),
'T', ' '
),
'%Y-%m-%d %H:%i:%s'
)
)
) >= 0"
), ConfigCheckoutPro::METHOD);


Expand Down Expand Up @@ -132,7 +147,7 @@ public function execute()

$dateRange[] = $orderAdditionalInformation->date_of_expiration;
$this->logger->debug([
'fetch' => 'Cancel Order Id ' . $orderId . ' successfully',
'fetch' => 'Cancel Order ' . $order->getIncrementId() . ' successfully',
'order_date_of_expiration' => $orderAdditionalInformation->date_of_expiration
]);
}
Expand Down
100 changes: 100 additions & 0 deletions Cron/FetchYapeOrderStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php
/**
* Copyright © MercadoPago. All rights reserved.
*
* @author Mercado Pago
* @license See LICENSE for license details.
*/

namespace MercadoPago\AdbPayment\Cron;

use Magento\Framework\App\ResourceConnection;
use Magento\Payment\Model\Method\Logger;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
use MercadoPago\AdbPayment\Gateway\Config\ConfigYape;
use MercadoPago\AdbPayment\Model\Console\Command\Notification\FetchStatus;

/**
* CronTab for fetch Yape Order Status.
*/
class FetchYapeOrderStatus
{
/**
* @var Logger
*/
protected $logger;

/**
* @var FetchStatus
*/
protected $fetchStatus;

/**
* @var CollectionFactory
*/
protected $collectionFactory;

/**
* @var ResourceConnection
*/
protected $resource;

/**
* Constructor.
*
* @param Logger $logger
* @param FetchStatus $fetchStatus
* @param CollectionFactory $collectionFactory
* @param ResourceConnection $resource;
*/
public function __construct(
Logger $logger,
FetchStatus $fetchStatus,
CollectionFactory $collectionFactory,
ResourceConnection $resource
) {
$this->logger = $logger;
$this->fetchStatus = $fetchStatus;
$this->collectionFactory = $collectionFactory;
$this->resource = $resource;
}

/**
* Get sales_order_payment table name.
*
* @return string
*/
public function getSalesOrderPaymentTableName()
{
return $this->resource->getTableName('sales_order_payment');
}

/**
* Execute the cron.
*
* @return void
*/
public function execute()
{
$orders = $this->collectionFactory->create()
->addFieldToFilter('state', Order::STATE_NEW);
$orders->getSelect()
->join(
['sop' => $this->getSalesOrderPaymentTableName()],
'main_table.entity_id = sop.parent_id',
['method']
)
->where('sop.method = ?', ConfigYape::METHOD);

foreach ($orders as $order) {
$orderId = $order->getEntityId();

$this->logger->debug([
'fetch' => 'Fetch Status Yape for Order Id '.$orderId,
]);

$this->fetchStatus->fetch($orderId);
}
}
}
Loading

0 comments on commit c413da9

Please sign in to comment.