=== CatCode Partita IVA Lookup with Openapi for WooCommerce ===
Contributors: catcodestudio
Tags: partita iva, vat number, b2b, checkout, woocommerce
Requires at least: 6.4
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

Finds an Italian company by its Partita IVA at the WooCommerce checkout through the Openapi Company API and fills in the company name and address.

== Description ==

A business buyer types the Partita IVA, presses "Find company", and the company name and registered address appear in the billing fields. The data comes from the Company API of [Openapi](https://openapi.com/) (company.openapi.com), which you connect with a token from your own Openapi account.

* **"Find company" button** next to the Partita IVA field, on the classic and the block checkout. Leaving the field does the same lookup.
* **Company name and address filled in** — name, street, CAP, town and province from the basic data of the company (IT-start). Leaving the field only fills empty fields; the button replaces what is there.
* **Check digit first** — a mistyped Partita IVA is caught without sending a request.
* **Answers are reused** — a company found once is not requested again for 24 hours (you choose how long), because every request is billed by Openapi.
* **Your field or ours** — the plugin adds its own Partita IVA field, or works on the fields of the CatCode FatturaPA plugin, or on the field of another plugin that you name (classic checkout).
* **Kept with the order** — number, name, status and address are saved on the order, with a note, and shown in a box on the order screen.
* **If Openapi cannot be reached, or the credit ran out** — the order goes through and a note says why the number was not verified.
* **Sandbox** — a switch for test.company.openapi.com with its own token.
* HPOS and block checkout compatible.
// @pro-begin
* Translations included: English, Italian.
// @pro-end

// @pro-begin
= Pro =

The Pro version is sold on [catcode.com.ua](https://catcode.com.ua/modules/catcode-piva-lookup-with-openapi-for-woocommerce/), with a 7-day trial that never starts by itself:

* **PEC and codice destinatario filled in** — the PEC address (IT-pec) and the SDI code (IT-sdicode) of the company go into the fields for the fattura elettronica: the plugin's own fields, the fields of CatCode FatturaPA, or the fields of another plugin.
* **Ceased companies** — refuse the order or warn the buyer when the company is shown as ceased, with the real-time flag of the tax office (IT-closed).
* **Public administration and split payment marks** on the order (IT-pa, IT-splitpayment).
* **Other countries** — France, Germany, Spain, Portugal, United Kingdom, Belgium, Austria, Switzerland and Poland with name and address; the other EU member states with a VIES check of the VAT number.
* **Look up again** — a button on the order screen sends a fresh request and writes the change to the order notes.
* **Daily limit and request journal** — a ceiling of requests per day and a table of requests per month and method.
* **Stricter when Openapi is unavailable** — choose whether an order is refused when the number cannot be checked.
* Updates from catcode.com.ua.

The licence runs for 1-5 years and includes updates and support for that term; a purchased licence keeps its Pro features after the term ends. One key covers two sites: the shop and its test copy.
// @pro-end

Openapi is a third-party service. This plugin is an independent integration made by CatCode; it is not an official plugin of Openapi and is not affiliated with or endorsed by Openapi.

== External services ==

The plugin connects to the Company API of Openapi (Openapi S.p.A., [openapi.com](https://openapi.com/)) at `company.openapi.com`, or at `test.company.openapi.com` when the sandbox is switched on. You need an Openapi account and a token; requests in production are billed by Openapi from the credit of your account. Documentation: [console.openapi.com/apis/company/documentation](https://console.openapi.com/apis/company/documentation). Terms and privacy policy of the service: [terms and conditions](https://openapi.com/terms-conditions-openapi), [privacy policy](https://privacy.openapi.com/en-privacy-policy.html?domain=openapi.com).

* When a buyer presses "Find company" or leaves the Partita IVA field, when an order with a Partita IVA is placed, and when you press "Check connection" or "Look up" on the settings screen: the Partita IVA (or codice fiscale) that was typed, and your Openapi token in the Authorization header. The request comes from your server; no other data of the buyer is sent.
// @pro-begin
* With the Pro options switched on, the same number is also sent to the IT-pec, IT-sdicode, IT-closed, IT-pa and IT-splitpayment methods, and a foreign VAT number to the "-start" method of its country or to EU-vies.
// @pro-end

== Installation ==

1. Upload the plugin and activate it. WooCommerce must be active.
2. Create a token for the Company API in the Openapi console (the IT-start method is enough for the free features).
3. WooCommerce → **Partita IVA Lookup**: paste the token, press "Check connection" and look at the settings.
4. Open the checkout: the "Partita IVA" field with the "Find company" button is there.

== Frequently Asked Questions ==

= Is the lookup free? =

The plugin is. The data comes from Openapi, which bills every request in production from the credit of your account; the price of each method is shown in your Openapi console. The sandbox is for tests and knows only the companies of its example list.

= Which token do I need? =

A token of the environment you use (production or sandbox) whose scopes include the Company API methods the plugin calls. IT-start is enough for the free features.

= Can private buyers still order? =

Yes. Leave "Required" off and the field is optional.

= I already have a Partita IVA field from another plugin. =

Choose "Use the fields of another plugin" and type the name of that field. This works on the classic checkout.

== Changelog ==

= 1.0.0 =
* First release.
