=== Fintoc for WooCommerce ===
Contributors: fintoc
Tags: woocommerce, payments, fintoc, bank transfer, cards, chile, mexico, clp, mxn
Requires at least: 6.2
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.2.0
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Accept bank transfers and card payments in Chile (CLP) and Mexico (MXN) through Fintoc. Customers pick their method on Fintoc's hosted SmartCheckout and orders are confirmed via webhooks verified against the Fintoc API.

== Description ==

Fintoc for WooCommerce lets your store accept account-to-account bank transfers and card payments through [Fintoc](https://fintoc.com/).

When a customer places an order, the plugin creates a Fintoc Checkout Session and redirects the customer to Fintoc's secure hosted checkout, where they pick their payment method and authorize the payment. The order is then confirmed in the background through webhook events; each event triggers a lookup against the Fintoc API, which is the source of truth for payment status.

= Features =

* Hosted, redirect-based checkout — no card data ever touches your server.
* Works with both the classic checkout shortcode and the new Blocks (Store API) checkout.
* HPOS (High-Performance Order Storage) compatible.
* API-verified webhooks — no webhook secret to configure — with replay protection and idempotent processing.
* Refunds initiated directly from the WooCommerce order screen.
* Separate test and live API keys, with an explicit test-mode toggle.
* Supports Chilean Pesos (CLP) and Mexican Pesos (MXN).

== Installation ==

1. Upload the `fintoc-for-woocommerce` folder to `/wp-content/plugins/`, or install the ZIP from **Plugins > Add New > Upload Plugin**.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Go to **WooCommerce > Settings > Payments > Fintoc**.
4. Enable the gateway, choose test or live mode, and paste your secret key from the [Fintoc dashboard](https://app.fintoc.com/).
5. Copy the **Webhook endpoint** URL shown on the settings page, register it in your Fintoc dashboard, and subscribe to the `payment_intent.*`, `checkout_session.*` and `refund.*` events.
6. Place a test order to confirm the full round-trip.

== Frequently Asked Questions ==

= Which currencies are supported? =

Chilean Pesos (CLP) and Mexican Pesos (MXN). The gateway hides itself automatically when the store currency is anything else.

= Do I need to expose a webhook? =

Yes. Webhooks are how Fintoc confirms payments. The plugin shows the exact endpoint URL to register on the settings screen. No webhook secret is needed: the plugin verifies every event by fetching the payment state directly from the Fintoc API before updating an order.

= Is the Blocks checkout supported? =

Yes. Both the classic shortcode checkout and the Blocks/Store API checkout are supported.

== Changelog ==

= 1.2.0 =
* SmartCheckout: sessions no longer pin bank_transfer — the Fintoc-hosted checkout offers every payment method enabled for the organization (bank transfer, cards).
* Test mode now defaults to off.
* Refund hardening: settings now instruct subscribing to refund.* events; reverting a failed refund reverses restocked inventory and restores the order's real pre-refund status; the customer is notified when a refund is reverted; Dashboard-created refunds are reconciled into WooCommerce; canceled refunds revert like failed ones; refund webhooks validate that the refund belongs to the order; permanent API errors no longer cause endless webhook retries; cross-mode refunds and over-precise partial amounts fail early with clear messages.

= 1.1.0 =
* Webhooks are now verified against the Fintoc API instead of an HMAC signature: the payload only locates the order and every state change comes from an authenticated API lookup. The webhook endpoint secret settings were removed — no secret to configure.
* Checkout sessions are created with `payment_method_types: bank_transfer`, skipping Fintoc's method selector so the checkout matches what the gateway promises.
* Embedded payments are now read from the documented `payment_resource.payment_intent` shape of the checkout session, fixing immediate confirmation on return and the `checkout_session.finished` safety net.
* Refund outcomes are reconciled asynchronously: `refund.succeeded` confirms the refund, and `refund.failed` reverts the WooCommerce refund, restores the order status and emails the store admin.

= 1.0.0 =
* Initial release: hosted checkout, webhooks, refunds, Blocks support, HPOS compatibility.
