=== Factunexo - Facturación Electrónica y Contabilidad For WooCommerce ===
Contributors: xinersoft
Donate link: https://www.xinersoft.com
Tags: woocommerce, e-invoicing, sri, ecuador, facturacion electronica
Requires at least: 6.8
Tested up to: 7.1
Stable tag: 1.0.10
Requires PHP: 8.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatic SRI electronic invoicing for WooCommerce stores in Ecuador. Issue authorized invoices from your orders with Factunexo.

== Description ==

Factunexo connects your WooCommerce store with the Factunexo electronic invoicing platform, so every sale is invoiced automatically and the invoice is authorized by the SRI (Servicio de Rentas Internas, Ecuador's tax authority).

= Main features =

* Automatic invoice issuing when an order reaches the status you choose (Processing or Completed)
* Real-time validation of Ecuadorian Cédula and RUC numbers at checkout
* Checkout fields for identification type and number, compatible with the classic checkout and the WooCommerce Blocks checkout
* Invoices issued to a company (legal entity) when the customer requests it
* Support for identification fields collected by another checkout plugin
* Invoice column in the WooCommerce orders list with sequential number and status (Saved, Authorized, Rejected)
* Product import and stock and price synchronization from Factunexo
* Compatible with HPOS (High-Performance Order Storage)
* Built-in diagnostic tools for connection and order data

= Requirements =

* An active Factunexo account ([sign up](https://www.factunexo.com.ec))
* WooCommerce 8.0 or later, installed and active
* A point of sale configured in Factunexo to issue invoices from (for example, 001 or 002)

== External services ==

This plugin connects to services operated by Xinersoft (Factunexo) to issue electronic invoices before the SRI. No data is sent until the store is connected to a Factunexo account.

**Factunexo API** (`https://merchant-01.contanexo.com`)

* When an order reaches the invoicing status configured in the plugin, it sends the buyer's data (name or company name, identification type and number, email, phone and billing address) together with the order's products, quantities, prices, taxes, discounts, shipping and payment method.
* When loading points of sale and warehouses, or importing and synchronizing products, it reads the merchant's catalog from Factunexo.
* When the store is connected, it sends the store URL and a WooCommerce REST API key pair with read and write permission, created so Factunexo can read and update the store's orders and products. In return it receives the API Key and API Secret for this store.
* Every other request is authenticated with the store's API Key and API Secret.

**Xinersoft authorization server** (`https://auth.xinersoft.com`, operated by Xinersoft, the company behind Factunexo)

* Before connecting, the plugin asks the Factunexo API which authorization server to use (`/.well-known/oauth-protected-resource`) and reads that server's public metadata (`/.well-known/oauth-authorization-server`). These requests carry no store data.
* When the administrator clicks "Conectar con Factunexo", the browser is redirected to the authorization server (OAuth 2.1 with PKCE), where the merchant signs in and approves the connection. The request includes the store's client identifier URL, the return URL in the store's admin, and random verification values.
* The authorization server downloads the store's public client description from `/wp-json/factunexo/v1/oauth-client` (store name and return URL only) to confirm where the connection returns to.
* After approval, the plugin exchanges the one-time authorization code for a short-lived token, which it uses once to connect the store. No credentials travel in URLs.

Terms of service: https://www.factunexo.com.ec/terminos-y-condiciones
Privacy policy: https://www.factunexo.com.ec/politica-de-privacidad

== Installation ==

1. In your WordPress admin, go to **Plugins → Add New**, search for "Factunexo" and click **Install Now**, or upload the plugin ZIP file from **Plugins → Add New → Upload Plugin**.
2. Activate the plugin. WooCommerce must be active.
3. Go to **Factunexo → Configuración** and click **Conectar con Factunexo** to link your account. You must be an owner or administrator of the Factunexo account, and the store must use HTTPS. You can also enter the API Key and API Secret manually.
4. Select the point of sale that will issue the invoices.
5. Choose when invoices are issued: when the order is Processing or when it is Completed.
6. Save the changes.

== Frequently Asked Questions ==

= Do I need a Factunexo account? =

Yes. You need an active Factunexo account with a plan that includes electronic invoicing. You can sign up at [factunexo.com.ec](https://www.factunexo.com.ec).

= Is the plugin free? =

The plugin is free. Issuing invoices requires a Factunexo subscription.

= Does it work with the WooCommerce Blocks checkout? =

Yes. The identification fields work in both the Blocks checkout and the classic checkout.

= When is the invoice created? =

When the order changes to the status selected in the settings. By default, that status is Completed.

= What happens if invoicing fails? =

The order is not affected. The error is added as a note on the order, and the plugin's diagnostic tools show the details.

= I already ask for the customer's identification with another plugin. Can I use it? =

Yes. In the settings you can turn off the plugin's checkout fields and enter the order meta keys where the other plugin stores the identification type and number.

= Why is my RUC rejected? =

Check that it has exactly 13 digits, that its third digit matches the taxpayer type (0 to 5 for individuals, 6 for public entities, 9 for private companies) and that it ends in the correct establishment number.

= Where are the invoices stored? =

In Factunexo. The plugin only stores references (IDs, sequential number, status and authorization number) in the WooCommerce order.

= Where can I get help? =

Read the documentation at [factunexo.com.ec](https://www.factunexo.com.ec/docs/integraciones/plugin-wordpress-woocommerce) or write to soporte@xinersoft.com.

== Screenshots ==

1. Plugin settings with the API Key and API Secret fields
2. Point of sale selection
3. Product import
4. Product synchronization
5. Identification fields in the WooCommerce checkout
6. Invoice issued to a company (legal entity)
7. Invoice column in the orders list, showing the sequential number and status

== Changelog ==

= 1.0.10 =
* WooCommerce dependency declared with the "Requires Plugins" header
* Admin scripts loaded with wp_enqueue_script
* Output escaping in admin notices and data
* New connection flow with OAuth 2.1 and PKCE: credentials no longer travel in URLs, and each store gets its own API credential
* Readme translated to English

= 1.0.0 =
* Initial release

== Upgrade Notice ==

= 1.0.10 =
Compatibility and security improvements required by the WordPress.org plugin guidelines.
