=== Cero Pendientes: Payment Reconciliation for WooCommerce ===
Contributors: bibian5519
Tags: mercado pago, woocommerce, pending orders, reconciliation, diagnostics
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
WC requires at least: 8.0
WC tested up to: 11.1

Diagnose your Mercado Pago setup in WooCommerce and manually reconcile orders stuck as pending though the payment was approved.

== Description ==

**This plugin does not charge or process payments.** It works alongside the official Mercado Pago plugin for WooCommerce (or any other way you collect with Mercado Pago) and helps with two very common problems:

* Orders that stay "Pending payment" or "On hold" even though the customer already paid (the payment notification was lost).
* Rejected payments or failing checkouts with no clear explanation, usually caused by a setting you can fix.

The admin interface is in Spanish (Argentina is the default). Spanish (Spain) and English (US) translation files are included. The Spanish text below is what the screens show.

= Diagnostics (WooCommerce > Conciliador MP) =

A list of checks, each one green, orange or red, with a plain-language explanation and what to do about it:

* Official Mercado Pago plugin detected, and its version.
* Mercado Pago payment methods enabled in WooCommerce.
* Test or production mode of the credentials (the token is never displayed).
* Site served over HTTPS.
* The payment notification address (webhook) and the REST API answer from the server.
* WP-Cron is running (WooCommerce uses it to cancel and update orders).
* Store currency versus the country of your Mercado Pago account.
* Number of Mercado Pago orders pending or on hold in the last N days.

= Manual reconciliation =

Lists the stuck Mercado Pago orders. For each one you query Mercado Pago for the real payment status (using the payment ID stored by the official plugin, or the order's external reference) and see the result:

* Approved payment: "Mark as paid" button.
* Rejected payment: "Mark as failed" button.
* Cancelled payment: "Cancel order" button.
* No payment, in process or in mediation: explained, and no action is offered.

**Nothing is changed without your click.** Every change leaves an order note with the payment number, the Mercado Pago status, the previous status and who applied it. For safety, if the amount or currency of the payment does not match the order, or the external reference belongs to another order, no action is offered.

= Privacy and security =

* No tracking, no statistics, no ads. No data is sent to the plugin authors.
* Mercado Pago is only queried when an administrator presses a button.
* The access token is read from the official plugin or stored in this plugin without autoload. It is never displayed on screen or written to logs, and it only travels in the header of the request to Mercado Pago.
* Every action requires the `manage_woocommerce` capability and a nonce.
* Compatible with High-Performance Order Storage (HPOS).

= External service: Mercado Pago API (Servicio externo) =

This plugin connects to the Mercado Pago API (`https://api.mercadopago.com`) to read the real status of your store's payments and to check that your access token works.

* **What is sent:** your access token (in the Authorization header), and the payment ID stored in the order or the order's external reference (for example `WC-123`). No customer personal data is sent.
* **When:** only when an administrator presses "Consultar", "Consultar todas a Mercado Pago" or "Correr diagnóstico completo". Never in the background, on page load, or on activation.
* **Endpoints used (read only, GET):** `/v1/payments/{id}`, `/v1/payments/search` and `/users/me`.
* Service provided by Mercado Pago. Developer terms and conditions: https://www.mercadopago.com.ar/developers/es/docs/resources/legal/terms-and-conditions . Privacy policy: https://www.mercadopago.com.ar/privacidad
* In addition, the full diagnostic visits two addresses of your own site (the payment notification address and the REST API) to check that they respond. No other server is contacted.

= Disclaimer =

Independent plugin. It is not affiliated with or endorsed by Mercado Pago or WooCommerce. "Mercado Pago" and "WooCommerce" are trademarks of their respective owners and are mentioned only to say which services the plugin works with.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/`, or install it from Plugins > Add New.
2. Activate the plugin. WooCommerce is required.
3. Go to WooCommerce > Conciliador MP.
4. If the official Mercado Pago plugin is configured, this plugin uses its token. Otherwise enter the token in the Ajustes (Settings) tab.

== Frequently Asked Questions ==

= Does this replace the official Mercado Pago plugin? =

No. It does not process payments. You still need the official plugin (or another way of charging with Mercado Pago) so your customers can pay. This plugin only diagnoses and reconciles.

= Why do my orders stay "Pending payment" even though the customer paid? =

Mercado Pago tells your store about a payment through a notification address (webhook). If that notice does not arrive, for example because of a firewall, a redirect, a server error, or WP-Cron not running, the order is never updated. The diagnostic checks those causes and the reconciliation lets you fix the affected orders.

= Where does it get the access token? =

If you do not enter your own, it reads the production token (or the test token, depending on the mode) from the official plugin. If you enter one in the Ajustes tab, that one takes priority. In neither case is it displayed or logged.

= What if the payment amount does not match the order? =

No apply button is offered. Review the payment by hand in your Mercado Pago account.

= Can a change be undone? =

Every change is recorded as an order note and made with WooCommerce's normal functions, so you can change the status again from the order screen. For a refund, use Mercado Pago.

= Does it work with HPOS? =

Yes. It declares compatibility with High-Performance Order Storage and only uses WooCommerce's order API.

= What is deleted on uninstall? =

The settings, your own token, temporary results and the reconciliation mark on orders. Notes already added to orders are kept as history.

= Which languages are included? =

Spanish (Argentina, the source language), Spanish (Spain) and English (US).

= For developers: which hooks are available? =

Actions: `cpmp_payment_checked( $order, $evaluation )`, `cpmp_order_reconciled( $order, $evaluation, $source, $user_id )`, `cpmp_diagnostic_completed( $checks )` and `cpmp_render_tab_{slug}`.

Filters: `cpmp_status_action_map( $map )` (Mercado Pago status to action: `complete`, `fail`, `cancel`, `none`), `cpmp_stuck_order_statuses( $statuses )`, `cpmp_stuck_orders_query_args( $args )`, `cpmp_before_apply( $proceed, $order, $evaluation, $source )`, `cpmp_diagnostic_checks( $checks )`, `cpmp_admin_tabs( $tabs )` and `cpmp_access_token( $token )`.

== Screenshots ==

1. Full diagnostic: every check in green, orange or red with what to do.
2. Mercado Pago orders that are pending or on hold.
3. The real status of each order in Mercado Pago, with the button to apply it.
4. Settings: days to check, minimum age and access token (never displayed).
5. Clear message when Mercado Pago rejects the token.

== Changelog ==

= 1.0.0 =
* First release: diagnostics, manual reconciliation with an order note, HPOS compatibility, es_AR, es_ES and en_US translations.

== Upgrade Notice ==

= 1.0.0 =
First release.
