diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c3b308f..8f4b9f50 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ 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). +## [4.11.2] - 2022-16-08 + +### Fixed +- PSE return page + ## [4.11.1] - 2022-07-07 ### Fixed diff --git a/README.md b/README.md index 1e8c4a22..9972c4ee 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

-# Prestashop 1.6.x & 1.7.x - Mercado Pago Module (v4.11.1) +# Prestashop 1.6.x & 1.7.x - Mercado Pago Module (v4.11.2) With the official module of Mercado Pago you will have an integration, hundreds of solutions and thousands of sales. Maximize your conversions and make your customers return to your store by increasing their confidence in the shopping experience. diff --git a/controllers/front/standardvalidation.php b/controllers/front/standardvalidation.php index e4556e03..2e03b5a8 100644 --- a/controllers/front/standardvalidation.php +++ b/controllers/front/standardvalidation.php @@ -31,10 +31,13 @@ class MercadoPagoStandardValidationModuleFrontController extends ModuleFrontController { + public $mp_transaction; + public function __construct() { parent::__construct(); $this->mercadopago = MPApi::getInstance(); + $this->mp_transaction = new MPTransaction(); } /** @@ -46,22 +49,42 @@ public function initContent() { $typeReturn = Tools::getValue('typeReturn'); $payment_ids = Tools::getValue('collection_id'); + $cartId = Tools::getValue('cart_id'); - if (isset($payment_ids) && $payment_ids != 'null' && $typeReturn != 'failure') { - $payment_id = explode(',', $payment_ids)[0]; - $payment = $this->mercadopago->getPaymentStandard($payment_id); - if ($payment !== false) { - $cart_id = $payment['external_reference']; - $transaction_id = $payment['order']['id']; + if (isset($payment_ids) && $payment_ids != false && $payment_ids != 'null' && $typeReturn != 'failure') { + $payment_id = explode(',', $payment_ids)[0]; + $this->redirectCheck($payment_id); + return; + } - $cart = new Cart($cart_id); - $order = $this->createOrder($cart, $transaction_id); + if (isset($cartId)) { + $order = $this->mp_transaction->where('cart_id', '=', $cartId)->get(); + $merchant = $this->mercadopago->getMerchantOrder($order['merchant_order_id']); + $payment_id = $merchant['payments'][0]['id']; - $this->redirectOrderConfirmation($cart, $order); - } + $this->redirectCheck($payment_id); + return; } + } + /** + * Default function to call redirect + * + * @return void + */ + public function redirectCheck($payment_id) + { + $payment = $this->mercadopago->getPaymentStandard($payment_id); + + if ($payment !== false) { + $cart_id = $payment['external_reference']; + $transaction_id = $payment['order']['id']; + $cart = new Cart($cart_id); + $order = $this->createOrder($cart, $transaction_id); + + $this->redirectOrderConfirmation($cart, $order); + } $this->redirectError(); } diff --git a/mercadopago.php b/mercadopago.php index 0e8e9d0b..1875530a 100644 --- a/mercadopago.php +++ b/mercadopago.php @@ -24,7 +24,7 @@ * International Registered Trademark & Property of MercadoPago */ -define('MP_VERSION', '4.11.1'); +define('MP_VERSION', '4.11.2'); define('MP_ROOT_URL', dirname(__FILE__)); if (!defined('_PS_VERSION_')) { @@ -73,7 +73,7 @@ public function __construct() $this->bootstrap = true; //Always update, because prestashop doesn't accept version coming from another variable (MP_VERSION) - $this->version = '4.11.1'; + $this->version = '4.11.2'; $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); parent::__construct();