E-Invoicing Mandates for Developers: ZATCA Phase 2, Pakistan FBR and the EU ViDA Timeline

ApexlyTech Team 10 min read
E-Invoicing Mandates for Developers: ZATCA Phase 2, Pakistan FBR and the EU ViDA Timeline

TL;DR: E-invoicing is moving from "send a PDF" to "the tax authority sees the invoice, in a structured format, as it is issued". In Saudi Arabia, ZATCA's Phase 2 (integration) is rolling out in waves; wave 25 covers taxpayers whose VAT-able revenue exceeded SAR 187,500 in any year from 2022 to 2025, with an integration deadline of 1 February 2027. In Pakistan, the FBR requires sales-tax-registered businesses to issue digital invoices through an integrated system, while large retailers have long had to connect their point of sale (POS) to the FBR. In the EU, the VAT in the Digital Age (ViDA) package lets Member States mandate domestic e-invoicing now and makes e-invoicing and digital reporting mandatory for intra-EU business-to-business supplies from 1 July 2030. The engineering pattern is the same everywhere: a validated, structured invoice; secure credentials; a reliable submission queue; and an audit trail. Build those once and each new regime is mostly mapping and testing.

Why this is a software problem, not just a tax one

Each regime looks different on paper, but the work in your ERP, POS or billing system is similar:

  • A structured invoice. XML or JSON with defined fields and code lists, validated before it leaves your system.
  • Identity and integrity. Certificates, tokens or signatures that prove the invoice came from you and has not been altered.
  • Submission and status. Real-time clearance (the authority must approve before the buyer gets the invoice) or near-real-time reporting (you send a copy within a deadline), with retries when the authority's service is slow or down.
  • Numbering and chaining. Sequence counters and hashes that must never be reused, even after a rejection.
  • Proof on the document. A QR code or authority-issued number printed on the invoice or receipt.
  • Retention and audit. Storing exactly what was sent and what came back.

Getting any of these wrong usually surfaces as rejected invoices at month end, or as a gap in the counter that cannot be explained to an auditor.

Saudi Arabia: ZATCA Phase 2 (Fatoora)

The phases and the current wave

ZATCA's e-invoicing has two phases. Phase 1, "generation", has applied since 4 December 2021: invoices must be generated and stored electronically by a compliant solution. Phase 2, "integration", applies from 1 January 2023 and is rolled out to taxpayers in waves; ZATCA says it notifies taxpayers of their wave at least six months in advance. Each wave lowers the revenue threshold.

WaveWho is includedIntegrate by
24Revenues subject to VAT above SAR 375,000 in 2022, 2023 or 202430 June 2026
25Revenues subject to VAT above SAR 187,500 in 2022, 2023, 2024 or 20251 February 2027

Wave 25 was announced on 24 July 2026 and is the first to use 2025 as a reference year. Check ZATCA's announcements for later waves and for the formal notification sent to your taxpayer account.

Clearance and reporting

Phase 2 has two models. Standard tax invoices (business to business) follow the clearance model: your solution submits the invoice to ZATCA's Fatoora platform, which validates and stamps it, and only the cleared invoice is shared with the buyer. Simplified tax invoices (mostly business to consumer) follow the reporting model: you issue the invoice to the customer at once and submit it to ZATCA within 24 hours of the transaction. Credit and debit notes go through the same clearance or reporting flow.

Onboarding: from OTP to production CSID

Each e-invoice generation solution (EGS) unit, such as each POS terminal or billing server, is onboarded separately:

  1. Generate a one-time password (OTP) in the Fatoora portal.
  2. Generate a key pair and a certificate signing request (CSR) with the required fields, and submit it with the OTP to receive a Compliance CSID (cryptographic stamp identifier).
  3. Pass the compliance checks: submit sample invoices of each type your unit will issue and get them validated.
  4. Receive the Production CSID, the certificate issued by ZATCA's certificate authority that lets the unit use the live e-invoicing APIs.
  5. Renew before the certificate expires, and keep private keys out of source code and logs.

ZATCA's developer portal provides an SDK for validating invoices offline and an integration sandbox to test against before going live.

