=== CFDI with Facturapi for WooCommerce ===
Contributors: catcodestudio
Tags: cfdi, facturapi, mexico, factura electronica, sat
Requires at least: 6.2
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

Issue Mexican CFDI 4.0 invoices for WooCommerce orders through your Facturapi account: RFC at checkout, SAT codes, PDF and XML in the order.

== Description ==

Facturapi is a Mexican electronic invoicing service with a public API. This plugin connects your WooCommerce store to your own Facturapi organization, so a paid order becomes a stamped CFDI 4.0.

Facturapi is a third-party product. This is an independent integration, not affiliated with or endorsed by Facturapi.

= What it does =

* **"I need an invoice" at checkout**, classic and block: RFC, fiscal name, tax regime, CFDI use and fiscal postal code. The RFC format is checked, and the regime and use must fit a person (13 characters) or a company (12).
* **SAT product and unit codes** on the product, on the category or as a default, with a search in the SAT catalogue through your Facturapi account.
* **A CFDI box in the order**: what stops the order from being invoiced, in plain words; the button; folio fiscal, status, PDF and XML.
* **Taxes from the order**: IVA 16, 8 or 0 %, IEPS when the tax rate is named so, and your choice for lines without tax (rate 0, exempt or no object of tax). Coupons go as the line's discount, shipping and fees as their own lines.
* **No duplicates**: the external ID, the idempotency key and the date are fixed before the first call. After a timeout, a rate-limit answer or a CFDI that Facturapi is still stamping, the plugin searches Facturapi for the order's external ID before it sends anything again.
* **Sales to the general public**: an order without an RFC goes to XAXX010101000 with use S01 and regime 616.
* **Other currencies**, with the FIX exchange rate you enter in the order.
* **Test and production**, switched in the settings, each with its own secret key. Each document remembers where it was issued.

= What you need =

A Facturapi account with an organization, and its Test and Live secret keys. For production invoices the organization needs its fiscal data and CSD certificate in Facturapi. Plans, stamps and fees are between you and Facturapi: https://www.facturapi.io/pricing . The Test environment needs no subscription.

= What the plugin does not do =

* It issues paid orders only, as payment in one exhibition (PUE). No PPD and no payment complement.
* No Carta Porte, foreign trade complement, withholdings (IVA or ISR retained) or payroll.
* No invoice with the foreign generic RFC XEXX010101000.
* A negative fee cannot be a CFDI line: use coupons for discounts.
* It does not choose SAT codes or tax treatment for you, and it is not tax advice. Agree on them with your accountant.

= External services =

This plugin connects to the **Facturapi API** (https://www.facturapi.io/v2) with the secret key you enter. It sends the order's lines, amounts and taxes and the buyer's fiscal data (RFC, name, regime, CFDI use, postal code) when a CFDI is issued, and searches the SAT catalogues when you use the search box. It sends nothing until you enter your key. Service: https://www.facturapi.io/ . Terms: https://www.facturapi.io/terms . Privacy: https://www.facturapi.io/privacy .

== Installation ==

1. Install and activate the plugin (WooCommerce must be active).
2. Open WooCommerce → CFDI Facturapi, enter the Test secret key (and the Live key for production) from your Facturapi dashboard, and test the connection.
3. Enter the postal code of the place of issue, the SAT code of shipping and how to report lines without tax.
4. Choose the SAT payment form of each payment method.
5. Set SAT codes on your categories or products.
6. Open a paid order and press "Issue CFDI" in the CFDI box.

== Frequently Asked Questions ==

= Which key do I paste? =

The organization's Test secret key (sk_test_…) for tests and its Live secret key (sk_live_…) for real invoices. Never the User secret key. The plugin stores the keys encrypted with the keys of your wp-config.php.

= Why must I choose the payment form myself? =

SAT asks for the actual form: credit card (04), debit card (28), transfer (03) and so on. A payment method's id does not say which one it was. Bank transfer, cheque and cash on delivery are preset.

= Why is there no default code for shipping? =

The code depends on what you sell and how you ship. The search box finds it in the SAT catalogue; agree on it with your accountant.

= The order total and the CFDI total differ by a cent =

SAT checks the tax line by line. Facturapi calculates every tax as base x rate, so if WooCommerce rounded the tax differently, the invoice follows the arithmetic. The order box shows the difference before you issue.

= Can I cancel a CFDI? =

In your Facturapi account, always. From the order with Pro.

== Screenshots ==

1. The settings: account, invoice data, SAT codes and payment forms.
2. "I need an invoice" at checkout.
3. The CFDI box in the order.

== Changelog ==

= 1.0.0 =
* First release: CFDI 4.0 through Facturapi, fiscal data at checkout, SAT codes by product and category, pre-check, PDF and XML.
