← All posts

Guides

CFDI and e-invoicing, for developers

A payment is not finished in Mexico until there is a valid CFDI behind it. This is the fiscal layer most international stacks ignore — SAT, PACs, complementos and catálogos — written for the engineer who has to make the factura come out automatically and correctly.

CFDI is where "accept a payment" turns into "produce a legal document the tax authority will accept." The good news is you never talk to the SAT directly — you integrate a PAC (authorized certifier) that stamps your XML. So these guides treat the PAC as a swappable dependency: pick by SDK quality and documentation, build to the CFDI shape, and stay vendor-neutral so a price change or outage does not strand you.

The durable patterns are the same across every complemento. Store the stamped, validated XML indexed by its UUID and reconcile it back to the payment id, so every charge has a provable factura attached — that link is what saves you in an audit. And treat the SAT's catálogos as data you refresh on a schedule, not constants you hardcode: they change, and a stale catalog is the most common reason a stamp gets rejected. From standard CFDI 4.0 to Carta Porte, hydrocarbons and the Banxico rules next door, that backbone holds.

The guides

FAQ

Do I integrate with the SAT directly to issue a CFDI?
No. You integrate an authorized PAC (Proveedor Autorizado de Certificación), which validates and stamps (timbra) your CFDI XML on the SAT's behalf and returns the UUID. Your job is to build a correct CFDI 4.0 document and send it to the PAC — choose the PAC by SDK and docs quality, and keep your code vendor-neutral so you can switch.
How should I store CFDIs so an audit is painless?
Store the full stamped XML (not just a PDF) indexed by its UUID, and link every CFDI to the payment id that produced it. Keep the SAT-required retention period in mind. The reconciliation — charge ↔ UUID ↔ order — is the thing auditors ask for, so build it from day one rather than reconstructing it later.
Do I need a complemento like Carta Porte or Hidrocarburos?
Only if your operation triggers it. Carta Porte is required when goods move on public roads/rails/water/air; the Hidrocarburos complement applies to fuel-sector transactions. They are add-ons to the base CFDI with their own catálogos and validation rules — build the base CFDI cleanly first, then attach the complemento your business actually needs.