Skip to content

Commit

Permalink
Merge pull request #245 from PluginAndPartners/release/prestashop-4.1…
Browse files Browse the repository at this point in the history
…1.2-develop

Release/prestashop 4.11.2 develop
  • Loading branch information
cleitonaguiarandrade authored Aug 16, 2022
2 parents 2d3fb40 + 1cef3ea commit 1d4ff72
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</a>
</p>

# 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.

Expand Down
43 changes: 33 additions & 10 deletions controllers/front/standardvalidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand All @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions mercadopago.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_')) {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1d4ff72

Please sign in to comment.