Government E-Invoicing — Live Wiring & Credentials
The platform ships a tax-provider abstraction with one plugin per country
tax regime, selected automatically by the market's tax.engine
(india_gst · zatca · cfdi · nfse · none). Every plugin issues a
deterministic local invoice by default — a valid GST/VAT-style document with
computed tax split, a locally-derived reference (IRN hash / UUID stand-in) and a
QR field set — so invoicing works out-of-the-box with zero external
dependencies and never blocks a completed ride.
When a buyer supplies real authority/GSP credentials (encrypted at rest via the provider-credential store, set on the admin Providers page), the plugin switches to live registration with the tax authority and uses the real returned identifiers. Any missing credential or any live-call failure falls back to the local invoice — the ride is always invoiced.
This is a graceful, credential-gated upgrade: no credentials → mock (dev/B2C); credentials → live filing.
How to enable live filing
- Obtain sandbox/production credentials from the relevant authority or an accredited intermediary (GSP / PAC / municipality) — see per-country below.
- In the admin panel → Providers → add the credential keys for the matching provider (they are AES-256-GCM encrypted at rest; only masked values are ever returned to the UI).
- No restart needed — the plugin resolves credentials per invoice.
Credentials may also be supplied via the process.env fallbacks listed below
(useful for a single-tenant deployment), but the encrypted store is preferred.
Per-country credential requirements
🇮🇳 India GST (india_gst) — IRP via a GSP
Passenger transport is SAC 9964. Intra-state → CGST+SGST; inter-state → IGST. Live filing registers the invoice with the Invoice Registration Portal (IRP) through a GSP (e.g. Cleartax, Masters India, or the NIC sandbox).
| Provider key | Credential | Env fallback |
|---|---|---|
india_gst |
gspBaseUrl |
GSP_BASE_URL |
india_gst |
clientId |
GSP_CLIENT_ID |
india_gst |
clientSecret |
GSP_CLIENT_SECRET |
india_gst |
username |
GSP_USERNAME |
india_gst |
password |
GSP_PASSWORD |
Gate: gspBaseUrl and clientId present → live. Returns the authority's
real IRN, signed QR code, and AckNo/AckDt.
Also set the seller GSTIN as the market's tax.sellerTaxId.
🇸🇦 Saudi Arabia ZATCA (zatca): Phase 2, built in
15% VAT. There are no keys to type: the platform onboards itself as an e-invoicing unit from Admin → Tax → ZATCA e-invoicing, using the OTP from the FATOORA portal.
Once onboarded, every ride invoice is a stamped UBL document that ZATCA receives within 24 hours. Until then, invoices carry the Phase 1 QR and are marked local only.
The full guide is in docs/zatca-phase2.md. The flow was validated against
ZATCA's own developer sandbox.
🇦🇪 United Arab Emirates: VAT on commission, and B2B invoices in Peppol PINT AE
Rides. Local passenger transport is VAT-exempt (Federal Decree-Law
8/2017, art. 46). The 5% falls on the platform's commission. The UAE market
uses the vat engine with taxableBase: 'commission', so each ride records
a commission tax document.
B2B e-invoices. The UAE requires business invoices on the Peppol network, through an Accredited Service Provider (ASP):
- a pilot from July 2026;
- mandatory for large businesses around January 2027, and for the rest during 2027;
- AED 5,000 per month of delay without an ASP.
Each month the platform issues two kinds of invoice:
- Company rides. To each company whose employees rode on its account. One line per ride, VAT category E (exempt), with the exemption reason.
- Fleet commission. To each fleet, for the commission on its drivers' rides. VAT category S, 5%.
Admin → Tax → UAE e-invoicing (Peppol PINT AE) (UAE installs only):
Seller details: the legal name, the TRN (15 digits, starting with 1), the address with its emirate, and the payment terms.
Choose a month that has ended and press Generate invoices:
- each invoice is built as PINT AE UBL 2.1
(
urn:peppol:pint:billing-1@ae-1, TRN endpoints with scheme0235); - each is checked and numbered
AE-EINV-YYYY-NNNNNN, gapless per year.
- each invoice is built as PINT AE UBL 2.1
(
An invoice with missing details shows Needs details, and says which:
- seller details;
- the buyer's TRN or address (fill these in with Buyer details; leave the TRN empty for a buyer that is not VAT-registered);
- an incomplete line.
Generate the month again once fixed. The invoice keeps its number.
XML downloads any invoice to upload to an ASP by hand.
With an ASP connected, Send submits it:
- status goes Sent, then Accepted or Rejected with the ASP's message;
- a rejected invoice can be fixed and generated again, keeping its number;
- a transport failure shows Failed and is retried every 10 minutes, up to 10 times;
- sent invoices are followed until the ASP decides.
| Provider key | Credential | Notes |
|---|---|---|
uae_asp |
baseUrl |
ASP API: POST /invoices (the XML, application/xml) → { id, status }; GET /invoices/{id} → { status, message } |
uae_asp |
apiKey |
Sent as a Bearer token |
An ASP with a different API needs a small adapter in
backend/src/tax/pint-ae/asp.client.ts. The ASP runs the official PINT AE
schematron. RideKit checks the rules that most often bounce invoices (TRNs,
emirates, totals, exemption reasons). Confirm the format, the identifiers and
your TRN with your ASP and tax adviser before going live.
Code:
tax/pint-ae/pint-ae.ts: XML, totals, checks;einvoice.service.ts: generate, send, sweep;einvoice.controller.ts:/admin/einvoices;- migration
1700000138000-UaeEinvoicing.ts; - admin
components/tax/EinvoicesCard.tsx.
🇲🇽 Mexico CFDI (cfdi) — timbrado via a PAC
16% IVA. Live filing stamps (timbra) the CFDI through an authorized PAC.
| Provider key | Credential | Env fallback |
|---|---|---|
cfdi |
pacBaseUrl |
CFDI_PAC_BASE_URL |
cfdi |
pacUser |
CFDI_PAC_USER |
cfdi |
pacPassword |
CFDI_PAC_PASSWORD |
Gate: pacBaseUrl and pacUser present → live. Returns the UUID (folio
fiscal) and stamped-XML reference. Set the seller RFC as tax.sellerTaxId;
the CSD certificate is held by the PAC.
🇧🇷 Brazil NFS-e (nfse) — municipal service invoice
ISS varies by municipality (5% placeholder). Live filing submits the NFS-e to the municipality's web service (each city differs).
| Provider key | Credential | Env fallback |
|---|---|---|
nfse |
municipalityBaseUrl |
NFSE_BASE_URL |
nfse |
cnpj |
NFSE_CNPJ |
nfse |
municipalToken |
NFSE_MUNICIPAL_TOKEN |
Gate: municipalityBaseUrl and cnpj present → live. Returns the NFS-e
number + verification code. Set the seller CNPJ as tax.sellerTaxId.
Notes
noneengine (US and most Tier-4/5 markets): no government e-invoicing; a plain receipt is produced. VAT/sales tax, where applicable, is still computed and shown per the markettax.rateBps.- The QR / IRN in mock mode is a deterministic stand-in, not authority-signed — fine for development, B2C under-threshold flows, and demos; not a legal substitute for a cleared invoice in a regime that mandates one.
- Failures are logged at
errorlevel (never silent) and the local invoice is used, so an operator sees a filing problem in logs while the customer still gets an invoice.