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 v7.1.1 #345

Merged
merged 1 commit into from
Jan 16, 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ 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).

## [7.1.1] - 2024-01-15
### Fixed
- Removes incorrectly showing the discount and commison information in the cart
- TypeError when opening orders in the admin panel

## [7.1.0] - 2024-01-11
### Added
- Added support to Woocommerce Blocks
### Fixed
- Fixed the error that did not allow changing the name of checkouts
- Fix checkout pro modal mode

## [7.0.6] - 2023-12-11
### Fixed
Expand Down
52 changes: 21 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,36 @@
<p align="center"><a href="https://www.mercadopago.com/"> <img src="https://http2.mlstatic.com/frontend-assets/ui-navigation/5.18.3/mercadopago/[email protected]" height="80" width="auto" alt="MercadoPago">
</a></p>
# Plugins Enablers (Woocommerce)

<p align="center">
<img src="https://img.shields.io/wordpress/plugin/v/woocommerce-mercadopago" alt="version">
<img src="https://img.shields.io/wordpress/plugin/dt/woocommerce-mercadopago" alt="download">
<img src="https://img.shields.io/github/license/mercadopago/cart-woocommerce" alt="license">
</p>
[![made-with-Php](https://img.shields.io/badge/Made%20with-Php-1f425f.svg)](https://www.php.net/) [![php-version](https://img.shields.io/badge/Php->=7.4-1f425f)]()

The Mercado Pago payments for WooCommerce plugin allows you to expand the functionalities of your online store and offer a unique payment experience for your customers.
The base project for the Plugins Enablers Initiative.

<br/>
## Install

## Documentation in English
Open your terminal and run the script below in your ````wp-content/plugins```` to install the base plugin.

For a better experience, you will be redirected to our site by clicking on the links below:
````
plugin_base_dir="woocommerce-plugins-enablers" \
&& git clone --quiet --recursive -j8 [email protected]:melisource/fury_woocommerce-plugins-enablers.git $plugin_base_dir \
&& cd $plugin_base_dir && composer i && composer i -d "./packages/sdk/"
````

* [Introduction](https://www.mercadopago.com.ar/developers/en/guides/plugins/woocommerce/introduction/)
* [Installation](https://www.mercadopago.com.ar/developers/en/docs/woocommerce/how-tos/install-module-manually)
* [Integration](https://www.mercadopago.com.ar/developers/en/docs/woocommerce/integration-configuration/plugin-configuration)
* [Payments configuration](https://www.mercadopago.com.ar/developers/en/docs/woocommerce/payments-configuration)
* [Test and receive payments](https://www.mercadopago.com.ar/developers/en/docs/woocommerce/integration-test)
## Getting started

## Documentación en Español
The purpose of this tutorial is to support the creation and integration of payment gateway plugins to the base plugin.

Para una mejor experiencia, será redirigido a nuestro sitio haciendo clic en los links a abajo:
#### Creating and integrating a payment gateway to the base plugin

* [Introducción](https://www.mercadopago.com.ar/developers/es/guides/plugins/woocommerce/introduction/)
* [Instalación](https://www.mercadopago.com.ar/developers/es/docs/woocommerce/how-tos/install-module-manually)
* [Integración](https://www.mercadopago.com.ar/developers/es/docs/woocommerce/integration-configuration/plugin-configuration)
* [Preferencias de pago](https://www.mercadopago.com.ar/developers/es/docs/woocommerce/payments-configuration)
* [Prueba y recibe pagos](https://www.mercadopago.com.ar/developers/e/docs/woocommerce/integration-test)
It is necessary that the creation of the payment gateway plugin be done along the lines of an additional Woocommerce plugin, and as part of the process, we must create a main class that will add the Wordpress loading hook to call the method that allows the plugin to be recognized as a Woocommerce payment gateway plugin.

## Documentação em Português
````
add_action('wp_loaded', 'initPaymentGateway');
````

Para uma melhor experiência, você será redirecionado para o nosso site, clicando nos links abaixo:
In addition, we must create a custom class to extend Woocommerce gateway class, allowing inheritance of gateway methods and the [configs api](https://woocommerce.com/document/settings-api/).

* [Introdução](https://www.mercadopago.com.br/developers/pt/guides/plugins/woocommerce/introduction/)
* [Instalação](https://www.mercadopago.com.br/developers/pt/docs/woocommerce/how-tos/install-module-manually)
* [Integração](https://www.mercadopago.com.br/developers/pt/docs/woocommerce/integration-configuration/plugin-configuration)
* [Preferências de pagamento](https://www.mercadopago.com.br/developers/pt/docs/woocommerce/payments-configuration)
* [Teste e receba pagamentos](https://www.mercadopago.com.br/developers/pt/docs/woocommerce/integration-test)
````
class MPGateway extends \WC_Payment_Gateway {}
````

*To learn more about how to structure your gateway class, access the official [Woocommerce documentation](https://woocommerce.com/document/payment-gateway-api/).*

Expand All @@ -54,4 +45,3 @@ function initPaymentGateway() {

As you can see in the example above, ````mercadopago```` is a global variable that represents an instance of the base plugin, global variables can be accessed from anywhere, that is, inside and outside the plugin. This variable allows payment gateway plugins to access resources of the base plugin.

Something's wrong? [Get in touch with our support](https://www.mercadopago.com.ar/developers/en/support)
10 changes: 9 additions & 1 deletion changelog.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
CHANGELOG:
== Changelog ==

= v7.1.0 (26/12/2023) =
= v7.1.1 (15/01/2024) =
* Fixed
- Removes incorrectly showing the discount and commison information in the cart
- TypeError when opening orders in the admin panel

= v7.1.0 (11/01/2024) =
* Added
- Added support to Woocommerce Blocks
* Fixed:
- Fixed the error that did not allow changing the name of checkouts
- Fix checkout pro modal mode

= v7.0.6 (11/12/2023) =
* Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "woocommerce-mercadopago",
"description": "Woocommerce MercadoPago Payment Gateway",
"version": "7.1.0",
"version": "7.1.1",
"main": "main.js",
"repository": {
"type": "git",
Expand Down
10 changes: 9 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: ecommerce, mercadopago, woocommerce
Requires at least: 5.6
Tested up to: 6.4
Requires PHP: 7.4 to 8.3
Stable tag: 7.1.0
Stable tag: 7.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -136,9 +136,17 @@ Check out our <a href="https://www.mercadopago.com.br/developers/pt/plugins_sdks

== Changelog ==

= v7.1.1 (15/01/2024) =
* Fixed
- Removes incorrectly showing the discount and commison information in the cart
- TypeError when opening orders in the admin panel

= v7.1.0 (11/01/2024) =
* Added
- Added support to Woocommerce Blocks
* Fixed:
- Fixed the error that did not allow changing the name of checkouts
- Fix checkout pro modal mode

= v7.0.6 (11/12/2023) =
* Fixed
Expand Down
4 changes: 0 additions & 4 deletions src/Blocks/AbstractBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,6 @@ public function registerDiscountAndCommissionFeesOnCart()
}

if (isset($this->gateway)) {
if ($this->mercadopago->hooks->cart->isCart()) {
$this->mercadopago->helpers->cart->removeDiscountAndCommissionOnFeesFromBlocks($this->gateway);
}

$action = $this->mercadopago->helpers->session->getSession(self::ACTION_SESSION_KEY);

if ($action == 'add') {
Expand Down
4 changes: 0 additions & 4 deletions src/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,6 @@ public function registerDiscountAndCommissionFeesOnCart()
if ($this->mercadopago->hooks->checkout->isCheckout()) {
$this->mercadopago->helpers->cart->addDiscountAndCommissionOnFees($this);
}

if ($this->mercadopago->hooks->cart->isCart()) {
$this->mercadopago->helpers->cart->removeDiscountAndCommissionOnFees($this);
}
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Gateways/CustomGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,8 @@ public function renderInstallmentsRateDetails($order_id): void
$currency = $this->countryConfigs['currency_symbol'];
$installments = $this->mercadopago->orderMetadata->getInstallmentsMeta($order);
$installmentAmount = $this->mercadopago->orderMetadata->getTransactionDetailsMeta($order);
$transactionAmount = $this->mercadopago->orderMetadata->getTransactionAmountMeta($order);
$totalPaidAmount = $this->mercadopago->orderMetadata->getTotalPaidAmountMeta($order);
$transactionAmount = Numbers::makesValueSafe($this->mercadopago->orderMetadata->getTransactionAmountMeta($order));
$totalPaidAmount = Numbers::makesValueSafe($this->mercadopago->orderMetadata->getTotalPaidAmountMeta($order));
$totalDiffCost = (float) $totalPaidAmount - (float) $transactionAmount;

if ($totalDiffCost > 0) {
Expand Down Expand Up @@ -726,8 +726,8 @@ public function registerInstallmentsFeeOnAdminOrder(int $orderId): void
$usedGateway = $this->mercadopago->orderMetadata->getUsedGatewayData($order);

if ($this::ID === $usedGateway) {
$totalPaidAmount = Numbers::format($this->mercadopago->orderMetadata->getTotalPaidAmountMeta($order));
$transactionAmount = Numbers::format($this->mercadopago->orderMetadata->getTransactionAmountMeta($order));
$totalPaidAmount = Numbers::format(Numbers::makesValueSafe($this->mercadopago->orderMetadata->getTotalPaidAmountMeta($order)));
$transactionAmount = Numbers::format(Numbers::makesValueSafe($this->mercadopago->orderMetadata->getTransactionAmountMeta($order)));
$installmentsFeeAmount = $totalPaidAmount - $transactionAmount;

if ($installmentsFeeAmount > 0) {
Expand Down
23 changes: 23 additions & 0 deletions src/Helpers/Numbers.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,29 @@ public static function format(float $value, int $decimals = 2, string $separator
return (float) number_format($value, $decimals, $separator, '');
}

/**
* makes the variable a safe float
*
* @param mixed $value
*
* @return float
*/
public static function makesValueSafe($value): float
{
if (is_string($value) && strlen($value) > 0 && !is_numeric($value[0])) {
$fixedValue = self::removeNonNumericPrefix($value);
return floatval($fixedValue);
}
return floatval($value);
}

public static function removeNonNumericPrefix($str)
{
return preg_replace("/[^0-9,.]/", "", $str);
}



/**
* Format value with currency symbol
*
Expand Down
2 changes: 1 addition & 1 deletion src/WoocommerceMercadoPago.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class WoocommerceMercadoPago
/**
* @const
*/
private const PLUGIN_VERSION = '7.1.0';
private const PLUGIN_VERSION = '7.1.1';

/**
* @const
Expand Down
2 changes: 1 addition & 1 deletion woocommerce-mercadopago.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Mercado Pago payments for WooCommerce
* Plugin URI: https://github.com/mercadopago/cart-woocommerce
* Description: Configure the payment options and accept payments with cards, ticket and money of Mercado Pago account.
* Version: 7.1.0
* Version: 7.1.1
* Author: Mercado Pago
* Author URI: https://developers.mercadopago.com/
* Text Domain: woocommerce-mercadopago
Expand Down
Loading