
Step 101
In WooCommerce, create REST API keys (Settings → Advanced → REST API) with read and write permission.
WooCommerce runs most small ecommerce in Spain and its hook system is made for this. There is no Cofactu plugin on WordPress.org; there is a webhook and an add_action that calls it. If you would rather not touch PHP, Make or Zapier do the same, and the direct catalogue connection receives orders with no code.
No WordPress.org plugin · webhook and direct connection. Today there is no Cofactu plugin to install from WordPress.org, and no date for one. Two routes work: the universal webhook, which invoices and files with the AEAT, and the direct catalogue connection, which receives the shop's orders and prepares the invoice as a draft.
Today there is no Cofactu plugin to install from WordPress.org, and no date for one. Two routes work: the universal webhook, which invoices and files with the AEAT, and the direct catalogue connection, which receives the shop's orders and prepares the invoice as a draft.
| Route | Today | What it does |
|---|---|---|
| Cofactu plugin, module or app on WordPress.org | Not available | It does not exist and has no date. There is nothing from Cofactu to install in the store. |
| Universal webhook | Available | Invoices every order you send and files it with the AEAT using your certificate. It needs an API key: from the SME plan or during the 30-day trial. |
| Direct catalogue connection | Available | No code, from the SME plan: Cofactu connects to the WooCommerce REST API. A paid order comes in as an order and, if you switch it on, as a draft invoice that you review and issue. For it to reach the AEAT without passing through you, use the universal webhook. |
| Make or Zapier | Available | With their HTTP module against the webhook. Cofactu has no app of its own in Make or Zapier. |
Checked on 26 October 2026 · What is not available has no date
WooCommerce fires its payment event, as it already does today.
From the native hook or from Make. Normalised JSON, API key in the header.
Cofactu numbers it, computes the chained SHA-256 fingerprint and generates the PDF with a QR code.
With your certificate, the record goes to the AEAT (the Spanish Tax Agency) in the background and the response CSV is stored.


It fires when the payment gateway confirms the charge. For cash-on-delivery or bank-transfer orders, also use woocommerce_order_status_completed. Save the file in wp-content/mu-plugins/ and it loads by itself.
<?php
// wp-content/mu-plugins/cofactu-verifactu.php
add_action('woocommerce_payment_complete', function (int $order_id): void {
$order = wc_get_order($order_id);
$lines = [];
foreach ($order->get_items() as $item) {
$subtotal = (float) $item->get_subtotal(); // excluding VAT
$tax = (float) $item->get_subtotal_tax();
$lines[] = [
'descripcion' => $item->get_name(),
'cantidad' => (float) $item->get_quantity(),
'precioUnitario' => $subtotal / max(1, $item->get_quantity()),
'tipoIva' => $subtotal > 0 ? round($tax / $subtotal * 100) : 0,
];
}
$nif = $order->get_meta('_billing_nif'); // the meta of your NIF plugin
wp_remote_post('https://api.cofactu.com/api/webhooks/ecommerce-orders', [
'headers' => [
'Authorization' => 'Bearer ' . COFACTU_API_KEY, // define() in wp-config.php
'Content-Type' => 'application/json',
],
'body' => wp_json_encode([
'platform' => 'woocommerce',
'externalOrderId' => (string) $order->get_id(),
'client' => $nif ? [
'nif' => $nif,
'nombre' => $order->get_formatted_billing_full_name(),
'email' => $order->get_billing_email(),
'direccion' => $order->get_billing_address_1(),
'codigoPostal' => $order->get_billing_postcode(),
'ciudad' => $order->get_billing_city(),
'pais' => $order->get_billing_country(),
] : null, // simplified F2 invoice
'lines' => $lines,
]),
'timeout' => 15,
]);
}); 
In WooCommerce, create REST API keys (Settings → Advanced → REST API) with read and write permission.

In Cofactu, go to Catalogue → Public catalogue → Ecommerce integrations → “Connect WooCommerce”: name, shop URL and the two keys. Cofactu shows you the webhook secret once.

In WooCommerce, create an order webhook (Settings → Advanced → Webhooks) pointing to the connection's “Webhook URL”, with that secret. Cofactu rejects anything not signed with it.

“Sync products” pushes your Cofactu catalogue to the shop: name, reference, price, description and image. Stock is not synced from here.

Each new order comes into Cofactu as an order. If it arrives paid and you have “Generate VeriFactu invoice automatically on payment” switched on, Cofactu prepares the invoice as a draft. If the shop resends the same order with changes, it is not touched: it is flagged for review.
Create an API key in Cofactu (Settings → API keys) with permission to create invoices. The API is included from the SME plan and during the 30-day trial.

In Make, use the “WooCommerce → Watch Orders” module with status processing or completed; in Zapier, “WooCommerce → Order Paid” (WooCommerce needs the Zapier plugin to expose the trigger).

HTTP module: POST to https://api.cofactu.com/api/webhooks/ecommerce-orders with Authorization: Bearer vf_live_….

Map id to externalOrderId, billing to client and line_items to lines (subtotal / quantity is the unit price excluding VAT).

POST https://api.cofactu.com/api/webhooks/ecommerce-orders with Authorization: Bearer vf_live_…. Prices exclude VAT and each line carries its tipoIva (VAT rate); client: null issues a simplified F2 invoice; externalOrderId makes the call idempotent. From Settings → Integrations → Ecommerce you can send a test order, which stays as a draft; real orders show up in Invoices with their AEAT status.
Settings → Integrations → Ecommerce ↗{
"platform": "woocommerce",
"externalOrderId": "2026-000123",
"client": {
"nif": "B12345678",
"nombre": "Tienda Ejemplo SL",
"email": "compras@ejemplo.com",
"direccion": "C/ Mayor 1",
"codigoPostal": "28001",
"ciudad": "Madrid",
"pais": "ES"
},
"lines": [
{
"descripcion": "Zapatillas running 42",
"cantidad": 1,
"precioUnitario": 79.34,
"tipoIva": 21
},
{
"descripcion": "Gastos de envío",
"cantidad": 1,
"precioUnitario": 4.13,
"tipoIva": 21
}
],
"autoSubmit": true
} No, and there is no date. Today you connect it in three ways: a twenty-line mu-plugin or Make/Zapier, which call the universal webhook, or the direct catalogue connection of Cofactu, which receives the orders and prepares the invoice as a draft.
No. “PDF Invoices” plugins produce a document, but not an invoicing record with a chained hash, QR code and submission to the AEAT. You can keep using them as a delivery note or proof of purchase; the tax invoice is issued by Cofactu.
With any NIF/CIF field plugin for WooCommerce (there are free ones) that saves it as order meta, and by reading that meta in the hook. Without a NIF, client: null issues a simplified F2 invoice.
The webhook is idempotent by platform + externalOrderId: the same order never produces two invoices. The second call returns the first invoice with its AEAT status.
For submission to the AEAT, yes: you upload it once to Cofactu and the webhook uses it on every order. Without a certificate, invoices are created as drafts and you send them when you have one. The JSON is the same for all four stores: platform, externalOrderId, client (or null for a simplified F2 invoice) and lines with a price excluding VAT and a tipoIva (VAT rate) per line.
30 days with all of Cofactu, API included and no card, and a test order to see the first chained invoice. After that, the API starts at the SME plan.
We use our own cookies, Google's (which ads bring sign-ups) and PostHog's (how the site is used). If you decline, the site works exactly the same. Learn more .
Navegar en tu idioma siempre es mejor. Cámbiate para disfrutar de una experiencia 100% adaptada.