What each invoice must carry

  • XML in ZATCA's UBL-based format, following the XML Implementation Standard and Data Dictionary, with the signature carried in UBL extensions.
  • A cryptographic stamp. The Security Features Implementation Standards specify SHA-256 hashing, ECDSA with 256-bit keys and an XAdES signature. ZATCA's technical guidelines show key generation on the secp256k1 curve.
  • A hash chain. Each invoice includes the previous invoice hash (PIH), so documents from one unit form a chain.
  • A UUID and an invoice counter value (ICV). ZATCA's guidance is explicit that once a document has used an ICV, no other document may use it; a rejected document is resubmitted as a new document with its own hash, UUID and ICV.
  • A QR code in TLV (tag-length-value) encoding, Base64, of up to 700 characters. Tags 1 to 5 (seller name, VAT number, timestamp, invoice total and VAT total) have applied since Phase 1; tags 6 to 9 (invoice hash, signature, public key and, for simplified invoices, ZATCA's stamp signature) apply in Phase 2.

Common pitfalls

  • Treating the counter like an ordinary sequence. If a database rollback or a retry reuses an ICV, or two processes issue from the same unit at once, the chain breaks. Issue from one serialised writer per EGS unit.
  • Losing reported invoices. A simplified invoice already printed for the customer must still reach ZATCA within 24 hours. Use a durable outbox queue with retries and alerting, not a fire-and-forget HTTP call.
  • Rounding. Line-level and document-level totals must reconcile exactly under ZATCA's rules. Decide where rounding happens and test edge cases such as discounts and multiple VAT categories.
  • Testing only the happy path. Run every invoice type, credit and debit notes, and rejection scenarios through the SDK and sandbox before onboarding production units.

Pakistan: FBR digital invoicing and POS integration

Digital invoicing for sales-tax-registered persons

The FBR introduced electronic invoicing for registered persons through S.R.O. 709(I)/2025 of 22 April 2025. Its FAQ gave integration dates of 1 June 2025 for corporate taxpayers and 1 July 2025 for non-corporate taxpayers. Integration is done through a licensed integrator under the Sales Tax Rules, 2006, and PRAL, the FBR's technology company, offers integration free of charge. The phase-in has since been rescheduled by further notifications, so check the latest S.R.O. and FBR notices for the date that applies to your category of taxpayer.

For developers, the FBR publishes technical documentation for the Digital Invoicing (DI) API, including methods to validate and to post invoice data and a sandbox for testing. The integration pattern is familiar: map your invoice data to the DI payload, call validate, post, store the FBR-issued invoice number returned for each invoice, and print it with a QR code on the invoice. Our FBR digital invoicing integration page sets out how we connect an ERP, POS or billing system and how to get a fixed quote.

POS integration for retailers

Separately, Tier-1 retailers and other specified businesses must integrate their POS systems with the FBR so that each sale is reported in real time and the customer receipt carries an FBR invoice number and QR code, which customers can verify in the FBR's Tax Asaan app. The FBR's own figures up to 30 September 2026 show 13,900 POS integrations covering 37,939 branches, including 12,152 integrations and 25,306 branches for Tier-1 retailers and 1,186 integrations for restaurants. For POS vendors, the requirement is to report every sale reliably, including when the shop's internet connection drops, which again means a local queue that syncs and reconciles when the connection returns.

The EU: VAT in the Digital Age (ViDA)

ViDA was adopted on 11 March 2025 as Council Directive (EU) 2025/516, with Council Regulation (EU) 2025/517 and Implementing Regulation (EU) 2025/518, published in the Official Journal on 25 March 2025. It entered into force on 14 April 2025. The key dates for e-invoicing:

DateWhat changes
14 Apr 2025Member States may require domestic e-invoicing without asking the EU for a derogation, and no longer need the buyer's acceptance
1 Jul 2028Deemed-supplier rules for platforms in short-term accommodation and passenger transport (Member States may defer to 1 January 2030); extended single VAT registration
1 Jul 2030Mandatory e-invoicing and near-real-time digital reporting for intra-EU business-to-business supplies; e-invoices to follow the European standard EN 16931 by default; invoices issued no later than 10 days after the chargeable event
1 Jan 2035Deadline for Member States with existing domestic real-time reporting systems to align them with the EU model

Meanwhile, national mandates are arriving well before 2030. Poland's KSeF system has applied since 1 February 2026 for businesses with 2024 sales above PLN 200 million and since 1 April 2026 for the rest. France's reform has been in effect since 1 September 2026, with obligations phased by company size through 2027. Belgium has required structured B2B e-invoices since 1 January 2026, and Germany has required businesses to be able to receive e-invoices since 1 January 2025, with issuing obligations phasing in. Each national system has its own channel (a government platform, Peppol or certified providers), so check the official guidance for every country you invoice in.

A developer's integration checklist

  1. Model the invoice once. Keep a canonical invoice model in your system, close to EN 16931's semantic model, and write a mapper per regime (ZATCA XML, FBR DI payload, national EU formats). Do not let regime-specific fields leak everywhere.
  2. Validate before you send. Use the authority's own validator or SDK in CI and at runtime. A schema check catches structure; business rules (totals, tax categories, mandatory fields per invoice type) catch most rejections.
  3. Use an outbox. Write the invoice and a pending submission in one database transaction, then submit from a worker with idempotent retries, back-off and alerts. This one pattern solves most clearance, reporting and offline-POS problems.
  4. Serialise counters and chains per device or unit. Never reuse a counter or hash after a rejection.
  5. Protect keys and tokens. Store private keys and API credentials in a secrets manager or hardware module, scoped per unit, with a renewal calendar.
  6. Store the evidence. Keep the exact XML or JSON sent, the response, the authority's stamp or number and timestamps, for the legally required retention period.
  7. Design for downtime. Decide what the cashier or billing clerk sees when the authority's API is unavailable, and how the backlog is cleared.
  8. Test every document type and failure in the sandbox: invoices, credit and debit notes, rejections, duplicates and timeouts.
  9. Monitor in production. Track rejection rates, queue age and certificate expiry on a dashboard someone actually looks at.

Build or use a library?

Libraries remove a lot of fiddly work: canonicalisation, hashing, signing, QR encoding. For Laravel applications, our open-source laravel-zatca package (source on GitHub) covers XML generation and cryptographic stamping for ZATCA Phase 1 and Phase 2, and it is one option among several. Whichever library you use, you still own the parts no package can do for you: onboarding each unit, mapping your data correctly, the outbox and retry design, and testing against ZATCA's SDK and sandbox. Review the code and pin a version, as you would for any dependency that touches tax records.

How ApexlyTech can help

We integrate e-invoicing into ERP, POS and billing systems, including our own Apex ERP, and maintain the open-source laravel-zatca package. If you need ZATCA onboarding for several branches, FBR digital invoicing or POS integration, or a canonical invoice model ready for EU mandates, see our custom software and SaaS development services, or contact us. If you are in ZATCA wave 25, our ZATCA e-invoicing integration page sets out what we do and how to get a fixed quote. Confirm tax treatment with your tax adviser; this guide covers the integration, not tax advice.

Frequently asked questions

Which ZATCA wave is current?

Wave 25, announced on 24 July 2026, covers taxpayers whose revenues subject to VAT exceeded SAR 187,500 in 2022, 2023, 2024 or 2025. They must integrate with Fatoora by 1 February 2027. ZATCA notifies each taxpayer of its wave at least six months ahead.

What is the difference between clearance and reporting in ZATCA Phase 2?

Standard (B2B) tax invoices must be cleared by ZATCA before they are shared with the buyer. Simplified (mostly B2C) invoices are issued to the customer immediately and reported to ZATCA within 24 hours.

What happens to the invoice counter when ZATCA rejects an invoice?

The counter value is not reused. ZATCA's guidance says a rejected document is resubmitted as a new document with its own hash, UUID and invoice counter value.

Is e-invoicing mandatory across the EU?

For intra-EU business-to-business supplies, from 1 July 2030 under ViDA. For domestic transactions it depends on the country: Poland, Belgium and France already have mandates, and others are phasing them in.

Can one system handle ZATCA, FBR and EU formats?

Yes, if it keeps a canonical invoice model and adds a mapper, validator and submission adapter per regime. The outbox, retry, key management and audit storage can be shared.

Sources