From 43aa4cb5d3ac1a5f2cb70a3fabe9d6eb9b2a9288 Mon Sep 17 00:00:00 2001
From: cleitonaguiarandrade
Date: Thu, 21 Jul 2022 17:10:48 -0300
Subject: [PATCH 1/5] Did validations to check when no payment id is returned
---
controllers/front/standardvalidation.php | 37 +++++++++++++++++++-----
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/controllers/front/standardvalidation.php b/controllers/front/standardvalidation.php
index e4556e03..664cac63 100644
--- a/controllers/front/standardvalidation.php
+++ b/controllers/front/standardvalidation.php
@@ -1,4 +1,5 @@
mercadopago = MPApi::getInstance();
+ $this->mp_transaction = new MPTransaction();
}
/**
@@ -46,20 +49,38 @@ public function initContent()
{
$typeReturn = Tools::getValue('typeReturn');
$payment_ids = Tools::getValue('collection_id');
+ $cartId = Tools::getValue('cart_id');
+
+ if (!isset($payment_ids) && isset($cartId) && $cartId != 'null' && $typeReturn != 'failure') {
+ $order = $this->mp_transaction->where('cart_id', '=', $cartId)->get();
+ $merchant = $this->mercadopago->getMerchantOrder($order['merchant_order_id']);
+ $payment_id = $merchant['payments'][0]['id'];
+
+ $this->redirectCheck($payment_id);
+ }
if (isset($payment_ids) && $payment_ids != 'null' && $typeReturn != 'failure') {
$payment_id = explode(',', $payment_ids)[0];
- $payment = $this->mercadopago->getPaymentStandard($payment_id);
+ $this->redirectCheck($payment_id);
+ }
+ }
- if ($payment !== false) {
- $cart_id = $payment['external_reference'];
- $transaction_id = $payment['order']['id'];
+ /**
+ * Default function to check where to redirect the page
+ *
+ * @return void
+ */
+ public function redirectCheck($payment_id)
+ {
+ $payment = $this->mercadopago->getPaymentStandard($payment_id);
- $cart = new Cart($cart_id);
- $order = $this->createOrder($cart, $transaction_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->redirectOrderConfirmation($cart, $order);
}
$this->redirectError();
From 44f0ce2e293b9d6a8e409bdb49dad552ccb26cb2 Mon Sep 17 00:00:00 2001
From: cleitonaguiarandrade
Date: Thu, 28 Jul 2022 10:26:18 -0300
Subject: [PATCH 2/5] Added new validation for when there's no payment id
---
controllers/front/standardvalidation.php | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/controllers/front/standardvalidation.php b/controllers/front/standardvalidation.php
index 664cac63..2e03b5a8 100644
--- a/controllers/front/standardvalidation.php
+++ b/controllers/front/standardvalidation.php
@@ -1,5 +1,4 @@
mp_transaction->where('cart_id', '=', $cartId)->get();
- $merchant = $this->mercadopago->getMerchantOrder($order['merchant_order_id']);
- $payment_id = $merchant['payments'][0]['id'];
+ if (isset($payment_ids) && $payment_ids != false && $payment_ids != 'null' && $typeReturn != 'failure') {
+ $payment_id = explode(',', $payment_ids)[0];
$this->redirectCheck($payment_id);
+ return;
}
- if (isset($payment_ids) && $payment_ids != 'null' && $typeReturn != 'failure') {
- $payment_id = explode(',', $payment_ids)[0];
+ 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->redirectCheck($payment_id);
+ return;
}
}
/**
- * Default function to check where to redirect the page
+ * Default function to call redirect
*
* @return void
*/
@@ -82,7 +85,6 @@ public function redirectCheck($payment_id)
$this->redirectOrderConfirmation($cart, $order);
}
-
$this->redirectError();
}
From 0af8ab9805af0514b31f5f7fb93e5ef1befc561c Mon Sep 17 00:00:00 2001
From: cleitonaguiarandrade
Date: Fri, 12 Aug 2022 15:18:31 -0300
Subject: [PATCH 3/5] Updated version
---
CHANGELOG.md | 5 +++++
README.md | 2 +-
mercadopago.php | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c3b308f..85ea1388 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-15-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/mercadopago.php b/mercadopago.php
index 0e8e9d0b..08d340bd 100644
--- a/mercadopago.php
+++ b/mercadopago.php
@@ -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();
From 0ab666f2a0830ee0616bf116ab954524759b4520 Mon Sep 17 00:00:00 2001
From: cleitonaguiarandrade
Date: Tue, 16 Aug 2022 00:40:28 -0300
Subject: [PATCH 4/5] Changed version of MP_VERSION constant to 4.11.2
---
mercadopago.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mercadopago.php b/mercadopago.php
index 08d340bd..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_')) {
From 1cef3ea167f1e75ad35d99f5cab9a9a9be723dbe Mon Sep 17 00:00:00 2001
From: cleitonaguiarandrade
Date: Tue, 16 Aug 2022 10:03:58 -0300
Subject: [PATCH 5/5] Changed release date
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 85ea1388..8f4b9f50 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,7 @@ 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-15-08
+## [4.11.2] - 2022-16-08
### Fixed
- PSE return page