Skip to content

Commit

Permalink
Merge pull request #348 from mercadopago/release/7.2.1
Browse files Browse the repository at this point in the history
Release v7.2.1
  • Loading branch information
WilOliveira authored Feb 15, 2024
2 parents f4d60e5 + e767f30 commit 72451d0
Show file tree
Hide file tree
Showing 43 changed files with 13,485 additions and 17,968 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +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.2.1] - 2024-02-15
### Added
- We have added a warning banner for when the language configured in worpress does not have the translation in our plugin.
### Changed
- Improvements have been made to the readme and changelog files so that the markdown makes more sense to our users.
- Now our plugin constructs the URLs for the assets using the absolute path instead of the relative path.
- Prevent block scripts from loading on admin screens and do not load block scripts in checkouts that do not use Checkout Blocks.
- We've reduced the size of the metadata sent in the payment.
### Fixed
- We've fixed the currency conversion calculation.

## [7.2.0] - 2024-02-01
### Added
- Introducing Mercado PSE as a new payment method for our users in Colombia.
Expand Down
138 changes: 111 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,131 @@
# Plugins Enablers (Woocommerce)
# Mercado Pago Payment Gateway Plugin (Woocommerce)

[![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)]()

Welcome to the readme for Mercado Pago Payment Gateway Plugin. This guide is intended to provide users with the necessary information to understandand extend the functionality of the plugin.

The base project for the Plugins Enablers Initiative.

## Install
## Table of Contents

Open your terminal and run the script below in your ````wp-content/plugins```` to install the base plugin.
1. [Introduction](#introduction)

````
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/"
````
2. [Plugin Overview](#plugin-overview)

## Getting started
3. [WordPress and WooCommerce Basics](#wordpress-and-woocommerce-basics)

The purpose of this tutorial is to support the creation and integration of payment gateway plugins to the base plugin.
4. [Installation](#installation)

#### Creating and integrating a payment gateway to the base plugin
5. [Plugin Configuration](#plugin-configuration)

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.
6. [Hooks and Filters](#hooks-and-filters)

````
add_action('wp_loaded', 'initPaymentGateway');
````
7. [Customization](#customization)

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/).
8. [Contributing](#contributing)

````
class MPGateway extends \WC_Payment_Gateway {}
````
9. [Support and Issues](#support-and-issues)

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

After creating and defining your gateway class, you need to make Woocommerce aware of it through the woocommerce_payment_gateways filter. It is the responsibility of the base plugin to abstract Woocommerce resources, so to add our gateway class to the filter, just reference the registerGateway method.
## Introduction

Mercado Pago Payment Gateway Plugin is a WooCommerce payment gateway extension designed to facilitate secure online transactions. This guide will help you understand the inner workings of the plugin and provide information on how to extend its functionality.



## Plugin Overview



Mercado Pago Payment Gateway Plugin integrates seamlessly with WooCommerce, enabling users to make payments using Mercado Pago. The plugin is built with flexibility and extensibility in mind, allowing developers to customize and extend its features.



## WordPress and WooCommerce Basics



To work effectively with our plugin, it's essential to have a basic understanding of WordPress and WooCommerce. If you are new to these platforms, consider familiarizing yourself with the following resources:

- [WordPress Documentation](https://wordpress.org/documentation/)

- [WooCommerce Documentation](https://developer.woo.com/docs/)



## Installation



Follow these steps to manual installation :

1. Download the plugin from ths GitHub repository.
2. Run `npm install` and `composer install`
3. Run `sh bin/create-release-zip.sh` to generate the final zip used to install it in the store.
4. Upload the plugin files generated by zip to the `/wp-content/plugins/` directory or install it via the WordPress admin interface.
5. Activate the plugin through the 'Plugins' menu in WordPress.


you can also get the plugin directly from the wordpress page at https://wordpress.org/plugins/woocommerce-mercadopago/



## Plugin Configuration


After installation, navigate to the [Mercado Pago developer site](https://www.mercadopago.com/developers/en/docs/woocommerce/introduction) to view integration documentation and configure the plugin.



## Customization

The WooCommerce payment plugin provides flexibility for customization and extensions. You can extend existing functionalities or add new ones according to your specific needs.

### Example Payment Gateway Extension
You can also extend the payment gateway class to add new custom gateways. See an example:
```php
namespace MercadoPago\Woocommerce\Templates\Gateways;

use MercadoPago\Woocommerce\Gateways\AbstractGateway;
use MercadoPago\Woocommerce\Templates\Transactions\ExamplePaymentTransaction;
use MercadoPago\Woocommerce\Templates\WoocommerceMercadopagoTemplate;

class ExamplePaymentGateway extends AbstractGateway {
// ... (your code here)
}
```
function initPaymentGateway() {
global $mercadopago;
$mercadopago->hooks->gateway->registerGateway('MercadoPago\Woocommerce\Gateways\MPGateway');
In this example, the `ExamplePaymentGateway` class extends the payment gateway functionality and can be customized to add new payment options.

### Example Payment Transaction Extension

To extend the payment transaction class, you can create a custom class that inherits from `AbstractPaymentTransaction`. See the example below:

```php
namespace MercadoPago\Woocommerce\Templates\Transactions;

use MercadoPago\Woocommerce\Gateways\AbstractGateway;
use MercadoPago\Woocommerce\Transactions\AbstractPaymentTransaction;

class ExamplePaymentTransaction extends AbstractPaymentTransaction {
// ... (your code here)
}
````
```
In this example, the `ExamplePaymentTransaction` class extends the payment transaction functionality and can be customized as needed.

You can see more on the github wiki page.

## Support and Issues



For any issues or questions, please reach out to our [support team](https://www.mercadopago.com/developers/en/support/center/tickets).



Thank you for using our plugin!



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

3 changes: 1 addition & 2 deletions assets/js/checkouts/custom/mp-custom-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,8 @@ function initCardForm(amount = getAmount()) {

function getAmount() {
const amount = parseFloat(document.getElementById('mp-amount').value.replace(',', '.'));
const currencyRatio = parseFloat(document.getElementById('currency_ratio').value.replace(',', '.'));

return String(amount * currencyRatio);
return String(amount);
}

/**
Expand Down
Loading

0 comments on commit 72451d0

Please sign in to comment.